babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001
  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. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  25565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25566. */
  25567. useBoundingInfoFromGeometry: boolean;
  25568. /**
  25569. * Creates a new geometry
  25570. * @param id defines the unique ID
  25571. * @param scene defines the hosting scene
  25572. * @param vertexData defines the VertexData used to get geometry data
  25573. * @param updatable defines if geometry must be updatable (false by default)
  25574. * @param mesh defines the mesh that will be associated with the geometry
  25575. */
  25576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25577. /**
  25578. * Gets the current extend of the geometry
  25579. */
  25580. get extend(): {
  25581. minimum: Vector3;
  25582. maximum: Vector3;
  25583. };
  25584. /**
  25585. * Gets the hosting scene
  25586. * @returns the hosting Scene
  25587. */
  25588. getScene(): Scene;
  25589. /**
  25590. * Gets the hosting engine
  25591. * @returns the hosting Engine
  25592. */
  25593. getEngine(): Engine;
  25594. /**
  25595. * Defines if the geometry is ready to use
  25596. * @returns true if the geometry is ready to be used
  25597. */
  25598. isReady(): boolean;
  25599. /**
  25600. * Gets a value indicating that the geometry should not be serialized
  25601. */
  25602. get doNotSerialize(): boolean;
  25603. /** @hidden */
  25604. _rebuild(): void;
  25605. /**
  25606. * Affects all geometry data in one call
  25607. * @param vertexData defines the geometry data
  25608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25609. */
  25610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25611. /**
  25612. * Set specific vertex data
  25613. * @param kind defines the data kind (Position, normal, etc...)
  25614. * @param data defines the vertex data to use
  25615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25617. */
  25618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25619. /**
  25620. * Removes a specific vertex data
  25621. * @param kind defines the data kind (Position, normal, etc...)
  25622. */
  25623. removeVerticesData(kind: string): void;
  25624. /**
  25625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25626. * @param buffer defines the vertex buffer to use
  25627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25628. */
  25629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25630. /**
  25631. * Update a specific vertex buffer
  25632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25633. * It will do nothing if the buffer is not updatable
  25634. * @param kind defines the data kind (Position, normal, etc...)
  25635. * @param data defines the data to use
  25636. * @param offset defines the offset in the target buffer where to store the data
  25637. * @param useBytes set to true if the offset is in bytes
  25638. */
  25639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25640. /**
  25641. * Update a specific vertex buffer
  25642. * This function will create a new buffer if the current one is not updatable
  25643. * @param kind defines the data kind (Position, normal, etc...)
  25644. * @param data defines the data to use
  25645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25646. */
  25647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25648. private _updateBoundingInfo;
  25649. /** @hidden */
  25650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25651. /**
  25652. * Gets total number of vertices
  25653. * @returns the total number of vertices
  25654. */
  25655. getTotalVertices(): number;
  25656. /**
  25657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25658. * @param kind defines the data kind (Position, normal, etc...)
  25659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25661. * @returns a float array containing vertex data
  25662. */
  25663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25664. /**
  25665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25666. * @param kind defines the data kind (Position, normal, etc...)
  25667. * @returns true if the vertex buffer with the specified kind is updatable
  25668. */
  25669. isVertexBufferUpdatable(kind: string): boolean;
  25670. /**
  25671. * Gets a specific vertex buffer
  25672. * @param kind defines the data kind (Position, normal, etc...)
  25673. * @returns a VertexBuffer
  25674. */
  25675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25676. /**
  25677. * Returns all vertex buffers
  25678. * @return an object holding all vertex buffers indexed by kind
  25679. */
  25680. getVertexBuffers(): Nullable<{
  25681. [key: string]: VertexBuffer;
  25682. }>;
  25683. /**
  25684. * Gets a boolean indicating if specific vertex buffer is present
  25685. * @param kind defines the data kind (Position, normal, etc...)
  25686. * @returns true if data is present
  25687. */
  25688. isVerticesDataPresent(kind: string): boolean;
  25689. /**
  25690. * Gets a list of all attached data kinds (Position, normal, etc...)
  25691. * @returns a list of string containing all kinds
  25692. */
  25693. getVerticesDataKinds(): string[];
  25694. /**
  25695. * Update index buffer
  25696. * @param indices defines the indices to store in the index buffer
  25697. * @param offset defines the offset in the target buffer where to store the data
  25698. * @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)
  25699. */
  25700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25701. /**
  25702. * Creates a new index buffer
  25703. * @param indices defines the indices to store in the index buffer
  25704. * @param totalVertices defines the total number of vertices (could be null)
  25705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25706. */
  25707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25708. /**
  25709. * Return the total number of indices
  25710. * @returns the total number of indices
  25711. */
  25712. getTotalIndices(): number;
  25713. /**
  25714. * Gets the index buffer array
  25715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25717. * @returns the index buffer array
  25718. */
  25719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25720. /**
  25721. * Gets the index buffer
  25722. * @return the index buffer
  25723. */
  25724. getIndexBuffer(): Nullable<DataBuffer>;
  25725. /** @hidden */
  25726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25727. /**
  25728. * Release the associated resources for a specific mesh
  25729. * @param mesh defines the source mesh
  25730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25731. */
  25732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25733. /**
  25734. * Apply current geometry to a given mesh
  25735. * @param mesh defines the mesh to apply geometry to
  25736. */
  25737. applyToMesh(mesh: Mesh): void;
  25738. private _updateExtend;
  25739. private _applyToMesh;
  25740. private notifyUpdate;
  25741. /**
  25742. * Load the geometry if it was flagged as delay loaded
  25743. * @param scene defines the hosting scene
  25744. * @param onLoaded defines a callback called when the geometry is loaded
  25745. */
  25746. load(scene: Scene, onLoaded?: () => void): void;
  25747. private _queueLoad;
  25748. /**
  25749. * Invert the geometry to move from a right handed system to a left handed one.
  25750. */
  25751. toLeftHanded(): void;
  25752. /** @hidden */
  25753. _resetPointsArrayCache(): void;
  25754. /** @hidden */
  25755. _generatePointsArray(): boolean;
  25756. /**
  25757. * Gets a value indicating if the geometry is disposed
  25758. * @returns true if the geometry was disposed
  25759. */
  25760. isDisposed(): boolean;
  25761. private _disposeVertexArrayObjects;
  25762. /**
  25763. * Free all associated resources
  25764. */
  25765. dispose(): void;
  25766. /**
  25767. * Clone the current geometry into a new geometry
  25768. * @param id defines the unique ID of the new geometry
  25769. * @returns a new geometry object
  25770. */
  25771. copy(id: string): Geometry;
  25772. /**
  25773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25774. * @return a JSON representation of the current geometry data (without the vertices data)
  25775. */
  25776. serialize(): any;
  25777. private toNumberArray;
  25778. /**
  25779. * Serialize all vertices data into a JSON oject
  25780. * @returns a JSON representation of the current geometry data
  25781. */
  25782. serializeVerticeData(): any;
  25783. /**
  25784. * Extracts a clone of a mesh geometry
  25785. * @param mesh defines the source mesh
  25786. * @param id defines the unique ID of the new geometry object
  25787. * @returns the new geometry object
  25788. */
  25789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25790. /**
  25791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25793. * Be aware Math.random() could cause collisions, but:
  25794. * "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"
  25795. * @returns a string containing a new GUID
  25796. */
  25797. static RandomId(): string;
  25798. /** @hidden */
  25799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25800. private static _CleanMatricesWeights;
  25801. /**
  25802. * Create a new geometry from persisted data (Using .babylon file format)
  25803. * @param parsedVertexData defines the persisted data
  25804. * @param scene defines the hosting scene
  25805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25806. * @returns the new geometry object
  25807. */
  25808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25809. }
  25810. }
  25811. declare module "babylonjs/Meshes/mesh.vertexData" {
  25812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25815. import { Geometry } from "babylonjs/Meshes/geometry";
  25816. import { Mesh } from "babylonjs/Meshes/mesh";
  25817. /**
  25818. * Define an interface for all classes that will get and set the data on vertices
  25819. */
  25820. export interface IGetSetVerticesData {
  25821. /**
  25822. * Gets a boolean indicating if specific vertex data is present
  25823. * @param kind defines the vertex data kind to use
  25824. * @returns true is data kind is present
  25825. */
  25826. isVerticesDataPresent(kind: string): boolean;
  25827. /**
  25828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25829. * @param kind defines the data kind (Position, normal, etc...)
  25830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25832. * @returns a float array containing vertex data
  25833. */
  25834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25835. /**
  25836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25837. * @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.
  25838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25839. * @returns the indices array or an empty array if the mesh has no geometry
  25840. */
  25841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25842. /**
  25843. * Set specific vertex data
  25844. * @param kind defines the data kind (Position, normal, etc...)
  25845. * @param data defines the vertex data to use
  25846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25848. */
  25849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25850. /**
  25851. * Update a specific associated vertex buffer
  25852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25853. * - VertexBuffer.PositionKind
  25854. * - VertexBuffer.UVKind
  25855. * - VertexBuffer.UV2Kind
  25856. * - VertexBuffer.UV3Kind
  25857. * - VertexBuffer.UV4Kind
  25858. * - VertexBuffer.UV5Kind
  25859. * - VertexBuffer.UV6Kind
  25860. * - VertexBuffer.ColorKind
  25861. * - VertexBuffer.MatricesIndicesKind
  25862. * - VertexBuffer.MatricesIndicesExtraKind
  25863. * - VertexBuffer.MatricesWeightsKind
  25864. * - VertexBuffer.MatricesWeightsExtraKind
  25865. * @param data defines the data source
  25866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25867. * @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)
  25868. */
  25869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25870. /**
  25871. * Creates a new index buffer
  25872. * @param indices defines the indices to store in the index buffer
  25873. * @param totalVertices defines the total number of vertices (could be null)
  25874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25875. */
  25876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25877. }
  25878. /**
  25879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25880. */
  25881. export class VertexData {
  25882. /**
  25883. * Mesh side orientation : usually the external or front surface
  25884. */
  25885. static readonly FRONTSIDE: number;
  25886. /**
  25887. * Mesh side orientation : usually the internal or back surface
  25888. */
  25889. static readonly BACKSIDE: number;
  25890. /**
  25891. * Mesh side orientation : both internal and external or front and back surfaces
  25892. */
  25893. static readonly DOUBLESIDE: number;
  25894. /**
  25895. * Mesh side orientation : by default, `FRONTSIDE`
  25896. */
  25897. static readonly DEFAULTSIDE: number;
  25898. /**
  25899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25900. */
  25901. positions: Nullable<FloatArray>;
  25902. /**
  25903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25904. */
  25905. normals: Nullable<FloatArray>;
  25906. /**
  25907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25908. */
  25909. tangents: Nullable<FloatArray>;
  25910. /**
  25911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25912. */
  25913. uvs: Nullable<FloatArray>;
  25914. /**
  25915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25916. */
  25917. uvs2: Nullable<FloatArray>;
  25918. /**
  25919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25920. */
  25921. uvs3: Nullable<FloatArray>;
  25922. /**
  25923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25924. */
  25925. uvs4: Nullable<FloatArray>;
  25926. /**
  25927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25928. */
  25929. uvs5: Nullable<FloatArray>;
  25930. /**
  25931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25932. */
  25933. uvs6: Nullable<FloatArray>;
  25934. /**
  25935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25936. */
  25937. colors: Nullable<FloatArray>;
  25938. /**
  25939. * 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).
  25940. */
  25941. matricesIndices: Nullable<FloatArray>;
  25942. /**
  25943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25944. */
  25945. matricesWeights: Nullable<FloatArray>;
  25946. /**
  25947. * An array extending the number of possible indices
  25948. */
  25949. matricesIndicesExtra: Nullable<FloatArray>;
  25950. /**
  25951. * An array extending the number of possible weights when the number of indices is extended
  25952. */
  25953. matricesWeightsExtra: Nullable<FloatArray>;
  25954. /**
  25955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25956. */
  25957. indices: Nullable<IndicesArray>;
  25958. /**
  25959. * Uses the passed data array to set the set the values for the specified kind of data
  25960. * @param data a linear array of floating numbers
  25961. * @param kind the type of data that is being set, eg positions, colors etc
  25962. */
  25963. set(data: FloatArray, kind: string): void;
  25964. /**
  25965. * Associates the vertexData to the passed Mesh.
  25966. * Sets it as updatable or not (default `false`)
  25967. * @param mesh the mesh the vertexData is applied to
  25968. * @param updatable when used and having the value true allows new data to update the vertexData
  25969. * @returns the VertexData
  25970. */
  25971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25972. /**
  25973. * Associates the vertexData to the passed Geometry.
  25974. * Sets it as updatable or not (default `false`)
  25975. * @param geometry the geometry the vertexData is applied to
  25976. * @param updatable when used and having the value true allows new data to update the vertexData
  25977. * @returns VertexData
  25978. */
  25979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25980. /**
  25981. * Updates the associated mesh
  25982. * @param mesh the mesh to be updated
  25983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25984. * @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
  25985. * @returns VertexData
  25986. */
  25987. updateMesh(mesh: Mesh): VertexData;
  25988. /**
  25989. * Updates the associated geometry
  25990. * @param geometry the geometry to be updated
  25991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25992. * @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
  25993. * @returns VertexData.
  25994. */
  25995. updateGeometry(geometry: Geometry): VertexData;
  25996. private _applyTo;
  25997. private _update;
  25998. /**
  25999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26000. * @param matrix the transforming matrix
  26001. * @returns the VertexData
  26002. */
  26003. transform(matrix: Matrix): VertexData;
  26004. /**
  26005. * Merges the passed VertexData into the current one
  26006. * @param other the VertexData to be merged into the current one
  26007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26008. * @returns the modified VertexData
  26009. */
  26010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26011. private _mergeElement;
  26012. private _validate;
  26013. /**
  26014. * Serializes the VertexData
  26015. * @returns a serialized object
  26016. */
  26017. serialize(): any;
  26018. /**
  26019. * Extracts the vertexData from a mesh
  26020. * @param mesh the mesh from which to extract the VertexData
  26021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26023. * @returns the object VertexData associated to the passed mesh
  26024. */
  26025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26026. /**
  26027. * Extracts the vertexData from the geometry
  26028. * @param geometry the geometry from which to extract the VertexData
  26029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26031. * @returns the object VertexData associated to the passed mesh
  26032. */
  26033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26034. private static _ExtractFrom;
  26035. /**
  26036. * Creates the VertexData for a Ribbon
  26037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26038. * * pathArray array of paths, each of which an array of successive Vector3
  26039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26041. * * 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
  26042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26043. * * 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)
  26044. * * 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)
  26045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26048. * @returns the VertexData of the ribbon
  26049. */
  26050. static CreateRibbon(options: {
  26051. pathArray: Vector3[][];
  26052. closeArray?: boolean;
  26053. closePath?: boolean;
  26054. offset?: number;
  26055. sideOrientation?: number;
  26056. frontUVs?: Vector4;
  26057. backUVs?: Vector4;
  26058. invertUV?: boolean;
  26059. uvs?: Vector2[];
  26060. colors?: Color4[];
  26061. }): VertexData;
  26062. /**
  26063. * Creates the VertexData for a box
  26064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26072. * * 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)
  26073. * * 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)
  26074. * @returns the VertexData of the box
  26075. */
  26076. static CreateBox(options: {
  26077. size?: number;
  26078. width?: number;
  26079. height?: number;
  26080. depth?: number;
  26081. faceUV?: Vector4[];
  26082. faceColors?: Color4[];
  26083. sideOrientation?: number;
  26084. frontUVs?: Vector4;
  26085. backUVs?: Vector4;
  26086. }): VertexData;
  26087. /**
  26088. * Creates the VertexData for a tiled box
  26089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26094. * @returns the VertexData of the box
  26095. */
  26096. static CreateTiledBox(options: {
  26097. pattern?: number;
  26098. width?: number;
  26099. height?: number;
  26100. depth?: number;
  26101. tileSize?: number;
  26102. tileWidth?: number;
  26103. tileHeight?: number;
  26104. alignHorizontal?: number;
  26105. alignVertical?: number;
  26106. faceUV?: Vector4[];
  26107. faceColors?: Color4[];
  26108. sideOrientation?: number;
  26109. }): VertexData;
  26110. /**
  26111. * Creates the VertexData for a tiled plane
  26112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26113. * * pattern a limited pattern arrangement depending on the number
  26114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26118. * * 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)
  26119. * * 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)
  26120. * @returns the VertexData of the tiled plane
  26121. */
  26122. static CreateTiledPlane(options: {
  26123. pattern?: number;
  26124. tileSize?: number;
  26125. tileWidth?: number;
  26126. tileHeight?: number;
  26127. size?: number;
  26128. width?: number;
  26129. height?: number;
  26130. alignHorizontal?: number;
  26131. alignVertical?: number;
  26132. sideOrientation?: number;
  26133. frontUVs?: Vector4;
  26134. backUVs?: Vector4;
  26135. }): VertexData;
  26136. /**
  26137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26139. * * segments sets the number of horizontal strips optional, default 32
  26140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26144. * * 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
  26145. * * 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
  26146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26147. * * 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)
  26148. * * 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)
  26149. * @returns the VertexData of the ellipsoid
  26150. */
  26151. static CreateSphere(options: {
  26152. segments?: number;
  26153. diameter?: number;
  26154. diameterX?: number;
  26155. diameterY?: number;
  26156. diameterZ?: number;
  26157. arc?: number;
  26158. slice?: number;
  26159. sideOrientation?: number;
  26160. frontUVs?: Vector4;
  26161. backUVs?: Vector4;
  26162. }): VertexData;
  26163. /**
  26164. * Creates the VertexData for a cylinder, cone or prism
  26165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26166. * * height sets the height (y direction) of the cylinder, optional, default 2
  26167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26172. * * 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
  26173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26178. * * 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)
  26179. * * 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)
  26180. * @returns the VertexData of the cylinder, cone or prism
  26181. */
  26182. static CreateCylinder(options: {
  26183. height?: number;
  26184. diameterTop?: number;
  26185. diameterBottom?: number;
  26186. diameter?: number;
  26187. tessellation?: number;
  26188. subdivisions?: number;
  26189. arc?: number;
  26190. faceColors?: Color4[];
  26191. faceUV?: Vector4[];
  26192. hasRings?: boolean;
  26193. enclose?: boolean;
  26194. sideOrientation?: number;
  26195. frontUVs?: Vector4;
  26196. backUVs?: Vector4;
  26197. }): VertexData;
  26198. /**
  26199. * Creates the VertexData for a torus
  26200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26201. * * diameter the diameter of the torus, optional default 1
  26202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26205. * * 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)
  26206. * * 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)
  26207. * @returns the VertexData of the torus
  26208. */
  26209. static CreateTorus(options: {
  26210. diameter?: number;
  26211. thickness?: number;
  26212. tessellation?: number;
  26213. sideOrientation?: number;
  26214. frontUVs?: Vector4;
  26215. backUVs?: Vector4;
  26216. }): VertexData;
  26217. /**
  26218. * Creates the VertexData of the LineSystem
  26219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26220. * - lines an array of lines, each line being an array of successive Vector3
  26221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26222. * @returns the VertexData of the LineSystem
  26223. */
  26224. static CreateLineSystem(options: {
  26225. lines: Vector3[][];
  26226. colors?: Nullable<Color4[][]>;
  26227. }): VertexData;
  26228. /**
  26229. * Create the VertexData for a DashedLines
  26230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26231. * - points an array successive Vector3
  26232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26234. * - dashNb the intended total number of dashes, optional, default 200
  26235. * @returns the VertexData for the DashedLines
  26236. */
  26237. static CreateDashedLines(options: {
  26238. points: Vector3[];
  26239. dashSize?: number;
  26240. gapSize?: number;
  26241. dashNb?: number;
  26242. }): VertexData;
  26243. /**
  26244. * Creates the VertexData for a Ground
  26245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26246. * - width the width (x direction) of the ground, optional, default 1
  26247. * - height the height (z direction) of the ground, optional, default 1
  26248. * - subdivisions the number of subdivisions per side, optional, default 1
  26249. * @returns the VertexData of the Ground
  26250. */
  26251. static CreateGround(options: {
  26252. width?: number;
  26253. height?: number;
  26254. subdivisions?: number;
  26255. subdivisionsX?: number;
  26256. subdivisionsY?: number;
  26257. }): VertexData;
  26258. /**
  26259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26261. * * xmin the ground minimum X coordinate, optional, default -1
  26262. * * zmin the ground minimum Z coordinate, optional, default -1
  26263. * * xmax the ground maximum X coordinate, optional, default 1
  26264. * * zmax the ground maximum Z coordinate, optional, default 1
  26265. * * 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}
  26266. * * 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}
  26267. * @returns the VertexData of the TiledGround
  26268. */
  26269. static CreateTiledGround(options: {
  26270. xmin: number;
  26271. zmin: number;
  26272. xmax: number;
  26273. zmax: number;
  26274. subdivisions?: {
  26275. w: number;
  26276. h: number;
  26277. };
  26278. precision?: {
  26279. w: number;
  26280. h: number;
  26281. };
  26282. }): VertexData;
  26283. /**
  26284. * Creates the VertexData of the Ground designed from a heightmap
  26285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26286. * * width the width (x direction) of the ground
  26287. * * height the height (z direction) of the ground
  26288. * * subdivisions the number of subdivisions per side
  26289. * * minHeight the minimum altitude on the ground, optional, default 0
  26290. * * maxHeight the maximum altitude on the ground, optional default 1
  26291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26292. * * buffer the array holding the image color data
  26293. * * bufferWidth the width of image
  26294. * * bufferHeight the height of image
  26295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26296. * @returns the VertexData of the Ground designed from a heightmap
  26297. */
  26298. static CreateGroundFromHeightMap(options: {
  26299. width: number;
  26300. height: number;
  26301. subdivisions: number;
  26302. minHeight: number;
  26303. maxHeight: number;
  26304. colorFilter: Color3;
  26305. buffer: Uint8Array;
  26306. bufferWidth: number;
  26307. bufferHeight: number;
  26308. alphaFilter: number;
  26309. }): VertexData;
  26310. /**
  26311. * Creates the VertexData for a Plane
  26312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26313. * * size sets the width and height of the plane to the value of size, optional default 1
  26314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26317. * * 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)
  26318. * * 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)
  26319. * @returns the VertexData of the box
  26320. */
  26321. static CreatePlane(options: {
  26322. size?: number;
  26323. width?: number;
  26324. height?: number;
  26325. sideOrientation?: number;
  26326. frontUVs?: Vector4;
  26327. backUVs?: Vector4;
  26328. }): VertexData;
  26329. /**
  26330. * Creates the VertexData of the Disc or regular Polygon
  26331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26332. * * radius the radius of the disc, optional default 0.5
  26333. * * tessellation the number of polygon sides, optional, default 64
  26334. * * 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
  26335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26336. * * 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)
  26337. * * 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)
  26338. * @returns the VertexData of the box
  26339. */
  26340. static CreateDisc(options: {
  26341. radius?: number;
  26342. tessellation?: number;
  26343. arc?: number;
  26344. sideOrientation?: number;
  26345. frontUVs?: Vector4;
  26346. backUVs?: Vector4;
  26347. }): VertexData;
  26348. /**
  26349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26351. * @param polygon a mesh built from polygonTriangulation.build()
  26352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26355. * @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)
  26356. * @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)
  26357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26358. * @returns the VertexData of the Polygon
  26359. */
  26360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26361. /**
  26362. * Creates the VertexData of the IcoSphere
  26363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26364. * * radius the radius of the IcoSphere, optional default 1
  26365. * * radiusX allows stretching in the x direction, optional, default radius
  26366. * * radiusY allows stretching in the y direction, optional, default radius
  26367. * * radiusZ allows stretching in the z direction, optional, default radius
  26368. * * flat when true creates a flat shaded mesh, optional, default true
  26369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26371. * * 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)
  26372. * * 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)
  26373. * @returns the VertexData of the IcoSphere
  26374. */
  26375. static CreateIcoSphere(options: {
  26376. radius?: number;
  26377. radiusX?: number;
  26378. radiusY?: number;
  26379. radiusZ?: number;
  26380. flat?: boolean;
  26381. subdivisions?: number;
  26382. sideOrientation?: number;
  26383. frontUVs?: Vector4;
  26384. backUVs?: Vector4;
  26385. }): VertexData;
  26386. /**
  26387. * Creates the VertexData for a Polyhedron
  26388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26389. * * type provided types are:
  26390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26391. * * 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)
  26392. * * size the size of the IcoSphere, optional default 1
  26393. * * sizeX allows stretching in the x direction, optional, default size
  26394. * * sizeY allows stretching in the y direction, optional, default size
  26395. * * sizeZ allows stretching in the z direction, optional, default size
  26396. * * 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
  26397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26399. * * flat when true creates a flat shaded mesh, optional, default true
  26400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26402. * * 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)
  26403. * * 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)
  26404. * @returns the VertexData of the Polyhedron
  26405. */
  26406. static CreatePolyhedron(options: {
  26407. type?: number;
  26408. size?: number;
  26409. sizeX?: number;
  26410. sizeY?: number;
  26411. sizeZ?: number;
  26412. custom?: any;
  26413. faceUV?: Vector4[];
  26414. faceColors?: Color4[];
  26415. flat?: boolean;
  26416. sideOrientation?: number;
  26417. frontUVs?: Vector4;
  26418. backUVs?: Vector4;
  26419. }): VertexData;
  26420. /**
  26421. * Creates the VertexData for a TorusKnot
  26422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26423. * * radius the radius of the torus knot, optional, default 2
  26424. * * tube the thickness of the tube, optional, default 0.5
  26425. * * radialSegments the number of sides on each tube segments, optional, default 32
  26426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26427. * * p the number of windings around the z axis, optional, default 2
  26428. * * q the number of windings around the x axis, optional, default 3
  26429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26430. * * 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)
  26431. * * 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)
  26432. * @returns the VertexData of the Torus Knot
  26433. */
  26434. static CreateTorusKnot(options: {
  26435. radius?: number;
  26436. tube?: number;
  26437. radialSegments?: number;
  26438. tubularSegments?: number;
  26439. p?: number;
  26440. q?: number;
  26441. sideOrientation?: number;
  26442. frontUVs?: Vector4;
  26443. backUVs?: Vector4;
  26444. }): VertexData;
  26445. /**
  26446. * Compute normals for given positions and indices
  26447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26451. * * facetNormals : optional array of facet normals (vector3)
  26452. * * facetPositions : optional array of facet positions (vector3)
  26453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26455. * * bInfo : optional bounding info, required for facetPartitioning computation
  26456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26458. * * useRightHandedSystem: optional boolean to for right handed system computation
  26459. * * depthSort : optional boolean to enable the facet depth sort computation
  26460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26462. */
  26463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26464. facetNormals?: any;
  26465. facetPositions?: any;
  26466. facetPartitioning?: any;
  26467. ratio?: number;
  26468. bInfo?: any;
  26469. bbSize?: Vector3;
  26470. subDiv?: any;
  26471. useRightHandedSystem?: boolean;
  26472. depthSort?: boolean;
  26473. distanceTo?: Vector3;
  26474. depthSortedFacets?: any;
  26475. }): void;
  26476. /** @hidden */
  26477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26478. /**
  26479. * Applies VertexData created from the imported parameters to the geometry
  26480. * @param parsedVertexData the parsed data from an imported file
  26481. * @param geometry the geometry to apply the VertexData to
  26482. */
  26483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26484. }
  26485. }
  26486. declare module "babylonjs/Morph/morphTarget" {
  26487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26488. import { Observable } from "babylonjs/Misc/observable";
  26489. import { Nullable, FloatArray } from "babylonjs/types";
  26490. import { Scene } from "babylonjs/scene";
  26491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26493. /**
  26494. * Defines a target to use with MorphTargetManager
  26495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26496. */
  26497. export class MorphTarget implements IAnimatable {
  26498. /** defines the name of the target */
  26499. name: string;
  26500. /**
  26501. * Gets or sets the list of animations
  26502. */
  26503. animations: import("babylonjs/Animations/animation").Animation[];
  26504. private _scene;
  26505. private _positions;
  26506. private _normals;
  26507. private _tangents;
  26508. private _uvs;
  26509. private _influence;
  26510. private _uniqueId;
  26511. /**
  26512. * Observable raised when the influence changes
  26513. */
  26514. onInfluenceChanged: Observable<boolean>;
  26515. /** @hidden */
  26516. _onDataLayoutChanged: Observable<void>;
  26517. /**
  26518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26519. */
  26520. get influence(): number;
  26521. set influence(influence: number);
  26522. /**
  26523. * Gets or sets the id of the morph Target
  26524. */
  26525. id: string;
  26526. private _animationPropertiesOverride;
  26527. /**
  26528. * Gets or sets the animation properties override
  26529. */
  26530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26532. /**
  26533. * Creates a new MorphTarget
  26534. * @param name defines the name of the target
  26535. * @param influence defines the influence to use
  26536. * @param scene defines the scene the morphtarget belongs to
  26537. */
  26538. constructor(
  26539. /** defines the name of the target */
  26540. name: string, influence?: number, scene?: Nullable<Scene>);
  26541. /**
  26542. * Gets the unique ID of this manager
  26543. */
  26544. get uniqueId(): number;
  26545. /**
  26546. * Gets a boolean defining if the target contains position data
  26547. */
  26548. get hasPositions(): boolean;
  26549. /**
  26550. * Gets a boolean defining if the target contains normal data
  26551. */
  26552. get hasNormals(): boolean;
  26553. /**
  26554. * Gets a boolean defining if the target contains tangent data
  26555. */
  26556. get hasTangents(): boolean;
  26557. /**
  26558. * Gets a boolean defining if the target contains texture coordinates data
  26559. */
  26560. get hasUVs(): boolean;
  26561. /**
  26562. * Affects position data to this target
  26563. * @param data defines the position data to use
  26564. */
  26565. setPositions(data: Nullable<FloatArray>): void;
  26566. /**
  26567. * Gets the position data stored in this target
  26568. * @returns a FloatArray containing the position data (or null if not present)
  26569. */
  26570. getPositions(): Nullable<FloatArray>;
  26571. /**
  26572. * Affects normal data to this target
  26573. * @param data defines the normal data to use
  26574. */
  26575. setNormals(data: Nullable<FloatArray>): void;
  26576. /**
  26577. * Gets the normal data stored in this target
  26578. * @returns a FloatArray containing the normal data (or null if not present)
  26579. */
  26580. getNormals(): Nullable<FloatArray>;
  26581. /**
  26582. * Affects tangent data to this target
  26583. * @param data defines the tangent data to use
  26584. */
  26585. setTangents(data: Nullable<FloatArray>): void;
  26586. /**
  26587. * Gets the tangent data stored in this target
  26588. * @returns a FloatArray containing the tangent data (or null if not present)
  26589. */
  26590. getTangents(): Nullable<FloatArray>;
  26591. /**
  26592. * Affects texture coordinates data to this target
  26593. * @param data defines the texture coordinates data to use
  26594. */
  26595. setUVs(data: Nullable<FloatArray>): void;
  26596. /**
  26597. * Gets the texture coordinates data stored in this target
  26598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26599. */
  26600. getUVs(): Nullable<FloatArray>;
  26601. /**
  26602. * Clone the current target
  26603. * @returns a new MorphTarget
  26604. */
  26605. clone(): MorphTarget;
  26606. /**
  26607. * Serializes the current target into a Serialization object
  26608. * @returns the serialized object
  26609. */
  26610. serialize(): any;
  26611. /**
  26612. * Returns the string "MorphTarget"
  26613. * @returns "MorphTarget"
  26614. */
  26615. getClassName(): string;
  26616. /**
  26617. * Creates a new target from serialized data
  26618. * @param serializationObject defines the serialized data to use
  26619. * @returns a new MorphTarget
  26620. */
  26621. static Parse(serializationObject: any): MorphTarget;
  26622. /**
  26623. * Creates a MorphTarget from mesh data
  26624. * @param mesh defines the source mesh
  26625. * @param name defines the name to use for the new target
  26626. * @param influence defines the influence to attach to the target
  26627. * @returns a new MorphTarget
  26628. */
  26629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26630. }
  26631. }
  26632. declare module "babylonjs/Morph/morphTargetManager" {
  26633. import { Nullable } from "babylonjs/types";
  26634. import { Scene } from "babylonjs/scene";
  26635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26636. /**
  26637. * This class is used to deform meshes using morphing between different targets
  26638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26639. */
  26640. export class MorphTargetManager {
  26641. private _targets;
  26642. private _targetInfluenceChangedObservers;
  26643. private _targetDataLayoutChangedObservers;
  26644. private _activeTargets;
  26645. private _scene;
  26646. private _influences;
  26647. private _supportsNormals;
  26648. private _supportsTangents;
  26649. private _supportsUVs;
  26650. private _vertexCount;
  26651. private _uniqueId;
  26652. private _tempInfluences;
  26653. /**
  26654. * Gets or sets a boolean indicating if normals must be morphed
  26655. */
  26656. enableNormalMorphing: boolean;
  26657. /**
  26658. * Gets or sets a boolean indicating if tangents must be morphed
  26659. */
  26660. enableTangentMorphing: boolean;
  26661. /**
  26662. * Gets or sets a boolean indicating if UV must be morphed
  26663. */
  26664. enableUVMorphing: boolean;
  26665. /**
  26666. * Creates a new MorphTargetManager
  26667. * @param scene defines the current scene
  26668. */
  26669. constructor(scene?: Nullable<Scene>);
  26670. /**
  26671. * Gets the unique ID of this manager
  26672. */
  26673. get uniqueId(): number;
  26674. /**
  26675. * Gets the number of vertices handled by this manager
  26676. */
  26677. get vertexCount(): number;
  26678. /**
  26679. * Gets a boolean indicating if this manager supports morphing of normals
  26680. */
  26681. get supportsNormals(): boolean;
  26682. /**
  26683. * Gets a boolean indicating if this manager supports morphing of tangents
  26684. */
  26685. get supportsTangents(): boolean;
  26686. /**
  26687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26688. */
  26689. get supportsUVs(): boolean;
  26690. /**
  26691. * Gets the number of targets stored in this manager
  26692. */
  26693. get numTargets(): number;
  26694. /**
  26695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26696. */
  26697. get numInfluencers(): number;
  26698. /**
  26699. * Gets the list of influences (one per target)
  26700. */
  26701. get influences(): Float32Array;
  26702. /**
  26703. * Gets the active target at specified index. An active target is a target with an influence > 0
  26704. * @param index defines the index to check
  26705. * @returns the requested target
  26706. */
  26707. getActiveTarget(index: number): MorphTarget;
  26708. /**
  26709. * Gets the target at specified index
  26710. * @param index defines the index to check
  26711. * @returns the requested target
  26712. */
  26713. getTarget(index: number): MorphTarget;
  26714. /**
  26715. * Add a new target to this manager
  26716. * @param target defines the target to add
  26717. */
  26718. addTarget(target: MorphTarget): void;
  26719. /**
  26720. * Removes a target from the manager
  26721. * @param target defines the target to remove
  26722. */
  26723. removeTarget(target: MorphTarget): void;
  26724. /**
  26725. * Clone the current manager
  26726. * @returns a new MorphTargetManager
  26727. */
  26728. clone(): MorphTargetManager;
  26729. /**
  26730. * Serializes the current manager into a Serialization object
  26731. * @returns the serialized object
  26732. */
  26733. serialize(): any;
  26734. private _syncActiveTargets;
  26735. /**
  26736. * Syncrhonize the targets with all the meshes using this morph target manager
  26737. */
  26738. synchronize(): void;
  26739. /**
  26740. * Creates a new MorphTargetManager from serialized data
  26741. * @param serializationObject defines the serialized data
  26742. * @param scene defines the hosting scene
  26743. * @returns the new MorphTargetManager
  26744. */
  26745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26746. }
  26747. }
  26748. declare module "babylonjs/Meshes/meshLODLevel" {
  26749. import { Mesh } from "babylonjs/Meshes/mesh";
  26750. import { Nullable } from "babylonjs/types";
  26751. /**
  26752. * Class used to represent a specific level of detail of a mesh
  26753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26754. */
  26755. export class MeshLODLevel {
  26756. /** Defines the distance where this level should start being displayed */
  26757. distance: number;
  26758. /** Defines the mesh to use to render this level */
  26759. mesh: Nullable<Mesh>;
  26760. /**
  26761. * Creates a new LOD level
  26762. * @param distance defines the distance where this level should star being displayed
  26763. * @param mesh defines the mesh to use to render this level
  26764. */
  26765. constructor(
  26766. /** Defines the distance where this level should start being displayed */
  26767. distance: number,
  26768. /** Defines the mesh to use to render this level */
  26769. mesh: Nullable<Mesh>);
  26770. }
  26771. }
  26772. declare module "babylonjs/Misc/canvasGenerator" {
  26773. /**
  26774. * Helper class used to generate a canvas to manipulate images
  26775. */
  26776. export class CanvasGenerator {
  26777. /**
  26778. * Create a new canvas (or offscreen canvas depending on the context)
  26779. * @param width defines the expected width
  26780. * @param height defines the expected height
  26781. * @return a new canvas or offscreen canvas
  26782. */
  26783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26784. }
  26785. }
  26786. declare module "babylonjs/Meshes/groundMesh" {
  26787. import { Scene } from "babylonjs/scene";
  26788. import { Vector3 } from "babylonjs/Maths/math.vector";
  26789. import { Mesh } from "babylonjs/Meshes/mesh";
  26790. /**
  26791. * Mesh representing the gorund
  26792. */
  26793. export class GroundMesh extends Mesh {
  26794. /** If octree should be generated */
  26795. generateOctree: boolean;
  26796. private _heightQuads;
  26797. /** @hidden */
  26798. _subdivisionsX: number;
  26799. /** @hidden */
  26800. _subdivisionsY: number;
  26801. /** @hidden */
  26802. _width: number;
  26803. /** @hidden */
  26804. _height: number;
  26805. /** @hidden */
  26806. _minX: number;
  26807. /** @hidden */
  26808. _maxX: number;
  26809. /** @hidden */
  26810. _minZ: number;
  26811. /** @hidden */
  26812. _maxZ: number;
  26813. constructor(name: string, scene: Scene);
  26814. /**
  26815. * "GroundMesh"
  26816. * @returns "GroundMesh"
  26817. */
  26818. getClassName(): string;
  26819. /**
  26820. * The minimum of x and y subdivisions
  26821. */
  26822. get subdivisions(): number;
  26823. /**
  26824. * X subdivisions
  26825. */
  26826. get subdivisionsX(): number;
  26827. /**
  26828. * Y subdivisions
  26829. */
  26830. get subdivisionsY(): number;
  26831. /**
  26832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26834. * @param chunksCount the number of subdivisions for x and y
  26835. * @param octreeBlocksSize (Default: 32)
  26836. */
  26837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26838. /**
  26839. * Returns a height (y) value in the Worl system :
  26840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26841. * @param x x coordinate
  26842. * @param z z coordinate
  26843. * @returns the ground y position if (x, z) are outside the ground surface.
  26844. */
  26845. getHeightAtCoordinates(x: number, z: number): number;
  26846. /**
  26847. * Returns a normalized vector (Vector3) orthogonal to the ground
  26848. * at the ground coordinates (x, z) expressed in the World system.
  26849. * @param x x coordinate
  26850. * @param z z coordinate
  26851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26852. */
  26853. getNormalAtCoordinates(x: number, z: number): Vector3;
  26854. /**
  26855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26856. * at the ground coordinates (x, z) expressed in the World system.
  26857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26858. * @param x x coordinate
  26859. * @param z z coordinate
  26860. * @param ref vector to store the result
  26861. * @returns the GroundMesh.
  26862. */
  26863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26864. /**
  26865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26866. * if the ground has been updated.
  26867. * This can be used in the render loop.
  26868. * @returns the GroundMesh.
  26869. */
  26870. updateCoordinateHeights(): GroundMesh;
  26871. private _getFacetAt;
  26872. private _initHeightQuads;
  26873. private _computeHeightQuads;
  26874. /**
  26875. * Serializes this ground mesh
  26876. * @param serializationObject object to write serialization to
  26877. */
  26878. serialize(serializationObject: any): void;
  26879. /**
  26880. * Parses a serialized ground mesh
  26881. * @param parsedMesh the serialized mesh
  26882. * @param scene the scene to create the ground mesh in
  26883. * @returns the created ground mesh
  26884. */
  26885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26886. }
  26887. }
  26888. declare module "babylonjs/Physics/physicsJoint" {
  26889. import { Vector3 } from "babylonjs/Maths/math.vector";
  26890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26891. /**
  26892. * Interface for Physics-Joint data
  26893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26894. */
  26895. export interface PhysicsJointData {
  26896. /**
  26897. * The main pivot of the joint
  26898. */
  26899. mainPivot?: Vector3;
  26900. /**
  26901. * The connected pivot of the joint
  26902. */
  26903. connectedPivot?: Vector3;
  26904. /**
  26905. * The main axis of the joint
  26906. */
  26907. mainAxis?: Vector3;
  26908. /**
  26909. * The connected axis of the joint
  26910. */
  26911. connectedAxis?: Vector3;
  26912. /**
  26913. * The collision of the joint
  26914. */
  26915. collision?: boolean;
  26916. /**
  26917. * Native Oimo/Cannon/Energy data
  26918. */
  26919. nativeParams?: any;
  26920. }
  26921. /**
  26922. * This is a holder class for the physics joint created by the physics plugin
  26923. * It holds a set of functions to control the underlying joint
  26924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26925. */
  26926. export class PhysicsJoint {
  26927. /**
  26928. * The type of the physics joint
  26929. */
  26930. type: number;
  26931. /**
  26932. * The data for the physics joint
  26933. */
  26934. jointData: PhysicsJointData;
  26935. private _physicsJoint;
  26936. protected _physicsPlugin: IPhysicsEnginePlugin;
  26937. /**
  26938. * Initializes the physics joint
  26939. * @param type The type of the physics joint
  26940. * @param jointData The data for the physics joint
  26941. */
  26942. constructor(
  26943. /**
  26944. * The type of the physics joint
  26945. */
  26946. type: number,
  26947. /**
  26948. * The data for the physics joint
  26949. */
  26950. jointData: PhysicsJointData);
  26951. /**
  26952. * Gets the physics joint
  26953. */
  26954. get physicsJoint(): any;
  26955. /**
  26956. * Sets the physics joint
  26957. */
  26958. set physicsJoint(newJoint: any);
  26959. /**
  26960. * Sets the physics plugin
  26961. */
  26962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26963. /**
  26964. * Execute a function that is physics-plugin specific.
  26965. * @param {Function} func the function that will be executed.
  26966. * It accepts two parameters: the physics world and the physics joint
  26967. */
  26968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26969. /**
  26970. * Distance-Joint type
  26971. */
  26972. static DistanceJoint: number;
  26973. /**
  26974. * Hinge-Joint type
  26975. */
  26976. static HingeJoint: number;
  26977. /**
  26978. * Ball-and-Socket joint type
  26979. */
  26980. static BallAndSocketJoint: number;
  26981. /**
  26982. * Wheel-Joint type
  26983. */
  26984. static WheelJoint: number;
  26985. /**
  26986. * Slider-Joint type
  26987. */
  26988. static SliderJoint: number;
  26989. /**
  26990. * Prismatic-Joint type
  26991. */
  26992. static PrismaticJoint: number;
  26993. /**
  26994. * Universal-Joint type
  26995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26996. */
  26997. static UniversalJoint: number;
  26998. /**
  26999. * Hinge-Joint 2 type
  27000. */
  27001. static Hinge2Joint: number;
  27002. /**
  27003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27004. */
  27005. static PointToPointJoint: number;
  27006. /**
  27007. * Spring-Joint type
  27008. */
  27009. static SpringJoint: number;
  27010. /**
  27011. * Lock-Joint type
  27012. */
  27013. static LockJoint: number;
  27014. }
  27015. /**
  27016. * A class representing a physics distance joint
  27017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27018. */
  27019. export class DistanceJoint extends PhysicsJoint {
  27020. /**
  27021. *
  27022. * @param jointData The data for the Distance-Joint
  27023. */
  27024. constructor(jointData: DistanceJointData);
  27025. /**
  27026. * Update the predefined distance.
  27027. * @param maxDistance The maximum preferred distance
  27028. * @param minDistance The minimum preferred distance
  27029. */
  27030. updateDistance(maxDistance: number, minDistance?: number): void;
  27031. }
  27032. /**
  27033. * Represents a Motor-Enabled Joint
  27034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27035. */
  27036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27037. /**
  27038. * Initializes the Motor-Enabled Joint
  27039. * @param type The type of the joint
  27040. * @param jointData The physica joint data for the joint
  27041. */
  27042. constructor(type: number, jointData: PhysicsJointData);
  27043. /**
  27044. * Set the motor values.
  27045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27046. * @param force the force to apply
  27047. * @param maxForce max force for this motor.
  27048. */
  27049. setMotor(force?: number, maxForce?: number): void;
  27050. /**
  27051. * Set the motor's limits.
  27052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27053. * @param upperLimit The upper limit of the motor
  27054. * @param lowerLimit The lower limit of the motor
  27055. */
  27056. setLimit(upperLimit: number, lowerLimit?: number): void;
  27057. }
  27058. /**
  27059. * This class represents a single physics Hinge-Joint
  27060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27061. */
  27062. export class HingeJoint extends MotorEnabledJoint {
  27063. /**
  27064. * Initializes the Hinge-Joint
  27065. * @param jointData The joint data for the Hinge-Joint
  27066. */
  27067. constructor(jointData: PhysicsJointData);
  27068. /**
  27069. * Set the motor values.
  27070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27071. * @param {number} force the force to apply
  27072. * @param {number} maxForce max force for this motor.
  27073. */
  27074. setMotor(force?: number, maxForce?: number): void;
  27075. /**
  27076. * Set the motor's limits.
  27077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27078. * @param upperLimit The upper limit of the motor
  27079. * @param lowerLimit The lower limit of the motor
  27080. */
  27081. setLimit(upperLimit: number, lowerLimit?: number): void;
  27082. }
  27083. /**
  27084. * This class represents a dual hinge physics joint (same as wheel joint)
  27085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27086. */
  27087. export class Hinge2Joint extends MotorEnabledJoint {
  27088. /**
  27089. * Initializes the Hinge2-Joint
  27090. * @param jointData The joint data for the Hinge2-Joint
  27091. */
  27092. constructor(jointData: PhysicsJointData);
  27093. /**
  27094. * Set the motor values.
  27095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27096. * @param {number} targetSpeed the speed the motor is to reach
  27097. * @param {number} maxForce max force for this motor.
  27098. * @param {motorIndex} the motor's index, 0 or 1.
  27099. */
  27100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27101. /**
  27102. * Set the motor limits.
  27103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27104. * @param {number} upperLimit the upper limit
  27105. * @param {number} lowerLimit lower limit
  27106. * @param {motorIndex} the motor's index, 0 or 1.
  27107. */
  27108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27109. }
  27110. /**
  27111. * Interface for a motor enabled joint
  27112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27113. */
  27114. export interface IMotorEnabledJoint {
  27115. /**
  27116. * Physics joint
  27117. */
  27118. physicsJoint: any;
  27119. /**
  27120. * Sets the motor of the motor-enabled joint
  27121. * @param force The force of the motor
  27122. * @param maxForce The maximum force of the motor
  27123. * @param motorIndex The index of the motor
  27124. */
  27125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27126. /**
  27127. * Sets the limit of the motor
  27128. * @param upperLimit The upper limit of the motor
  27129. * @param lowerLimit The lower limit of the motor
  27130. * @param motorIndex The index of the motor
  27131. */
  27132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27133. }
  27134. /**
  27135. * Joint data for a Distance-Joint
  27136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27137. */
  27138. export interface DistanceJointData extends PhysicsJointData {
  27139. /**
  27140. * Max distance the 2 joint objects can be apart
  27141. */
  27142. maxDistance: number;
  27143. }
  27144. /**
  27145. * Joint data from a spring joint
  27146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27147. */
  27148. export interface SpringJointData extends PhysicsJointData {
  27149. /**
  27150. * Length of the spring
  27151. */
  27152. length: number;
  27153. /**
  27154. * Stiffness of the spring
  27155. */
  27156. stiffness: number;
  27157. /**
  27158. * Damping of the spring
  27159. */
  27160. damping: number;
  27161. /** this callback will be called when applying the force to the impostors. */
  27162. forceApplicationCallback: () => void;
  27163. }
  27164. }
  27165. declare module "babylonjs/Physics/physicsRaycastResult" {
  27166. import { Vector3 } from "babylonjs/Maths/math.vector";
  27167. /**
  27168. * Holds the data for the raycast result
  27169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27170. */
  27171. export class PhysicsRaycastResult {
  27172. private _hasHit;
  27173. private _hitDistance;
  27174. private _hitNormalWorld;
  27175. private _hitPointWorld;
  27176. private _rayFromWorld;
  27177. private _rayToWorld;
  27178. /**
  27179. * Gets if there was a hit
  27180. */
  27181. get hasHit(): boolean;
  27182. /**
  27183. * Gets the distance from the hit
  27184. */
  27185. get hitDistance(): number;
  27186. /**
  27187. * Gets the hit normal/direction in the world
  27188. */
  27189. get hitNormalWorld(): Vector3;
  27190. /**
  27191. * Gets the hit point in the world
  27192. */
  27193. get hitPointWorld(): Vector3;
  27194. /**
  27195. * Gets the ray "start point" of the ray in the world
  27196. */
  27197. get rayFromWorld(): Vector3;
  27198. /**
  27199. * Gets the ray "end point" of the ray in the world
  27200. */
  27201. get rayToWorld(): Vector3;
  27202. /**
  27203. * Sets the hit data (normal & point in world space)
  27204. * @param hitNormalWorld defines the normal in world space
  27205. * @param hitPointWorld defines the point in world space
  27206. */
  27207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27208. /**
  27209. * Sets the distance from the start point to the hit point
  27210. * @param distance
  27211. */
  27212. setHitDistance(distance: number): void;
  27213. /**
  27214. * Calculates the distance manually
  27215. */
  27216. calculateHitDistance(): void;
  27217. /**
  27218. * Resets all the values to default
  27219. * @param from The from point on world space
  27220. * @param to The to point on world space
  27221. */
  27222. reset(from?: Vector3, to?: Vector3): void;
  27223. }
  27224. /**
  27225. * Interface for the size containing width and height
  27226. */
  27227. interface IXYZ {
  27228. /**
  27229. * X
  27230. */
  27231. x: number;
  27232. /**
  27233. * Y
  27234. */
  27235. y: number;
  27236. /**
  27237. * Z
  27238. */
  27239. z: number;
  27240. }
  27241. }
  27242. declare module "babylonjs/Physics/IPhysicsEngine" {
  27243. import { Nullable } from "babylonjs/types";
  27244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27249. /**
  27250. * Interface used to describe a physics joint
  27251. */
  27252. export interface PhysicsImpostorJoint {
  27253. /** Defines the main impostor to which the joint is linked */
  27254. mainImpostor: PhysicsImpostor;
  27255. /** Defines the impostor that is connected to the main impostor using this joint */
  27256. connectedImpostor: PhysicsImpostor;
  27257. /** Defines the joint itself */
  27258. joint: PhysicsJoint;
  27259. }
  27260. /** @hidden */
  27261. export interface IPhysicsEnginePlugin {
  27262. world: any;
  27263. name: string;
  27264. setGravity(gravity: Vector3): void;
  27265. setTimeStep(timeStep: number): void;
  27266. getTimeStep(): number;
  27267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27271. removePhysicsBody(impostor: PhysicsImpostor): void;
  27272. generateJoint(joint: PhysicsImpostorJoint): void;
  27273. removeJoint(joint: PhysicsImpostorJoint): void;
  27274. isSupported(): boolean;
  27275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27282. getBodyMass(impostor: PhysicsImpostor): number;
  27283. getBodyFriction(impostor: PhysicsImpostor): number;
  27284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27285. getBodyRestitution(impostor: PhysicsImpostor): number;
  27286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27287. getBodyPressure?(impostor: PhysicsImpostor): number;
  27288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27297. sleepBody(impostor: PhysicsImpostor): void;
  27298. wakeUpBody(impostor: PhysicsImpostor): void;
  27299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27303. getRadius(impostor: PhysicsImpostor): number;
  27304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27306. dispose(): void;
  27307. }
  27308. /**
  27309. * Interface used to define a physics engine
  27310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27311. */
  27312. export interface IPhysicsEngine {
  27313. /**
  27314. * Gets the gravity vector used by the simulation
  27315. */
  27316. gravity: Vector3;
  27317. /**
  27318. * Sets the gravity vector used by the simulation
  27319. * @param gravity defines the gravity vector to use
  27320. */
  27321. setGravity(gravity: Vector3): void;
  27322. /**
  27323. * Set the time step of the physics engine.
  27324. * Default is 1/60.
  27325. * To slow it down, enter 1/600 for example.
  27326. * To speed it up, 1/30
  27327. * @param newTimeStep the new timestep to apply to this world.
  27328. */
  27329. setTimeStep(newTimeStep: number): void;
  27330. /**
  27331. * Get the time step of the physics engine.
  27332. * @returns the current time step
  27333. */
  27334. getTimeStep(): number;
  27335. /**
  27336. * Set the sub time step of the physics engine.
  27337. * Default is 0 meaning there is no sub steps
  27338. * To increase physics resolution precision, set a small value (like 1 ms)
  27339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27340. */
  27341. setSubTimeStep(subTimeStep: number): void;
  27342. /**
  27343. * Get the sub time step of the physics engine.
  27344. * @returns the current sub time step
  27345. */
  27346. getSubTimeStep(): number;
  27347. /**
  27348. * Release all resources
  27349. */
  27350. dispose(): void;
  27351. /**
  27352. * Gets the name of the current physics plugin
  27353. * @returns the name of the plugin
  27354. */
  27355. getPhysicsPluginName(): string;
  27356. /**
  27357. * Adding a new impostor for the impostor tracking.
  27358. * This will be done by the impostor itself.
  27359. * @param impostor the impostor to add
  27360. */
  27361. addImpostor(impostor: PhysicsImpostor): void;
  27362. /**
  27363. * Remove an impostor from the engine.
  27364. * This impostor and its mesh will not longer be updated by the physics engine.
  27365. * @param impostor the impostor to remove
  27366. */
  27367. removeImpostor(impostor: PhysicsImpostor): void;
  27368. /**
  27369. * Add a joint to the physics engine
  27370. * @param mainImpostor defines the main impostor to which the joint is added.
  27371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27372. * @param joint defines the joint that will connect both impostors.
  27373. */
  27374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27375. /**
  27376. * Removes a joint from the simulation
  27377. * @param mainImpostor defines the impostor used with the joint
  27378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27379. * @param joint defines the joint to remove
  27380. */
  27381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27382. /**
  27383. * Gets the current plugin used to run the simulation
  27384. * @returns current plugin
  27385. */
  27386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27387. /**
  27388. * Gets the list of physic impostors
  27389. * @returns an array of PhysicsImpostor
  27390. */
  27391. getImpostors(): Array<PhysicsImpostor>;
  27392. /**
  27393. * Gets the impostor for a physics enabled object
  27394. * @param object defines the object impersonated by the impostor
  27395. * @returns the PhysicsImpostor or null if not found
  27396. */
  27397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27398. /**
  27399. * Gets the impostor for a physics body object
  27400. * @param body defines physics body used by the impostor
  27401. * @returns the PhysicsImpostor or null if not found
  27402. */
  27403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27404. /**
  27405. * Does a raycast in the physics world
  27406. * @param from when should the ray start?
  27407. * @param to when should the ray end?
  27408. * @returns PhysicsRaycastResult
  27409. */
  27410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27411. /**
  27412. * Called by the scene. No need to call it.
  27413. * @param delta defines the timespam between frames
  27414. */
  27415. _step(delta: number): void;
  27416. }
  27417. }
  27418. declare module "babylonjs/Physics/physicsImpostor" {
  27419. import { Nullable, IndicesArray } from "babylonjs/types";
  27420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27423. import { Scene } from "babylonjs/scene";
  27424. import { Bone } from "babylonjs/Bones/bone";
  27425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27427. import { Space } from "babylonjs/Maths/math.axis";
  27428. /**
  27429. * The interface for the physics imposter parameters
  27430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27431. */
  27432. export interface PhysicsImpostorParameters {
  27433. /**
  27434. * The mass of the physics imposter
  27435. */
  27436. mass: number;
  27437. /**
  27438. * The friction of the physics imposter
  27439. */
  27440. friction?: number;
  27441. /**
  27442. * The coefficient of restitution of the physics imposter
  27443. */
  27444. restitution?: number;
  27445. /**
  27446. * The native options of the physics imposter
  27447. */
  27448. nativeOptions?: any;
  27449. /**
  27450. * Specifies if the parent should be ignored
  27451. */
  27452. ignoreParent?: boolean;
  27453. /**
  27454. * Specifies if bi-directional transformations should be disabled
  27455. */
  27456. disableBidirectionalTransformation?: boolean;
  27457. /**
  27458. * The pressure inside the physics imposter, soft object only
  27459. */
  27460. pressure?: number;
  27461. /**
  27462. * The stiffness the physics imposter, soft object only
  27463. */
  27464. stiffness?: number;
  27465. /**
  27466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27467. */
  27468. velocityIterations?: number;
  27469. /**
  27470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27471. */
  27472. positionIterations?: number;
  27473. /**
  27474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27476. * Add to fix multiple points
  27477. */
  27478. fixedPoints?: number;
  27479. /**
  27480. * The collision margin around a soft object
  27481. */
  27482. margin?: number;
  27483. /**
  27484. * The collision margin around a soft object
  27485. */
  27486. damping?: number;
  27487. /**
  27488. * The path for a rope based on an extrusion
  27489. */
  27490. path?: any;
  27491. /**
  27492. * The shape of an extrusion used for a rope based on an extrusion
  27493. */
  27494. shape?: any;
  27495. }
  27496. /**
  27497. * Interface for a physics-enabled object
  27498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27499. */
  27500. export interface IPhysicsEnabledObject {
  27501. /**
  27502. * The position of the physics-enabled object
  27503. */
  27504. position: Vector3;
  27505. /**
  27506. * The rotation of the physics-enabled object
  27507. */
  27508. rotationQuaternion: Nullable<Quaternion>;
  27509. /**
  27510. * The scale of the physics-enabled object
  27511. */
  27512. scaling: Vector3;
  27513. /**
  27514. * The rotation of the physics-enabled object
  27515. */
  27516. rotation?: Vector3;
  27517. /**
  27518. * The parent of the physics-enabled object
  27519. */
  27520. parent?: any;
  27521. /**
  27522. * The bounding info of the physics-enabled object
  27523. * @returns The bounding info of the physics-enabled object
  27524. */
  27525. getBoundingInfo(): BoundingInfo;
  27526. /**
  27527. * Computes the world matrix
  27528. * @param force Specifies if the world matrix should be computed by force
  27529. * @returns A world matrix
  27530. */
  27531. computeWorldMatrix(force: boolean): Matrix;
  27532. /**
  27533. * Gets the world matrix
  27534. * @returns A world matrix
  27535. */
  27536. getWorldMatrix?(): Matrix;
  27537. /**
  27538. * Gets the child meshes
  27539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27540. * @returns An array of abstract meshes
  27541. */
  27542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27543. /**
  27544. * Gets the vertex data
  27545. * @param kind The type of vertex data
  27546. * @returns A nullable array of numbers, or a float32 array
  27547. */
  27548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27549. /**
  27550. * Gets the indices from the mesh
  27551. * @returns A nullable array of index arrays
  27552. */
  27553. getIndices?(): Nullable<IndicesArray>;
  27554. /**
  27555. * Gets the scene from the mesh
  27556. * @returns the indices array or null
  27557. */
  27558. getScene?(): Scene;
  27559. /**
  27560. * Gets the absolute position from the mesh
  27561. * @returns the absolute position
  27562. */
  27563. getAbsolutePosition(): Vector3;
  27564. /**
  27565. * Gets the absolute pivot point from the mesh
  27566. * @returns the absolute pivot point
  27567. */
  27568. getAbsolutePivotPoint(): Vector3;
  27569. /**
  27570. * Rotates the mesh
  27571. * @param axis The axis of rotation
  27572. * @param amount The amount of rotation
  27573. * @param space The space of the rotation
  27574. * @returns The rotation transform node
  27575. */
  27576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27577. /**
  27578. * Translates the mesh
  27579. * @param axis The axis of translation
  27580. * @param distance The distance of translation
  27581. * @param space The space of the translation
  27582. * @returns The transform node
  27583. */
  27584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27585. /**
  27586. * Sets the absolute position of the mesh
  27587. * @param absolutePosition The absolute position of the mesh
  27588. * @returns The transform node
  27589. */
  27590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27591. /**
  27592. * Gets the class name of the mesh
  27593. * @returns The class name
  27594. */
  27595. getClassName(): string;
  27596. }
  27597. /**
  27598. * Represents a physics imposter
  27599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27600. */
  27601. export class PhysicsImpostor {
  27602. /**
  27603. * The physics-enabled object used as the physics imposter
  27604. */
  27605. object: IPhysicsEnabledObject;
  27606. /**
  27607. * The type of the physics imposter
  27608. */
  27609. type: number;
  27610. private _options;
  27611. private _scene?;
  27612. /**
  27613. * The default object size of the imposter
  27614. */
  27615. static DEFAULT_OBJECT_SIZE: Vector3;
  27616. /**
  27617. * The identity quaternion of the imposter
  27618. */
  27619. static IDENTITY_QUATERNION: Quaternion;
  27620. /** @hidden */
  27621. _pluginData: any;
  27622. private _physicsEngine;
  27623. private _physicsBody;
  27624. private _bodyUpdateRequired;
  27625. private _onBeforePhysicsStepCallbacks;
  27626. private _onAfterPhysicsStepCallbacks;
  27627. /** @hidden */
  27628. _onPhysicsCollideCallbacks: Array<{
  27629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27630. otherImpostors: Array<PhysicsImpostor>;
  27631. }>;
  27632. private _deltaPosition;
  27633. private _deltaRotation;
  27634. private _deltaRotationConjugated;
  27635. /** @hidden */
  27636. _isFromLine: boolean;
  27637. private _parent;
  27638. private _isDisposed;
  27639. private static _tmpVecs;
  27640. private static _tmpQuat;
  27641. /**
  27642. * Specifies if the physics imposter is disposed
  27643. */
  27644. get isDisposed(): boolean;
  27645. /**
  27646. * Gets the mass of the physics imposter
  27647. */
  27648. get mass(): number;
  27649. set mass(value: number);
  27650. /**
  27651. * Gets the coefficient of friction
  27652. */
  27653. get friction(): number;
  27654. /**
  27655. * Sets the coefficient of friction
  27656. */
  27657. set friction(value: number);
  27658. /**
  27659. * Gets the coefficient of restitution
  27660. */
  27661. get restitution(): number;
  27662. /**
  27663. * Sets the coefficient of restitution
  27664. */
  27665. set restitution(value: number);
  27666. /**
  27667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27668. */
  27669. get pressure(): number;
  27670. /**
  27671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27672. */
  27673. set pressure(value: number);
  27674. /**
  27675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27676. */
  27677. get stiffness(): number;
  27678. /**
  27679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27680. */
  27681. set stiffness(value: number);
  27682. /**
  27683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27684. */
  27685. get velocityIterations(): number;
  27686. /**
  27687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27688. */
  27689. set velocityIterations(value: number);
  27690. /**
  27691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27692. */
  27693. get positionIterations(): number;
  27694. /**
  27695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27696. */
  27697. set positionIterations(value: number);
  27698. /**
  27699. * The unique id of the physics imposter
  27700. * set by the physics engine when adding this impostor to the array
  27701. */
  27702. uniqueId: number;
  27703. /**
  27704. * @hidden
  27705. */
  27706. soft: boolean;
  27707. /**
  27708. * @hidden
  27709. */
  27710. segments: number;
  27711. private _joints;
  27712. /**
  27713. * Initializes the physics imposter
  27714. * @param object The physics-enabled object used as the physics imposter
  27715. * @param type The type of the physics imposter
  27716. * @param _options The options for the physics imposter
  27717. * @param _scene The Babylon scene
  27718. */
  27719. constructor(
  27720. /**
  27721. * The physics-enabled object used as the physics imposter
  27722. */
  27723. object: IPhysicsEnabledObject,
  27724. /**
  27725. * The type of the physics imposter
  27726. */
  27727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27728. /**
  27729. * This function will completly initialize this impostor.
  27730. * It will create a new body - but only if this mesh has no parent.
  27731. * If it has, this impostor will not be used other than to define the impostor
  27732. * of the child mesh.
  27733. * @hidden
  27734. */
  27735. _init(): void;
  27736. private _getPhysicsParent;
  27737. /**
  27738. * Should a new body be generated.
  27739. * @returns boolean specifying if body initialization is required
  27740. */
  27741. isBodyInitRequired(): boolean;
  27742. /**
  27743. * Sets the updated scaling
  27744. * @param updated Specifies if the scaling is updated
  27745. */
  27746. setScalingUpdated(): void;
  27747. /**
  27748. * Force a regeneration of this or the parent's impostor's body.
  27749. * Use under cautious - This will remove all joints already implemented.
  27750. */
  27751. forceUpdate(): void;
  27752. /**
  27753. * Gets the body that holds this impostor. Either its own, or its parent.
  27754. */
  27755. get physicsBody(): any;
  27756. /**
  27757. * Get the parent of the physics imposter
  27758. * @returns Physics imposter or null
  27759. */
  27760. get parent(): Nullable<PhysicsImpostor>;
  27761. /**
  27762. * Sets the parent of the physics imposter
  27763. */
  27764. set parent(value: Nullable<PhysicsImpostor>);
  27765. /**
  27766. * Set the physics body. Used mainly by the physics engine/plugin
  27767. */
  27768. set physicsBody(physicsBody: any);
  27769. /**
  27770. * Resets the update flags
  27771. */
  27772. resetUpdateFlags(): void;
  27773. /**
  27774. * Gets the object extend size
  27775. * @returns the object extend size
  27776. */
  27777. getObjectExtendSize(): Vector3;
  27778. /**
  27779. * Gets the object center
  27780. * @returns The object center
  27781. */
  27782. getObjectCenter(): Vector3;
  27783. /**
  27784. * Get a specific parameter from the options parameters
  27785. * @param paramName The object parameter name
  27786. * @returns The object parameter
  27787. */
  27788. getParam(paramName: string): any;
  27789. /**
  27790. * Sets a specific parameter in the options given to the physics plugin
  27791. * @param paramName The parameter name
  27792. * @param value The value of the parameter
  27793. */
  27794. setParam(paramName: string, value: number): void;
  27795. /**
  27796. * Specifically change the body's mass option. Won't recreate the physics body object
  27797. * @param mass The mass of the physics imposter
  27798. */
  27799. setMass(mass: number): void;
  27800. /**
  27801. * Gets the linear velocity
  27802. * @returns linear velocity or null
  27803. */
  27804. getLinearVelocity(): Nullable<Vector3>;
  27805. /**
  27806. * Sets the linear velocity
  27807. * @param velocity linear velocity or null
  27808. */
  27809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27810. /**
  27811. * Gets the angular velocity
  27812. * @returns angular velocity or null
  27813. */
  27814. getAngularVelocity(): Nullable<Vector3>;
  27815. /**
  27816. * Sets the angular velocity
  27817. * @param velocity The velocity or null
  27818. */
  27819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27820. /**
  27821. * Execute a function with the physics plugin native code
  27822. * Provide a function the will have two variables - the world object and the physics body object
  27823. * @param func The function to execute with the physics plugin native code
  27824. */
  27825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27826. /**
  27827. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27831. /**
  27832. * Unregister a function that will be executed before the physics world is stepping forward
  27833. * @param func The function to execute before the physics world is stepped forward
  27834. */
  27835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27836. /**
  27837. * Register a function that will be executed after the physics step
  27838. * @param func The function to execute after physics step
  27839. */
  27840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Unregisters a function that will be executed after the physics step
  27843. * @param func The function to execute after physics step
  27844. */
  27845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * register a function that will be executed when this impostor collides against a different body
  27848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27849. * @param func Callback that is executed on collision
  27850. */
  27851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27852. /**
  27853. * Unregisters the physics imposter on contact
  27854. * @param collideAgainst The physics object to collide against
  27855. * @param func Callback to execute on collision
  27856. */
  27857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27858. private _tmpQuat;
  27859. private _tmpQuat2;
  27860. /**
  27861. * Get the parent rotation
  27862. * @returns The parent rotation
  27863. */
  27864. getParentsRotation(): Quaternion;
  27865. /**
  27866. * this function is executed by the physics engine.
  27867. */
  27868. beforeStep: () => void;
  27869. /**
  27870. * this function is executed by the physics engine
  27871. */
  27872. afterStep: () => void;
  27873. /**
  27874. * Legacy collision detection event support
  27875. */
  27876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27877. /**
  27878. * event and body object due to cannon's event-based architecture.
  27879. */
  27880. onCollide: (e: {
  27881. body: any;
  27882. }) => void;
  27883. /**
  27884. * Apply a force
  27885. * @param force The force to apply
  27886. * @param contactPoint The contact point for the force
  27887. * @returns The physics imposter
  27888. */
  27889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27890. /**
  27891. * Apply an impulse
  27892. * @param force The impulse force
  27893. * @param contactPoint The contact point for the impulse force
  27894. * @returns The physics imposter
  27895. */
  27896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27897. /**
  27898. * A help function to create a joint
  27899. * @param otherImpostor A physics imposter used to create a joint
  27900. * @param jointType The type of joint
  27901. * @param jointData The data for the joint
  27902. * @returns The physics imposter
  27903. */
  27904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27905. /**
  27906. * Add a joint to this impostor with a different impostor
  27907. * @param otherImpostor A physics imposter used to add a joint
  27908. * @param joint The joint to add
  27909. * @returns The physics imposter
  27910. */
  27911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27912. /**
  27913. * Add an anchor to a cloth impostor
  27914. * @param otherImpostor rigid impostor to anchor to
  27915. * @param width ratio across width from 0 to 1
  27916. * @param height ratio up height from 0 to 1
  27917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27919. * @returns impostor the soft imposter
  27920. */
  27921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27922. /**
  27923. * Add a hook to a rope impostor
  27924. * @param otherImpostor rigid impostor to anchor to
  27925. * @param length ratio across rope from 0 to 1
  27926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27928. * @returns impostor the rope imposter
  27929. */
  27930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27931. /**
  27932. * Will keep this body still, in a sleep mode.
  27933. * @returns the physics imposter
  27934. */
  27935. sleep(): PhysicsImpostor;
  27936. /**
  27937. * Wake the body up.
  27938. * @returns The physics imposter
  27939. */
  27940. wakeUp(): PhysicsImpostor;
  27941. /**
  27942. * Clones the physics imposter
  27943. * @param newObject The physics imposter clones to this physics-enabled object
  27944. * @returns A nullable physics imposter
  27945. */
  27946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27947. /**
  27948. * Disposes the physics imposter
  27949. */
  27950. dispose(): void;
  27951. /**
  27952. * Sets the delta position
  27953. * @param position The delta position amount
  27954. */
  27955. setDeltaPosition(position: Vector3): void;
  27956. /**
  27957. * Sets the delta rotation
  27958. * @param rotation The delta rotation amount
  27959. */
  27960. setDeltaRotation(rotation: Quaternion): void;
  27961. /**
  27962. * Gets the box size of the physics imposter and stores the result in the input parameter
  27963. * @param result Stores the box size
  27964. * @returns The physics imposter
  27965. */
  27966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27967. /**
  27968. * Gets the radius of the physics imposter
  27969. * @returns Radius of the physics imposter
  27970. */
  27971. getRadius(): number;
  27972. /**
  27973. * Sync a bone with this impostor
  27974. * @param bone The bone to sync to the impostor.
  27975. * @param boneMesh The mesh that the bone is influencing.
  27976. * @param jointPivot The pivot of the joint / bone in local space.
  27977. * @param distToJoint Optional distance from the impostor to the joint.
  27978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27979. */
  27980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27981. /**
  27982. * Sync impostor to a bone
  27983. * @param bone The bone that the impostor will be synced to.
  27984. * @param boneMesh The mesh that the bone is influencing.
  27985. * @param jointPivot The pivot of the joint / bone in local space.
  27986. * @param distToJoint Optional distance from the impostor to the joint.
  27987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27988. * @param boneAxis Optional vector3 axis the bone is aligned with
  27989. */
  27990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27991. /**
  27992. * No-Imposter type
  27993. */
  27994. static NoImpostor: number;
  27995. /**
  27996. * Sphere-Imposter type
  27997. */
  27998. static SphereImpostor: number;
  27999. /**
  28000. * Box-Imposter type
  28001. */
  28002. static BoxImpostor: number;
  28003. /**
  28004. * Plane-Imposter type
  28005. */
  28006. static PlaneImpostor: number;
  28007. /**
  28008. * Mesh-imposter type
  28009. */
  28010. static MeshImpostor: number;
  28011. /**
  28012. * Capsule-Impostor type (Ammo.js plugin only)
  28013. */
  28014. static CapsuleImpostor: number;
  28015. /**
  28016. * Cylinder-Imposter type
  28017. */
  28018. static CylinderImpostor: number;
  28019. /**
  28020. * Particle-Imposter type
  28021. */
  28022. static ParticleImpostor: number;
  28023. /**
  28024. * Heightmap-Imposter type
  28025. */
  28026. static HeightmapImpostor: number;
  28027. /**
  28028. * ConvexHull-Impostor type (Ammo.js plugin only)
  28029. */
  28030. static ConvexHullImpostor: number;
  28031. /**
  28032. * Custom-Imposter type (Ammo.js plugin only)
  28033. */
  28034. static CustomImpostor: number;
  28035. /**
  28036. * Rope-Imposter type
  28037. */
  28038. static RopeImpostor: number;
  28039. /**
  28040. * Cloth-Imposter type
  28041. */
  28042. static ClothImpostor: number;
  28043. /**
  28044. * Softbody-Imposter type
  28045. */
  28046. static SoftbodyImpostor: number;
  28047. }
  28048. }
  28049. declare module "babylonjs/Meshes/mesh" {
  28050. import { Observable } from "babylonjs/Misc/observable";
  28051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28053. import { Camera } from "babylonjs/Cameras/camera";
  28054. import { Scene } from "babylonjs/scene";
  28055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28056. import { Color4 } from "babylonjs/Maths/math.color";
  28057. import { Engine } from "babylonjs/Engines/engine";
  28058. import { Node } from "babylonjs/node";
  28059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28061. import { Buffer } from "babylonjs/Meshes/buffer";
  28062. import { Geometry } from "babylonjs/Meshes/geometry";
  28063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28066. import { Effect } from "babylonjs/Materials/effect";
  28067. import { Material } from "babylonjs/Materials/material";
  28068. import { Skeleton } from "babylonjs/Bones/skeleton";
  28069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28071. import { Path3D } from "babylonjs/Maths/math.path";
  28072. import { Plane } from "babylonjs/Maths/math.plane";
  28073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28079. /**
  28080. * @hidden
  28081. **/
  28082. export class _CreationDataStorage {
  28083. closePath?: boolean;
  28084. closeArray?: boolean;
  28085. idx: number[];
  28086. dashSize: number;
  28087. gapSize: number;
  28088. path3D: Path3D;
  28089. pathArray: Vector3[][];
  28090. arc: number;
  28091. radius: number;
  28092. cap: number;
  28093. tessellation: number;
  28094. }
  28095. /**
  28096. * @hidden
  28097. **/
  28098. class _InstanceDataStorage {
  28099. visibleInstances: any;
  28100. batchCache: _InstancesBatch;
  28101. instancesBufferSize: number;
  28102. instancesBuffer: Nullable<Buffer>;
  28103. instancesData: Float32Array;
  28104. overridenInstanceCount: number;
  28105. isFrozen: boolean;
  28106. previousBatch: Nullable<_InstancesBatch>;
  28107. hardwareInstancedRendering: boolean;
  28108. sideOrientation: number;
  28109. manualUpdate: boolean;
  28110. }
  28111. /**
  28112. * @hidden
  28113. **/
  28114. export class _InstancesBatch {
  28115. mustReturn: boolean;
  28116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28117. renderSelf: boolean[];
  28118. hardwareInstancedRendering: boolean[];
  28119. }
  28120. /**
  28121. * @hidden
  28122. **/
  28123. class _ThinInstanceDataStorage {
  28124. instancesCount: number;
  28125. matrixBuffer: Nullable<Buffer>;
  28126. matrixBufferSize: number;
  28127. matrixData: Nullable<Float32Array>;
  28128. boundingVectors: Array<Vector3>;
  28129. }
  28130. /**
  28131. * Class used to represent renderable models
  28132. */
  28133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28134. /**
  28135. * Mesh side orientation : usually the external or front surface
  28136. */
  28137. static readonly FRONTSIDE: number;
  28138. /**
  28139. * Mesh side orientation : usually the internal or back surface
  28140. */
  28141. static readonly BACKSIDE: number;
  28142. /**
  28143. * Mesh side orientation : both internal and external or front and back surfaces
  28144. */
  28145. static readonly DOUBLESIDE: number;
  28146. /**
  28147. * Mesh side orientation : by default, `FRONTSIDE`
  28148. */
  28149. static readonly DEFAULTSIDE: number;
  28150. /**
  28151. * Mesh cap setting : no cap
  28152. */
  28153. static readonly NO_CAP: number;
  28154. /**
  28155. * Mesh cap setting : one cap at the beginning of the mesh
  28156. */
  28157. static readonly CAP_START: number;
  28158. /**
  28159. * Mesh cap setting : one cap at the end of the mesh
  28160. */
  28161. static readonly CAP_END: number;
  28162. /**
  28163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28164. */
  28165. static readonly CAP_ALL: number;
  28166. /**
  28167. * Mesh pattern setting : no flip or rotate
  28168. */
  28169. static readonly NO_FLIP: number;
  28170. /**
  28171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28172. */
  28173. static readonly FLIP_TILE: number;
  28174. /**
  28175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28176. */
  28177. static readonly ROTATE_TILE: number;
  28178. /**
  28179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28180. */
  28181. static readonly FLIP_ROW: number;
  28182. /**
  28183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28184. */
  28185. static readonly ROTATE_ROW: number;
  28186. /**
  28187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28188. */
  28189. static readonly FLIP_N_ROTATE_TILE: number;
  28190. /**
  28191. * Mesh pattern setting : rotate pattern and rotate
  28192. */
  28193. static readonly FLIP_N_ROTATE_ROW: number;
  28194. /**
  28195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28196. */
  28197. static readonly CENTER: number;
  28198. /**
  28199. * Mesh tile positioning : part tiles on left
  28200. */
  28201. static readonly LEFT: number;
  28202. /**
  28203. * Mesh tile positioning : part tiles on right
  28204. */
  28205. static readonly RIGHT: number;
  28206. /**
  28207. * Mesh tile positioning : part tiles on top
  28208. */
  28209. static readonly TOP: number;
  28210. /**
  28211. * Mesh tile positioning : part tiles on bottom
  28212. */
  28213. static readonly BOTTOM: number;
  28214. /**
  28215. * Gets the default side orientation.
  28216. * @param orientation the orientation to value to attempt to get
  28217. * @returns the default orientation
  28218. * @hidden
  28219. */
  28220. static _GetDefaultSideOrientation(orientation?: number): number;
  28221. private _internalMeshDataInfo;
  28222. /**
  28223. * An event triggered before rendering the mesh
  28224. */
  28225. get onBeforeRenderObservable(): Observable<Mesh>;
  28226. /**
  28227. * An event triggered before binding the mesh
  28228. */
  28229. get onBeforeBindObservable(): Observable<Mesh>;
  28230. /**
  28231. * An event triggered after rendering the mesh
  28232. */
  28233. get onAfterRenderObservable(): Observable<Mesh>;
  28234. /**
  28235. * An event triggered before drawing the mesh
  28236. */
  28237. get onBeforeDrawObservable(): Observable<Mesh>;
  28238. private _onBeforeDrawObserver;
  28239. /**
  28240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28241. */
  28242. set onBeforeDraw(callback: () => void);
  28243. get hasInstances(): boolean;
  28244. get hasThinInstances(): boolean;
  28245. /**
  28246. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28247. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28248. */
  28249. delayLoadState: number;
  28250. /**
  28251. * Gets the list of instances created from this mesh
  28252. * it is not supposed to be modified manually.
  28253. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28254. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28255. */
  28256. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28257. /**
  28258. * Gets the file containing delay loading data for this mesh
  28259. */
  28260. delayLoadingFile: string;
  28261. /** @hidden */
  28262. _binaryInfo: any;
  28263. /**
  28264. * User defined function used to change how LOD level selection is done
  28265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28266. */
  28267. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28268. /**
  28269. * Gets or sets the morph target manager
  28270. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28271. */
  28272. get morphTargetManager(): Nullable<MorphTargetManager>;
  28273. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28274. /** @hidden */
  28275. _creationDataStorage: Nullable<_CreationDataStorage>;
  28276. /** @hidden */
  28277. _geometry: Nullable<Geometry>;
  28278. /** @hidden */
  28279. _delayInfo: Array<string>;
  28280. /** @hidden */
  28281. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28282. /** @hidden */
  28283. _instanceDataStorage: _InstanceDataStorage;
  28284. /** @hidden */
  28285. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28286. private _effectiveMaterial;
  28287. /** @hidden */
  28288. _shouldGenerateFlatShading: boolean;
  28289. /** @hidden */
  28290. _originalBuilderSideOrientation: number;
  28291. /**
  28292. * Use this property to change the original side orientation defined at construction time
  28293. */
  28294. overrideMaterialSideOrientation: Nullable<number>;
  28295. /**
  28296. * Gets the source mesh (the one used to clone this one from)
  28297. */
  28298. get source(): Nullable<Mesh>;
  28299. /**
  28300. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28301. */
  28302. get isUnIndexed(): boolean;
  28303. set isUnIndexed(value: boolean);
  28304. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28305. get worldMatrixInstancedBuffer(): Float32Array;
  28306. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28307. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28308. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28309. /**
  28310. * @constructor
  28311. * @param name The value used by scene.getMeshByName() to do a lookup.
  28312. * @param scene The scene to add this mesh to.
  28313. * @param parent The parent of this mesh, if it has one
  28314. * @param source An optional Mesh from which geometry is shared, cloned.
  28315. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28316. * When false, achieved by calling a clone(), also passing False.
  28317. * This will make creation of children, recursive.
  28318. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28319. */
  28320. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28321. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28322. doNotInstantiate: boolean;
  28323. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28324. /**
  28325. * Gets the class name
  28326. * @returns the string "Mesh".
  28327. */
  28328. getClassName(): string;
  28329. /** @hidden */
  28330. get _isMesh(): boolean;
  28331. /**
  28332. * Returns a description of this mesh
  28333. * @param fullDetails define if full details about this mesh must be used
  28334. * @returns a descriptive string representing this mesh
  28335. */
  28336. toString(fullDetails?: boolean): string;
  28337. /** @hidden */
  28338. _unBindEffect(): void;
  28339. /**
  28340. * Gets a boolean indicating if this mesh has LOD
  28341. */
  28342. get hasLODLevels(): boolean;
  28343. /**
  28344. * Gets the list of MeshLODLevel associated with the current mesh
  28345. * @returns an array of MeshLODLevel
  28346. */
  28347. getLODLevels(): MeshLODLevel[];
  28348. private _sortLODLevels;
  28349. /**
  28350. * Add a mesh as LOD level triggered at the given distance.
  28351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28352. * @param distance The distance from the center of the object to show this level
  28353. * @param mesh The mesh to be added as LOD level (can be null)
  28354. * @return This mesh (for chaining)
  28355. */
  28356. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28357. /**
  28358. * Returns the LOD level mesh at the passed distance or null if not found.
  28359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28360. * @param distance The distance from the center of the object to show this level
  28361. * @returns a Mesh or `null`
  28362. */
  28363. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28364. /**
  28365. * Remove a mesh from the LOD array
  28366. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28367. * @param mesh defines the mesh to be removed
  28368. * @return This mesh (for chaining)
  28369. */
  28370. removeLODLevel(mesh: Mesh): Mesh;
  28371. /**
  28372. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28374. * @param camera defines the camera to use to compute distance
  28375. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28376. * @return This mesh (for chaining)
  28377. */
  28378. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28379. /**
  28380. * Gets the mesh internal Geometry object
  28381. */
  28382. get geometry(): Nullable<Geometry>;
  28383. /**
  28384. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28385. * @returns the total number of vertices
  28386. */
  28387. getTotalVertices(): number;
  28388. /**
  28389. * Returns the content of an associated vertex buffer
  28390. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28391. * - VertexBuffer.PositionKind
  28392. * - VertexBuffer.UVKind
  28393. * - VertexBuffer.UV2Kind
  28394. * - VertexBuffer.UV3Kind
  28395. * - VertexBuffer.UV4Kind
  28396. * - VertexBuffer.UV5Kind
  28397. * - VertexBuffer.UV6Kind
  28398. * - VertexBuffer.ColorKind
  28399. * - VertexBuffer.MatricesIndicesKind
  28400. * - VertexBuffer.MatricesIndicesExtraKind
  28401. * - VertexBuffer.MatricesWeightsKind
  28402. * - VertexBuffer.MatricesWeightsExtraKind
  28403. * @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
  28404. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28405. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28406. */
  28407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28408. /**
  28409. * Returns the mesh VertexBuffer object from the requested `kind`
  28410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28411. * - VertexBuffer.PositionKind
  28412. * - VertexBuffer.NormalKind
  28413. * - VertexBuffer.UVKind
  28414. * - VertexBuffer.UV2Kind
  28415. * - VertexBuffer.UV3Kind
  28416. * - VertexBuffer.UV4Kind
  28417. * - VertexBuffer.UV5Kind
  28418. * - VertexBuffer.UV6Kind
  28419. * - VertexBuffer.ColorKind
  28420. * - VertexBuffer.MatricesIndicesKind
  28421. * - VertexBuffer.MatricesIndicesExtraKind
  28422. * - VertexBuffer.MatricesWeightsKind
  28423. * - VertexBuffer.MatricesWeightsExtraKind
  28424. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28425. */
  28426. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28427. /**
  28428. * Tests if a specific vertex buffer is associated with this mesh
  28429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28430. * - VertexBuffer.PositionKind
  28431. * - VertexBuffer.NormalKind
  28432. * - VertexBuffer.UVKind
  28433. * - VertexBuffer.UV2Kind
  28434. * - VertexBuffer.UV3Kind
  28435. * - VertexBuffer.UV4Kind
  28436. * - VertexBuffer.UV5Kind
  28437. * - VertexBuffer.UV6Kind
  28438. * - VertexBuffer.ColorKind
  28439. * - VertexBuffer.MatricesIndicesKind
  28440. * - VertexBuffer.MatricesIndicesExtraKind
  28441. * - VertexBuffer.MatricesWeightsKind
  28442. * - VertexBuffer.MatricesWeightsExtraKind
  28443. * @returns a boolean
  28444. */
  28445. isVerticesDataPresent(kind: string): boolean;
  28446. /**
  28447. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28449. * - VertexBuffer.PositionKind
  28450. * - VertexBuffer.UVKind
  28451. * - VertexBuffer.UV2Kind
  28452. * - VertexBuffer.UV3Kind
  28453. * - VertexBuffer.UV4Kind
  28454. * - VertexBuffer.UV5Kind
  28455. * - VertexBuffer.UV6Kind
  28456. * - VertexBuffer.ColorKind
  28457. * - VertexBuffer.MatricesIndicesKind
  28458. * - VertexBuffer.MatricesIndicesExtraKind
  28459. * - VertexBuffer.MatricesWeightsKind
  28460. * - VertexBuffer.MatricesWeightsExtraKind
  28461. * @returns a boolean
  28462. */
  28463. isVertexBufferUpdatable(kind: string): boolean;
  28464. /**
  28465. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28466. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28467. * - VertexBuffer.PositionKind
  28468. * - VertexBuffer.NormalKind
  28469. * - VertexBuffer.UVKind
  28470. * - VertexBuffer.UV2Kind
  28471. * - VertexBuffer.UV3Kind
  28472. * - VertexBuffer.UV4Kind
  28473. * - VertexBuffer.UV5Kind
  28474. * - VertexBuffer.UV6Kind
  28475. * - VertexBuffer.ColorKind
  28476. * - VertexBuffer.MatricesIndicesKind
  28477. * - VertexBuffer.MatricesIndicesExtraKind
  28478. * - VertexBuffer.MatricesWeightsKind
  28479. * - VertexBuffer.MatricesWeightsExtraKind
  28480. * @returns an array of strings
  28481. */
  28482. getVerticesDataKinds(): string[];
  28483. /**
  28484. * Returns a positive integer : the total number of indices in this mesh geometry.
  28485. * @returns the numner of indices or zero if the mesh has no geometry.
  28486. */
  28487. getTotalIndices(): number;
  28488. /**
  28489. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28490. * @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.
  28491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28492. * @returns the indices array or an empty array if the mesh has no geometry
  28493. */
  28494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28495. get isBlocked(): boolean;
  28496. /**
  28497. * Determine if the current mesh is ready to be rendered
  28498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28499. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28500. * @returns true if all associated assets are ready (material, textures, shaders)
  28501. */
  28502. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28503. /**
  28504. * 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.
  28505. */
  28506. get areNormalsFrozen(): boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  28509. * @returns the current mesh
  28510. */
  28511. freezeNormals(): Mesh;
  28512. /**
  28513. * 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
  28514. * @returns the current mesh
  28515. */
  28516. unfreezeNormals(): Mesh;
  28517. /**
  28518. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28519. */
  28520. set overridenInstanceCount(count: number);
  28521. /** @hidden */
  28522. _preActivate(): Mesh;
  28523. /** @hidden */
  28524. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28525. /** @hidden */
  28526. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28527. protected _afterComputeWorldMatrix(): void;
  28528. /** @hidden */
  28529. _postActivate(): void;
  28530. /**
  28531. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28532. * This means the mesh underlying bounding box and sphere are recomputed.
  28533. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28534. * @returns the current mesh
  28535. */
  28536. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28537. /** @hidden */
  28538. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28539. /**
  28540. * This function will subdivide the mesh into multiple submeshes
  28541. * @param count defines the expected number of submeshes
  28542. */
  28543. subdivide(count: number): void;
  28544. /**
  28545. * Copy a FloatArray into a specific associated vertex buffer
  28546. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28547. * - VertexBuffer.PositionKind
  28548. * - VertexBuffer.UVKind
  28549. * - VertexBuffer.UV2Kind
  28550. * - VertexBuffer.UV3Kind
  28551. * - VertexBuffer.UV4Kind
  28552. * - VertexBuffer.UV5Kind
  28553. * - VertexBuffer.UV6Kind
  28554. * - VertexBuffer.ColorKind
  28555. * - VertexBuffer.MatricesIndicesKind
  28556. * - VertexBuffer.MatricesIndicesExtraKind
  28557. * - VertexBuffer.MatricesWeightsKind
  28558. * - VertexBuffer.MatricesWeightsExtraKind
  28559. * @param data defines the data source
  28560. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28561. * @param stride defines the data stride size (can be null)
  28562. * @returns the current mesh
  28563. */
  28564. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28565. /**
  28566. * Delete a vertex buffer associated with this mesh
  28567. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28568. * - VertexBuffer.PositionKind
  28569. * - VertexBuffer.UVKind
  28570. * - VertexBuffer.UV2Kind
  28571. * - VertexBuffer.UV3Kind
  28572. * - VertexBuffer.UV4Kind
  28573. * - VertexBuffer.UV5Kind
  28574. * - VertexBuffer.UV6Kind
  28575. * - VertexBuffer.ColorKind
  28576. * - VertexBuffer.MatricesIndicesKind
  28577. * - VertexBuffer.MatricesIndicesExtraKind
  28578. * - VertexBuffer.MatricesWeightsKind
  28579. * - VertexBuffer.MatricesWeightsExtraKind
  28580. */
  28581. removeVerticesData(kind: string): void;
  28582. /**
  28583. * Flags an associated vertex buffer as updatable
  28584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28585. * - VertexBuffer.PositionKind
  28586. * - VertexBuffer.UVKind
  28587. * - VertexBuffer.UV2Kind
  28588. * - VertexBuffer.UV3Kind
  28589. * - VertexBuffer.UV4Kind
  28590. * - VertexBuffer.UV5Kind
  28591. * - VertexBuffer.UV6Kind
  28592. * - VertexBuffer.ColorKind
  28593. * - VertexBuffer.MatricesIndicesKind
  28594. * - VertexBuffer.MatricesIndicesExtraKind
  28595. * - VertexBuffer.MatricesWeightsKind
  28596. * - VertexBuffer.MatricesWeightsExtraKind
  28597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28598. */
  28599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28600. /**
  28601. * Sets the mesh global Vertex Buffer
  28602. * @param buffer defines the buffer to use
  28603. * @returns the current mesh
  28604. */
  28605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28606. /**
  28607. * Update a specific associated vertex buffer
  28608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28609. * - VertexBuffer.PositionKind
  28610. * - VertexBuffer.UVKind
  28611. * - VertexBuffer.UV2Kind
  28612. * - VertexBuffer.UV3Kind
  28613. * - VertexBuffer.UV4Kind
  28614. * - VertexBuffer.UV5Kind
  28615. * - VertexBuffer.UV6Kind
  28616. * - VertexBuffer.ColorKind
  28617. * - VertexBuffer.MatricesIndicesKind
  28618. * - VertexBuffer.MatricesIndicesExtraKind
  28619. * - VertexBuffer.MatricesWeightsKind
  28620. * - VertexBuffer.MatricesWeightsExtraKind
  28621. * @param data defines the data source
  28622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28623. * @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)
  28624. * @returns the current mesh
  28625. */
  28626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28627. /**
  28628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28629. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28632. * @returns the current mesh
  28633. */
  28634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28635. /**
  28636. * Creates a un-shared specific occurence of the geometry for the mesh.
  28637. * @returns the current mesh
  28638. */
  28639. makeGeometryUnique(): Mesh;
  28640. /**
  28641. * Set the index buffer of this mesh
  28642. * @param indices defines the source data
  28643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28645. * @returns the current mesh
  28646. */
  28647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28648. /**
  28649. * Update the current index buffer
  28650. * @param indices defines the source data
  28651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28652. * @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)
  28653. * @returns the current mesh
  28654. */
  28655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28656. /**
  28657. * Invert the geometry to move from a right handed system to a left handed one.
  28658. * @returns the current mesh
  28659. */
  28660. toLeftHanded(): Mesh;
  28661. /** @hidden */
  28662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28663. /** @hidden */
  28664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28665. /**
  28666. * Registers for this mesh a javascript function called just before the rendering process
  28667. * @param func defines the function to call before rendering this mesh
  28668. * @returns the current mesh
  28669. */
  28670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28671. /**
  28672. * Disposes a previously registered javascript function called before the rendering
  28673. * @param func defines the function to remove
  28674. * @returns the current mesh
  28675. */
  28676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28677. /**
  28678. * Registers for this mesh a javascript function called just after the rendering is complete
  28679. * @param func defines the function to call after rendering this mesh
  28680. * @returns the current mesh
  28681. */
  28682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28683. /**
  28684. * Disposes a previously registered javascript function called after the rendering.
  28685. * @param func defines the function to remove
  28686. * @returns the current mesh
  28687. */
  28688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28689. /** @hidden */
  28690. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28691. /** @hidden */
  28692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28693. /** @hidden */
  28694. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28695. /** @hidden */
  28696. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28697. /** @hidden */
  28698. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28699. /** @hidden */
  28700. _rebuild(): void;
  28701. /** @hidden */
  28702. _freeze(): void;
  28703. /** @hidden */
  28704. _unFreeze(): void;
  28705. /**
  28706. * 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
  28707. * @param subMesh defines the subMesh to render
  28708. * @param enableAlphaMode defines if alpha mode can be changed
  28709. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28710. * @returns the current mesh
  28711. */
  28712. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28713. private _onBeforeDraw;
  28714. /**
  28715. * Renormalize the mesh and patch it up if there are no weights
  28716. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28717. * However in the case of zero weights then we set just a single influence to 1.
  28718. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28719. */
  28720. cleanMatrixWeights(): void;
  28721. private normalizeSkinFourWeights;
  28722. private normalizeSkinWeightsAndExtra;
  28723. /**
  28724. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28725. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28726. * the user know there was an issue with importing the mesh
  28727. * @returns a validation object with skinned, valid and report string
  28728. */
  28729. validateSkinning(): {
  28730. skinned: boolean;
  28731. valid: boolean;
  28732. report: string;
  28733. };
  28734. /** @hidden */
  28735. _checkDelayState(): Mesh;
  28736. private _queueLoad;
  28737. /**
  28738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28739. * A mesh is in the frustum if its bounding box intersects the frustum
  28740. * @param frustumPlanes defines the frustum to test
  28741. * @returns true if the mesh is in the frustum planes
  28742. */
  28743. isInFrustum(frustumPlanes: Plane[]): boolean;
  28744. /**
  28745. * Sets the mesh material by the material or multiMaterial `id` property
  28746. * @param id is a string identifying the material or the multiMaterial
  28747. * @returns the current mesh
  28748. */
  28749. setMaterialByID(id: string): Mesh;
  28750. /**
  28751. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28752. * @returns an array of IAnimatable
  28753. */
  28754. getAnimatables(): IAnimatable[];
  28755. /**
  28756. * Modifies the mesh geometry according to the passed transformation matrix.
  28757. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28758. * The mesh normals are modified using the same transformation.
  28759. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28760. * @param transform defines the transform matrix to use
  28761. * @see https://doc.babylonjs.com/resources/baking_transformations
  28762. * @returns the current mesh
  28763. */
  28764. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28765. /**
  28766. * Modifies the mesh geometry according to its own current World Matrix.
  28767. * The mesh World Matrix is then reset.
  28768. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28770. * @see https://doc.babylonjs.com/resources/baking_transformations
  28771. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28772. * @returns the current mesh
  28773. */
  28774. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28775. /** @hidden */
  28776. get _positions(): Nullable<Vector3[]>;
  28777. /** @hidden */
  28778. _resetPointsArrayCache(): Mesh;
  28779. /** @hidden */
  28780. _generatePointsArray(): boolean;
  28781. /**
  28782. * Returns a new Mesh object generated from the current mesh properties.
  28783. * This method must not get confused with createInstance()
  28784. * @param name is a string, the name given to the new mesh
  28785. * @param newParent can be any Node object (default `null`)
  28786. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28787. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28788. * @returns a new mesh
  28789. */
  28790. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28791. /**
  28792. * Releases resources associated with this mesh.
  28793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28795. */
  28796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28797. /** @hidden */
  28798. _disposeInstanceSpecificData(): void;
  28799. /** @hidden */
  28800. _disposeThinInstanceSpecificData(): void;
  28801. /**
  28802. * Modifies the mesh geometry according to a displacement map.
  28803. * 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.
  28804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28805. * @param url is a string, the URL from the image file is to be downloaded.
  28806. * @param minHeight is the lower limit of the displacement.
  28807. * @param maxHeight is the upper limit of the displacement.
  28808. * @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.
  28809. * @param uvOffset is an optional vector2 used to offset UV.
  28810. * @param uvScale is an optional vector2 used to scale UV.
  28811. * @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.
  28812. * @returns the Mesh.
  28813. */
  28814. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28815. /**
  28816. * Modifies the mesh geometry according to a displacementMap buffer.
  28817. * 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.
  28818. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28819. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28820. * @param heightMapWidth is the width of the buffer image.
  28821. * @param heightMapHeight is the height of the buffer image.
  28822. * @param minHeight is the lower limit of the displacement.
  28823. * @param maxHeight is the upper limit of the displacement.
  28824. * @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.
  28825. * @param uvOffset is an optional vector2 used to offset UV.
  28826. * @param uvScale is an optional vector2 used to scale UV.
  28827. * @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.
  28828. * @returns the Mesh.
  28829. */
  28830. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28831. /**
  28832. * Modify the mesh to get a flat shading rendering.
  28833. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28834. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28835. * @returns current mesh
  28836. */
  28837. convertToFlatShadedMesh(): Mesh;
  28838. /**
  28839. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28840. * In other words, more vertices, no more indices and a single bigger VBO.
  28841. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28842. * @returns current mesh
  28843. */
  28844. convertToUnIndexedMesh(): Mesh;
  28845. /**
  28846. * Inverses facet orientations.
  28847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28848. * @param flipNormals will also inverts the normals
  28849. * @returns current mesh
  28850. */
  28851. flipFaces(flipNormals?: boolean): Mesh;
  28852. /**
  28853. * Increase the number of facets and hence vertices in a mesh
  28854. * Vertex normals are interpolated from existing vertex normals
  28855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28856. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28857. */
  28858. increaseVertices(numberPerEdge: number): void;
  28859. /**
  28860. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28861. * This will undo any application of covertToFlatShadedMesh
  28862. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28863. */
  28864. forceSharedVertices(): void;
  28865. /** @hidden */
  28866. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28867. /** @hidden */
  28868. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28869. /**
  28870. * Creates a new InstancedMesh object from the mesh model.
  28871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28872. * @param name defines the name of the new instance
  28873. * @returns a new InstancedMesh
  28874. */
  28875. createInstance(name: string): InstancedMesh;
  28876. /**
  28877. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28878. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28879. * @returns the current mesh
  28880. */
  28881. synchronizeInstances(): Mesh;
  28882. /**
  28883. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28884. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28885. * This should be used together with the simplification to avoid disappearing triangles.
  28886. * @param successCallback an optional success callback to be called after the optimization finished.
  28887. * @returns the current mesh
  28888. */
  28889. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28890. /**
  28891. * Serialize current mesh
  28892. * @param serializationObject defines the object which will receive the serialization data
  28893. */
  28894. serialize(serializationObject: any): void;
  28895. /** @hidden */
  28896. _syncGeometryWithMorphTargetManager(): void;
  28897. /** @hidden */
  28898. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28899. /**
  28900. * Returns a new Mesh object parsed from the source provided.
  28901. * @param parsedMesh is the source
  28902. * @param scene defines the hosting scene
  28903. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28904. * @returns a new Mesh
  28905. */
  28906. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28907. /**
  28908. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28910. * @param name defines the name of the mesh to create
  28911. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28912. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28913. * @param closePath creates a seam between the first and the last points of each path of the path array
  28914. * @param offset is taken in account only if the `pathArray` is containing a single path
  28915. * @param scene defines the hosting scene
  28916. * @param updatable defines if the mesh must be flagged as updatable
  28917. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28918. * @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)
  28919. * @returns a new Mesh
  28920. */
  28921. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28922. /**
  28923. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28924. * @param name defines the name of the mesh to create
  28925. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28926. * @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
  28927. * @param scene defines the hosting scene
  28928. * @param updatable defines if the mesh must be flagged as updatable
  28929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28930. * @returns a new Mesh
  28931. */
  28932. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28933. /**
  28934. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28935. * @param name defines the name of the mesh to create
  28936. * @param size sets the size (float) of each box side (default 1)
  28937. * @param scene defines the hosting scene
  28938. * @param updatable defines if the mesh must be flagged as updatable
  28939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28940. * @returns a new Mesh
  28941. */
  28942. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28943. /**
  28944. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28945. * @param name defines the name of the mesh to create
  28946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28948. * @param scene defines the hosting scene
  28949. * @param updatable defines if the mesh must be flagged as updatable
  28950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28951. * @returns a new Mesh
  28952. */
  28953. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28954. /**
  28955. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28956. * @param name defines the name of the mesh to create
  28957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28959. * @param scene defines the hosting scene
  28960. * @returns a new Mesh
  28961. */
  28962. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28963. /**
  28964. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28965. * @param name defines the name of the mesh to create
  28966. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28967. * @param diameterTop set the top cap diameter (floats, default 1)
  28968. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28969. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28970. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28971. * @param scene defines the hosting scene
  28972. * @param updatable defines if the mesh must be flagged as updatable
  28973. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28974. * @returns a new Mesh
  28975. */
  28976. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28977. /**
  28978. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28979. * @param name defines the name of the mesh to create
  28980. * @param diameter sets the diameter size (float) of the torus (default 1)
  28981. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28982. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28983. * @param scene defines the hosting scene
  28984. * @param updatable defines if the mesh must be flagged as updatable
  28985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28986. * @returns a new Mesh
  28987. */
  28988. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28989. /**
  28990. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28991. * @param name defines the name of the mesh to create
  28992. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28993. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28994. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28995. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28996. * @param p the number of windings on X axis (positive integers, default 2)
  28997. * @param q the number of windings on Y axis (positive integers, default 3)
  28998. * @param scene defines the hosting scene
  28999. * @param updatable defines if the mesh must be flagged as updatable
  29000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29001. * @returns a new Mesh
  29002. */
  29003. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29004. /**
  29005. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29006. * @param name defines the name of the mesh to create
  29007. * @param points is an array successive Vector3
  29008. * @param scene defines the hosting scene
  29009. * @param updatable defines if the mesh must be flagged as updatable
  29010. * @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).
  29011. * @returns a new Mesh
  29012. */
  29013. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29014. /**
  29015. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29016. * @param name defines the name of the mesh to create
  29017. * @param points is an array successive Vector3
  29018. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29019. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29020. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29021. * @param scene defines the hosting scene
  29022. * @param updatable defines if the mesh must be flagged as updatable
  29023. * @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)
  29024. * @returns a new Mesh
  29025. */
  29026. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29027. /**
  29028. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29030. * 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.
  29031. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29032. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29033. * Remember you can only change the shape positions, not their number when updating a polygon.
  29034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29035. * @param name defines the name of the mesh to create
  29036. * @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
  29037. * @param scene defines the hosting scene
  29038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29039. * @param updatable defines if the mesh must be flagged as updatable
  29040. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29041. * @param earcutInjection can be used to inject your own earcut reference
  29042. * @returns a new Mesh
  29043. */
  29044. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29045. /**
  29046. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29048. * @param name defines the name of the mesh to create
  29049. * @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
  29050. * @param depth defines the height of extrusion
  29051. * @param scene defines the hosting scene
  29052. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29053. * @param updatable defines if the mesh must be flagged as updatable
  29054. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29055. * @param earcutInjection can be used to inject your own earcut reference
  29056. * @returns a new Mesh
  29057. */
  29058. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29059. /**
  29060. * Creates an extruded shape mesh.
  29061. * 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
  29062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29064. * @param name defines the name of the mesh to create
  29065. * @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
  29066. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29067. * @param scale is the value to scale the shape
  29068. * @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
  29069. * @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
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @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)
  29074. * @returns a new Mesh
  29075. */
  29076. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29077. /**
  29078. * Creates an custom extruded shape mesh.
  29079. * The custom extrusion is a parametric shape.
  29080. * It has no predefined shape. Its final shape will depend on the input parameters.
  29081. * Please consider using the same method from the MeshBuilder class instead
  29082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29083. * @param name defines the name of the mesh to create
  29084. * @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
  29085. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29086. * @param scaleFunction is a custom Javascript function called on each path point
  29087. * @param rotationFunction is a custom Javascript function called on each path point
  29088. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29089. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29090. * @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
  29091. * @param scene defines the hosting scene
  29092. * @param updatable defines if the mesh must be flagged as updatable
  29093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29094. * @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)
  29095. * @returns a new Mesh
  29096. */
  29097. 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;
  29098. /**
  29099. * Creates lathe mesh.
  29100. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29101. * Please consider using the same method from the MeshBuilder class instead
  29102. * @param name defines the name of the mesh to create
  29103. * @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
  29104. * @param radius is the radius value of the lathe
  29105. * @param tessellation is the side number of the lathe.
  29106. * @param scene defines the hosting scene
  29107. * @param updatable defines if the mesh must be flagged as updatable
  29108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29109. * @returns a new Mesh
  29110. */
  29111. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29112. /**
  29113. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29114. * @param name defines the name of the mesh to create
  29115. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29116. * @param scene defines the hosting scene
  29117. * @param updatable defines if the mesh must be flagged as updatable
  29118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29119. * @returns a new Mesh
  29120. */
  29121. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29122. /**
  29123. * Creates a ground mesh.
  29124. * Please consider using the same method from the MeshBuilder class instead
  29125. * @param name defines the name of the mesh to create
  29126. * @param width set the width of the ground
  29127. * @param height set the height of the ground
  29128. * @param subdivisions sets the number of subdivisions per side
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @returns a new Mesh
  29132. */
  29133. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29134. /**
  29135. * Creates a tiled ground mesh.
  29136. * Please consider using the same method from the MeshBuilder class instead
  29137. * @param name defines the name of the mesh to create
  29138. * @param xmin set the ground minimum X coordinate
  29139. * @param zmin set the ground minimum Y coordinate
  29140. * @param xmax set the ground maximum X coordinate
  29141. * @param zmax set the ground maximum Z coordinate
  29142. * @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
  29143. * @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
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @returns a new Mesh
  29147. */
  29148. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29149. w: number;
  29150. h: number;
  29151. }, precision: {
  29152. w: number;
  29153. h: number;
  29154. }, scene: Scene, updatable?: boolean): Mesh;
  29155. /**
  29156. * Creates a ground mesh from a height map.
  29157. * Please consider using the same method from the MeshBuilder class instead
  29158. * @see https://doc.babylonjs.com/babylon101/height_map
  29159. * @param name defines the name of the mesh to create
  29160. * @param url sets the URL of the height map image resource
  29161. * @param width set the ground width size
  29162. * @param height set the ground height size
  29163. * @param subdivisions sets the number of subdivision per side
  29164. * @param minHeight is the minimum altitude on the ground
  29165. * @param maxHeight is the maximum altitude on the ground
  29166. * @param scene defines the hosting scene
  29167. * @param updatable defines if the mesh must be flagged as updatable
  29168. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29169. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29170. * @returns a new Mesh
  29171. */
  29172. 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;
  29173. /**
  29174. * Creates a tube mesh.
  29175. * The tube is a parametric shape.
  29176. * It has no predefined shape. Its final shape will depend on the input parameters.
  29177. * Please consider using the same method from the MeshBuilder class instead
  29178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29179. * @param name defines the name of the mesh to create
  29180. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29181. * @param radius sets the tube radius size
  29182. * @param tessellation is the number of sides on the tubular surface
  29183. * @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
  29184. * @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
  29185. * @param scene defines the hosting scene
  29186. * @param updatable defines if the mesh must be flagged as updatable
  29187. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29188. * @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)
  29189. * @returns a new Mesh
  29190. */
  29191. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29192. (i: number, distance: number): number;
  29193. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29194. /**
  29195. * Creates a polyhedron mesh.
  29196. * Please consider using the same method from the MeshBuilder class instead.
  29197. * * 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
  29198. * * The parameter `size` (positive float, default 1) sets the polygon size
  29199. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29200. * * 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`
  29201. * * 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
  29202. * * 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)`)
  29203. * * 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
  29204. * * 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
  29205. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29206. * * 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
  29207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29208. * @param name defines the name of the mesh to create
  29209. * @param options defines the options used to create the mesh
  29210. * @param scene defines the hosting scene
  29211. * @returns a new Mesh
  29212. */
  29213. static CreatePolyhedron(name: string, options: {
  29214. type?: number;
  29215. size?: number;
  29216. sizeX?: number;
  29217. sizeY?: number;
  29218. sizeZ?: number;
  29219. custom?: any;
  29220. faceUV?: Vector4[];
  29221. faceColors?: Color4[];
  29222. updatable?: boolean;
  29223. sideOrientation?: number;
  29224. }, scene: Scene): Mesh;
  29225. /**
  29226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29228. * * 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`)
  29229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29230. * * 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
  29231. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29232. * * 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
  29233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29234. * @param name defines the name of the mesh
  29235. * @param options defines the options used to create the mesh
  29236. * @param scene defines the hosting scene
  29237. * @returns a new Mesh
  29238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29239. */
  29240. static CreateIcoSphere(name: string, options: {
  29241. radius?: number;
  29242. flat?: boolean;
  29243. subdivisions?: number;
  29244. sideOrientation?: number;
  29245. updatable?: boolean;
  29246. }, scene: Scene): Mesh;
  29247. /**
  29248. * Creates a decal mesh.
  29249. * Please consider using the same method from the MeshBuilder class instead.
  29250. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29251. * @param name defines the name of the mesh
  29252. * @param sourceMesh defines the mesh receiving the decal
  29253. * @param position sets the position of the decal in world coordinates
  29254. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29255. * @param size sets the decal scaling
  29256. * @param angle sets the angle to rotate the decal
  29257. * @returns a new Mesh
  29258. */
  29259. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29260. /**
  29261. * Prepare internal position array for software CPU skinning
  29262. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29263. */
  29264. setPositionsForCPUSkinning(): Float32Array;
  29265. /**
  29266. * Prepare internal normal array for software CPU skinning
  29267. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29268. */
  29269. setNormalsForCPUSkinning(): Float32Array;
  29270. /**
  29271. * Updates the vertex buffer by applying transformation from the bones
  29272. * @param skeleton defines the skeleton to apply to current mesh
  29273. * @returns the current mesh
  29274. */
  29275. applySkeleton(skeleton: Skeleton): Mesh;
  29276. /**
  29277. * 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
  29278. * @param meshes defines the list of meshes to scan
  29279. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29280. */
  29281. static MinMax(meshes: AbstractMesh[]): {
  29282. min: Vector3;
  29283. max: Vector3;
  29284. };
  29285. /**
  29286. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29287. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29288. * @returns a vector3
  29289. */
  29290. static Center(meshesOrMinMaxVector: {
  29291. min: Vector3;
  29292. max: Vector3;
  29293. } | AbstractMesh[]): Vector3;
  29294. /**
  29295. * Merge the array of meshes into a single mesh for performance reasons.
  29296. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29297. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29298. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29299. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29300. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29301. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29302. * @returns a new mesh
  29303. */
  29304. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29305. /** @hidden */
  29306. addInstance(instance: InstancedMesh): void;
  29307. /** @hidden */
  29308. removeInstance(instance: InstancedMesh): void;
  29309. }
  29310. }
  29311. declare module "babylonjs/Cameras/camera" {
  29312. import { SmartArray } from "babylonjs/Misc/smartArray";
  29313. import { Observable } from "babylonjs/Misc/observable";
  29314. import { Nullable } from "babylonjs/types";
  29315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29316. import { Scene } from "babylonjs/scene";
  29317. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29318. import { Node } from "babylonjs/node";
  29319. import { Mesh } from "babylonjs/Meshes/mesh";
  29320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29321. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29322. import { Viewport } from "babylonjs/Maths/math.viewport";
  29323. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29324. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29326. import { Ray } from "babylonjs/Culling/ray";
  29327. /**
  29328. * This is the base class of all the camera used in the application.
  29329. * @see https://doc.babylonjs.com/features/cameras
  29330. */
  29331. export class Camera extends Node {
  29332. /** @hidden */
  29333. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29334. /**
  29335. * This is the default projection mode used by the cameras.
  29336. * It helps recreating a feeling of perspective and better appreciate depth.
  29337. * This is the best way to simulate real life cameras.
  29338. */
  29339. static readonly PERSPECTIVE_CAMERA: number;
  29340. /**
  29341. * This helps creating camera with an orthographic mode.
  29342. * 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.
  29343. */
  29344. static readonly ORTHOGRAPHIC_CAMERA: number;
  29345. /**
  29346. * This is the default FOV mode for perspective cameras.
  29347. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29348. */
  29349. static readonly FOVMODE_VERTICAL_FIXED: number;
  29350. /**
  29351. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29352. */
  29353. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29354. /**
  29355. * This specifies ther is no need for a camera rig.
  29356. * Basically only one eye is rendered corresponding to the camera.
  29357. */
  29358. static readonly RIG_MODE_NONE: number;
  29359. /**
  29360. * Simulates a camera Rig with one blue eye and one red eye.
  29361. * This can be use with 3d blue and red glasses.
  29362. */
  29363. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29364. /**
  29365. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29366. */
  29367. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29368. /**
  29369. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29370. */
  29371. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29372. /**
  29373. * Defines that both eyes of the camera will be rendered over under each other.
  29374. */
  29375. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29376. /**
  29377. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29378. */
  29379. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29380. /**
  29381. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29382. */
  29383. static readonly RIG_MODE_VR: number;
  29384. /**
  29385. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29386. */
  29387. static readonly RIG_MODE_WEBVR: number;
  29388. /**
  29389. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29390. */
  29391. static readonly RIG_MODE_CUSTOM: number;
  29392. /**
  29393. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29394. */
  29395. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29396. /**
  29397. * Define the input manager associated with the camera.
  29398. */
  29399. inputs: CameraInputsManager<Camera>;
  29400. /** @hidden */
  29401. _position: Vector3;
  29402. /**
  29403. * Define the current local position of the camera in the scene
  29404. */
  29405. get position(): Vector3;
  29406. set position(newPosition: Vector3);
  29407. /**
  29408. * The vector the camera should consider as up.
  29409. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29410. */
  29411. upVector: Vector3;
  29412. /**
  29413. * Define the current limit on the left side for an orthographic camera
  29414. * In scene unit
  29415. */
  29416. orthoLeft: Nullable<number>;
  29417. /**
  29418. * Define the current limit on the right side for an orthographic camera
  29419. * In scene unit
  29420. */
  29421. orthoRight: Nullable<number>;
  29422. /**
  29423. * Define the current limit on the bottom side for an orthographic camera
  29424. * In scene unit
  29425. */
  29426. orthoBottom: Nullable<number>;
  29427. /**
  29428. * Define the current limit on the top side for an orthographic camera
  29429. * In scene unit
  29430. */
  29431. orthoTop: Nullable<number>;
  29432. /**
  29433. * Field Of View is set in Radians. (default is 0.8)
  29434. */
  29435. fov: number;
  29436. /**
  29437. * Define the minimum distance the camera can see from.
  29438. * This is important to note that the depth buffer are not infinite and the closer it starts
  29439. * the more your scene might encounter depth fighting issue.
  29440. */
  29441. minZ: number;
  29442. /**
  29443. * Define the maximum distance the camera can see to.
  29444. * This is important to note that the depth buffer are not infinite and the further it end
  29445. * the more your scene might encounter depth fighting issue.
  29446. */
  29447. maxZ: number;
  29448. /**
  29449. * Define the default inertia of the camera.
  29450. * This helps giving a smooth feeling to the camera movement.
  29451. */
  29452. inertia: number;
  29453. /**
  29454. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29455. */
  29456. mode: number;
  29457. /**
  29458. * Define whether the camera is intermediate.
  29459. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29460. */
  29461. isIntermediate: boolean;
  29462. /**
  29463. * Define the viewport of the camera.
  29464. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29465. */
  29466. viewport: Viewport;
  29467. /**
  29468. * Restricts the camera to viewing objects with the same layerMask.
  29469. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29470. */
  29471. layerMask: number;
  29472. /**
  29473. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29474. */
  29475. fovMode: number;
  29476. /**
  29477. * Rig mode of the camera.
  29478. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29479. * This is normally controlled byt the camera themselves as internal use.
  29480. */
  29481. cameraRigMode: number;
  29482. /**
  29483. * Defines the distance between both "eyes" in case of a RIG
  29484. */
  29485. interaxialDistance: number;
  29486. /**
  29487. * Defines if stereoscopic rendering is done side by side or over under.
  29488. */
  29489. isStereoscopicSideBySide: boolean;
  29490. /**
  29491. * 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
  29492. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29493. * else in the scene. (Eg. security camera)
  29494. *
  29495. * 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)
  29496. */
  29497. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29498. /**
  29499. * When set, the camera will render to this render target instead of the default canvas
  29500. *
  29501. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29502. */
  29503. outputRenderTarget: Nullable<RenderTargetTexture>;
  29504. /**
  29505. * Observable triggered when the camera view matrix has changed.
  29506. */
  29507. onViewMatrixChangedObservable: Observable<Camera>;
  29508. /**
  29509. * Observable triggered when the camera Projection matrix has changed.
  29510. */
  29511. onProjectionMatrixChangedObservable: Observable<Camera>;
  29512. /**
  29513. * Observable triggered when the inputs have been processed.
  29514. */
  29515. onAfterCheckInputsObservable: Observable<Camera>;
  29516. /**
  29517. * Observable triggered when reset has been called and applied to the camera.
  29518. */
  29519. onRestoreStateObservable: Observable<Camera>;
  29520. /**
  29521. * Is this camera a part of a rig system?
  29522. */
  29523. isRigCamera: boolean;
  29524. /**
  29525. * If isRigCamera set to true this will be set with the parent camera.
  29526. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29527. */
  29528. rigParent?: Camera;
  29529. /** @hidden */
  29530. _cameraRigParams: any;
  29531. /** @hidden */
  29532. _rigCameras: Camera[];
  29533. /** @hidden */
  29534. _rigPostProcess: Nullable<PostProcess>;
  29535. protected _webvrViewMatrix: Matrix;
  29536. /** @hidden */
  29537. _skipRendering: boolean;
  29538. /** @hidden */
  29539. _projectionMatrix: Matrix;
  29540. /** @hidden */
  29541. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29542. /** @hidden */
  29543. _activeMeshes: SmartArray<AbstractMesh>;
  29544. protected _globalPosition: Vector3;
  29545. /** @hidden */
  29546. _computedViewMatrix: Matrix;
  29547. private _doNotComputeProjectionMatrix;
  29548. private _transformMatrix;
  29549. private _frustumPlanes;
  29550. private _refreshFrustumPlanes;
  29551. private _storedFov;
  29552. private _stateStored;
  29553. /**
  29554. * Instantiates a new camera object.
  29555. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29556. * @see https://doc.babylonjs.com/features/cameras
  29557. * @param name Defines the name of the camera in the scene
  29558. * @param position Defines the position of the camera
  29559. * @param scene Defines the scene the camera belongs too
  29560. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29561. */
  29562. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29563. /**
  29564. * Store current camera state (fov, position, etc..)
  29565. * @returns the camera
  29566. */
  29567. storeState(): Camera;
  29568. /**
  29569. * Restores the camera state values if it has been stored. You must call storeState() first
  29570. */
  29571. protected _restoreStateValues(): boolean;
  29572. /**
  29573. * Restored camera state. You must call storeState() first.
  29574. * @returns true if restored and false otherwise
  29575. */
  29576. restoreState(): boolean;
  29577. /**
  29578. * Gets the class name of the camera.
  29579. * @returns the class name
  29580. */
  29581. getClassName(): string;
  29582. /** @hidden */
  29583. readonly _isCamera: boolean;
  29584. /**
  29585. * Gets a string representation of the camera useful for debug purpose.
  29586. * @param fullDetails Defines that a more verboe level of logging is required
  29587. * @returns the string representation
  29588. */
  29589. toString(fullDetails?: boolean): string;
  29590. /**
  29591. * Gets the current world space position of the camera.
  29592. */
  29593. get globalPosition(): Vector3;
  29594. /**
  29595. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29596. * @returns the active meshe list
  29597. */
  29598. getActiveMeshes(): SmartArray<AbstractMesh>;
  29599. /**
  29600. * Check whether a mesh is part of the current active mesh list of the camera
  29601. * @param mesh Defines the mesh to check
  29602. * @returns true if active, false otherwise
  29603. */
  29604. isActiveMesh(mesh: Mesh): boolean;
  29605. /**
  29606. * Is this camera ready to be used/rendered
  29607. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29608. * @return true if the camera is ready
  29609. */
  29610. isReady(completeCheck?: boolean): boolean;
  29611. /** @hidden */
  29612. _initCache(): void;
  29613. /** @hidden */
  29614. _updateCache(ignoreParentClass?: boolean): void;
  29615. /** @hidden */
  29616. _isSynchronized(): boolean;
  29617. /** @hidden */
  29618. _isSynchronizedViewMatrix(): boolean;
  29619. /** @hidden */
  29620. _isSynchronizedProjectionMatrix(): boolean;
  29621. /**
  29622. * Attach the input controls to a specific dom element to get the input from.
  29623. * @param element Defines the element the controls should be listened from
  29624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29625. */
  29626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29627. /**
  29628. * Detach the current controls from the specified dom element.
  29629. * @param element Defines the element to stop listening the inputs from
  29630. */
  29631. detachControl(element: HTMLElement): void;
  29632. /**
  29633. * Update the camera state according to the different inputs gathered during the frame.
  29634. */
  29635. update(): void;
  29636. /** @hidden */
  29637. _checkInputs(): void;
  29638. /** @hidden */
  29639. get rigCameras(): Camera[];
  29640. /**
  29641. * Gets the post process used by the rig cameras
  29642. */
  29643. get rigPostProcess(): Nullable<PostProcess>;
  29644. /**
  29645. * Internal, gets the first post proces.
  29646. * @returns the first post process to be run on this camera.
  29647. */
  29648. _getFirstPostProcess(): Nullable<PostProcess>;
  29649. private _cascadePostProcessesToRigCams;
  29650. /**
  29651. * Attach a post process to the camera.
  29652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29653. * @param postProcess The post process to attach to the camera
  29654. * @param insertAt The position of the post process in case several of them are in use in the scene
  29655. * @returns the position the post process has been inserted at
  29656. */
  29657. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29658. /**
  29659. * Detach a post process to the camera.
  29660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29661. * @param postProcess The post process to detach from the camera
  29662. */
  29663. detachPostProcess(postProcess: PostProcess): void;
  29664. /**
  29665. * Gets the current world matrix of the camera
  29666. */
  29667. getWorldMatrix(): Matrix;
  29668. /** @hidden */
  29669. _getViewMatrix(): Matrix;
  29670. /**
  29671. * Gets the current view matrix of the camera.
  29672. * @param force forces the camera to recompute the matrix without looking at the cached state
  29673. * @returns the view matrix
  29674. */
  29675. getViewMatrix(force?: boolean): Matrix;
  29676. /**
  29677. * Freeze the projection matrix.
  29678. * It will prevent the cache check of the camera projection compute and can speed up perf
  29679. * if no parameter of the camera are meant to change
  29680. * @param projection Defines manually a projection if necessary
  29681. */
  29682. freezeProjectionMatrix(projection?: Matrix): void;
  29683. /**
  29684. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29685. */
  29686. unfreezeProjectionMatrix(): void;
  29687. /**
  29688. * Gets the current projection matrix of the camera.
  29689. * @param force forces the camera to recompute the matrix without looking at the cached state
  29690. * @returns the projection matrix
  29691. */
  29692. getProjectionMatrix(force?: boolean): Matrix;
  29693. /**
  29694. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29695. * @returns a Matrix
  29696. */
  29697. getTransformationMatrix(): Matrix;
  29698. private _updateFrustumPlanes;
  29699. /**
  29700. * Checks if a cullable object (mesh...) is in the camera frustum
  29701. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29702. * @param target The object to check
  29703. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29704. * @returns true if the object is in frustum otherwise false
  29705. */
  29706. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29707. /**
  29708. * Checks if a cullable object (mesh...) is in the camera frustum
  29709. * Unlike isInFrustum this cheks the full bounding box
  29710. * @param target The object to check
  29711. * @returns true if the object is in frustum otherwise false
  29712. */
  29713. isCompletelyInFrustum(target: ICullable): boolean;
  29714. /**
  29715. * Gets a ray in the forward direction from the camera.
  29716. * @param length Defines the length of the ray to create
  29717. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29718. * @param origin Defines the start point of the ray which defaults to the camera position
  29719. * @returns the forward ray
  29720. */
  29721. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29722. /**
  29723. * Releases resources associated with this node.
  29724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29726. */
  29727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29728. /** @hidden */
  29729. _isLeftCamera: boolean;
  29730. /**
  29731. * Gets the left camera of a rig setup in case of Rigged Camera
  29732. */
  29733. get isLeftCamera(): boolean;
  29734. /** @hidden */
  29735. _isRightCamera: boolean;
  29736. /**
  29737. * Gets the right camera of a rig setup in case of Rigged Camera
  29738. */
  29739. get isRightCamera(): boolean;
  29740. /**
  29741. * Gets the left camera of a rig setup in case of Rigged Camera
  29742. */
  29743. get leftCamera(): Nullable<FreeCamera>;
  29744. /**
  29745. * Gets the right camera of a rig setup in case of Rigged Camera
  29746. */
  29747. get rightCamera(): Nullable<FreeCamera>;
  29748. /**
  29749. * Gets the left camera target of a rig setup in case of Rigged Camera
  29750. * @returns the target position
  29751. */
  29752. getLeftTarget(): Nullable<Vector3>;
  29753. /**
  29754. * Gets the right camera target of a rig setup in case of Rigged Camera
  29755. * @returns the target position
  29756. */
  29757. getRightTarget(): Nullable<Vector3>;
  29758. /**
  29759. * @hidden
  29760. */
  29761. setCameraRigMode(mode: number, rigParams: any): void;
  29762. /** @hidden */
  29763. static _setStereoscopicRigMode(camera: Camera): void;
  29764. /** @hidden */
  29765. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29766. /** @hidden */
  29767. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29768. /** @hidden */
  29769. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29770. /** @hidden */
  29771. _getVRProjectionMatrix(): Matrix;
  29772. protected _updateCameraRotationMatrix(): void;
  29773. protected _updateWebVRCameraRotationMatrix(): void;
  29774. /**
  29775. * This function MUST be overwritten by the different WebVR cameras available.
  29776. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29777. * @hidden
  29778. */
  29779. _getWebVRProjectionMatrix(): Matrix;
  29780. /**
  29781. * This function MUST be overwritten by the different WebVR cameras available.
  29782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29783. * @hidden
  29784. */
  29785. _getWebVRViewMatrix(): Matrix;
  29786. /** @hidden */
  29787. setCameraRigParameter(name: string, value: any): void;
  29788. /**
  29789. * needs to be overridden by children so sub has required properties to be copied
  29790. * @hidden
  29791. */
  29792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29793. /**
  29794. * May need to be overridden by children
  29795. * @hidden
  29796. */
  29797. _updateRigCameras(): void;
  29798. /** @hidden */
  29799. _setupInputs(): void;
  29800. /**
  29801. * Serialiaze the camera setup to a json represention
  29802. * @returns the JSON representation
  29803. */
  29804. serialize(): any;
  29805. /**
  29806. * Clones the current camera.
  29807. * @param name The cloned camera name
  29808. * @returns the cloned camera
  29809. */
  29810. clone(name: string): Camera;
  29811. /**
  29812. * Gets the direction of the camera relative to a given local axis.
  29813. * @param localAxis Defines the reference axis to provide a relative direction.
  29814. * @return the direction
  29815. */
  29816. getDirection(localAxis: Vector3): Vector3;
  29817. /**
  29818. * Returns the current camera absolute rotation
  29819. */
  29820. get absoluteRotation(): Quaternion;
  29821. /**
  29822. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29823. * @param localAxis Defines the reference axis to provide a relative direction.
  29824. * @param result Defines the vector to store the result in
  29825. */
  29826. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29827. /**
  29828. * Gets a camera constructor for a given camera type
  29829. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29830. * @param name The name of the camera the result will be able to instantiate
  29831. * @param scene The scene the result will construct the camera in
  29832. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29833. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29834. * @returns a factory method to construc the camera
  29835. */
  29836. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29837. /**
  29838. * Compute the world matrix of the camera.
  29839. * @returns the camera world matrix
  29840. */
  29841. computeWorldMatrix(): Matrix;
  29842. /**
  29843. * Parse a JSON and creates the camera from the parsed information
  29844. * @param parsedCamera The JSON to parse
  29845. * @param scene The scene to instantiate the camera in
  29846. * @returns the newly constructed camera
  29847. */
  29848. static Parse(parsedCamera: any, scene: Scene): Camera;
  29849. }
  29850. }
  29851. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29852. import { Nullable } from "babylonjs/types";
  29853. import { Scene } from "babylonjs/scene";
  29854. import { Vector4 } from "babylonjs/Maths/math.vector";
  29855. import { Mesh } from "babylonjs/Meshes/mesh";
  29856. /**
  29857. * Class containing static functions to help procedurally build meshes
  29858. */
  29859. export class DiscBuilder {
  29860. /**
  29861. * Creates a plane polygonal mesh. By default, this is a disc
  29862. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29863. * * 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
  29864. * * 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
  29865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29866. * * 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
  29867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29868. * @param name defines the name of the mesh
  29869. * @param options defines the options used to create the mesh
  29870. * @param scene defines the hosting scene
  29871. * @returns the plane polygonal mesh
  29872. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29873. */
  29874. static CreateDisc(name: string, options: {
  29875. radius?: number;
  29876. tessellation?: number;
  29877. arc?: number;
  29878. updatable?: boolean;
  29879. sideOrientation?: number;
  29880. frontUVs?: Vector4;
  29881. backUVs?: Vector4;
  29882. }, scene?: Nullable<Scene>): Mesh;
  29883. }
  29884. }
  29885. declare module "babylonjs/Materials/fresnelParameters" {
  29886. import { DeepImmutable } from "babylonjs/types";
  29887. import { Color3 } from "babylonjs/Maths/math.color";
  29888. /**
  29889. * Options to be used when creating a FresnelParameters.
  29890. */
  29891. export type IFresnelParametersCreationOptions = {
  29892. /**
  29893. * Define the color used on edges (grazing angle)
  29894. */
  29895. leftColor?: Color3;
  29896. /**
  29897. * Define the color used on center
  29898. */
  29899. rightColor?: Color3;
  29900. /**
  29901. * Define bias applied to computed fresnel term
  29902. */
  29903. bias?: number;
  29904. /**
  29905. * Defined the power exponent applied to fresnel term
  29906. */
  29907. power?: number;
  29908. /**
  29909. * Define if the fresnel effect is enable or not.
  29910. */
  29911. isEnabled?: boolean;
  29912. };
  29913. /**
  29914. * Serialized format for FresnelParameters.
  29915. */
  29916. export type IFresnelParametersSerialized = {
  29917. /**
  29918. * Define the color used on edges (grazing angle) [as an array]
  29919. */
  29920. leftColor: number[];
  29921. /**
  29922. * Define the color used on center [as an array]
  29923. */
  29924. rightColor: number[];
  29925. /**
  29926. * Define bias applied to computed fresnel term
  29927. */
  29928. bias: number;
  29929. /**
  29930. * Defined the power exponent applied to fresnel term
  29931. */
  29932. power?: number;
  29933. /**
  29934. * Define if the fresnel effect is enable or not.
  29935. */
  29936. isEnabled: boolean;
  29937. };
  29938. /**
  29939. * This represents all the required information to add a fresnel effect on a material:
  29940. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29941. */
  29942. export class FresnelParameters {
  29943. private _isEnabled;
  29944. /**
  29945. * Define if the fresnel effect is enable or not.
  29946. */
  29947. get isEnabled(): boolean;
  29948. set isEnabled(value: boolean);
  29949. /**
  29950. * Define the color used on edges (grazing angle)
  29951. */
  29952. leftColor: Color3;
  29953. /**
  29954. * Define the color used on center
  29955. */
  29956. rightColor: Color3;
  29957. /**
  29958. * Define bias applied to computed fresnel term
  29959. */
  29960. bias: number;
  29961. /**
  29962. * Defined the power exponent applied to fresnel term
  29963. */
  29964. power: number;
  29965. /**
  29966. * Creates a new FresnelParameters object.
  29967. *
  29968. * @param options provide your own settings to optionally to override defaults
  29969. */
  29970. constructor(options?: IFresnelParametersCreationOptions);
  29971. /**
  29972. * Clones the current fresnel and its valuues
  29973. * @returns a clone fresnel configuration
  29974. */
  29975. clone(): FresnelParameters;
  29976. /**
  29977. * Determines equality between FresnelParameters objects
  29978. * @param otherFresnelParameters defines the second operand
  29979. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29980. */
  29981. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29982. /**
  29983. * Serializes the current fresnel parameters to a JSON representation.
  29984. * @return the JSON serialization
  29985. */
  29986. serialize(): IFresnelParametersSerialized;
  29987. /**
  29988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29989. * @param parsedFresnelParameters Define the JSON representation
  29990. * @returns the parsed parameters
  29991. */
  29992. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29993. }
  29994. }
  29995. declare module "babylonjs/Materials/materialFlags" {
  29996. /**
  29997. * This groups all the flags used to control the materials channel.
  29998. */
  29999. export class MaterialFlags {
  30000. private static _DiffuseTextureEnabled;
  30001. /**
  30002. * Are diffuse textures enabled in the application.
  30003. */
  30004. static get DiffuseTextureEnabled(): boolean;
  30005. static set DiffuseTextureEnabled(value: boolean);
  30006. private static _DetailTextureEnabled;
  30007. /**
  30008. * Are detail textures enabled in the application.
  30009. */
  30010. static get DetailTextureEnabled(): boolean;
  30011. static set DetailTextureEnabled(value: boolean);
  30012. private static _AmbientTextureEnabled;
  30013. /**
  30014. * Are ambient textures enabled in the application.
  30015. */
  30016. static get AmbientTextureEnabled(): boolean;
  30017. static set AmbientTextureEnabled(value: boolean);
  30018. private static _OpacityTextureEnabled;
  30019. /**
  30020. * Are opacity textures enabled in the application.
  30021. */
  30022. static get OpacityTextureEnabled(): boolean;
  30023. static set OpacityTextureEnabled(value: boolean);
  30024. private static _ReflectionTextureEnabled;
  30025. /**
  30026. * Are reflection textures enabled in the application.
  30027. */
  30028. static get ReflectionTextureEnabled(): boolean;
  30029. static set ReflectionTextureEnabled(value: boolean);
  30030. private static _EmissiveTextureEnabled;
  30031. /**
  30032. * Are emissive textures enabled in the application.
  30033. */
  30034. static get EmissiveTextureEnabled(): boolean;
  30035. static set EmissiveTextureEnabled(value: boolean);
  30036. private static _SpecularTextureEnabled;
  30037. /**
  30038. * Are specular textures enabled in the application.
  30039. */
  30040. static get SpecularTextureEnabled(): boolean;
  30041. static set SpecularTextureEnabled(value: boolean);
  30042. private static _BumpTextureEnabled;
  30043. /**
  30044. * Are bump textures enabled in the application.
  30045. */
  30046. static get BumpTextureEnabled(): boolean;
  30047. static set BumpTextureEnabled(value: boolean);
  30048. private static _LightmapTextureEnabled;
  30049. /**
  30050. * Are lightmap textures enabled in the application.
  30051. */
  30052. static get LightmapTextureEnabled(): boolean;
  30053. static set LightmapTextureEnabled(value: boolean);
  30054. private static _RefractionTextureEnabled;
  30055. /**
  30056. * Are refraction textures enabled in the application.
  30057. */
  30058. static get RefractionTextureEnabled(): boolean;
  30059. static set RefractionTextureEnabled(value: boolean);
  30060. private static _ColorGradingTextureEnabled;
  30061. /**
  30062. * Are color grading textures enabled in the application.
  30063. */
  30064. static get ColorGradingTextureEnabled(): boolean;
  30065. static set ColorGradingTextureEnabled(value: boolean);
  30066. private static _FresnelEnabled;
  30067. /**
  30068. * Are fresnels enabled in the application.
  30069. */
  30070. static get FresnelEnabled(): boolean;
  30071. static set FresnelEnabled(value: boolean);
  30072. private static _ClearCoatTextureEnabled;
  30073. /**
  30074. * Are clear coat textures enabled in the application.
  30075. */
  30076. static get ClearCoatTextureEnabled(): boolean;
  30077. static set ClearCoatTextureEnabled(value: boolean);
  30078. private static _ClearCoatBumpTextureEnabled;
  30079. /**
  30080. * Are clear coat bump textures enabled in the application.
  30081. */
  30082. static get ClearCoatBumpTextureEnabled(): boolean;
  30083. static set ClearCoatBumpTextureEnabled(value: boolean);
  30084. private static _ClearCoatTintTextureEnabled;
  30085. /**
  30086. * Are clear coat tint textures enabled in the application.
  30087. */
  30088. static get ClearCoatTintTextureEnabled(): boolean;
  30089. static set ClearCoatTintTextureEnabled(value: boolean);
  30090. private static _SheenTextureEnabled;
  30091. /**
  30092. * Are sheen textures enabled in the application.
  30093. */
  30094. static get SheenTextureEnabled(): boolean;
  30095. static set SheenTextureEnabled(value: boolean);
  30096. private static _AnisotropicTextureEnabled;
  30097. /**
  30098. * Are anisotropic textures enabled in the application.
  30099. */
  30100. static get AnisotropicTextureEnabled(): boolean;
  30101. static set AnisotropicTextureEnabled(value: boolean);
  30102. private static _ThicknessTextureEnabled;
  30103. /**
  30104. * Are thickness textures enabled in the application.
  30105. */
  30106. static get ThicknessTextureEnabled(): boolean;
  30107. static set ThicknessTextureEnabled(value: boolean);
  30108. }
  30109. }
  30110. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30111. /** @hidden */
  30112. export var defaultFragmentDeclaration: {
  30113. name: string;
  30114. shader: string;
  30115. };
  30116. }
  30117. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30118. /** @hidden */
  30119. export var defaultUboDeclaration: {
  30120. name: string;
  30121. shader: string;
  30122. };
  30123. }
  30124. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30125. /** @hidden */
  30126. export var lightFragmentDeclaration: {
  30127. name: string;
  30128. shader: string;
  30129. };
  30130. }
  30131. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30132. /** @hidden */
  30133. export var lightUboDeclaration: {
  30134. name: string;
  30135. shader: string;
  30136. };
  30137. }
  30138. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30139. /** @hidden */
  30140. export var lightsFragmentFunctions: {
  30141. name: string;
  30142. shader: string;
  30143. };
  30144. }
  30145. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30146. /** @hidden */
  30147. export var shadowsFragmentFunctions: {
  30148. name: string;
  30149. shader: string;
  30150. };
  30151. }
  30152. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30153. /** @hidden */
  30154. export var fresnelFunction: {
  30155. name: string;
  30156. shader: string;
  30157. };
  30158. }
  30159. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30160. /** @hidden */
  30161. export var bumpFragmentMainFunctions: {
  30162. name: string;
  30163. shader: string;
  30164. };
  30165. }
  30166. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30167. /** @hidden */
  30168. export var bumpFragmentFunctions: {
  30169. name: string;
  30170. shader: string;
  30171. };
  30172. }
  30173. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30174. /** @hidden */
  30175. export var logDepthDeclaration: {
  30176. name: string;
  30177. shader: string;
  30178. };
  30179. }
  30180. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30181. /** @hidden */
  30182. export var bumpFragment: {
  30183. name: string;
  30184. shader: string;
  30185. };
  30186. }
  30187. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30188. /** @hidden */
  30189. export var depthPrePass: {
  30190. name: string;
  30191. shader: string;
  30192. };
  30193. }
  30194. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30195. /** @hidden */
  30196. export var lightFragment: {
  30197. name: string;
  30198. shader: string;
  30199. };
  30200. }
  30201. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30202. /** @hidden */
  30203. export var logDepthFragment: {
  30204. name: string;
  30205. shader: string;
  30206. };
  30207. }
  30208. declare module "babylonjs/Shaders/default.fragment" {
  30209. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30210. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30211. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30212. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30213. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30214. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30215. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30216. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30217. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30218. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30219. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30220. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30221. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30222. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30223. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30224. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30225. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30226. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30227. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30228. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30229. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30230. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30231. /** @hidden */
  30232. export var defaultPixelShader: {
  30233. name: string;
  30234. shader: string;
  30235. };
  30236. }
  30237. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30238. /** @hidden */
  30239. export var defaultVertexDeclaration: {
  30240. name: string;
  30241. shader: string;
  30242. };
  30243. }
  30244. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30245. /** @hidden */
  30246. export var bumpVertexDeclaration: {
  30247. name: string;
  30248. shader: string;
  30249. };
  30250. }
  30251. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30252. /** @hidden */
  30253. export var bumpVertex: {
  30254. name: string;
  30255. shader: string;
  30256. };
  30257. }
  30258. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30259. /** @hidden */
  30260. export var fogVertex: {
  30261. name: string;
  30262. shader: string;
  30263. };
  30264. }
  30265. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30266. /** @hidden */
  30267. export var shadowsVertex: {
  30268. name: string;
  30269. shader: string;
  30270. };
  30271. }
  30272. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30273. /** @hidden */
  30274. export var pointCloudVertex: {
  30275. name: string;
  30276. shader: string;
  30277. };
  30278. }
  30279. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30280. /** @hidden */
  30281. export var logDepthVertex: {
  30282. name: string;
  30283. shader: string;
  30284. };
  30285. }
  30286. declare module "babylonjs/Shaders/default.vertex" {
  30287. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30288. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30289. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30290. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30303. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30304. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30305. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30306. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30307. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30308. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30309. /** @hidden */
  30310. export var defaultVertexShader: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30316. import { Nullable } from "babylonjs/types";
  30317. import { Scene } from "babylonjs/scene";
  30318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30320. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30321. /**
  30322. * @hidden
  30323. */
  30324. export interface IMaterialDetailMapDefines {
  30325. DETAIL: boolean;
  30326. DETAILDIRECTUV: number;
  30327. DETAIL_NORMALBLENDMETHOD: number;
  30328. /** @hidden */
  30329. _areTexturesDirty: boolean;
  30330. }
  30331. /**
  30332. * Define the code related to the detail map parameters of a material
  30333. *
  30334. * Inspired from:
  30335. * 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
  30336. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30337. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30338. */
  30339. export class DetailMapConfiguration {
  30340. private _texture;
  30341. /**
  30342. * The detail texture of the material.
  30343. */
  30344. texture: Nullable<BaseTexture>;
  30345. /**
  30346. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30347. * Bigger values mean stronger blending
  30348. */
  30349. diffuseBlendLevel: number;
  30350. /**
  30351. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30352. * Bigger values mean stronger blending. Only used with PBR materials
  30353. */
  30354. roughnessBlendLevel: number;
  30355. /**
  30356. * Defines how strong the bump effect from the detail map is
  30357. * Bigger values mean stronger effect
  30358. */
  30359. bumpLevel: number;
  30360. private _normalBlendMethod;
  30361. /**
  30362. * The method used to blend the bump and detail normals together
  30363. */
  30364. normalBlendMethod: number;
  30365. private _isEnabled;
  30366. /**
  30367. * Enable or disable the detail map on this material
  30368. */
  30369. isEnabled: boolean;
  30370. /** @hidden */
  30371. private _internalMarkAllSubMeshesAsTexturesDirty;
  30372. /** @hidden */
  30373. _markAllSubMeshesAsTexturesDirty(): void;
  30374. /**
  30375. * Instantiate a new detail map
  30376. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30377. */
  30378. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30379. /**
  30380. * Gets whether the submesh is ready to be used or not.
  30381. * @param defines the list of "defines" to update.
  30382. * @param scene defines the scene the material belongs to.
  30383. * @returns - boolean indicating that the submesh is ready or not.
  30384. */
  30385. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30386. /**
  30387. * Update the defines for detail map usage
  30388. * @param defines the list of "defines" to update.
  30389. * @param scene defines the scene the material belongs to.
  30390. */
  30391. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30392. /**
  30393. * Binds the material data.
  30394. * @param uniformBuffer defines the Uniform buffer to fill in.
  30395. * @param scene defines the scene the material belongs to.
  30396. * @param isFrozen defines whether the material is frozen or not.
  30397. */
  30398. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30399. /**
  30400. * Checks to see if a texture is used in the material.
  30401. * @param texture - Base texture to use.
  30402. * @returns - Boolean specifying if a texture is used in the material.
  30403. */
  30404. hasTexture(texture: BaseTexture): boolean;
  30405. /**
  30406. * Returns an array of the actively used textures.
  30407. * @param activeTextures Array of BaseTextures
  30408. */
  30409. getActiveTextures(activeTextures: BaseTexture[]): void;
  30410. /**
  30411. * Returns the animatable textures.
  30412. * @param animatables Array of animatable textures.
  30413. */
  30414. getAnimatables(animatables: IAnimatable[]): void;
  30415. /**
  30416. * Disposes the resources of the material.
  30417. * @param forceDisposeTextures - Forces the disposal of all textures.
  30418. */
  30419. dispose(forceDisposeTextures?: boolean): void;
  30420. /**
  30421. * Get the current class name useful for serialization or dynamic coding.
  30422. * @returns "DetailMap"
  30423. */
  30424. getClassName(): string;
  30425. /**
  30426. * Add the required uniforms to the current list.
  30427. * @param uniforms defines the current uniform list.
  30428. */
  30429. static AddUniforms(uniforms: string[]): void;
  30430. /**
  30431. * Add the required samplers to the current list.
  30432. * @param samplers defines the current sampler list.
  30433. */
  30434. static AddSamplers(samplers: string[]): void;
  30435. /**
  30436. * Add the required uniforms to the current buffer.
  30437. * @param uniformBuffer defines the current uniform buffer.
  30438. */
  30439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30440. /**
  30441. * Makes a duplicate of the current instance into another one.
  30442. * @param detailMap define the instance where to copy the info
  30443. */
  30444. copyTo(detailMap: DetailMapConfiguration): void;
  30445. /**
  30446. * Serializes this detail map instance
  30447. * @returns - An object with the serialized instance.
  30448. */
  30449. serialize(): any;
  30450. /**
  30451. * Parses a detail map setting from a serialized object.
  30452. * @param source - Serialized object.
  30453. * @param scene Defines the scene we are parsing for
  30454. * @param rootUrl Defines the rootUrl to load from
  30455. */
  30456. parse(source: any, scene: Scene, rootUrl: string): void;
  30457. }
  30458. }
  30459. declare module "babylonjs/Materials/standardMaterial" {
  30460. import { SmartArray } from "babylonjs/Misc/smartArray";
  30461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30462. import { Nullable } from "babylonjs/types";
  30463. import { Scene } from "babylonjs/scene";
  30464. import { Matrix } from "babylonjs/Maths/math.vector";
  30465. import { Color3 } from "babylonjs/Maths/math.color";
  30466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30468. import { Mesh } from "babylonjs/Meshes/mesh";
  30469. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30470. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30471. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30476. import "babylonjs/Shaders/default.fragment";
  30477. import "babylonjs/Shaders/default.vertex";
  30478. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30479. /** @hidden */
  30480. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30481. MAINUV1: boolean;
  30482. MAINUV2: boolean;
  30483. DIFFUSE: boolean;
  30484. DIFFUSEDIRECTUV: number;
  30485. DETAIL: boolean;
  30486. DETAILDIRECTUV: number;
  30487. DETAIL_NORMALBLENDMETHOD: number;
  30488. AMBIENT: boolean;
  30489. AMBIENTDIRECTUV: number;
  30490. OPACITY: boolean;
  30491. OPACITYDIRECTUV: number;
  30492. OPACITYRGB: boolean;
  30493. REFLECTION: boolean;
  30494. EMISSIVE: boolean;
  30495. EMISSIVEDIRECTUV: number;
  30496. SPECULAR: boolean;
  30497. SPECULARDIRECTUV: number;
  30498. BUMP: boolean;
  30499. BUMPDIRECTUV: number;
  30500. PARALLAX: boolean;
  30501. PARALLAXOCCLUSION: boolean;
  30502. SPECULAROVERALPHA: boolean;
  30503. CLIPPLANE: boolean;
  30504. CLIPPLANE2: boolean;
  30505. CLIPPLANE3: boolean;
  30506. CLIPPLANE4: boolean;
  30507. CLIPPLANE5: boolean;
  30508. CLIPPLANE6: boolean;
  30509. ALPHATEST: boolean;
  30510. DEPTHPREPASS: boolean;
  30511. ALPHAFROMDIFFUSE: boolean;
  30512. POINTSIZE: boolean;
  30513. FOG: boolean;
  30514. SPECULARTERM: boolean;
  30515. DIFFUSEFRESNEL: boolean;
  30516. OPACITYFRESNEL: boolean;
  30517. REFLECTIONFRESNEL: boolean;
  30518. REFRACTIONFRESNEL: boolean;
  30519. EMISSIVEFRESNEL: boolean;
  30520. FRESNEL: boolean;
  30521. NORMAL: boolean;
  30522. UV1: boolean;
  30523. UV2: boolean;
  30524. VERTEXCOLOR: boolean;
  30525. VERTEXALPHA: boolean;
  30526. NUM_BONE_INFLUENCERS: number;
  30527. BonesPerMesh: number;
  30528. BONETEXTURE: boolean;
  30529. INSTANCES: boolean;
  30530. THIN_INSTANCES: boolean;
  30531. GLOSSINESS: boolean;
  30532. ROUGHNESS: boolean;
  30533. EMISSIVEASILLUMINATION: boolean;
  30534. LINKEMISSIVEWITHDIFFUSE: boolean;
  30535. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30536. LIGHTMAP: boolean;
  30537. LIGHTMAPDIRECTUV: number;
  30538. OBJECTSPACE_NORMALMAP: boolean;
  30539. USELIGHTMAPASSHADOWMAP: boolean;
  30540. REFLECTIONMAP_3D: boolean;
  30541. REFLECTIONMAP_SPHERICAL: boolean;
  30542. REFLECTIONMAP_PLANAR: boolean;
  30543. REFLECTIONMAP_CUBIC: boolean;
  30544. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30545. REFLECTIONMAP_PROJECTION: boolean;
  30546. REFLECTIONMAP_SKYBOX: boolean;
  30547. REFLECTIONMAP_EXPLICIT: boolean;
  30548. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30549. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30550. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30551. INVERTCUBICMAP: boolean;
  30552. LOGARITHMICDEPTH: boolean;
  30553. REFRACTION: boolean;
  30554. REFRACTIONMAP_3D: boolean;
  30555. REFLECTIONOVERALPHA: boolean;
  30556. TWOSIDEDLIGHTING: boolean;
  30557. SHADOWFLOAT: boolean;
  30558. MORPHTARGETS: boolean;
  30559. MORPHTARGETS_NORMAL: boolean;
  30560. MORPHTARGETS_TANGENT: boolean;
  30561. MORPHTARGETS_UV: boolean;
  30562. NUM_MORPH_INFLUENCERS: number;
  30563. NONUNIFORMSCALING: boolean;
  30564. PREMULTIPLYALPHA: boolean;
  30565. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30566. ALPHABLEND: boolean;
  30567. PREPASS: boolean;
  30568. SCENE_MRT_COUNT: number;
  30569. RGBDLIGHTMAP: boolean;
  30570. RGBDREFLECTION: boolean;
  30571. RGBDREFRACTION: boolean;
  30572. IMAGEPROCESSING: boolean;
  30573. VIGNETTE: boolean;
  30574. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30575. VIGNETTEBLENDMODEOPAQUE: boolean;
  30576. TONEMAPPING: boolean;
  30577. TONEMAPPING_ACES: boolean;
  30578. CONTRAST: boolean;
  30579. COLORCURVES: boolean;
  30580. COLORGRADING: boolean;
  30581. COLORGRADING3D: boolean;
  30582. SAMPLER3DGREENDEPTH: boolean;
  30583. SAMPLER3DBGRMAP: boolean;
  30584. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30585. MULTIVIEW: boolean;
  30586. /**
  30587. * If the reflection texture on this material is in linear color space
  30588. * @hidden
  30589. */
  30590. IS_REFLECTION_LINEAR: boolean;
  30591. /**
  30592. * If the refraction texture on this material is in linear color space
  30593. * @hidden
  30594. */
  30595. IS_REFRACTION_LINEAR: boolean;
  30596. EXPOSURE: boolean;
  30597. constructor();
  30598. setReflectionMode(modeToEnable: string): void;
  30599. }
  30600. /**
  30601. * This is the default material used in Babylon. It is the best trade off between quality
  30602. * and performances.
  30603. * @see https://doc.babylonjs.com/babylon101/materials
  30604. */
  30605. export class StandardMaterial extends PushMaterial {
  30606. private _diffuseTexture;
  30607. /**
  30608. * The basic texture of the material as viewed under a light.
  30609. */
  30610. diffuseTexture: Nullable<BaseTexture>;
  30611. private _ambientTexture;
  30612. /**
  30613. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30614. */
  30615. ambientTexture: Nullable<BaseTexture>;
  30616. private _opacityTexture;
  30617. /**
  30618. * Define the transparency of the material from a texture.
  30619. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30620. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30621. */
  30622. opacityTexture: Nullable<BaseTexture>;
  30623. private _reflectionTexture;
  30624. /**
  30625. * Define the texture used to display the reflection.
  30626. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30627. */
  30628. reflectionTexture: Nullable<BaseTexture>;
  30629. private _emissiveTexture;
  30630. /**
  30631. * Define texture of the material as if self lit.
  30632. * This will be mixed in the final result even in the absence of light.
  30633. */
  30634. emissiveTexture: Nullable<BaseTexture>;
  30635. private _specularTexture;
  30636. /**
  30637. * Define how the color and intensity of the highlight given by the light in the material.
  30638. */
  30639. specularTexture: Nullable<BaseTexture>;
  30640. private _bumpTexture;
  30641. /**
  30642. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30643. * 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.
  30644. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30645. */
  30646. bumpTexture: Nullable<BaseTexture>;
  30647. private _lightmapTexture;
  30648. /**
  30649. * Complex lighting can be computationally expensive to compute at runtime.
  30650. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30651. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30652. */
  30653. lightmapTexture: Nullable<BaseTexture>;
  30654. private _refractionTexture;
  30655. /**
  30656. * Define the texture used to display the refraction.
  30657. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30658. */
  30659. refractionTexture: Nullable<BaseTexture>;
  30660. /**
  30661. * The color of the material lit by the environmental background lighting.
  30662. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30663. */
  30664. ambientColor: Color3;
  30665. /**
  30666. * The basic color of the material as viewed under a light.
  30667. */
  30668. diffuseColor: Color3;
  30669. /**
  30670. * Define how the color and intensity of the highlight given by the light in the material.
  30671. */
  30672. specularColor: Color3;
  30673. /**
  30674. * Define the color of the material as if self lit.
  30675. * This will be mixed in the final result even in the absence of light.
  30676. */
  30677. emissiveColor: Color3;
  30678. /**
  30679. * Defines how sharp are the highlights in the material.
  30680. * The bigger the value the sharper giving a more glossy feeling to the result.
  30681. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30682. */
  30683. specularPower: number;
  30684. private _useAlphaFromDiffuseTexture;
  30685. /**
  30686. * Does the transparency come from the diffuse texture alpha channel.
  30687. */
  30688. useAlphaFromDiffuseTexture: boolean;
  30689. private _useEmissiveAsIllumination;
  30690. /**
  30691. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30692. */
  30693. useEmissiveAsIllumination: boolean;
  30694. private _linkEmissiveWithDiffuse;
  30695. /**
  30696. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30697. * the emissive level when the final color is close to one.
  30698. */
  30699. linkEmissiveWithDiffuse: boolean;
  30700. private _useSpecularOverAlpha;
  30701. /**
  30702. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30703. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30704. */
  30705. useSpecularOverAlpha: boolean;
  30706. private _useReflectionOverAlpha;
  30707. /**
  30708. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30709. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30710. */
  30711. useReflectionOverAlpha: boolean;
  30712. private _disableLighting;
  30713. /**
  30714. * Does lights from the scene impacts this material.
  30715. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30716. */
  30717. disableLighting: boolean;
  30718. private _useObjectSpaceNormalMap;
  30719. /**
  30720. * Allows using an object space normal map (instead of tangent space).
  30721. */
  30722. useObjectSpaceNormalMap: boolean;
  30723. private _useParallax;
  30724. /**
  30725. * Is parallax enabled or not.
  30726. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30727. */
  30728. useParallax: boolean;
  30729. private _useParallaxOcclusion;
  30730. /**
  30731. * Is parallax occlusion enabled or not.
  30732. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30733. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30734. */
  30735. useParallaxOcclusion: boolean;
  30736. /**
  30737. * 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.
  30738. */
  30739. parallaxScaleBias: number;
  30740. private _roughness;
  30741. /**
  30742. * Helps to define how blurry the reflections should appears in the material.
  30743. */
  30744. roughness: number;
  30745. /**
  30746. * In case of refraction, define the value of the index of refraction.
  30747. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30748. */
  30749. indexOfRefraction: number;
  30750. /**
  30751. * Invert the refraction texture alongside the y axis.
  30752. * It can be useful with procedural textures or probe for instance.
  30753. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30754. */
  30755. invertRefractionY: boolean;
  30756. /**
  30757. * Defines the alpha limits in alpha test mode.
  30758. */
  30759. alphaCutOff: number;
  30760. private _useLightmapAsShadowmap;
  30761. /**
  30762. * In case of light mapping, define whether the map contains light or shadow informations.
  30763. */
  30764. useLightmapAsShadowmap: boolean;
  30765. private _diffuseFresnelParameters;
  30766. /**
  30767. * Define the diffuse fresnel parameters of the material.
  30768. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30769. */
  30770. diffuseFresnelParameters: FresnelParameters;
  30771. private _opacityFresnelParameters;
  30772. /**
  30773. * Define the opacity fresnel parameters of the material.
  30774. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30775. */
  30776. opacityFresnelParameters: FresnelParameters;
  30777. private _reflectionFresnelParameters;
  30778. /**
  30779. * Define the reflection fresnel parameters of the material.
  30780. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30781. */
  30782. reflectionFresnelParameters: FresnelParameters;
  30783. private _refractionFresnelParameters;
  30784. /**
  30785. * Define the refraction fresnel parameters of the material.
  30786. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30787. */
  30788. refractionFresnelParameters: FresnelParameters;
  30789. private _emissiveFresnelParameters;
  30790. /**
  30791. * Define the emissive fresnel parameters of the material.
  30792. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30793. */
  30794. emissiveFresnelParameters: FresnelParameters;
  30795. private _useReflectionFresnelFromSpecular;
  30796. /**
  30797. * If true automatically deducts the fresnels values from the material specularity.
  30798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30799. */
  30800. useReflectionFresnelFromSpecular: boolean;
  30801. private _useGlossinessFromSpecularMapAlpha;
  30802. /**
  30803. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30804. */
  30805. useGlossinessFromSpecularMapAlpha: boolean;
  30806. private _maxSimultaneousLights;
  30807. /**
  30808. * Defines the maximum number of lights that can be used in the material
  30809. */
  30810. maxSimultaneousLights: number;
  30811. private _invertNormalMapX;
  30812. /**
  30813. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30814. */
  30815. invertNormalMapX: boolean;
  30816. private _invertNormalMapY;
  30817. /**
  30818. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30819. */
  30820. invertNormalMapY: boolean;
  30821. private _twoSidedLighting;
  30822. /**
  30823. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30824. */
  30825. twoSidedLighting: boolean;
  30826. /**
  30827. * Default configuration related to image processing available in the standard Material.
  30828. */
  30829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30830. /**
  30831. * Gets the image processing configuration used either in this material.
  30832. */
  30833. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30834. /**
  30835. * Sets the Default image processing configuration used either in the this material.
  30836. *
  30837. * If sets to null, the scene one is in use.
  30838. */
  30839. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30840. /**
  30841. * Keep track of the image processing observer to allow dispose and replace.
  30842. */
  30843. private _imageProcessingObserver;
  30844. /**
  30845. * Attaches a new image processing configuration to the Standard Material.
  30846. * @param configuration
  30847. */
  30848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30849. /**
  30850. * Gets wether the color curves effect is enabled.
  30851. */
  30852. get cameraColorCurvesEnabled(): boolean;
  30853. /**
  30854. * Sets wether the color curves effect is enabled.
  30855. */
  30856. set cameraColorCurvesEnabled(value: boolean);
  30857. /**
  30858. * Gets wether the color grading effect is enabled.
  30859. */
  30860. get cameraColorGradingEnabled(): boolean;
  30861. /**
  30862. * Gets wether the color grading effect is enabled.
  30863. */
  30864. set cameraColorGradingEnabled(value: boolean);
  30865. /**
  30866. * Gets wether tonemapping is enabled or not.
  30867. */
  30868. get cameraToneMappingEnabled(): boolean;
  30869. /**
  30870. * Sets wether tonemapping is enabled or not
  30871. */
  30872. set cameraToneMappingEnabled(value: boolean);
  30873. /**
  30874. * The camera exposure used on this material.
  30875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30876. * This corresponds to a photographic exposure.
  30877. */
  30878. get cameraExposure(): number;
  30879. /**
  30880. * The camera exposure used on this material.
  30881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30882. * This corresponds to a photographic exposure.
  30883. */
  30884. set cameraExposure(value: number);
  30885. /**
  30886. * Gets The camera contrast used on this material.
  30887. */
  30888. get cameraContrast(): number;
  30889. /**
  30890. * Sets The camera contrast used on this material.
  30891. */
  30892. set cameraContrast(value: number);
  30893. /**
  30894. * Gets the Color Grading 2D Lookup Texture.
  30895. */
  30896. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30897. /**
  30898. * Sets the Color Grading 2D Lookup Texture.
  30899. */
  30900. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30901. /**
  30902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30904. * 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;
  30905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30906. */
  30907. get cameraColorCurves(): Nullable<ColorCurves>;
  30908. /**
  30909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30911. * 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;
  30912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30913. */
  30914. set cameraColorCurves(value: Nullable<ColorCurves>);
  30915. /**
  30916. * Defines the detail map parameters for the material.
  30917. */
  30918. readonly detailMap: DetailMapConfiguration;
  30919. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30920. protected _worldViewProjectionMatrix: Matrix;
  30921. protected _globalAmbientColor: Color3;
  30922. protected _useLogarithmicDepth: boolean;
  30923. protected _rebuildInParallel: boolean;
  30924. /**
  30925. * Instantiates a new standard material.
  30926. * This is the default material used in Babylon. It is the best trade off between quality
  30927. * and performances.
  30928. * @see https://doc.babylonjs.com/babylon101/materials
  30929. * @param name Define the name of the material in the scene
  30930. * @param scene Define the scene the material belong to
  30931. */
  30932. constructor(name: string, scene: Scene);
  30933. /**
  30934. * Gets a boolean indicating that current material needs to register RTT
  30935. */
  30936. get hasRenderTargetTextures(): boolean;
  30937. /**
  30938. * Gets the current class name of the material e.g. "StandardMaterial"
  30939. * Mainly use in serialization.
  30940. * @returns the class name
  30941. */
  30942. getClassName(): string;
  30943. /**
  30944. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30945. * You can try switching to logarithmic depth.
  30946. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30947. */
  30948. get useLogarithmicDepth(): boolean;
  30949. set useLogarithmicDepth(value: boolean);
  30950. /**
  30951. * Specifies if the material will require alpha blending
  30952. * @returns a boolean specifying if alpha blending is needed
  30953. */
  30954. needAlphaBlending(): boolean;
  30955. /**
  30956. * Specifies if this material should be rendered in alpha test mode
  30957. * @returns a boolean specifying if an alpha test is needed.
  30958. */
  30959. needAlphaTesting(): boolean;
  30960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30961. /**
  30962. * Get the texture used for alpha test purpose.
  30963. * @returns the diffuse texture in case of the standard material.
  30964. */
  30965. getAlphaTestTexture(): Nullable<BaseTexture>;
  30966. /**
  30967. * Get if the submesh is ready to be used and all its information available.
  30968. * Child classes can use it to update shaders
  30969. * @param mesh defines the mesh to check
  30970. * @param subMesh defines which submesh to check
  30971. * @param useInstances specifies that instances should be used
  30972. * @returns a boolean indicating that the submesh is ready or not
  30973. */
  30974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30975. /**
  30976. * Builds the material UBO layouts.
  30977. * Used internally during the effect preparation.
  30978. */
  30979. buildUniformLayout(): void;
  30980. /**
  30981. * Unbinds the material from the mesh
  30982. */
  30983. unbind(): void;
  30984. /**
  30985. * Binds the submesh to this material by preparing the effect and shader to draw
  30986. * @param world defines the world transformation matrix
  30987. * @param mesh defines the mesh containing the submesh
  30988. * @param subMesh defines the submesh to bind the material to
  30989. */
  30990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30991. /**
  30992. * Get the list of animatables in the material.
  30993. * @returns the list of animatables object used in the material
  30994. */
  30995. getAnimatables(): IAnimatable[];
  30996. /**
  30997. * Gets the active textures from the material
  30998. * @returns an array of textures
  30999. */
  31000. getActiveTextures(): BaseTexture[];
  31001. /**
  31002. * Specifies if the material uses a texture
  31003. * @param texture defines the texture to check against the material
  31004. * @returns a boolean specifying if the material uses the texture
  31005. */
  31006. hasTexture(texture: BaseTexture): boolean;
  31007. /**
  31008. * Disposes the material
  31009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31011. */
  31012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31013. /**
  31014. * Makes a duplicate of the material, and gives it a new name
  31015. * @param name defines the new name for the duplicated material
  31016. * @returns the cloned material
  31017. */
  31018. clone(name: string): StandardMaterial;
  31019. /**
  31020. * Serializes this material in a JSON representation
  31021. * @returns the serialized material object
  31022. */
  31023. serialize(): any;
  31024. /**
  31025. * Creates a standard material from parsed material data
  31026. * @param source defines the JSON representation of the material
  31027. * @param scene defines the hosting scene
  31028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31029. * @returns a new standard material
  31030. */
  31031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31032. /**
  31033. * Are diffuse textures enabled in the application.
  31034. */
  31035. static get DiffuseTextureEnabled(): boolean;
  31036. static set DiffuseTextureEnabled(value: boolean);
  31037. /**
  31038. * Are detail textures enabled in the application.
  31039. */
  31040. static get DetailTextureEnabled(): boolean;
  31041. static set DetailTextureEnabled(value: boolean);
  31042. /**
  31043. * Are ambient textures enabled in the application.
  31044. */
  31045. static get AmbientTextureEnabled(): boolean;
  31046. static set AmbientTextureEnabled(value: boolean);
  31047. /**
  31048. * Are opacity textures enabled in the application.
  31049. */
  31050. static get OpacityTextureEnabled(): boolean;
  31051. static set OpacityTextureEnabled(value: boolean);
  31052. /**
  31053. * Are reflection textures enabled in the application.
  31054. */
  31055. static get ReflectionTextureEnabled(): boolean;
  31056. static set ReflectionTextureEnabled(value: boolean);
  31057. /**
  31058. * Are emissive textures enabled in the application.
  31059. */
  31060. static get EmissiveTextureEnabled(): boolean;
  31061. static set EmissiveTextureEnabled(value: boolean);
  31062. /**
  31063. * Are specular textures enabled in the application.
  31064. */
  31065. static get SpecularTextureEnabled(): boolean;
  31066. static set SpecularTextureEnabled(value: boolean);
  31067. /**
  31068. * Are bump textures enabled in the application.
  31069. */
  31070. static get BumpTextureEnabled(): boolean;
  31071. static set BumpTextureEnabled(value: boolean);
  31072. /**
  31073. * Are lightmap textures enabled in the application.
  31074. */
  31075. static get LightmapTextureEnabled(): boolean;
  31076. static set LightmapTextureEnabled(value: boolean);
  31077. /**
  31078. * Are refraction textures enabled in the application.
  31079. */
  31080. static get RefractionTextureEnabled(): boolean;
  31081. static set RefractionTextureEnabled(value: boolean);
  31082. /**
  31083. * Are color grading textures enabled in the application.
  31084. */
  31085. static get ColorGradingTextureEnabled(): boolean;
  31086. static set ColorGradingTextureEnabled(value: boolean);
  31087. /**
  31088. * Are fresnels enabled in the application.
  31089. */
  31090. static get FresnelEnabled(): boolean;
  31091. static set FresnelEnabled(value: boolean);
  31092. }
  31093. }
  31094. declare module "babylonjs/Particles/solidParticleSystem" {
  31095. import { Nullable } from "babylonjs/types";
  31096. import { Mesh } from "babylonjs/Meshes/mesh";
  31097. import { Scene, IDisposable } from "babylonjs/scene";
  31098. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31099. import { Material } from "babylonjs/Materials/material";
  31100. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31101. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31102. /**
  31103. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31104. *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.
  31105. * The SPS is also a particle system. It provides some methods to manage the particles.
  31106. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31107. *
  31108. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31109. */
  31110. export class SolidParticleSystem implements IDisposable {
  31111. /**
  31112. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31113. * Example : var p = SPS.particles[i];
  31114. */
  31115. particles: SolidParticle[];
  31116. /**
  31117. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31118. */
  31119. nbParticles: number;
  31120. /**
  31121. * If the particles must ever face the camera (default false). Useful for planar particles.
  31122. */
  31123. billboard: boolean;
  31124. /**
  31125. * Recompute normals when adding a shape
  31126. */
  31127. recomputeNormals: boolean;
  31128. /**
  31129. * This a counter ofr your own usage. It's not set by any SPS functions.
  31130. */
  31131. counter: number;
  31132. /**
  31133. * The SPS name. This name is also given to the underlying mesh.
  31134. */
  31135. name: string;
  31136. /**
  31137. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31138. */
  31139. mesh: Mesh;
  31140. /**
  31141. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31142. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31143. */
  31144. vars: any;
  31145. /**
  31146. * This array is populated when the SPS is set as 'pickable'.
  31147. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31148. * Each element of this array is an object `{idx: int, faceId: int}`.
  31149. * `idx` is the picked particle index in the `SPS.particles` array
  31150. * `faceId` is the picked face index counted within this particle.
  31151. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31152. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31153. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31154. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31155. */
  31156. pickedParticles: {
  31157. idx: number;
  31158. faceId: number;
  31159. }[];
  31160. /**
  31161. * This array is populated when the SPS is set as 'pickable'
  31162. * Each key of this array is a submesh index.
  31163. * Each element of this array is a second array defined like this :
  31164. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31165. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31166. * `idx` is the picked particle index in the `SPS.particles` array
  31167. * `faceId` is the picked face index counted within this particle.
  31168. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31169. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31170. */
  31171. pickedBySubMesh: {
  31172. idx: number;
  31173. faceId: number;
  31174. }[][];
  31175. /**
  31176. * This array is populated when `enableDepthSort` is set to true.
  31177. * Each element of this array is an instance of the class DepthSortedParticle.
  31178. */
  31179. depthSortedParticles: DepthSortedParticle[];
  31180. /**
  31181. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31182. * @hidden
  31183. */
  31184. _bSphereOnly: boolean;
  31185. /**
  31186. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31187. * @hidden
  31188. */
  31189. _bSphereRadiusFactor: number;
  31190. private _scene;
  31191. private _positions;
  31192. private _indices;
  31193. private _normals;
  31194. private _colors;
  31195. private _uvs;
  31196. private _indices32;
  31197. private _positions32;
  31198. private _normals32;
  31199. private _fixedNormal32;
  31200. private _colors32;
  31201. private _uvs32;
  31202. private _index;
  31203. private _updatable;
  31204. private _pickable;
  31205. private _isVisibilityBoxLocked;
  31206. private _alwaysVisible;
  31207. private _depthSort;
  31208. private _expandable;
  31209. private _shapeCounter;
  31210. private _copy;
  31211. private _color;
  31212. private _computeParticleColor;
  31213. private _computeParticleTexture;
  31214. private _computeParticleRotation;
  31215. private _computeParticleVertex;
  31216. private _computeBoundingBox;
  31217. private _depthSortParticles;
  31218. private _camera;
  31219. private _mustUnrotateFixedNormals;
  31220. private _particlesIntersect;
  31221. private _needs32Bits;
  31222. private _isNotBuilt;
  31223. private _lastParticleId;
  31224. private _idxOfId;
  31225. private _multimaterialEnabled;
  31226. private _useModelMaterial;
  31227. private _indicesByMaterial;
  31228. private _materialIndexes;
  31229. private _depthSortFunction;
  31230. private _materialSortFunction;
  31231. private _materials;
  31232. private _multimaterial;
  31233. private _materialIndexesById;
  31234. private _defaultMaterial;
  31235. private _autoUpdateSubMeshes;
  31236. private _tmpVertex;
  31237. /**
  31238. * Creates a SPS (Solid Particle System) object.
  31239. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31240. * @param scene (Scene) is the scene in which the SPS is added.
  31241. * @param options defines the options of the sps e.g.
  31242. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31243. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31244. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31245. * * 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.
  31246. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31247. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31248. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31249. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31250. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31251. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31252. */
  31253. constructor(name: string, scene: Scene, options?: {
  31254. updatable?: boolean;
  31255. isPickable?: boolean;
  31256. enableDepthSort?: boolean;
  31257. particleIntersection?: boolean;
  31258. boundingSphereOnly?: boolean;
  31259. bSphereRadiusFactor?: number;
  31260. expandable?: boolean;
  31261. useModelMaterial?: boolean;
  31262. enableMultiMaterial?: boolean;
  31263. });
  31264. /**
  31265. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31266. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31267. * @returns the created mesh
  31268. */
  31269. buildMesh(): Mesh;
  31270. /**
  31271. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31272. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31273. * Thus the particles generated from `digest()` have their property `position` set yet.
  31274. * @param mesh ( Mesh ) is the mesh to be digested
  31275. * @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
  31276. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31277. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31278. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31279. * @returns the current SPS
  31280. */
  31281. digest(mesh: Mesh, options?: {
  31282. facetNb?: number;
  31283. number?: number;
  31284. delta?: number;
  31285. storage?: [];
  31286. }): SolidParticleSystem;
  31287. /**
  31288. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31289. * @hidden
  31290. */
  31291. private _unrotateFixedNormals;
  31292. /**
  31293. * Resets the temporary working copy particle
  31294. * @hidden
  31295. */
  31296. private _resetCopy;
  31297. /**
  31298. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31299. * @param p the current index in the positions array to be updated
  31300. * @param ind the current index in the indices array
  31301. * @param shape a Vector3 array, the shape geometry
  31302. * @param positions the positions array to be updated
  31303. * @param meshInd the shape indices array
  31304. * @param indices the indices array to be updated
  31305. * @param meshUV the shape uv array
  31306. * @param uvs the uv array to be updated
  31307. * @param meshCol the shape color array
  31308. * @param colors the color array to be updated
  31309. * @param meshNor the shape normals array
  31310. * @param normals the normals array to be updated
  31311. * @param idx the particle index
  31312. * @param idxInShape the particle index in its shape
  31313. * @param options the addShape() method passed options
  31314. * @model the particle model
  31315. * @hidden
  31316. */
  31317. private _meshBuilder;
  31318. /**
  31319. * Returns a shape Vector3 array from positions float array
  31320. * @param positions float array
  31321. * @returns a vector3 array
  31322. * @hidden
  31323. */
  31324. private _posToShape;
  31325. /**
  31326. * Returns a shapeUV array from a float uvs (array deep copy)
  31327. * @param uvs as a float array
  31328. * @returns a shapeUV array
  31329. * @hidden
  31330. */
  31331. private _uvsToShapeUV;
  31332. /**
  31333. * Adds a new particle object in the particles array
  31334. * @param idx particle index in particles array
  31335. * @param id particle id
  31336. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31337. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31338. * @param model particle ModelShape object
  31339. * @param shapeId model shape identifier
  31340. * @param idxInShape index of the particle in the current model
  31341. * @param bInfo model bounding info object
  31342. * @param storage target storage array, if any
  31343. * @hidden
  31344. */
  31345. private _addParticle;
  31346. /**
  31347. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31348. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31349. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31350. * @param nb (positive integer) the number of particles to be created from this model
  31351. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31352. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31354. * @returns the number of shapes in the system
  31355. */
  31356. addShape(mesh: Mesh, nb: number, options?: {
  31357. positionFunction?: any;
  31358. vertexFunction?: any;
  31359. storage?: [];
  31360. }): number;
  31361. /**
  31362. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31363. * @hidden
  31364. */
  31365. private _rebuildParticle;
  31366. /**
  31367. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31368. * @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.
  31369. * @returns the SPS.
  31370. */
  31371. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31372. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31373. * Returns an array with the removed particles.
  31374. * 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.
  31375. * The SPS can't be empty so at least one particle needs to remain in place.
  31376. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31377. * @param start index of the first particle to remove
  31378. * @param end index of the last particle to remove (included)
  31379. * @returns an array populated with the removed particles
  31380. */
  31381. removeParticles(start: number, end: number): SolidParticle[];
  31382. /**
  31383. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31384. * @param solidParticleArray an array populated with Solid Particles objects
  31385. * @returns the SPS
  31386. */
  31387. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31388. /**
  31389. * Creates a new particle and modifies the SPS mesh geometry :
  31390. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31391. * - calls _addParticle() to populate the particle array
  31392. * factorized code from addShape() and insertParticlesFromArray()
  31393. * @param idx particle index in the particles array
  31394. * @param i particle index in its shape
  31395. * @param modelShape particle ModelShape object
  31396. * @param shape shape vertex array
  31397. * @param meshInd shape indices array
  31398. * @param meshUV shape uv array
  31399. * @param meshCol shape color array
  31400. * @param meshNor shape normals array
  31401. * @param bbInfo shape bounding info
  31402. * @param storage target particle storage
  31403. * @options addShape() passed options
  31404. * @hidden
  31405. */
  31406. private _insertNewParticle;
  31407. /**
  31408. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31409. * This method calls `updateParticle()` for each particle of the SPS.
  31410. * For an animated SPS, it is usually called within the render loop.
  31411. * 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.
  31412. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31413. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31414. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31415. * @returns the SPS.
  31416. */
  31417. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31418. /**
  31419. * Disposes the SPS.
  31420. */
  31421. dispose(): void;
  31422. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31423. * idx is the particle index in the SPS
  31424. * faceId is the picked face index counted within this particle.
  31425. * Returns null if the pickInfo can't identify a picked particle.
  31426. * @param pickingInfo (PickingInfo object)
  31427. * @returns {idx: number, faceId: number} or null
  31428. */
  31429. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31430. idx: number;
  31431. faceId: number;
  31432. }>;
  31433. /**
  31434. * Returns a SolidParticle object from its identifier : particle.id
  31435. * @param id (integer) the particle Id
  31436. * @returns the searched particle or null if not found in the SPS.
  31437. */
  31438. getParticleById(id: number): Nullable<SolidParticle>;
  31439. /**
  31440. * Returns a new array populated with the particles having the passed shapeId.
  31441. * @param shapeId (integer) the shape identifier
  31442. * @returns a new solid particle array
  31443. */
  31444. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31445. /**
  31446. * Populates the passed array "ref" with the particles having the passed shapeId.
  31447. * @param shapeId the shape identifier
  31448. * @returns the SPS
  31449. * @param ref
  31450. */
  31451. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31452. /**
  31453. * Computes the required SubMeshes according the materials assigned to the particles.
  31454. * @returns the solid particle system.
  31455. * Does nothing if called before the SPS mesh is built.
  31456. */
  31457. computeSubMeshes(): SolidParticleSystem;
  31458. /**
  31459. * Sorts the solid particles by material when MultiMaterial is enabled.
  31460. * Updates the indices32 array.
  31461. * Updates the indicesByMaterial array.
  31462. * Updates the mesh indices array.
  31463. * @returns the SPS
  31464. * @hidden
  31465. */
  31466. private _sortParticlesByMaterial;
  31467. /**
  31468. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31469. * @hidden
  31470. */
  31471. private _setMaterialIndexesById;
  31472. /**
  31473. * Returns an array with unique values of Materials from the passed array
  31474. * @param array the material array to be checked and filtered
  31475. * @hidden
  31476. */
  31477. private _filterUniqueMaterialId;
  31478. /**
  31479. * Sets a new Standard Material as _defaultMaterial if not already set.
  31480. * @hidden
  31481. */
  31482. private _setDefaultMaterial;
  31483. /**
  31484. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31485. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31486. * @returns the SPS.
  31487. */
  31488. refreshVisibleSize(): SolidParticleSystem;
  31489. /**
  31490. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31491. * @param size the size (float) of the visibility box
  31492. * note : this doesn't lock the SPS mesh bounding box.
  31493. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31494. */
  31495. setVisibilityBox(size: number): void;
  31496. /**
  31497. * Gets whether the SPS as always visible or not
  31498. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31499. */
  31500. get isAlwaysVisible(): boolean;
  31501. /**
  31502. * Sets the SPS as always visible or not
  31503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31504. */
  31505. set isAlwaysVisible(val: boolean);
  31506. /**
  31507. * Sets 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. set isVisibilityBoxLocked(val: boolean);
  31511. /**
  31512. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31513. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31514. */
  31515. get isVisibilityBoxLocked(): boolean;
  31516. /**
  31517. * Tells to `setParticles()` to compute the particle rotations or not.
  31518. * Default value : true. The SPS is faster when it's set to false.
  31519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31520. */
  31521. set computeParticleRotation(val: boolean);
  31522. /**
  31523. * Tells to `setParticles()` to compute the particle colors or not.
  31524. * Default value : true. The SPS is faster when it's set to false.
  31525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31526. */
  31527. set computeParticleColor(val: boolean);
  31528. set computeParticleTexture(val: boolean);
  31529. /**
  31530. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31531. * Default value : false. The SPS is faster when it's set to false.
  31532. * Note : the particle custom vertex positions aren't stored values.
  31533. */
  31534. set computeParticleVertex(val: boolean);
  31535. /**
  31536. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31537. */
  31538. set computeBoundingBox(val: boolean);
  31539. /**
  31540. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31541. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31542. * Default : `true`
  31543. */
  31544. set depthSortParticles(val: boolean);
  31545. /**
  31546. * Gets if `setParticles()` computes the particle rotations or not.
  31547. * Default value : true. The SPS is faster when it's set to false.
  31548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31549. */
  31550. get computeParticleRotation(): boolean;
  31551. /**
  31552. * Gets if `setParticles()` computes the particle colors or not.
  31553. * Default value : true. The SPS is faster when it's set to false.
  31554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31555. */
  31556. get computeParticleColor(): boolean;
  31557. /**
  31558. * Gets if `setParticles()` computes the particle textures or not.
  31559. * Default value : true. The SPS is faster when it's set to false.
  31560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31561. */
  31562. get computeParticleTexture(): boolean;
  31563. /**
  31564. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31565. * Default value : false. The SPS is faster when it's set to false.
  31566. * Note : the particle custom vertex positions aren't stored values.
  31567. */
  31568. get computeParticleVertex(): boolean;
  31569. /**
  31570. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31571. */
  31572. get computeBoundingBox(): boolean;
  31573. /**
  31574. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31576. * Default : `true`
  31577. */
  31578. get depthSortParticles(): boolean;
  31579. /**
  31580. * Gets if the SPS is created as expandable at construction time.
  31581. * Default : `false`
  31582. */
  31583. get expandable(): boolean;
  31584. /**
  31585. * Gets if the SPS supports the Multi Materials
  31586. */
  31587. get multimaterialEnabled(): boolean;
  31588. /**
  31589. * Gets if the SPS uses the model materials for its own multimaterial.
  31590. */
  31591. get useModelMaterial(): boolean;
  31592. /**
  31593. * The SPS used material array.
  31594. */
  31595. get materials(): Material[];
  31596. /**
  31597. * Sets the SPS MultiMaterial from the passed materials.
  31598. * Note : the passed array is internally copied and not used then by reference.
  31599. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31600. */
  31601. setMultiMaterial(materials: Material[]): void;
  31602. /**
  31603. * The SPS computed multimaterial object
  31604. */
  31605. get multimaterial(): MultiMaterial;
  31606. set multimaterial(mm: MultiMaterial);
  31607. /**
  31608. * If the subMeshes must be updated on the next call to setParticles()
  31609. */
  31610. get autoUpdateSubMeshes(): boolean;
  31611. set autoUpdateSubMeshes(val: boolean);
  31612. /**
  31613. * This function does nothing. It may be overwritten to set all the particle first values.
  31614. * The SPS doesn't call this function, you may have to call it by your own.
  31615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31616. */
  31617. initParticles(): void;
  31618. /**
  31619. * This function does nothing. It may be overwritten to recycle a particle.
  31620. * The SPS doesn't call this function, you may have to call it by your own.
  31621. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31622. * @param particle The particle to recycle
  31623. * @returns the recycled particle
  31624. */
  31625. recycleParticle(particle: SolidParticle): SolidParticle;
  31626. /**
  31627. * Updates a particle : this function should be overwritten by the user.
  31628. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31630. * @example : just set a particle position or velocity and recycle conditions
  31631. * @param particle The particle to update
  31632. * @returns the updated particle
  31633. */
  31634. updateParticle(particle: SolidParticle): SolidParticle;
  31635. /**
  31636. * Updates a vertex of a particle : it can be overwritten by the user.
  31637. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31638. * @param particle the current particle
  31639. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31640. * @param pt the index of the current vertex in the particle shape
  31641. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31642. * @example : just set a vertex particle position or color
  31643. * @returns the sps
  31644. */
  31645. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31646. /**
  31647. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31648. * This does nothing and may be overwritten by the user.
  31649. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31650. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31651. * @param update the boolean update value actually passed to setParticles()
  31652. */
  31653. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31654. /**
  31655. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31656. * This will be passed three parameters.
  31657. * This does nothing and may be overwritten by the user.
  31658. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31659. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31660. * @param update the boolean update value actually passed to setParticles()
  31661. */
  31662. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31663. }
  31664. }
  31665. declare module "babylonjs/Particles/solidParticle" {
  31666. import { Nullable } from "babylonjs/types";
  31667. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31668. import { Color4 } from "babylonjs/Maths/math.color";
  31669. import { Mesh } from "babylonjs/Meshes/mesh";
  31670. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31671. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31672. import { Plane } from "babylonjs/Maths/math.plane";
  31673. import { Material } from "babylonjs/Materials/material";
  31674. /**
  31675. * Represents one particle of a solid particle system.
  31676. */
  31677. export class SolidParticle {
  31678. /**
  31679. * particle global index
  31680. */
  31681. idx: number;
  31682. /**
  31683. * particle identifier
  31684. */
  31685. id: number;
  31686. /**
  31687. * The color of the particle
  31688. */
  31689. color: Nullable<Color4>;
  31690. /**
  31691. * The world space position of the particle.
  31692. */
  31693. position: Vector3;
  31694. /**
  31695. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31696. */
  31697. rotation: Vector3;
  31698. /**
  31699. * The world space rotation quaternion of the particle.
  31700. */
  31701. rotationQuaternion: Nullable<Quaternion>;
  31702. /**
  31703. * The scaling of the particle.
  31704. */
  31705. scaling: Vector3;
  31706. /**
  31707. * The uvs of the particle.
  31708. */
  31709. uvs: Vector4;
  31710. /**
  31711. * The current speed of the particle.
  31712. */
  31713. velocity: Vector3;
  31714. /**
  31715. * The pivot point in the particle local space.
  31716. */
  31717. pivot: Vector3;
  31718. /**
  31719. * Must the particle be translated from its pivot point in its local space ?
  31720. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31721. * Default : false
  31722. */
  31723. translateFromPivot: boolean;
  31724. /**
  31725. * Is the particle active or not ?
  31726. */
  31727. alive: boolean;
  31728. /**
  31729. * Is the particle visible or not ?
  31730. */
  31731. isVisible: boolean;
  31732. /**
  31733. * Index of this particle in the global "positions" array (Internal use)
  31734. * @hidden
  31735. */
  31736. _pos: number;
  31737. /**
  31738. * @hidden Index of this particle in the global "indices" array (Internal use)
  31739. */
  31740. _ind: number;
  31741. /**
  31742. * @hidden ModelShape of this particle (Internal use)
  31743. */
  31744. _model: ModelShape;
  31745. /**
  31746. * ModelShape id of this particle
  31747. */
  31748. shapeId: number;
  31749. /**
  31750. * Index of the particle in its shape id
  31751. */
  31752. idxInShape: number;
  31753. /**
  31754. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31755. */
  31756. _modelBoundingInfo: BoundingInfo;
  31757. /**
  31758. * @hidden Particle BoundingInfo object (Internal use)
  31759. */
  31760. _boundingInfo: BoundingInfo;
  31761. /**
  31762. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31763. */
  31764. _sps: SolidParticleSystem;
  31765. /**
  31766. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31767. */
  31768. _stillInvisible: boolean;
  31769. /**
  31770. * @hidden Last computed particle rotation matrix
  31771. */
  31772. _rotationMatrix: number[];
  31773. /**
  31774. * Parent particle Id, if any.
  31775. * Default null.
  31776. */
  31777. parentId: Nullable<number>;
  31778. /**
  31779. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31780. */
  31781. materialIndex: Nullable<number>;
  31782. /**
  31783. * Custom object or properties.
  31784. */
  31785. props: Nullable<any>;
  31786. /**
  31787. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31788. * The possible values are :
  31789. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31790. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31791. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31792. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31793. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31794. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31795. * */
  31796. cullingStrategy: number;
  31797. /**
  31798. * @hidden Internal global position in the SPS.
  31799. */
  31800. _globalPosition: Vector3;
  31801. /**
  31802. * Creates a Solid Particle object.
  31803. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31804. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31805. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31806. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31807. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31808. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31809. * @param shapeId (integer) is the model shape identifier in the SPS.
  31810. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31811. * @param sps defines the sps it is associated to
  31812. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31813. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31814. */
  31815. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31816. /**
  31817. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31818. * @param target the particle target
  31819. * @returns the current particle
  31820. */
  31821. copyToRef(target: SolidParticle): SolidParticle;
  31822. /**
  31823. * Legacy support, changed scale to scaling
  31824. */
  31825. get scale(): Vector3;
  31826. /**
  31827. * Legacy support, changed scale to scaling
  31828. */
  31829. set scale(scale: Vector3);
  31830. /**
  31831. * Legacy support, changed quaternion to rotationQuaternion
  31832. */
  31833. get quaternion(): Nullable<Quaternion>;
  31834. /**
  31835. * Legacy support, changed quaternion to rotationQuaternion
  31836. */
  31837. set quaternion(q: Nullable<Quaternion>);
  31838. /**
  31839. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31840. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31841. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31842. * @returns true if it intersects
  31843. */
  31844. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31845. /**
  31846. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31847. * A particle is in the frustum if its bounding box intersects the frustum
  31848. * @param frustumPlanes defines the frustum to test
  31849. * @returns true if the particle is in the frustum planes
  31850. */
  31851. isInFrustum(frustumPlanes: Plane[]): boolean;
  31852. /**
  31853. * get the rotation matrix of the particle
  31854. * @hidden
  31855. */
  31856. getRotationMatrix(m: Matrix): void;
  31857. }
  31858. /**
  31859. * Represents the shape of the model used by one particle of a solid particle system.
  31860. * SPS internal tool, don't use it manually.
  31861. */
  31862. export class ModelShape {
  31863. /**
  31864. * The shape id
  31865. * @hidden
  31866. */
  31867. shapeID: number;
  31868. /**
  31869. * flat array of model positions (internal use)
  31870. * @hidden
  31871. */
  31872. _shape: Vector3[];
  31873. /**
  31874. * flat array of model UVs (internal use)
  31875. * @hidden
  31876. */
  31877. _shapeUV: number[];
  31878. /**
  31879. * color array of the model
  31880. * @hidden
  31881. */
  31882. _shapeColors: number[];
  31883. /**
  31884. * indices array of the model
  31885. * @hidden
  31886. */
  31887. _indices: number[];
  31888. /**
  31889. * normals array of the model
  31890. * @hidden
  31891. */
  31892. _normals: number[];
  31893. /**
  31894. * length of the shape in the model indices array (internal use)
  31895. * @hidden
  31896. */
  31897. _indicesLength: number;
  31898. /**
  31899. * Custom position function (internal use)
  31900. * @hidden
  31901. */
  31902. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31903. /**
  31904. * Custom vertex function (internal use)
  31905. * @hidden
  31906. */
  31907. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31908. /**
  31909. * Model material (internal use)
  31910. * @hidden
  31911. */
  31912. _material: Nullable<Material>;
  31913. /**
  31914. * 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.
  31915. * SPS internal tool, don't use it manually.
  31916. * @hidden
  31917. */
  31918. 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>);
  31919. }
  31920. /**
  31921. * Represents a Depth Sorted Particle in the solid particle system.
  31922. * @hidden
  31923. */
  31924. export class DepthSortedParticle {
  31925. /**
  31926. * Particle index
  31927. */
  31928. idx: number;
  31929. /**
  31930. * Index of the particle in the "indices" array
  31931. */
  31932. ind: number;
  31933. /**
  31934. * Length of the particle shape in the "indices" array
  31935. */
  31936. indicesLength: number;
  31937. /**
  31938. * Squared distance from the particle to the camera
  31939. */
  31940. sqDistance: number;
  31941. /**
  31942. * Material index when used with MultiMaterials
  31943. */
  31944. materialIndex: number;
  31945. /**
  31946. * Creates a new sorted particle
  31947. * @param materialIndex
  31948. */
  31949. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31950. }
  31951. /**
  31952. * Represents a solid particle vertex
  31953. */
  31954. export class SolidParticleVertex {
  31955. /**
  31956. * Vertex position
  31957. */
  31958. position: Vector3;
  31959. /**
  31960. * Vertex color
  31961. */
  31962. color: Color4;
  31963. /**
  31964. * Vertex UV
  31965. */
  31966. uv: Vector2;
  31967. /**
  31968. * Creates a new solid particle vertex
  31969. */
  31970. constructor();
  31971. /** Vertex x coordinate */
  31972. get x(): number;
  31973. set x(val: number);
  31974. /** Vertex y coordinate */
  31975. get y(): number;
  31976. set y(val: number);
  31977. /** Vertex z coordinate */
  31978. get z(): number;
  31979. set z(val: number);
  31980. }
  31981. }
  31982. declare module "babylonjs/Collisions/meshCollisionData" {
  31983. import { Collider } from "babylonjs/Collisions/collider";
  31984. import { Vector3 } from "babylonjs/Maths/math.vector";
  31985. import { Nullable } from "babylonjs/types";
  31986. import { Observer } from "babylonjs/Misc/observable";
  31987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31988. /**
  31989. * @hidden
  31990. */
  31991. export class _MeshCollisionData {
  31992. _checkCollisions: boolean;
  31993. _collisionMask: number;
  31994. _collisionGroup: number;
  31995. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31996. _collider: Nullable<Collider>;
  31997. _oldPositionForCollisions: Vector3;
  31998. _diffPositionForCollisions: Vector3;
  31999. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32000. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32001. }
  32002. }
  32003. declare module "babylonjs/Meshes/abstractMesh" {
  32004. import { Observable } from "babylonjs/Misc/observable";
  32005. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32006. import { Camera } from "babylonjs/Cameras/camera";
  32007. import { Scene, IDisposable } from "babylonjs/scene";
  32008. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32009. import { Node } from "babylonjs/node";
  32010. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32012. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32014. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32015. import { Material } from "babylonjs/Materials/material";
  32016. import { Light } from "babylonjs/Lights/light";
  32017. import { Skeleton } from "babylonjs/Bones/skeleton";
  32018. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32019. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32020. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32021. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32022. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32023. import { Plane } from "babylonjs/Maths/math.plane";
  32024. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32025. import { Ray } from "babylonjs/Culling/ray";
  32026. import { Collider } from "babylonjs/Collisions/collider";
  32027. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32028. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32029. /** @hidden */
  32030. class _FacetDataStorage {
  32031. facetPositions: Vector3[];
  32032. facetNormals: Vector3[];
  32033. facetPartitioning: number[][];
  32034. facetNb: number;
  32035. partitioningSubdivisions: number;
  32036. partitioningBBoxRatio: number;
  32037. facetDataEnabled: boolean;
  32038. facetParameters: any;
  32039. bbSize: Vector3;
  32040. subDiv: {
  32041. max: number;
  32042. X: number;
  32043. Y: number;
  32044. Z: number;
  32045. };
  32046. facetDepthSort: boolean;
  32047. facetDepthSortEnabled: boolean;
  32048. depthSortedIndices: IndicesArray;
  32049. depthSortedFacets: {
  32050. ind: number;
  32051. sqDistance: number;
  32052. }[];
  32053. facetDepthSortFunction: (f1: {
  32054. ind: number;
  32055. sqDistance: number;
  32056. }, f2: {
  32057. ind: number;
  32058. sqDistance: number;
  32059. }) => number;
  32060. facetDepthSortFrom: Vector3;
  32061. facetDepthSortOrigin: Vector3;
  32062. invertedMatrix: Matrix;
  32063. }
  32064. /**
  32065. * @hidden
  32066. **/
  32067. class _InternalAbstractMeshDataInfo {
  32068. _hasVertexAlpha: boolean;
  32069. _useVertexColors: boolean;
  32070. _numBoneInfluencers: number;
  32071. _applyFog: boolean;
  32072. _receiveShadows: boolean;
  32073. _facetData: _FacetDataStorage;
  32074. _visibility: number;
  32075. _skeleton: Nullable<Skeleton>;
  32076. _layerMask: number;
  32077. _computeBonesUsingShaders: boolean;
  32078. _isActive: boolean;
  32079. _onlyForInstances: boolean;
  32080. _isActiveIntermediate: boolean;
  32081. _onlyForInstancesIntermediate: boolean;
  32082. _actAsRegularMesh: boolean;
  32083. }
  32084. /**
  32085. * Class used to store all common mesh properties
  32086. */
  32087. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32088. /** No occlusion */
  32089. static OCCLUSION_TYPE_NONE: number;
  32090. /** Occlusion set to optimisitic */
  32091. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32092. /** Occlusion set to strict */
  32093. static OCCLUSION_TYPE_STRICT: number;
  32094. /** Use an accurante occlusion algorithm */
  32095. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32096. /** Use a conservative occlusion algorithm */
  32097. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32098. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32099. * Test order :
  32100. * Is the bounding sphere outside the frustum ?
  32101. * If not, are the bounding box vertices outside the frustum ?
  32102. * It not, then the cullable object is in the frustum.
  32103. */
  32104. static readonly CULLINGSTRATEGY_STANDARD: number;
  32105. /** Culling strategy : Bounding Sphere Only.
  32106. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32107. * It's also less accurate than the standard because some not visible objects can still be selected.
  32108. * Test : is the bounding sphere outside the frustum ?
  32109. * If not, then the cullable object is in the frustum.
  32110. */
  32111. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32112. /** Culling strategy : Optimistic Inclusion.
  32113. * This in an inclusion test first, then the standard exclusion test.
  32114. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32115. * 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.
  32116. * Anyway, it's as accurate as the standard strategy.
  32117. * Test :
  32118. * Is the cullable object bounding sphere center in the frustum ?
  32119. * If not, apply the default culling strategy.
  32120. */
  32121. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32122. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32123. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32124. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32125. * 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.
  32126. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32127. * Test :
  32128. * Is the cullable object bounding sphere center in the frustum ?
  32129. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32130. */
  32131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32132. /**
  32133. * No billboard
  32134. */
  32135. static get BILLBOARDMODE_NONE(): number;
  32136. /** Billboard on X axis */
  32137. static get BILLBOARDMODE_X(): number;
  32138. /** Billboard on Y axis */
  32139. static get BILLBOARDMODE_Y(): number;
  32140. /** Billboard on Z axis */
  32141. static get BILLBOARDMODE_Z(): number;
  32142. /** Billboard on all axes */
  32143. static get BILLBOARDMODE_ALL(): number;
  32144. /** Billboard on using position instead of orientation */
  32145. static get BILLBOARDMODE_USE_POSITION(): number;
  32146. /** @hidden */
  32147. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32148. /**
  32149. * The culling strategy to use to check whether the mesh must be rendered or not.
  32150. * This value can be changed at any time and will be used on the next render mesh selection.
  32151. * The possible values are :
  32152. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32153. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32154. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32156. * Please read each static variable documentation to get details about the culling process.
  32157. * */
  32158. cullingStrategy: number;
  32159. /**
  32160. * Gets the number of facets in the mesh
  32161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32162. */
  32163. get facetNb(): number;
  32164. /**
  32165. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32167. */
  32168. get partitioningSubdivisions(): number;
  32169. set partitioningSubdivisions(nb: number);
  32170. /**
  32171. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32172. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32174. */
  32175. get partitioningBBoxRatio(): number;
  32176. set partitioningBBoxRatio(ratio: number);
  32177. /**
  32178. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32179. * Works only for updatable meshes.
  32180. * Doesn't work with multi-materials
  32181. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32182. */
  32183. get mustDepthSortFacets(): boolean;
  32184. set mustDepthSortFacets(sort: boolean);
  32185. /**
  32186. * The location (Vector3) where the facet depth sort must be computed from.
  32187. * By default, the active camera position.
  32188. * Used only when facet depth sort is enabled
  32189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32190. */
  32191. get facetDepthSortFrom(): Vector3;
  32192. set facetDepthSortFrom(location: Vector3);
  32193. /**
  32194. * gets a boolean indicating if facetData is enabled
  32195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32196. */
  32197. get isFacetDataEnabled(): boolean;
  32198. /** @hidden */
  32199. _updateNonUniformScalingState(value: boolean): boolean;
  32200. /**
  32201. * An event triggered when this mesh collides with another one
  32202. */
  32203. onCollideObservable: Observable<AbstractMesh>;
  32204. /** Set a function to call when this mesh collides with another one */
  32205. set onCollide(callback: () => void);
  32206. /**
  32207. * An event triggered when the collision's position changes
  32208. */
  32209. onCollisionPositionChangeObservable: Observable<Vector3>;
  32210. /** Set a function to call when the collision's position changes */
  32211. set onCollisionPositionChange(callback: () => void);
  32212. /**
  32213. * An event triggered when material is changed
  32214. */
  32215. onMaterialChangedObservable: Observable<AbstractMesh>;
  32216. /**
  32217. * Gets or sets the orientation for POV movement & rotation
  32218. */
  32219. definedFacingForward: boolean;
  32220. /** @hidden */
  32221. _occlusionQuery: Nullable<WebGLQuery>;
  32222. /** @hidden */
  32223. _renderingGroup: Nullable<RenderingGroup>;
  32224. /**
  32225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32226. */
  32227. get visibility(): number;
  32228. /**
  32229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32230. */
  32231. set visibility(value: number);
  32232. /** Gets or sets the alpha index used to sort transparent meshes
  32233. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32234. */
  32235. alphaIndex: number;
  32236. /**
  32237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32238. */
  32239. isVisible: boolean;
  32240. /**
  32241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32242. */
  32243. isPickable: boolean;
  32244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32245. showSubMeshesBoundingBox: boolean;
  32246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32247. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32248. */
  32249. isBlocker: boolean;
  32250. /**
  32251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32252. */
  32253. enablePointerMoveEvents: boolean;
  32254. /**
  32255. * Specifies the rendering group id for this mesh (0 by default)
  32256. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32257. */
  32258. renderingGroupId: number;
  32259. private _material;
  32260. /** Gets or sets current material */
  32261. get material(): Nullable<Material>;
  32262. set material(value: Nullable<Material>);
  32263. /**
  32264. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32265. * @see https://doc.babylonjs.com/babylon101/shadows
  32266. */
  32267. get receiveShadows(): boolean;
  32268. set receiveShadows(value: boolean);
  32269. /** Defines color to use when rendering outline */
  32270. outlineColor: Color3;
  32271. /** Define width to use when rendering outline */
  32272. outlineWidth: number;
  32273. /** Defines color to use when rendering overlay */
  32274. overlayColor: Color3;
  32275. /** Defines alpha to use when rendering overlay */
  32276. overlayAlpha: number;
  32277. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32278. get hasVertexAlpha(): boolean;
  32279. set hasVertexAlpha(value: boolean);
  32280. /** 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) */
  32281. get useVertexColors(): boolean;
  32282. set useVertexColors(value: boolean);
  32283. /**
  32284. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32285. */
  32286. get computeBonesUsingShaders(): boolean;
  32287. set computeBonesUsingShaders(value: boolean);
  32288. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32289. get numBoneInfluencers(): number;
  32290. set numBoneInfluencers(value: number);
  32291. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32292. get applyFog(): boolean;
  32293. set applyFog(value: boolean);
  32294. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32295. useOctreeForRenderingSelection: boolean;
  32296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32297. useOctreeForPicking: boolean;
  32298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32299. useOctreeForCollisions: boolean;
  32300. /**
  32301. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32302. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32303. */
  32304. get layerMask(): number;
  32305. set layerMask(value: number);
  32306. /**
  32307. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32308. */
  32309. alwaysSelectAsActiveMesh: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32312. */
  32313. doNotSyncBoundingInfo: boolean;
  32314. /**
  32315. * Gets or sets the current action manager
  32316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32317. */
  32318. actionManager: Nullable<AbstractActionManager>;
  32319. private _meshCollisionData;
  32320. /**
  32321. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32323. */
  32324. ellipsoid: Vector3;
  32325. /**
  32326. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32327. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32328. */
  32329. ellipsoidOffset: Vector3;
  32330. /**
  32331. * Gets or sets a collision mask used to mask collisions (default is -1).
  32332. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32333. */
  32334. get collisionMask(): number;
  32335. set collisionMask(mask: number);
  32336. /**
  32337. * Gets or sets the current collision group mask (-1 by default).
  32338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32339. */
  32340. get collisionGroup(): number;
  32341. set collisionGroup(mask: number);
  32342. /**
  32343. * Gets or sets current surrounding meshes (null by default).
  32344. *
  32345. * By default collision detection is tested against every mesh in the scene.
  32346. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32347. * meshes will be tested for the collision.
  32348. *
  32349. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32350. */
  32351. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32352. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32353. /**
  32354. * Defines edge width used when edgesRenderer is enabled
  32355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32356. */
  32357. edgesWidth: number;
  32358. /**
  32359. * Defines edge color used when edgesRenderer is enabled
  32360. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32361. */
  32362. edgesColor: Color4;
  32363. /** @hidden */
  32364. _edgesRenderer: Nullable<IEdgesRenderer>;
  32365. /** @hidden */
  32366. _masterMesh: Nullable<AbstractMesh>;
  32367. /** @hidden */
  32368. _boundingInfo: Nullable<BoundingInfo>;
  32369. /** @hidden */
  32370. _renderId: number;
  32371. /**
  32372. * Gets or sets the list of subMeshes
  32373. * @see https://doc.babylonjs.com/how_to/multi_materials
  32374. */
  32375. subMeshes: SubMesh[];
  32376. /** @hidden */
  32377. _intersectionsInProgress: AbstractMesh[];
  32378. /** @hidden */
  32379. _unIndexed: boolean;
  32380. /** @hidden */
  32381. _lightSources: Light[];
  32382. /** Gets the list of lights affecting that mesh */
  32383. get lightSources(): Light[];
  32384. /** @hidden */
  32385. get _positions(): Nullable<Vector3[]>;
  32386. /** @hidden */
  32387. _waitingData: {
  32388. lods: Nullable<any>;
  32389. actions: Nullable<any>;
  32390. freezeWorldMatrix: Nullable<boolean>;
  32391. };
  32392. /** @hidden */
  32393. _bonesTransformMatrices: Nullable<Float32Array>;
  32394. /** @hidden */
  32395. _transformMatrixTexture: Nullable<RawTexture>;
  32396. /**
  32397. * Gets or sets a skeleton to apply skining transformations
  32398. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32399. */
  32400. set skeleton(value: Nullable<Skeleton>);
  32401. get skeleton(): Nullable<Skeleton>;
  32402. /**
  32403. * An event triggered when the mesh is rebuilt.
  32404. */
  32405. onRebuildObservable: Observable<AbstractMesh>;
  32406. /**
  32407. * Creates a new AbstractMesh
  32408. * @param name defines the name of the mesh
  32409. * @param scene defines the hosting scene
  32410. */
  32411. constructor(name: string, scene?: Nullable<Scene>);
  32412. /**
  32413. * Returns the string "AbstractMesh"
  32414. * @returns "AbstractMesh"
  32415. */
  32416. getClassName(): string;
  32417. /**
  32418. * Gets a string representation of the current mesh
  32419. * @param fullDetails defines a boolean indicating if full details must be included
  32420. * @returns a string representation of the current mesh
  32421. */
  32422. toString(fullDetails?: boolean): string;
  32423. /**
  32424. * @hidden
  32425. */
  32426. protected _getEffectiveParent(): Nullable<Node>;
  32427. /** @hidden */
  32428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32429. /** @hidden */
  32430. _rebuild(): void;
  32431. /** @hidden */
  32432. _resyncLightSources(): void;
  32433. /** @hidden */
  32434. _resyncLightSource(light: Light): void;
  32435. /** @hidden */
  32436. _unBindEffect(): void;
  32437. /** @hidden */
  32438. _removeLightSource(light: Light, dispose: boolean): void;
  32439. private _markSubMeshesAsDirty;
  32440. /** @hidden */
  32441. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32442. /** @hidden */
  32443. _markSubMeshesAsAttributesDirty(): void;
  32444. /** @hidden */
  32445. _markSubMeshesAsMiscDirty(): void;
  32446. /**
  32447. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32448. */
  32449. get scaling(): Vector3;
  32450. set scaling(newScaling: Vector3);
  32451. /**
  32452. * Returns true if the mesh is blocked. Implemented by child classes
  32453. */
  32454. get isBlocked(): boolean;
  32455. /**
  32456. * Returns the mesh itself by default. Implemented by child classes
  32457. * @param camera defines the camera to use to pick the right LOD level
  32458. * @returns the currentAbstractMesh
  32459. */
  32460. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32461. /**
  32462. * Returns 0 by default. Implemented by child classes
  32463. * @returns an integer
  32464. */
  32465. getTotalVertices(): number;
  32466. /**
  32467. * Returns a positive integer : the total number of indices in this mesh geometry.
  32468. * @returns the numner of indices or zero if the mesh has no geometry.
  32469. */
  32470. getTotalIndices(): number;
  32471. /**
  32472. * Returns null by default. Implemented by child classes
  32473. * @returns null
  32474. */
  32475. getIndices(): Nullable<IndicesArray>;
  32476. /**
  32477. * Returns the array of the requested vertex data kind. Implemented by child classes
  32478. * @param kind defines the vertex data kind to use
  32479. * @returns null
  32480. */
  32481. getVerticesData(kind: string): Nullable<FloatArray>;
  32482. /**
  32483. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32484. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32485. * Note that a new underlying VertexBuffer object is created each call.
  32486. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32487. * @param kind defines vertex data kind:
  32488. * * VertexBuffer.PositionKind
  32489. * * VertexBuffer.UVKind
  32490. * * VertexBuffer.UV2Kind
  32491. * * VertexBuffer.UV3Kind
  32492. * * VertexBuffer.UV4Kind
  32493. * * VertexBuffer.UV5Kind
  32494. * * VertexBuffer.UV6Kind
  32495. * * VertexBuffer.ColorKind
  32496. * * VertexBuffer.MatricesIndicesKind
  32497. * * VertexBuffer.MatricesIndicesExtraKind
  32498. * * VertexBuffer.MatricesWeightsKind
  32499. * * VertexBuffer.MatricesWeightsExtraKind
  32500. * @param data defines the data source
  32501. * @param updatable defines if the data must be flagged as updatable (or static)
  32502. * @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
  32503. * @returns the current mesh
  32504. */
  32505. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32506. /**
  32507. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32508. * If the mesh has no geometry, it is simply returned as it is.
  32509. * @param kind defines vertex data kind:
  32510. * * VertexBuffer.PositionKind
  32511. * * VertexBuffer.UVKind
  32512. * * VertexBuffer.UV2Kind
  32513. * * VertexBuffer.UV3Kind
  32514. * * VertexBuffer.UV4Kind
  32515. * * VertexBuffer.UV5Kind
  32516. * * VertexBuffer.UV6Kind
  32517. * * VertexBuffer.ColorKind
  32518. * * VertexBuffer.MatricesIndicesKind
  32519. * * VertexBuffer.MatricesIndicesExtraKind
  32520. * * VertexBuffer.MatricesWeightsKind
  32521. * * VertexBuffer.MatricesWeightsExtraKind
  32522. * @param data defines the data source
  32523. * @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
  32524. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32525. * @returns the current mesh
  32526. */
  32527. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32528. /**
  32529. * Sets the mesh indices,
  32530. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32531. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32532. * @param totalVertices Defines the total number of vertices
  32533. * @returns the current mesh
  32534. */
  32535. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32536. /**
  32537. * Gets a boolean indicating if specific vertex data is present
  32538. * @param kind defines the vertex data kind to use
  32539. * @returns true is data kind is present
  32540. */
  32541. isVerticesDataPresent(kind: string): boolean;
  32542. /**
  32543. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32544. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32545. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32546. * @returns a BoundingInfo
  32547. */
  32548. getBoundingInfo(): BoundingInfo;
  32549. /**
  32550. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32551. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32552. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32553. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32554. * @returns the current mesh
  32555. */
  32556. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32557. /**
  32558. * Overwrite the current bounding info
  32559. * @param boundingInfo defines the new bounding info
  32560. * @returns the current mesh
  32561. */
  32562. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32563. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32564. get useBones(): boolean;
  32565. /** @hidden */
  32566. _preActivate(): void;
  32567. /** @hidden */
  32568. _preActivateForIntermediateRendering(renderId: number): void;
  32569. /** @hidden */
  32570. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32571. /** @hidden */
  32572. _postActivate(): void;
  32573. /** @hidden */
  32574. _freeze(): void;
  32575. /** @hidden */
  32576. _unFreeze(): void;
  32577. /**
  32578. * Gets the current world matrix
  32579. * @returns a Matrix
  32580. */
  32581. getWorldMatrix(): Matrix;
  32582. /** @hidden */
  32583. _getWorldMatrixDeterminant(): number;
  32584. /**
  32585. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32586. */
  32587. get isAnInstance(): boolean;
  32588. /**
  32589. * Gets a boolean indicating if this mesh has instances
  32590. */
  32591. get hasInstances(): boolean;
  32592. /**
  32593. * Gets a boolean indicating if this mesh has thin instances
  32594. */
  32595. get hasThinInstances(): boolean;
  32596. /**
  32597. * Perform relative position change from the point of view of behind the front of the mesh.
  32598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32599. * Supports definition of mesh facing forward or backward
  32600. * @param amountRight defines the distance on the right axis
  32601. * @param amountUp defines the distance on the up axis
  32602. * @param amountForward defines the distance on the forward axis
  32603. * @returns the current mesh
  32604. */
  32605. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32606. /**
  32607. * Calculate relative position change from the point of view of behind the front of the mesh.
  32608. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32609. * Supports definition of mesh facing forward or backward
  32610. * @param amountRight defines the distance on the right axis
  32611. * @param amountUp defines the distance on the up axis
  32612. * @param amountForward defines the distance on the forward axis
  32613. * @returns the new displacement vector
  32614. */
  32615. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32616. /**
  32617. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32618. * Supports definition of mesh facing forward or backward
  32619. * @param flipBack defines the flip
  32620. * @param twirlClockwise defines the twirl
  32621. * @param tiltRight defines the tilt
  32622. * @returns the current mesh
  32623. */
  32624. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32625. /**
  32626. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32627. * Supports definition of mesh facing forward or backward.
  32628. * @param flipBack defines the flip
  32629. * @param twirlClockwise defines the twirl
  32630. * @param tiltRight defines the tilt
  32631. * @returns the new rotation vector
  32632. */
  32633. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32634. /**
  32635. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32636. * This means the mesh underlying bounding box and sphere are recomputed.
  32637. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32638. * @returns the current mesh
  32639. */
  32640. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32641. /** @hidden */
  32642. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32643. /** @hidden */
  32644. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32645. /** @hidden */
  32646. _updateBoundingInfo(): AbstractMesh;
  32647. /** @hidden */
  32648. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32649. /** @hidden */
  32650. protected _afterComputeWorldMatrix(): void;
  32651. /** @hidden */
  32652. get _effectiveMesh(): AbstractMesh;
  32653. /**
  32654. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32655. * A mesh is in the frustum if its bounding box intersects the frustum
  32656. * @param frustumPlanes defines the frustum to test
  32657. * @returns true if the mesh is in the frustum planes
  32658. */
  32659. isInFrustum(frustumPlanes: Plane[]): boolean;
  32660. /**
  32661. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32662. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32663. * @param frustumPlanes defines the frustum to test
  32664. * @returns true if the mesh is completely in the frustum planes
  32665. */
  32666. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32667. /**
  32668. * True if the mesh intersects another mesh or a SolidParticle object
  32669. * @param mesh defines a target mesh or SolidParticle to test
  32670. * @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)
  32671. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32672. * @returns true if there is an intersection
  32673. */
  32674. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32675. /**
  32676. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32677. * @param point defines the point to test
  32678. * @returns true if there is an intersection
  32679. */
  32680. intersectsPoint(point: Vector3): boolean;
  32681. /**
  32682. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32684. */
  32685. get checkCollisions(): boolean;
  32686. set checkCollisions(collisionEnabled: boolean);
  32687. /**
  32688. * Gets Collider object used to compute collisions (not physics)
  32689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32690. */
  32691. get collider(): Nullable<Collider>;
  32692. /**
  32693. * Move the mesh using collision engine
  32694. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32695. * @param displacement defines the requested displacement vector
  32696. * @returns the current mesh
  32697. */
  32698. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32699. private _onCollisionPositionChange;
  32700. /** @hidden */
  32701. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32702. /** @hidden */
  32703. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32704. /** @hidden */
  32705. _checkCollision(collider: Collider): AbstractMesh;
  32706. /** @hidden */
  32707. _generatePointsArray(): boolean;
  32708. /**
  32709. * Checks if the passed Ray intersects with the mesh
  32710. * @param ray defines the ray to use
  32711. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32713. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32714. * @returns the picking info
  32715. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32716. */
  32717. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32718. /**
  32719. * Clones the current mesh
  32720. * @param name defines the mesh name
  32721. * @param newParent defines the new mesh parent
  32722. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32723. * @returns the new mesh
  32724. */
  32725. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32726. /**
  32727. * Disposes all the submeshes of the current meshnp
  32728. * @returns the current mesh
  32729. */
  32730. releaseSubMeshes(): AbstractMesh;
  32731. /**
  32732. * Releases resources associated with this abstract mesh.
  32733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32735. */
  32736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32737. /**
  32738. * Adds the passed mesh as a child to the current mesh
  32739. * @param mesh defines the child mesh
  32740. * @returns the current mesh
  32741. */
  32742. addChild(mesh: AbstractMesh): AbstractMesh;
  32743. /**
  32744. * Removes the passed mesh from the current mesh children list
  32745. * @param mesh defines the child mesh
  32746. * @returns the current mesh
  32747. */
  32748. removeChild(mesh: AbstractMesh): AbstractMesh;
  32749. /** @hidden */
  32750. private _initFacetData;
  32751. /**
  32752. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32753. * This method can be called within the render loop.
  32754. * 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
  32755. * @returns the current mesh
  32756. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32757. */
  32758. updateFacetData(): AbstractMesh;
  32759. /**
  32760. * Returns the facetLocalNormals array.
  32761. * The normals are expressed in the mesh local spac
  32762. * @returns an array of Vector3
  32763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32764. */
  32765. getFacetLocalNormals(): Vector3[];
  32766. /**
  32767. * Returns the facetLocalPositions array.
  32768. * The facet positions are expressed in the mesh local space
  32769. * @returns an array of Vector3
  32770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32771. */
  32772. getFacetLocalPositions(): Vector3[];
  32773. /**
  32774. * Returns the facetLocalPartioning array
  32775. * @returns an array of array of numbers
  32776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32777. */
  32778. getFacetLocalPartitioning(): number[][];
  32779. /**
  32780. * Returns the i-th facet position in the world system.
  32781. * This method allocates a new Vector3 per call
  32782. * @param i defines the facet index
  32783. * @returns a new Vector3
  32784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32785. */
  32786. getFacetPosition(i: number): Vector3;
  32787. /**
  32788. * Sets the reference Vector3 with the i-th facet position in the world system
  32789. * @param i defines the facet index
  32790. * @param ref defines the target vector
  32791. * @returns the current mesh
  32792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32793. */
  32794. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32795. /**
  32796. * Returns the i-th facet normal in the world system.
  32797. * This method allocates a new Vector3 per call
  32798. * @param i defines the facet index
  32799. * @returns a new Vector3
  32800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32801. */
  32802. getFacetNormal(i: number): Vector3;
  32803. /**
  32804. * Sets the reference Vector3 with the i-th facet normal in the world system
  32805. * @param i defines the facet index
  32806. * @param ref defines the target vector
  32807. * @returns the current mesh
  32808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32809. */
  32810. getFacetNormalToRef(i: number, ref: Vector3): this;
  32811. /**
  32812. * 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)
  32813. * @param x defines x coordinate
  32814. * @param y defines y coordinate
  32815. * @param z defines z coordinate
  32816. * @returns the array of facet indexes
  32817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32818. */
  32819. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32820. /**
  32821. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32822. * @param projected sets as the (x,y,z) world projection on the facet
  32823. * @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
  32824. * @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
  32825. * @param x defines x coordinate
  32826. * @param y defines y coordinate
  32827. * @param z defines z coordinate
  32828. * @returns the face index if found (or null instead)
  32829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32830. */
  32831. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32832. /**
  32833. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32834. * @param projected sets as the (x,y,z) local projection on the facet
  32835. * @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
  32836. * @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
  32837. * @param x defines x coordinate
  32838. * @param y defines y coordinate
  32839. * @param z defines z coordinate
  32840. * @returns the face index if found (or null instead)
  32841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32842. */
  32843. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32844. /**
  32845. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32846. * @returns the parameters
  32847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32848. */
  32849. getFacetDataParameters(): any;
  32850. /**
  32851. * Disables the feature FacetData and frees the related memory
  32852. * @returns the current mesh
  32853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32854. */
  32855. disableFacetData(): AbstractMesh;
  32856. /**
  32857. * Updates the AbstractMesh indices array
  32858. * @param indices defines the data source
  32859. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32860. * @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)
  32861. * @returns the current mesh
  32862. */
  32863. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32864. /**
  32865. * Creates new normals data for the mesh
  32866. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32867. * @returns the current mesh
  32868. */
  32869. createNormals(updatable: boolean): AbstractMesh;
  32870. /**
  32871. * Align the mesh with a normal
  32872. * @param normal defines the normal to use
  32873. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32874. * @returns the current mesh
  32875. */
  32876. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32877. /** @hidden */
  32878. _checkOcclusionQuery(): boolean;
  32879. /**
  32880. * Disables the mesh edge rendering mode
  32881. * @returns the currentAbstractMesh
  32882. */
  32883. disableEdgesRendering(): AbstractMesh;
  32884. /**
  32885. * Enables the edge rendering mode on the mesh.
  32886. * This mode makes the mesh edges visible
  32887. * @param epsilon defines the maximal distance between two angles to detect a face
  32888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32889. * @returns the currentAbstractMesh
  32890. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32891. */
  32892. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32893. /**
  32894. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32895. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32896. */
  32897. getConnectedParticleSystems(): IParticleSystem[];
  32898. }
  32899. }
  32900. declare module "babylonjs/Actions/actionEvent" {
  32901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32902. import { Nullable } from "babylonjs/types";
  32903. import { Sprite } from "babylonjs/Sprites/sprite";
  32904. import { Scene } from "babylonjs/scene";
  32905. import { Vector2 } from "babylonjs/Maths/math.vector";
  32906. /**
  32907. * Interface used to define ActionEvent
  32908. */
  32909. export interface IActionEvent {
  32910. /** The mesh or sprite that triggered the action */
  32911. source: any;
  32912. /** The X mouse cursor position at the time of the event */
  32913. pointerX: number;
  32914. /** The Y mouse cursor position at the time of the event */
  32915. pointerY: number;
  32916. /** The mesh that is currently pointed at (can be null) */
  32917. meshUnderPointer: Nullable<AbstractMesh>;
  32918. /** the original (browser) event that triggered the ActionEvent */
  32919. sourceEvent?: any;
  32920. /** additional data for the event */
  32921. additionalData?: any;
  32922. }
  32923. /**
  32924. * ActionEvent is the event being sent when an action is triggered.
  32925. */
  32926. export class ActionEvent implements IActionEvent {
  32927. /** The mesh or sprite that triggered the action */
  32928. source: any;
  32929. /** The X mouse cursor position at the time of the event */
  32930. pointerX: number;
  32931. /** The Y mouse cursor position at the time of the event */
  32932. pointerY: number;
  32933. /** The mesh that is currently pointed at (can be null) */
  32934. meshUnderPointer: Nullable<AbstractMesh>;
  32935. /** the original (browser) event that triggered the ActionEvent */
  32936. sourceEvent?: any;
  32937. /** additional data for the event */
  32938. additionalData?: any;
  32939. /**
  32940. * Creates a new ActionEvent
  32941. * @param source The mesh or sprite that triggered the action
  32942. * @param pointerX The X mouse cursor position at the time of the event
  32943. * @param pointerY The Y mouse cursor position at the time of the event
  32944. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32945. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32946. * @param additionalData additional data for the event
  32947. */
  32948. constructor(
  32949. /** The mesh or sprite that triggered the action */
  32950. source: any,
  32951. /** The X mouse cursor position at the time of the event */
  32952. pointerX: number,
  32953. /** The Y mouse cursor position at the time of the event */
  32954. pointerY: number,
  32955. /** The mesh that is currently pointed at (can be null) */
  32956. meshUnderPointer: Nullable<AbstractMesh>,
  32957. /** the original (browser) event that triggered the ActionEvent */
  32958. sourceEvent?: any,
  32959. /** additional data for the event */
  32960. additionalData?: any);
  32961. /**
  32962. * Helper function to auto-create an ActionEvent from a source mesh.
  32963. * @param source The source mesh that triggered the event
  32964. * @param evt The original (browser) event
  32965. * @param additionalData additional data for the event
  32966. * @returns the new ActionEvent
  32967. */
  32968. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32969. /**
  32970. * Helper function to auto-create an ActionEvent from a source sprite
  32971. * @param source The source sprite that triggered the event
  32972. * @param scene Scene associated with the sprite
  32973. * @param evt The original (browser) event
  32974. * @param additionalData additional data for the event
  32975. * @returns the new ActionEvent
  32976. */
  32977. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32978. /**
  32979. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32980. * @param scene the scene where the event occurred
  32981. * @param evt The original (browser) event
  32982. * @returns the new ActionEvent
  32983. */
  32984. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32985. /**
  32986. * Helper function to auto-create an ActionEvent from a primitive
  32987. * @param prim defines the target primitive
  32988. * @param pointerPos defines the pointer position
  32989. * @param evt The original (browser) event
  32990. * @param additionalData additional data for the event
  32991. * @returns the new ActionEvent
  32992. */
  32993. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32994. }
  32995. }
  32996. declare module "babylonjs/Actions/abstractActionManager" {
  32997. import { IDisposable } from "babylonjs/scene";
  32998. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32999. import { IAction } from "babylonjs/Actions/action";
  33000. import { Nullable } from "babylonjs/types";
  33001. /**
  33002. * Abstract class used to decouple action Manager from scene and meshes.
  33003. * Do not instantiate.
  33004. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33005. */
  33006. export abstract class AbstractActionManager implements IDisposable {
  33007. /** Gets the list of active triggers */
  33008. static Triggers: {
  33009. [key: string]: number;
  33010. };
  33011. /** Gets the cursor to use when hovering items */
  33012. hoverCursor: string;
  33013. /** Gets the list of actions */
  33014. actions: IAction[];
  33015. /**
  33016. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33017. */
  33018. isRecursive: boolean;
  33019. /**
  33020. * Releases all associated resources
  33021. */
  33022. abstract dispose(): void;
  33023. /**
  33024. * Does this action manager has pointer triggers
  33025. */
  33026. abstract get hasPointerTriggers(): boolean;
  33027. /**
  33028. * Does this action manager has pick triggers
  33029. */
  33030. abstract get hasPickTriggers(): boolean;
  33031. /**
  33032. * Process a specific trigger
  33033. * @param trigger defines the trigger to process
  33034. * @param evt defines the event details to be processed
  33035. */
  33036. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33037. /**
  33038. * Does this action manager handles actions of any of the given triggers
  33039. * @param triggers defines the triggers to be tested
  33040. * @return a boolean indicating whether one (or more) of the triggers is handled
  33041. */
  33042. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33043. /**
  33044. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33045. * speed.
  33046. * @param triggerA defines the trigger to be tested
  33047. * @param triggerB defines the trigger to be tested
  33048. * @return a boolean indicating whether one (or more) of the triggers is handled
  33049. */
  33050. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33051. /**
  33052. * Does this action manager handles actions of a given trigger
  33053. * @param trigger defines the trigger to be tested
  33054. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33055. * @return whether the trigger is handled
  33056. */
  33057. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33058. /**
  33059. * Serialize this manager to a JSON object
  33060. * @param name defines the property name to store this manager
  33061. * @returns a JSON representation of this manager
  33062. */
  33063. abstract serialize(name: string): any;
  33064. /**
  33065. * Registers an action to this action manager
  33066. * @param action defines the action to be registered
  33067. * @return the action amended (prepared) after registration
  33068. */
  33069. abstract registerAction(action: IAction): Nullable<IAction>;
  33070. /**
  33071. * Unregisters an action to this action manager
  33072. * @param action defines the action to be unregistered
  33073. * @return a boolean indicating whether the action has been unregistered
  33074. */
  33075. abstract unregisterAction(action: IAction): Boolean;
  33076. /**
  33077. * Does exist one action manager with at least one trigger
  33078. **/
  33079. static get HasTriggers(): boolean;
  33080. /**
  33081. * Does exist one action manager with at least one pick trigger
  33082. **/
  33083. static get HasPickTriggers(): boolean;
  33084. /**
  33085. * Does exist one action manager that handles actions of a given trigger
  33086. * @param trigger defines the trigger to be tested
  33087. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33088. **/
  33089. static HasSpecificTrigger(trigger: number): boolean;
  33090. }
  33091. }
  33092. declare module "babylonjs/node" {
  33093. import { Scene } from "babylonjs/scene";
  33094. import { Nullable } from "babylonjs/types";
  33095. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33096. import { Engine } from "babylonjs/Engines/engine";
  33097. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33098. import { Observable } from "babylonjs/Misc/observable";
  33099. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33101. import { Animatable } from "babylonjs/Animations/animatable";
  33102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33103. import { Animation } from "babylonjs/Animations/animation";
  33104. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33106. /**
  33107. * Defines how a node can be built from a string name.
  33108. */
  33109. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33110. /**
  33111. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33112. */
  33113. export class Node implements IBehaviorAware<Node> {
  33114. /** @hidden */
  33115. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33116. private static _NodeConstructors;
  33117. /**
  33118. * Add a new node constructor
  33119. * @param type defines the type name of the node to construct
  33120. * @param constructorFunc defines the constructor function
  33121. */
  33122. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33123. /**
  33124. * Returns a node constructor based on type name
  33125. * @param type defines the type name
  33126. * @param name defines the new node name
  33127. * @param scene defines the hosting scene
  33128. * @param options defines optional options to transmit to constructors
  33129. * @returns the new constructor or null
  33130. */
  33131. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33132. /**
  33133. * Gets or sets the name of the node
  33134. */
  33135. name: string;
  33136. /**
  33137. * Gets or sets the id of the node
  33138. */
  33139. id: string;
  33140. /**
  33141. * Gets or sets the unique id of the node
  33142. */
  33143. uniqueId: number;
  33144. /**
  33145. * Gets or sets a string used to store user defined state for the node
  33146. */
  33147. state: string;
  33148. /**
  33149. * Gets or sets an object used to store user defined information for the node
  33150. */
  33151. metadata: any;
  33152. /**
  33153. * For internal use only. Please do not use.
  33154. */
  33155. reservedDataStore: any;
  33156. /**
  33157. * List of inspectable custom properties (used by the Inspector)
  33158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33159. */
  33160. inspectableCustomProperties: IInspectable[];
  33161. private _doNotSerialize;
  33162. /**
  33163. * Gets or sets a boolean used to define if the node must be serialized
  33164. */
  33165. get doNotSerialize(): boolean;
  33166. set doNotSerialize(value: boolean);
  33167. /** @hidden */
  33168. _isDisposed: boolean;
  33169. /**
  33170. * Gets a list of Animations associated with the node
  33171. */
  33172. animations: import("babylonjs/Animations/animation").Animation[];
  33173. protected _ranges: {
  33174. [name: string]: Nullable<AnimationRange>;
  33175. };
  33176. /**
  33177. * Callback raised when the node is ready to be used
  33178. */
  33179. onReady: Nullable<(node: Node) => void>;
  33180. private _isEnabled;
  33181. private _isParentEnabled;
  33182. private _isReady;
  33183. /** @hidden */
  33184. _currentRenderId: number;
  33185. private _parentUpdateId;
  33186. /** @hidden */
  33187. _childUpdateId: number;
  33188. /** @hidden */
  33189. _waitingParentId: Nullable<string>;
  33190. /** @hidden */
  33191. _scene: Scene;
  33192. /** @hidden */
  33193. _cache: any;
  33194. private _parentNode;
  33195. private _children;
  33196. /** @hidden */
  33197. _worldMatrix: Matrix;
  33198. /** @hidden */
  33199. _worldMatrixDeterminant: number;
  33200. /** @hidden */
  33201. _worldMatrixDeterminantIsDirty: boolean;
  33202. /** @hidden */
  33203. private _sceneRootNodesIndex;
  33204. /**
  33205. * Gets a boolean indicating if the node has been disposed
  33206. * @returns true if the node was disposed
  33207. */
  33208. isDisposed(): boolean;
  33209. /**
  33210. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33211. * @see https://doc.babylonjs.com/how_to/parenting
  33212. */
  33213. set parent(parent: Nullable<Node>);
  33214. get parent(): Nullable<Node>;
  33215. /** @hidden */
  33216. _addToSceneRootNodes(): void;
  33217. /** @hidden */
  33218. _removeFromSceneRootNodes(): void;
  33219. private _animationPropertiesOverride;
  33220. /**
  33221. * Gets or sets the animation properties override
  33222. */
  33223. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33224. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33225. /**
  33226. * Gets a string idenfifying the name of the class
  33227. * @returns "Node" string
  33228. */
  33229. getClassName(): string;
  33230. /** @hidden */
  33231. readonly _isNode: boolean;
  33232. /**
  33233. * An event triggered when the mesh is disposed
  33234. */
  33235. onDisposeObservable: Observable<Node>;
  33236. private _onDisposeObserver;
  33237. /**
  33238. * Sets a callback that will be raised when the node will be disposed
  33239. */
  33240. set onDispose(callback: () => void);
  33241. /**
  33242. * Creates a new Node
  33243. * @param name the name and id to be given to this node
  33244. * @param scene the scene this node will be added to
  33245. */
  33246. constructor(name: string, scene?: Nullable<Scene>);
  33247. /**
  33248. * Gets the scene of the node
  33249. * @returns a scene
  33250. */
  33251. getScene(): Scene;
  33252. /**
  33253. * Gets the engine of the node
  33254. * @returns a Engine
  33255. */
  33256. getEngine(): Engine;
  33257. private _behaviors;
  33258. /**
  33259. * Attach a behavior to the node
  33260. * @see https://doc.babylonjs.com/features/behaviour
  33261. * @param behavior defines the behavior to attach
  33262. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33263. * @returns the current Node
  33264. */
  33265. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33266. /**
  33267. * Remove an attached behavior
  33268. * @see https://doc.babylonjs.com/features/behaviour
  33269. * @param behavior defines the behavior to attach
  33270. * @returns the current Node
  33271. */
  33272. removeBehavior(behavior: Behavior<Node>): Node;
  33273. /**
  33274. * Gets the list of attached behaviors
  33275. * @see https://doc.babylonjs.com/features/behaviour
  33276. */
  33277. get behaviors(): Behavior<Node>[];
  33278. /**
  33279. * Gets an attached behavior by name
  33280. * @param name defines the name of the behavior to look for
  33281. * @see https://doc.babylonjs.com/features/behaviour
  33282. * @returns null if behavior was not found else the requested behavior
  33283. */
  33284. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33285. /**
  33286. * Returns the latest update of the World matrix
  33287. * @returns a Matrix
  33288. */
  33289. getWorldMatrix(): Matrix;
  33290. /** @hidden */
  33291. _getWorldMatrixDeterminant(): number;
  33292. /**
  33293. * Returns directly the latest state of the mesh World matrix.
  33294. * A Matrix is returned.
  33295. */
  33296. get worldMatrixFromCache(): Matrix;
  33297. /** @hidden */
  33298. _initCache(): void;
  33299. /** @hidden */
  33300. updateCache(force?: boolean): void;
  33301. /** @hidden */
  33302. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33303. /** @hidden */
  33304. _updateCache(ignoreParentClass?: boolean): void;
  33305. /** @hidden */
  33306. _isSynchronized(): boolean;
  33307. /** @hidden */
  33308. _markSyncedWithParent(): void;
  33309. /** @hidden */
  33310. isSynchronizedWithParent(): boolean;
  33311. /** @hidden */
  33312. isSynchronized(): boolean;
  33313. /**
  33314. * Is this node ready to be used/rendered
  33315. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33316. * @return true if the node is ready
  33317. */
  33318. isReady(completeCheck?: boolean): boolean;
  33319. /**
  33320. * Is this node enabled?
  33321. * 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
  33322. * @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
  33323. * @return whether this node (and its parent) is enabled
  33324. */
  33325. isEnabled(checkAncestors?: boolean): boolean;
  33326. /** @hidden */
  33327. protected _syncParentEnabledState(): void;
  33328. /**
  33329. * Set the enabled state of this node
  33330. * @param value defines the new enabled state
  33331. */
  33332. setEnabled(value: boolean): void;
  33333. /**
  33334. * Is this node a descendant of the given node?
  33335. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33336. * @param ancestor defines the parent node to inspect
  33337. * @returns a boolean indicating if this node is a descendant of the given node
  33338. */
  33339. isDescendantOf(ancestor: Node): boolean;
  33340. /** @hidden */
  33341. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33342. /**
  33343. * Will return all nodes that have this node as ascendant
  33344. * @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
  33345. * @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
  33346. * @return all children nodes of all types
  33347. */
  33348. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33349. /**
  33350. * Get all child-meshes of this node
  33351. * @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)
  33352. * @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
  33353. * @returns an array of AbstractMesh
  33354. */
  33355. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33356. /**
  33357. * Get all direct children of this node
  33358. * @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
  33359. * @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)
  33360. * @returns an array of Node
  33361. */
  33362. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33363. /** @hidden */
  33364. _setReady(state: boolean): void;
  33365. /**
  33366. * Get an animation by name
  33367. * @param name defines the name of the animation to look for
  33368. * @returns null if not found else the requested animation
  33369. */
  33370. getAnimationByName(name: string): Nullable<Animation>;
  33371. /**
  33372. * Creates an animation range for this node
  33373. * @param name defines the name of the range
  33374. * @param from defines the starting key
  33375. * @param to defines the end key
  33376. */
  33377. createAnimationRange(name: string, from: number, to: number): void;
  33378. /**
  33379. * Delete a specific animation range
  33380. * @param name defines the name of the range to delete
  33381. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33382. */
  33383. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33384. /**
  33385. * Get an animation range by name
  33386. * @param name defines the name of the animation range to look for
  33387. * @returns null if not found else the requested animation range
  33388. */
  33389. getAnimationRange(name: string): Nullable<AnimationRange>;
  33390. /**
  33391. * Gets the list of all animation ranges defined on this node
  33392. * @returns an array
  33393. */
  33394. getAnimationRanges(): Nullable<AnimationRange>[];
  33395. /**
  33396. * Will start the animation sequence
  33397. * @param name defines the range frames for animation sequence
  33398. * @param loop defines if the animation should loop (false by default)
  33399. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33400. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33401. * @returns the object created for this animation. If range does not exist, it will return null
  33402. */
  33403. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33404. /**
  33405. * Serialize animation ranges into a JSON compatible object
  33406. * @returns serialization object
  33407. */
  33408. serializeAnimationRanges(): any;
  33409. /**
  33410. * Computes the world matrix of the node
  33411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33412. * @returns the world matrix
  33413. */
  33414. computeWorldMatrix(force?: boolean): Matrix;
  33415. /**
  33416. * Releases resources associated with this node.
  33417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33419. */
  33420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33421. /**
  33422. * Parse animation range data from a serialization object and store them into a given node
  33423. * @param node defines where to store the animation ranges
  33424. * @param parsedNode defines the serialization object to read data from
  33425. * @param scene defines the hosting scene
  33426. */
  33427. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33428. /**
  33429. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33430. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33431. * @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
  33432. * @returns the new bounding vectors
  33433. */
  33434. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33435. min: Vector3;
  33436. max: Vector3;
  33437. };
  33438. }
  33439. }
  33440. declare module "babylonjs/Animations/animation" {
  33441. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33442. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33443. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33444. import { Nullable } from "babylonjs/types";
  33445. import { Scene } from "babylonjs/scene";
  33446. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33447. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33448. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33449. import { Node } from "babylonjs/node";
  33450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33451. import { Size } from "babylonjs/Maths/math.size";
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33454. /**
  33455. * @hidden
  33456. */
  33457. export class _IAnimationState {
  33458. key: number;
  33459. repeatCount: number;
  33460. workValue?: any;
  33461. loopMode?: number;
  33462. offsetValue?: any;
  33463. highLimitValue?: any;
  33464. }
  33465. /**
  33466. * Class used to store any kind of animation
  33467. */
  33468. export class Animation {
  33469. /**Name of the animation */
  33470. name: string;
  33471. /**Property to animate */
  33472. targetProperty: string;
  33473. /**The frames per second of the animation */
  33474. framePerSecond: number;
  33475. /**The data type of the animation */
  33476. dataType: number;
  33477. /**The loop mode of the animation */
  33478. loopMode?: number | undefined;
  33479. /**Specifies if blending should be enabled */
  33480. enableBlending?: boolean | undefined;
  33481. /**
  33482. * Use matrix interpolation instead of using direct key value when animating matrices
  33483. */
  33484. static AllowMatricesInterpolation: boolean;
  33485. /**
  33486. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33487. */
  33488. static AllowMatrixDecomposeForInterpolation: boolean;
  33489. /** Define the Url to load snippets */
  33490. static SnippetUrl: string;
  33491. /** Snippet ID if the animation was created from the snippet server */
  33492. snippetId: string;
  33493. /**
  33494. * Stores the key frames of the animation
  33495. */
  33496. private _keys;
  33497. /**
  33498. * Stores the easing function of the animation
  33499. */
  33500. private _easingFunction;
  33501. /**
  33502. * @hidden Internal use only
  33503. */
  33504. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33505. /**
  33506. * The set of event that will be linked to this animation
  33507. */
  33508. private _events;
  33509. /**
  33510. * Stores an array of target property paths
  33511. */
  33512. targetPropertyPath: string[];
  33513. /**
  33514. * Stores the blending speed of the animation
  33515. */
  33516. blendingSpeed: number;
  33517. /**
  33518. * Stores the animation ranges for the animation
  33519. */
  33520. private _ranges;
  33521. /**
  33522. * @hidden Internal use
  33523. */
  33524. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33525. /**
  33526. * Sets up an animation
  33527. * @param property The property to animate
  33528. * @param animationType The animation type to apply
  33529. * @param framePerSecond The frames per second of the animation
  33530. * @param easingFunction The easing function used in the animation
  33531. * @returns The created animation
  33532. */
  33533. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33534. /**
  33535. * Create and start an animation on a node
  33536. * @param name defines the name of the global animation that will be run on all nodes
  33537. * @param node defines the root node where the animation will take place
  33538. * @param targetProperty defines property to animate
  33539. * @param framePerSecond defines the number of frame per second yo use
  33540. * @param totalFrame defines the number of frames in total
  33541. * @param from defines the initial value
  33542. * @param to defines the final value
  33543. * @param loopMode defines which loop mode you want to use (off by default)
  33544. * @param easingFunction defines the easing function to use (linear by default)
  33545. * @param onAnimationEnd defines the callback to call when animation end
  33546. * @returns the animatable created for this animation
  33547. */
  33548. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33549. /**
  33550. * Create and start an animation on a node and its descendants
  33551. * @param name defines the name of the global animation that will be run on all nodes
  33552. * @param node defines the root node where the animation will take place
  33553. * @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
  33554. * @param targetProperty defines property to animate
  33555. * @param framePerSecond defines the number of frame per second to use
  33556. * @param totalFrame defines the number of frames in total
  33557. * @param from defines the initial value
  33558. * @param to defines the final value
  33559. * @param loopMode defines which loop mode you want to use (off by default)
  33560. * @param easingFunction defines the easing function to use (linear by default)
  33561. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33562. * @returns the list of animatables created for all nodes
  33563. * @example https://www.babylonjs-playground.com/#MH0VLI
  33564. */
  33565. 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[]>;
  33566. /**
  33567. * Creates a new animation, merges it with the existing animations and starts it
  33568. * @param name Name of the animation
  33569. * @param node Node which contains the scene that begins the animations
  33570. * @param targetProperty Specifies which property to animate
  33571. * @param framePerSecond The frames per second of the animation
  33572. * @param totalFrame The total number of frames
  33573. * @param from The frame at the beginning of the animation
  33574. * @param to The frame at the end of the animation
  33575. * @param loopMode Specifies the loop mode of the animation
  33576. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33577. * @param onAnimationEnd Callback to run once the animation is complete
  33578. * @returns Nullable animation
  33579. */
  33580. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33581. /**
  33582. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33583. * @param sourceAnimation defines the Animation containing keyframes to convert
  33584. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33585. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33586. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33587. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33588. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33589. */
  33590. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33591. /**
  33592. * Transition property of an host to the target Value
  33593. * @param property The property to transition
  33594. * @param targetValue The target Value of the property
  33595. * @param host The object where the property to animate belongs
  33596. * @param scene Scene used to run the animation
  33597. * @param frameRate Framerate (in frame/s) to use
  33598. * @param transition The transition type we want to use
  33599. * @param duration The duration of the animation, in milliseconds
  33600. * @param onAnimationEnd Callback trigger at the end of the animation
  33601. * @returns Nullable animation
  33602. */
  33603. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33604. /**
  33605. * Return the array of runtime animations currently using this animation
  33606. */
  33607. get runtimeAnimations(): RuntimeAnimation[];
  33608. /**
  33609. * Specifies if any of the runtime animations are currently running
  33610. */
  33611. get hasRunningRuntimeAnimations(): boolean;
  33612. /**
  33613. * Initializes the animation
  33614. * @param name Name of the animation
  33615. * @param targetProperty Property to animate
  33616. * @param framePerSecond The frames per second of the animation
  33617. * @param dataType The data type of the animation
  33618. * @param loopMode The loop mode of the animation
  33619. * @param enableBlending Specifies if blending should be enabled
  33620. */
  33621. constructor(
  33622. /**Name of the animation */
  33623. name: string,
  33624. /**Property to animate */
  33625. targetProperty: string,
  33626. /**The frames per second of the animation */
  33627. framePerSecond: number,
  33628. /**The data type of the animation */
  33629. dataType: number,
  33630. /**The loop mode of the animation */
  33631. loopMode?: number | undefined,
  33632. /**Specifies if blending should be enabled */
  33633. enableBlending?: boolean | undefined);
  33634. /**
  33635. * Converts the animation to a string
  33636. * @param fullDetails support for multiple levels of logging within scene loading
  33637. * @returns String form of the animation
  33638. */
  33639. toString(fullDetails?: boolean): string;
  33640. /**
  33641. * Add an event to this animation
  33642. * @param event Event to add
  33643. */
  33644. addEvent(event: AnimationEvent): void;
  33645. /**
  33646. * Remove all events found at the given frame
  33647. * @param frame The frame to remove events from
  33648. */
  33649. removeEvents(frame: number): void;
  33650. /**
  33651. * Retrieves all the events from the animation
  33652. * @returns Events from the animation
  33653. */
  33654. getEvents(): AnimationEvent[];
  33655. /**
  33656. * Creates an animation range
  33657. * @param name Name of the animation range
  33658. * @param from Starting frame of the animation range
  33659. * @param to Ending frame of the animation
  33660. */
  33661. createRange(name: string, from: number, to: number): void;
  33662. /**
  33663. * Deletes an animation range by name
  33664. * @param name Name of the animation range to delete
  33665. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33666. */
  33667. deleteRange(name: string, deleteFrames?: boolean): void;
  33668. /**
  33669. * Gets the animation range by name, or null if not defined
  33670. * @param name Name of the animation range
  33671. * @returns Nullable animation range
  33672. */
  33673. getRange(name: string): Nullable<AnimationRange>;
  33674. /**
  33675. * Gets the key frames from the animation
  33676. * @returns The key frames of the animation
  33677. */
  33678. getKeys(): Array<IAnimationKey>;
  33679. /**
  33680. * Gets the highest frame rate of the animation
  33681. * @returns Highest frame rate of the animation
  33682. */
  33683. getHighestFrame(): number;
  33684. /**
  33685. * Gets the easing function of the animation
  33686. * @returns Easing function of the animation
  33687. */
  33688. getEasingFunction(): IEasingFunction;
  33689. /**
  33690. * Sets the easing function of the animation
  33691. * @param easingFunction A custom mathematical formula for animation
  33692. */
  33693. setEasingFunction(easingFunction: EasingFunction): void;
  33694. /**
  33695. * Interpolates a scalar linearly
  33696. * @param startValue Start value of the animation curve
  33697. * @param endValue End value of the animation curve
  33698. * @param gradient Scalar amount to interpolate
  33699. * @returns Interpolated scalar value
  33700. */
  33701. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33702. /**
  33703. * Interpolates a scalar cubically
  33704. * @param startValue Start value of the animation curve
  33705. * @param outTangent End tangent of the animation
  33706. * @param endValue End value of the animation curve
  33707. * @param inTangent Start tangent of the animation curve
  33708. * @param gradient Scalar amount to interpolate
  33709. * @returns Interpolated scalar value
  33710. */
  33711. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33712. /**
  33713. * Interpolates a quaternion using a spherical linear interpolation
  33714. * @param startValue Start value of the animation curve
  33715. * @param endValue End value of the animation curve
  33716. * @param gradient Scalar amount to interpolate
  33717. * @returns Interpolated quaternion value
  33718. */
  33719. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33720. /**
  33721. * Interpolates a quaternion cubically
  33722. * @param startValue Start value of the animation curve
  33723. * @param outTangent End tangent of the animation curve
  33724. * @param endValue End value of the animation curve
  33725. * @param inTangent Start tangent of the animation curve
  33726. * @param gradient Scalar amount to interpolate
  33727. * @returns Interpolated quaternion value
  33728. */
  33729. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33730. /**
  33731. * Interpolates a Vector3 linearl
  33732. * @param startValue Start value of the animation curve
  33733. * @param endValue End value of the animation curve
  33734. * @param gradient Scalar amount to interpolate
  33735. * @returns Interpolated scalar value
  33736. */
  33737. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33738. /**
  33739. * Interpolates a Vector3 cubically
  33740. * @param startValue Start value of the animation curve
  33741. * @param outTangent End tangent of the animation
  33742. * @param endValue End value of the animation curve
  33743. * @param inTangent Start tangent of the animation curve
  33744. * @param gradient Scalar amount to interpolate
  33745. * @returns InterpolatedVector3 value
  33746. */
  33747. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33748. /**
  33749. * Interpolates a Vector2 linearly
  33750. * @param startValue Start value of the animation curve
  33751. * @param endValue End value of the animation curve
  33752. * @param gradient Scalar amount to interpolate
  33753. * @returns Interpolated Vector2 value
  33754. */
  33755. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33756. /**
  33757. * Interpolates a Vector2 cubically
  33758. * @param startValue Start value of the animation curve
  33759. * @param outTangent End tangent of the animation
  33760. * @param endValue End value of the animation curve
  33761. * @param inTangent Start tangent of the animation curve
  33762. * @param gradient Scalar amount to interpolate
  33763. * @returns Interpolated Vector2 value
  33764. */
  33765. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33766. /**
  33767. * Interpolates a size linearly
  33768. * @param startValue Start value of the animation curve
  33769. * @param endValue End value of the animation curve
  33770. * @param gradient Scalar amount to interpolate
  33771. * @returns Interpolated Size value
  33772. */
  33773. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33774. /**
  33775. * Interpolates a Color3 linearly
  33776. * @param startValue Start value of the animation curve
  33777. * @param endValue End value of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated Color3 value
  33780. */
  33781. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33782. /**
  33783. * Interpolates a Color4 linearly
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated Color3 value
  33788. */
  33789. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33790. /**
  33791. * @hidden Internal use only
  33792. */
  33793. _getKeyValue(value: any): any;
  33794. /**
  33795. * @hidden Internal use only
  33796. */
  33797. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33798. /**
  33799. * Defines the function to use to interpolate matrices
  33800. * @param startValue defines the start matrix
  33801. * @param endValue defines the end matrix
  33802. * @param gradient defines the gradient between both matrices
  33803. * @param result defines an optional target matrix where to store the interpolation
  33804. * @returns the interpolated matrix
  33805. */
  33806. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33807. /**
  33808. * Makes a copy of the animation
  33809. * @returns Cloned animation
  33810. */
  33811. clone(): Animation;
  33812. /**
  33813. * Sets the key frames of the animation
  33814. * @param values The animation key frames to set
  33815. */
  33816. setKeys(values: Array<IAnimationKey>): void;
  33817. /**
  33818. * Serializes the animation to an object
  33819. * @returns Serialized object
  33820. */
  33821. serialize(): any;
  33822. /**
  33823. * Float animation type
  33824. */
  33825. static readonly ANIMATIONTYPE_FLOAT: number;
  33826. /**
  33827. * Vector3 animation type
  33828. */
  33829. static readonly ANIMATIONTYPE_VECTOR3: number;
  33830. /**
  33831. * Quaternion animation type
  33832. */
  33833. static readonly ANIMATIONTYPE_QUATERNION: number;
  33834. /**
  33835. * Matrix animation type
  33836. */
  33837. static readonly ANIMATIONTYPE_MATRIX: number;
  33838. /**
  33839. * Color3 animation type
  33840. */
  33841. static readonly ANIMATIONTYPE_COLOR3: number;
  33842. /**
  33843. * Color3 animation type
  33844. */
  33845. static readonly ANIMATIONTYPE_COLOR4: number;
  33846. /**
  33847. * Vector2 animation type
  33848. */
  33849. static readonly ANIMATIONTYPE_VECTOR2: number;
  33850. /**
  33851. * Size animation type
  33852. */
  33853. static readonly ANIMATIONTYPE_SIZE: number;
  33854. /**
  33855. * Relative Loop Mode
  33856. */
  33857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33858. /**
  33859. * Cycle Loop Mode
  33860. */
  33861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33862. /**
  33863. * Constant Loop Mode
  33864. */
  33865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33866. /** @hidden */
  33867. static _UniversalLerp(left: any, right: any, amount: number): any;
  33868. /**
  33869. * Parses an animation object and creates an animation
  33870. * @param parsedAnimation Parsed animation object
  33871. * @returns Animation object
  33872. */
  33873. static Parse(parsedAnimation: any): Animation;
  33874. /**
  33875. * Appends the serialized animations from the source animations
  33876. * @param source Source containing the animations
  33877. * @param destination Target to store the animations
  33878. */
  33879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33880. /**
  33881. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33882. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33883. * @param url defines the url to load from
  33884. * @returns a promise that will resolve to the new animation or an array of animations
  33885. */
  33886. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33887. /**
  33888. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33889. * @param snippetId defines the snippet to load
  33890. * @returns a promise that will resolve to the new animation or a new array of animations
  33891. */
  33892. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33893. }
  33894. }
  33895. declare module "babylonjs/Animations/animatable.interface" {
  33896. import { Nullable } from "babylonjs/types";
  33897. import { Animation } from "babylonjs/Animations/animation";
  33898. /**
  33899. * Interface containing an array of animations
  33900. */
  33901. export interface IAnimatable {
  33902. /**
  33903. * Array of animations
  33904. */
  33905. animations: Nullable<Array<Animation>>;
  33906. }
  33907. }
  33908. declare module "babylonjs/Misc/decorators" {
  33909. import { Nullable } from "babylonjs/types";
  33910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33911. import { Scene } from "babylonjs/scene";
  33912. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33913. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33914. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33916. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33917. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33918. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33919. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33920. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33921. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33922. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33923. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33924. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33925. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33926. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33927. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33928. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33929. /**
  33930. * Decorator used to define property that can be serialized as reference to a camera
  33931. * @param sourceName defines the name of the property to decorate
  33932. */
  33933. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33934. /**
  33935. * Class used to help serialization objects
  33936. */
  33937. export class SerializationHelper {
  33938. /** @hidden */
  33939. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33940. /** @hidden */
  33941. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33942. /** @hidden */
  33943. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33944. /** @hidden */
  33945. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33946. /**
  33947. * Appends the serialized animations from the source animations
  33948. * @param source Source containing the animations
  33949. * @param destination Target to store the animations
  33950. */
  33951. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33952. /**
  33953. * Static function used to serialized a specific entity
  33954. * @param entity defines the entity to serialize
  33955. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33956. * @returns a JSON compatible object representing the serialization of the entity
  33957. */
  33958. static Serialize<T>(entity: T, serializationObject?: any): any;
  33959. /**
  33960. * Creates a new entity from a serialization data object
  33961. * @param creationFunction defines a function used to instanciated the new entity
  33962. * @param source defines the source serialization data
  33963. * @param scene defines the hosting scene
  33964. * @param rootUrl defines the root url for resources
  33965. * @returns a new entity
  33966. */
  33967. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33968. /**
  33969. * Clones an object
  33970. * @param creationFunction defines the function used to instanciate the new object
  33971. * @param source defines the source object
  33972. * @returns the cloned object
  33973. */
  33974. static Clone<T>(creationFunction: () => T, source: T): T;
  33975. /**
  33976. * Instanciates a new object based on a source one (some data will be shared between both object)
  33977. * @param creationFunction defines the function used to instanciate the new object
  33978. * @param source defines the source object
  33979. * @returns the new object
  33980. */
  33981. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33982. }
  33983. }
  33984. declare module "babylonjs/Materials/Textures/baseTexture" {
  33985. import { Observable } from "babylonjs/Misc/observable";
  33986. import { Nullable } from "babylonjs/types";
  33987. import { Scene } from "babylonjs/scene";
  33988. import { Matrix } from "babylonjs/Maths/math.vector";
  33989. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33991. import { ISize } from "babylonjs/Maths/math.size";
  33992. import "babylonjs/Misc/fileTools";
  33993. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33994. /**
  33995. * Base class of all the textures in babylon.
  33996. * It groups all the common properties the materials, post process, lights... might need
  33997. * in order to make a correct use of the texture.
  33998. */
  33999. export class BaseTexture implements IAnimatable {
  34000. /**
  34001. * Default anisotropic filtering level for the application.
  34002. * It is set to 4 as a good tradeoff between perf and quality.
  34003. */
  34004. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34005. /**
  34006. * Gets or sets the unique id of the texture
  34007. */
  34008. uniqueId: number;
  34009. /**
  34010. * Define the name of the texture.
  34011. */
  34012. name: string;
  34013. /**
  34014. * Gets or sets an object used to store user defined information.
  34015. */
  34016. metadata: any;
  34017. /**
  34018. * For internal use only. Please do not use.
  34019. */
  34020. reservedDataStore: any;
  34021. private _hasAlpha;
  34022. /**
  34023. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34024. */
  34025. set hasAlpha(value: boolean);
  34026. get hasAlpha(): boolean;
  34027. /**
  34028. * Defines if the alpha value should be determined via the rgb values.
  34029. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34030. */
  34031. getAlphaFromRGB: boolean;
  34032. /**
  34033. * Intensity or strength of the texture.
  34034. * It is commonly used by materials to fine tune the intensity of the texture
  34035. */
  34036. level: number;
  34037. /**
  34038. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34039. * This is part of the texture as textures usually maps to one uv set.
  34040. */
  34041. coordinatesIndex: number;
  34042. private _coordinatesMode;
  34043. /**
  34044. * How a texture is mapped.
  34045. *
  34046. * | Value | Type | Description |
  34047. * | ----- | ----------------------------------- | ----------- |
  34048. * | 0 | EXPLICIT_MODE | |
  34049. * | 1 | SPHERICAL_MODE | |
  34050. * | 2 | PLANAR_MODE | |
  34051. * | 3 | CUBIC_MODE | |
  34052. * | 4 | PROJECTION_MODE | |
  34053. * | 5 | SKYBOX_MODE | |
  34054. * | 6 | INVCUBIC_MODE | |
  34055. * | 7 | EQUIRECTANGULAR_MODE | |
  34056. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34057. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34058. */
  34059. set coordinatesMode(value: number);
  34060. get coordinatesMode(): number;
  34061. /**
  34062. * | Value | Type | Description |
  34063. * | ----- | ------------------ | ----------- |
  34064. * | 0 | CLAMP_ADDRESSMODE | |
  34065. * | 1 | WRAP_ADDRESSMODE | |
  34066. * | 2 | MIRROR_ADDRESSMODE | |
  34067. */
  34068. wrapU: number;
  34069. /**
  34070. * | Value | Type | Description |
  34071. * | ----- | ------------------ | ----------- |
  34072. * | 0 | CLAMP_ADDRESSMODE | |
  34073. * | 1 | WRAP_ADDRESSMODE | |
  34074. * | 2 | MIRROR_ADDRESSMODE | |
  34075. */
  34076. wrapV: number;
  34077. /**
  34078. * | Value | Type | Description |
  34079. * | ----- | ------------------ | ----------- |
  34080. * | 0 | CLAMP_ADDRESSMODE | |
  34081. * | 1 | WRAP_ADDRESSMODE | |
  34082. * | 2 | MIRROR_ADDRESSMODE | |
  34083. */
  34084. wrapR: number;
  34085. /**
  34086. * With compliant hardware and browser (supporting anisotropic filtering)
  34087. * this defines the level of anisotropic filtering in the texture.
  34088. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34089. */
  34090. anisotropicFilteringLevel: number;
  34091. /**
  34092. * Define if the texture is a cube texture or if false a 2d texture.
  34093. */
  34094. get isCube(): boolean;
  34095. set isCube(value: boolean);
  34096. /**
  34097. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34098. */
  34099. get is3D(): boolean;
  34100. set is3D(value: boolean);
  34101. /**
  34102. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34103. */
  34104. get is2DArray(): boolean;
  34105. set is2DArray(value: boolean);
  34106. /**
  34107. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34108. * HDR texture are usually stored in linear space.
  34109. * This only impacts the PBR and Background materials
  34110. */
  34111. gammaSpace: boolean;
  34112. /**
  34113. * Gets or sets whether or not the texture contains RGBD data.
  34114. */
  34115. get isRGBD(): boolean;
  34116. set isRGBD(value: boolean);
  34117. /**
  34118. * Is Z inverted in the texture (useful in a cube texture).
  34119. */
  34120. invertZ: boolean;
  34121. /**
  34122. * Are mip maps generated for this texture or not.
  34123. */
  34124. get noMipmap(): boolean;
  34125. /**
  34126. * @hidden
  34127. */
  34128. lodLevelInAlpha: boolean;
  34129. /**
  34130. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34131. */
  34132. get lodGenerationOffset(): number;
  34133. set lodGenerationOffset(value: number);
  34134. /**
  34135. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34136. */
  34137. get lodGenerationScale(): number;
  34138. set lodGenerationScale(value: number);
  34139. /**
  34140. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34141. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34142. * average roughness values.
  34143. */
  34144. get linearSpecularLOD(): boolean;
  34145. set linearSpecularLOD(value: boolean);
  34146. /**
  34147. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34148. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34149. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34150. */
  34151. get irradianceTexture(): Nullable<BaseTexture>;
  34152. set irradianceTexture(value: Nullable<BaseTexture>);
  34153. /**
  34154. * Define if the texture is a render target.
  34155. */
  34156. isRenderTarget: boolean;
  34157. /**
  34158. * Define the unique id of the texture in the scene.
  34159. */
  34160. get uid(): string;
  34161. /** @hidden */
  34162. _prefiltered: boolean;
  34163. /**
  34164. * Return a string representation of the texture.
  34165. * @returns the texture as a string
  34166. */
  34167. toString(): string;
  34168. /**
  34169. * Get the class name of the texture.
  34170. * @returns "BaseTexture"
  34171. */
  34172. getClassName(): string;
  34173. /**
  34174. * Define the list of animation attached to the texture.
  34175. */
  34176. animations: import("babylonjs/Animations/animation").Animation[];
  34177. /**
  34178. * An event triggered when the texture is disposed.
  34179. */
  34180. onDisposeObservable: Observable<BaseTexture>;
  34181. private _onDisposeObserver;
  34182. /**
  34183. * Callback triggered when the texture has been disposed.
  34184. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34185. */
  34186. set onDispose(callback: () => void);
  34187. /**
  34188. * Define the current state of the loading sequence when in delayed load mode.
  34189. */
  34190. delayLoadState: number;
  34191. private _scene;
  34192. private _engine;
  34193. /** @hidden */
  34194. _texture: Nullable<InternalTexture>;
  34195. private _uid;
  34196. /**
  34197. * Define if the texture is preventinga material to render or not.
  34198. * If not and the texture is not ready, the engine will use a default black texture instead.
  34199. */
  34200. get isBlocking(): boolean;
  34201. /**
  34202. * Instantiates a new BaseTexture.
  34203. * Base class of all the textures in babylon.
  34204. * It groups all the common properties the materials, post process, lights... might need
  34205. * in order to make a correct use of the texture.
  34206. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34207. */
  34208. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34209. /**
  34210. * Get the scene the texture belongs to.
  34211. * @returns the scene or null if undefined
  34212. */
  34213. getScene(): Nullable<Scene>;
  34214. /** @hidden */
  34215. protected _getEngine(): Nullable<ThinEngine>;
  34216. /**
  34217. * Get the texture transform matrix used to offset tile the texture for istance.
  34218. * @returns the transformation matrix
  34219. */
  34220. getTextureMatrix(): Matrix;
  34221. /**
  34222. * Get the texture reflection matrix used to rotate/transform the reflection.
  34223. * @returns the reflection matrix
  34224. */
  34225. getReflectionTextureMatrix(): Matrix;
  34226. /**
  34227. * Get the underlying lower level texture from Babylon.
  34228. * @returns the insternal texture
  34229. */
  34230. getInternalTexture(): Nullable<InternalTexture>;
  34231. /**
  34232. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34233. * @returns true if ready or not blocking
  34234. */
  34235. isReadyOrNotBlocking(): boolean;
  34236. /**
  34237. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34238. * @returns true if fully ready
  34239. */
  34240. isReady(): boolean;
  34241. private _cachedSize;
  34242. /**
  34243. * Get the size of the texture.
  34244. * @returns the texture size.
  34245. */
  34246. getSize(): ISize;
  34247. /**
  34248. * Get the base size of the texture.
  34249. * It can be different from the size if the texture has been resized for POT for instance
  34250. * @returns the base size
  34251. */
  34252. getBaseSize(): ISize;
  34253. /**
  34254. * Update the sampling mode of the texture.
  34255. * Default is Trilinear mode.
  34256. *
  34257. * | Value | Type | Description |
  34258. * | ----- | ------------------ | ----------- |
  34259. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34260. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34261. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34262. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34263. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34264. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34265. * | 7 | NEAREST_LINEAR | |
  34266. * | 8 | NEAREST_NEAREST | |
  34267. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34268. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34269. * | 11 | LINEAR_LINEAR | |
  34270. * | 12 | LINEAR_NEAREST | |
  34271. *
  34272. * > _mag_: magnification filter (close to the viewer)
  34273. * > _min_: minification filter (far from the viewer)
  34274. * > _mip_: filter used between mip map levels
  34275. *@param samplingMode Define the new sampling mode of the texture
  34276. */
  34277. updateSamplingMode(samplingMode: number): void;
  34278. /**
  34279. * Scales the texture if is `canRescale()`
  34280. * @param ratio the resize factor we want to use to rescale
  34281. */
  34282. scale(ratio: number): void;
  34283. /**
  34284. * Get if the texture can rescale.
  34285. */
  34286. get canRescale(): boolean;
  34287. /** @hidden */
  34288. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34289. /** @hidden */
  34290. _rebuild(): void;
  34291. /**
  34292. * Triggers the load sequence in delayed load mode.
  34293. */
  34294. delayLoad(): void;
  34295. /**
  34296. * Clones the texture.
  34297. * @returns the cloned texture
  34298. */
  34299. clone(): Nullable<BaseTexture>;
  34300. /**
  34301. * Get the texture underlying type (INT, FLOAT...)
  34302. */
  34303. get textureType(): number;
  34304. /**
  34305. * Get the texture underlying format (RGB, RGBA...)
  34306. */
  34307. get textureFormat(): number;
  34308. /**
  34309. * Indicates that textures need to be re-calculated for all materials
  34310. */
  34311. protected _markAllSubMeshesAsTexturesDirty(): void;
  34312. /**
  34313. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34314. * This will returns an RGBA array buffer containing either in values (0-255) or
  34315. * float values (0-1) depending of the underlying buffer type.
  34316. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34317. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34318. * @param buffer defines a user defined buffer to fill with data (can be null)
  34319. * @returns The Array buffer containing the pixels data.
  34320. */
  34321. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34322. /**
  34323. * Release and destroy the underlying lower level texture aka internalTexture.
  34324. */
  34325. releaseInternalTexture(): void;
  34326. /** @hidden */
  34327. get _lodTextureHigh(): Nullable<BaseTexture>;
  34328. /** @hidden */
  34329. get _lodTextureMid(): Nullable<BaseTexture>;
  34330. /** @hidden */
  34331. get _lodTextureLow(): Nullable<BaseTexture>;
  34332. /**
  34333. * Dispose the texture and release its associated resources.
  34334. */
  34335. dispose(): void;
  34336. /**
  34337. * Serialize the texture into a JSON representation that can be parsed later on.
  34338. * @returns the JSON representation of the texture
  34339. */
  34340. serialize(): any;
  34341. /**
  34342. * Helper function to be called back once a list of texture contains only ready textures.
  34343. * @param textures Define the list of textures to wait for
  34344. * @param callback Define the callback triggered once the entire list will be ready
  34345. */
  34346. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34347. private static _isScene;
  34348. }
  34349. }
  34350. declare module "babylonjs/Materials/effect" {
  34351. import { Observable } from "babylonjs/Misc/observable";
  34352. import { Nullable } from "babylonjs/types";
  34353. import { IDisposable } from "babylonjs/scene";
  34354. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34355. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34356. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34357. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34358. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34359. import { Engine } from "babylonjs/Engines/engine";
  34360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34364. /**
  34365. * Options to be used when creating an effect.
  34366. */
  34367. export interface IEffectCreationOptions {
  34368. /**
  34369. * Atrributes that will be used in the shader.
  34370. */
  34371. attributes: string[];
  34372. /**
  34373. * Uniform varible names that will be set in the shader.
  34374. */
  34375. uniformsNames: string[];
  34376. /**
  34377. * Uniform buffer variable names that will be set in the shader.
  34378. */
  34379. uniformBuffersNames: string[];
  34380. /**
  34381. * Sampler texture variable names that will be set in the shader.
  34382. */
  34383. samplers: string[];
  34384. /**
  34385. * Define statements that will be set in the shader.
  34386. */
  34387. defines: any;
  34388. /**
  34389. * Possible fallbacks for this effect to improve performance when needed.
  34390. */
  34391. fallbacks: Nullable<IEffectFallbacks>;
  34392. /**
  34393. * Callback that will be called when the shader is compiled.
  34394. */
  34395. onCompiled: Nullable<(effect: Effect) => void>;
  34396. /**
  34397. * Callback that will be called if an error occurs during shader compilation.
  34398. */
  34399. onError: Nullable<(effect: Effect, errors: string) => void>;
  34400. /**
  34401. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34402. */
  34403. indexParameters?: any;
  34404. /**
  34405. * Max number of lights that can be used in the shader.
  34406. */
  34407. maxSimultaneousLights?: number;
  34408. /**
  34409. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34410. */
  34411. transformFeedbackVaryings?: Nullable<string[]>;
  34412. /**
  34413. * 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
  34414. */
  34415. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34416. /**
  34417. * Is this effect rendering to several color attachments ?
  34418. */
  34419. multiTarget?: boolean;
  34420. }
  34421. /**
  34422. * Effect containing vertex and fragment shader that can be executed on an object.
  34423. */
  34424. export class Effect implements IDisposable {
  34425. /**
  34426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34427. */
  34428. static ShadersRepository: string;
  34429. /**
  34430. * Enable logging of the shader code when a compilation error occurs
  34431. */
  34432. static LogShaderCodeOnCompilationError: boolean;
  34433. /**
  34434. * Name of the effect.
  34435. */
  34436. name: any;
  34437. /**
  34438. * String container all the define statements that should be set on the shader.
  34439. */
  34440. defines: string;
  34441. /**
  34442. * Callback that will be called when the shader is compiled.
  34443. */
  34444. onCompiled: Nullable<(effect: Effect) => void>;
  34445. /**
  34446. * Callback that will be called if an error occurs during shader compilation.
  34447. */
  34448. onError: Nullable<(effect: Effect, errors: string) => void>;
  34449. /**
  34450. * Callback that will be called when effect is bound.
  34451. */
  34452. onBind: Nullable<(effect: Effect) => void>;
  34453. /**
  34454. * Unique ID of the effect.
  34455. */
  34456. uniqueId: number;
  34457. /**
  34458. * Observable that will be called when the shader is compiled.
  34459. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34460. */
  34461. onCompileObservable: Observable<Effect>;
  34462. /**
  34463. * Observable that will be called if an error occurs during shader compilation.
  34464. */
  34465. onErrorObservable: Observable<Effect>;
  34466. /** @hidden */
  34467. _onBindObservable: Nullable<Observable<Effect>>;
  34468. /**
  34469. * @hidden
  34470. * Specifies if the effect was previously ready
  34471. */
  34472. _wasPreviouslyReady: boolean;
  34473. /**
  34474. * Observable that will be called when effect is bound.
  34475. */
  34476. get onBindObservable(): Observable<Effect>;
  34477. /** @hidden */
  34478. _bonesComputationForcedToCPU: boolean;
  34479. /** @hidden */
  34480. _multiTarget: boolean;
  34481. private static _uniqueIdSeed;
  34482. private _engine;
  34483. private _uniformBuffersNames;
  34484. private _uniformBuffersNamesList;
  34485. private _uniformsNames;
  34486. private _samplerList;
  34487. private _samplers;
  34488. private _isReady;
  34489. private _compilationError;
  34490. private _allFallbacksProcessed;
  34491. private _attributesNames;
  34492. private _attributes;
  34493. private _attributeLocationByName;
  34494. private _uniforms;
  34495. /**
  34496. * Key for the effect.
  34497. * @hidden
  34498. */
  34499. _key: string;
  34500. private _indexParameters;
  34501. private _fallbacks;
  34502. private _vertexSourceCode;
  34503. private _fragmentSourceCode;
  34504. private _vertexSourceCodeOverride;
  34505. private _fragmentSourceCodeOverride;
  34506. private _transformFeedbackVaryings;
  34507. /**
  34508. * Compiled shader to webGL program.
  34509. * @hidden
  34510. */
  34511. _pipelineContext: Nullable<IPipelineContext>;
  34512. private _valueCache;
  34513. private static _baseCache;
  34514. /**
  34515. * Instantiates an effect.
  34516. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34517. * @param baseName Name of the effect.
  34518. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34519. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34520. * @param samplers List of sampler variables that will be passed to the shader.
  34521. * @param engine Engine to be used to render the effect
  34522. * @param defines Define statements to be added to the shader.
  34523. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34524. * @param onCompiled Callback that will be called when the shader is compiled.
  34525. * @param onError Callback that will be called if an error occurs during shader compilation.
  34526. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34527. */
  34528. 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);
  34529. private _useFinalCode;
  34530. /**
  34531. * Unique key for this effect
  34532. */
  34533. get key(): string;
  34534. /**
  34535. * If the effect has been compiled and prepared.
  34536. * @returns if the effect is compiled and prepared.
  34537. */
  34538. isReady(): boolean;
  34539. private _isReadyInternal;
  34540. /**
  34541. * The engine the effect was initialized with.
  34542. * @returns the engine.
  34543. */
  34544. getEngine(): Engine;
  34545. /**
  34546. * The pipeline context for this effect
  34547. * @returns the associated pipeline context
  34548. */
  34549. getPipelineContext(): Nullable<IPipelineContext>;
  34550. /**
  34551. * The set of names of attribute variables for the shader.
  34552. * @returns An array of attribute names.
  34553. */
  34554. getAttributesNames(): string[];
  34555. /**
  34556. * Returns the attribute at the given index.
  34557. * @param index The index of the attribute.
  34558. * @returns The location of the attribute.
  34559. */
  34560. getAttributeLocation(index: number): number;
  34561. /**
  34562. * Returns the attribute based on the name of the variable.
  34563. * @param name of the attribute to look up.
  34564. * @returns the attribute location.
  34565. */
  34566. getAttributeLocationByName(name: string): number;
  34567. /**
  34568. * The number of attributes.
  34569. * @returns the numnber of attributes.
  34570. */
  34571. getAttributesCount(): number;
  34572. /**
  34573. * Gets the index of a uniform variable.
  34574. * @param uniformName of the uniform to look up.
  34575. * @returns the index.
  34576. */
  34577. getUniformIndex(uniformName: string): number;
  34578. /**
  34579. * Returns the attribute based on the name of the variable.
  34580. * @param uniformName of the uniform to look up.
  34581. * @returns the location of the uniform.
  34582. */
  34583. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34584. /**
  34585. * Returns an array of sampler variable names
  34586. * @returns The array of sampler variable names.
  34587. */
  34588. getSamplers(): string[];
  34589. /**
  34590. * Returns an array of uniform variable names
  34591. * @returns The array of uniform variable names.
  34592. */
  34593. getUniformNames(): string[];
  34594. /**
  34595. * Returns an array of uniform buffer variable names
  34596. * @returns The array of uniform buffer variable names.
  34597. */
  34598. getUniformBuffersNames(): string[];
  34599. /**
  34600. * Returns the index parameters used to create the effect
  34601. * @returns The index parameters object
  34602. */
  34603. getIndexParameters(): any;
  34604. /**
  34605. * The error from the last compilation.
  34606. * @returns the error string.
  34607. */
  34608. getCompilationError(): string;
  34609. /**
  34610. * Gets a boolean indicating that all fallbacks were used during compilation
  34611. * @returns true if all fallbacks were used
  34612. */
  34613. allFallbacksProcessed(): boolean;
  34614. /**
  34615. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34616. * @param func The callback to be used.
  34617. */
  34618. executeWhenCompiled(func: (effect: Effect) => void): void;
  34619. private _checkIsReady;
  34620. private _loadShader;
  34621. /**
  34622. * Gets the vertex shader source code of this effect
  34623. */
  34624. get vertexSourceCode(): string;
  34625. /**
  34626. * Gets the fragment shader source code of this effect
  34627. */
  34628. get fragmentSourceCode(): string;
  34629. /**
  34630. * Recompiles the webGL program
  34631. * @param vertexSourceCode The source code for the vertex shader.
  34632. * @param fragmentSourceCode The source code for the fragment shader.
  34633. * @param onCompiled Callback called when completed.
  34634. * @param onError Callback called on error.
  34635. * @hidden
  34636. */
  34637. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34638. /**
  34639. * Prepares the effect
  34640. * @hidden
  34641. */
  34642. _prepareEffect(): void;
  34643. private _getShaderCodeAndErrorLine;
  34644. private _processCompilationErrors;
  34645. /**
  34646. * Checks if the effect is supported. (Must be called after compilation)
  34647. */
  34648. get isSupported(): boolean;
  34649. /**
  34650. * Binds a texture to the engine to be used as output of the shader.
  34651. * @param channel Name of the output variable.
  34652. * @param texture Texture to bind.
  34653. * @hidden
  34654. */
  34655. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34656. /**
  34657. * Sets a texture on the engine to be used in the shader.
  34658. * @param channel Name of the sampler variable.
  34659. * @param texture Texture to set.
  34660. */
  34661. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34662. /**
  34663. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34664. * @param channel Name of the sampler variable.
  34665. * @param texture Texture to set.
  34666. */
  34667. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34668. /**
  34669. * Sets an array of textures on the engine to be used in the shader.
  34670. * @param channel Name of the variable.
  34671. * @param textures Textures to set.
  34672. */
  34673. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34674. /**
  34675. * 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)
  34676. * @param channel Name of the sampler variable.
  34677. * @param postProcess Post process to get the input texture from.
  34678. */
  34679. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34680. /**
  34681. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34682. * 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)
  34683. * @param channel Name of the sampler variable.
  34684. * @param postProcess Post process to get the output texture from.
  34685. */
  34686. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34687. /** @hidden */
  34688. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34689. /** @hidden */
  34690. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34691. /** @hidden */
  34692. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34693. /** @hidden */
  34694. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34695. /**
  34696. * Binds a buffer to a uniform.
  34697. * @param buffer Buffer to bind.
  34698. * @param name Name of the uniform variable to bind to.
  34699. */
  34700. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34701. /**
  34702. * Binds block to a uniform.
  34703. * @param blockName Name of the block to bind.
  34704. * @param index Index to bind.
  34705. */
  34706. bindUniformBlock(blockName: string, index: number): void;
  34707. /**
  34708. * Sets an interger value on a uniform variable.
  34709. * @param uniformName Name of the variable.
  34710. * @param value Value to be set.
  34711. * @returns this effect.
  34712. */
  34713. setInt(uniformName: string, value: number): Effect;
  34714. /**
  34715. * Sets an int array on a uniform variable.
  34716. * @param uniformName Name of the variable.
  34717. * @param array array to be set.
  34718. * @returns this effect.
  34719. */
  34720. setIntArray(uniformName: string, array: Int32Array): Effect;
  34721. /**
  34722. * 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)
  34723. * @param uniformName Name of the variable.
  34724. * @param array array to be set.
  34725. * @returns this effect.
  34726. */
  34727. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34728. /**
  34729. * 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)
  34730. * @param uniformName Name of the variable.
  34731. * @param array array to be set.
  34732. * @returns this effect.
  34733. */
  34734. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34735. /**
  34736. * 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)
  34737. * @param uniformName Name of the variable.
  34738. * @param array array to be set.
  34739. * @returns this effect.
  34740. */
  34741. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34742. /**
  34743. * Sets an float array on a uniform variable.
  34744. * @param uniformName Name of the variable.
  34745. * @param array array to be set.
  34746. * @returns this effect.
  34747. */
  34748. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34749. /**
  34750. * 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)
  34751. * @param uniformName Name of the variable.
  34752. * @param array array to be set.
  34753. * @returns this effect.
  34754. */
  34755. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34756. /**
  34757. * 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)
  34758. * @param uniformName Name of the variable.
  34759. * @param array array to be set.
  34760. * @returns this effect.
  34761. */
  34762. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34763. /**
  34764. * 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)
  34765. * @param uniformName Name of the variable.
  34766. * @param array array to be set.
  34767. * @returns this effect.
  34768. */
  34769. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34770. /**
  34771. * Sets an array on a uniform variable.
  34772. * @param uniformName Name of the variable.
  34773. * @param array array to be set.
  34774. * @returns this effect.
  34775. */
  34776. setArray(uniformName: string, array: number[]): Effect;
  34777. /**
  34778. * 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)
  34779. * @param uniformName Name of the variable.
  34780. * @param array array to be set.
  34781. * @returns this effect.
  34782. */
  34783. setArray2(uniformName: string, array: number[]): Effect;
  34784. /**
  34785. * 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)
  34786. * @param uniformName Name of the variable.
  34787. * @param array array to be set.
  34788. * @returns this effect.
  34789. */
  34790. setArray3(uniformName: string, array: number[]): Effect;
  34791. /**
  34792. * 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)
  34793. * @param uniformName Name of the variable.
  34794. * @param array array to be set.
  34795. * @returns this effect.
  34796. */
  34797. setArray4(uniformName: string, array: number[]): Effect;
  34798. /**
  34799. * Sets matrices on a uniform variable.
  34800. * @param uniformName Name of the variable.
  34801. * @param matrices matrices to be set.
  34802. * @returns this effect.
  34803. */
  34804. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34805. /**
  34806. * Sets matrix on a uniform variable.
  34807. * @param uniformName Name of the variable.
  34808. * @param matrix matrix to be set.
  34809. * @returns this effect.
  34810. */
  34811. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34812. /**
  34813. * 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)
  34814. * @param uniformName Name of the variable.
  34815. * @param matrix matrix to be set.
  34816. * @returns this effect.
  34817. */
  34818. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34819. /**
  34820. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34821. * @param uniformName Name of the variable.
  34822. * @param matrix matrix to be set.
  34823. * @returns this effect.
  34824. */
  34825. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34826. /**
  34827. * Sets a float on a uniform variable.
  34828. * @param uniformName Name of the variable.
  34829. * @param value value to be set.
  34830. * @returns this effect.
  34831. */
  34832. setFloat(uniformName: string, value: number): Effect;
  34833. /**
  34834. * Sets a boolean on a uniform variable.
  34835. * @param uniformName Name of the variable.
  34836. * @param bool value to be set.
  34837. * @returns this effect.
  34838. */
  34839. setBool(uniformName: string, bool: boolean): Effect;
  34840. /**
  34841. * Sets a Vector2 on a uniform variable.
  34842. * @param uniformName Name of the variable.
  34843. * @param vector2 vector2 to be set.
  34844. * @returns this effect.
  34845. */
  34846. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34847. /**
  34848. * Sets a float2 on a uniform variable.
  34849. * @param uniformName Name of the variable.
  34850. * @param x First float in float2.
  34851. * @param y Second float in float2.
  34852. * @returns this effect.
  34853. */
  34854. setFloat2(uniformName: string, x: number, y: number): Effect;
  34855. /**
  34856. * Sets a Vector3 on a uniform variable.
  34857. * @param uniformName Name of the variable.
  34858. * @param vector3 Value to be set.
  34859. * @returns this effect.
  34860. */
  34861. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34862. /**
  34863. * Sets a float3 on a uniform variable.
  34864. * @param uniformName Name of the variable.
  34865. * @param x First float in float3.
  34866. * @param y Second float in float3.
  34867. * @param z Third float in float3.
  34868. * @returns this effect.
  34869. */
  34870. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34871. /**
  34872. * Sets a Vector4 on a uniform variable.
  34873. * @param uniformName Name of the variable.
  34874. * @param vector4 Value to be set.
  34875. * @returns this effect.
  34876. */
  34877. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34878. /**
  34879. * Sets a float4 on a uniform variable.
  34880. * @param uniformName Name of the variable.
  34881. * @param x First float in float4.
  34882. * @param y Second float in float4.
  34883. * @param z Third float in float4.
  34884. * @param w Fourth float in float4.
  34885. * @returns this effect.
  34886. */
  34887. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34888. /**
  34889. * Sets a Color3 on a uniform variable.
  34890. * @param uniformName Name of the variable.
  34891. * @param color3 Value to be set.
  34892. * @returns this effect.
  34893. */
  34894. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34895. /**
  34896. * Sets a Color4 on a uniform variable.
  34897. * @param uniformName Name of the variable.
  34898. * @param color3 Value to be set.
  34899. * @param alpha Alpha value to be set.
  34900. * @returns this effect.
  34901. */
  34902. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34903. /**
  34904. * Sets a Color4 on a uniform variable
  34905. * @param uniformName defines the name of the variable
  34906. * @param color4 defines the value to be set
  34907. * @returns this effect.
  34908. */
  34909. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34910. /** Release all associated resources */
  34911. dispose(): void;
  34912. /**
  34913. * This function will add a new shader to the shader store
  34914. * @param name the name of the shader
  34915. * @param pixelShader optional pixel shader content
  34916. * @param vertexShader optional vertex shader content
  34917. */
  34918. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34919. /**
  34920. * Store of each shader (The can be looked up using effect.key)
  34921. */
  34922. static ShadersStore: {
  34923. [key: string]: string;
  34924. };
  34925. /**
  34926. * Store of each included file for a shader (The can be looked up using effect.key)
  34927. */
  34928. static IncludesShadersStore: {
  34929. [key: string]: string;
  34930. };
  34931. /**
  34932. * Resets the cache of effects.
  34933. */
  34934. static ResetCache(): void;
  34935. }
  34936. }
  34937. declare module "babylonjs/Engines/engineCapabilities" {
  34938. /**
  34939. * Interface used to describe the capabilities of the engine relatively to the current browser
  34940. */
  34941. export interface EngineCapabilities {
  34942. /** Maximum textures units per fragment shader */
  34943. maxTexturesImageUnits: number;
  34944. /** Maximum texture units per vertex shader */
  34945. maxVertexTextureImageUnits: number;
  34946. /** Maximum textures units in the entire pipeline */
  34947. maxCombinedTexturesImageUnits: number;
  34948. /** Maximum texture size */
  34949. maxTextureSize: number;
  34950. /** Maximum texture samples */
  34951. maxSamples?: number;
  34952. /** Maximum cube texture size */
  34953. maxCubemapTextureSize: number;
  34954. /** Maximum render texture size */
  34955. maxRenderTextureSize: number;
  34956. /** Maximum number of vertex attributes */
  34957. maxVertexAttribs: number;
  34958. /** Maximum number of varyings */
  34959. maxVaryingVectors: number;
  34960. /** Maximum number of uniforms per vertex shader */
  34961. maxVertexUniformVectors: number;
  34962. /** Maximum number of uniforms per fragment shader */
  34963. maxFragmentUniformVectors: number;
  34964. /** Defines if standard derivates (dx/dy) are supported */
  34965. standardDerivatives: boolean;
  34966. /** Defines if s3tc texture compression is supported */
  34967. s3tc?: WEBGL_compressed_texture_s3tc;
  34968. /** Defines if pvrtc texture compression is supported */
  34969. pvrtc: any;
  34970. /** Defines if etc1 texture compression is supported */
  34971. etc1: any;
  34972. /** Defines if etc2 texture compression is supported */
  34973. etc2: any;
  34974. /** Defines if astc texture compression is supported */
  34975. astc: any;
  34976. /** Defines if float textures are supported */
  34977. textureFloat: boolean;
  34978. /** Defines if vertex array objects are supported */
  34979. vertexArrayObject: boolean;
  34980. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34981. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34982. /** Gets the maximum level of anisotropy supported */
  34983. maxAnisotropy: number;
  34984. /** Defines if instancing is supported */
  34985. instancedArrays: boolean;
  34986. /** Defines if 32 bits indices are supported */
  34987. uintIndices: boolean;
  34988. /** Defines if high precision shaders are supported */
  34989. highPrecisionShaderSupported: boolean;
  34990. /** Defines if depth reading in the fragment shader is supported */
  34991. fragmentDepthSupported: boolean;
  34992. /** Defines if float texture linear filtering is supported*/
  34993. textureFloatLinearFiltering: boolean;
  34994. /** Defines if rendering to float textures is supported */
  34995. textureFloatRender: boolean;
  34996. /** Defines if half float textures are supported*/
  34997. textureHalfFloat: boolean;
  34998. /** Defines if half float texture linear filtering is supported*/
  34999. textureHalfFloatLinearFiltering: boolean;
  35000. /** Defines if rendering to half float textures is supported */
  35001. textureHalfFloatRender: boolean;
  35002. /** Defines if textureLOD shader command is supported */
  35003. textureLOD: boolean;
  35004. /** Defines if draw buffers extension is supported */
  35005. drawBuffersExtension: boolean;
  35006. /** Defines if depth textures are supported */
  35007. depthTextureExtension: boolean;
  35008. /** Defines if float color buffer are supported */
  35009. colorBufferFloat: boolean;
  35010. /** Gets disjoint timer query extension (null if not supported) */
  35011. timerQuery?: EXT_disjoint_timer_query;
  35012. /** Defines if timestamp can be used with timer query */
  35013. canUseTimestampForTimerQuery: boolean;
  35014. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35015. multiview?: any;
  35016. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35017. oculusMultiview?: any;
  35018. /** Function used to let the system compiles shaders in background */
  35019. parallelShaderCompile?: {
  35020. COMPLETION_STATUS_KHR: number;
  35021. };
  35022. /** Max number of texture samples for MSAA */
  35023. maxMSAASamples: number;
  35024. /** Defines if the blend min max extension is supported */
  35025. blendMinMax: boolean;
  35026. }
  35027. }
  35028. declare module "babylonjs/States/depthCullingState" {
  35029. import { Nullable } from "babylonjs/types";
  35030. /**
  35031. * @hidden
  35032. **/
  35033. export class DepthCullingState {
  35034. private _isDepthTestDirty;
  35035. private _isDepthMaskDirty;
  35036. private _isDepthFuncDirty;
  35037. private _isCullFaceDirty;
  35038. private _isCullDirty;
  35039. private _isZOffsetDirty;
  35040. private _isFrontFaceDirty;
  35041. private _depthTest;
  35042. private _depthMask;
  35043. private _depthFunc;
  35044. private _cull;
  35045. private _cullFace;
  35046. private _zOffset;
  35047. private _frontFace;
  35048. /**
  35049. * Initializes the state.
  35050. */
  35051. constructor();
  35052. get isDirty(): boolean;
  35053. get zOffset(): number;
  35054. set zOffset(value: number);
  35055. get cullFace(): Nullable<number>;
  35056. set cullFace(value: Nullable<number>);
  35057. get cull(): Nullable<boolean>;
  35058. set cull(value: Nullable<boolean>);
  35059. get depthFunc(): Nullable<number>;
  35060. set depthFunc(value: Nullable<number>);
  35061. get depthMask(): boolean;
  35062. set depthMask(value: boolean);
  35063. get depthTest(): boolean;
  35064. set depthTest(value: boolean);
  35065. get frontFace(): Nullable<number>;
  35066. set frontFace(value: Nullable<number>);
  35067. reset(): void;
  35068. apply(gl: WebGLRenderingContext): void;
  35069. }
  35070. }
  35071. declare module "babylonjs/States/stencilState" {
  35072. /**
  35073. * @hidden
  35074. **/
  35075. export class StencilState {
  35076. /** 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 */
  35077. static readonly ALWAYS: number;
  35078. /** Passed to stencilOperation to specify that stencil value must be kept */
  35079. static readonly KEEP: number;
  35080. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35081. static readonly REPLACE: number;
  35082. private _isStencilTestDirty;
  35083. private _isStencilMaskDirty;
  35084. private _isStencilFuncDirty;
  35085. private _isStencilOpDirty;
  35086. private _stencilTest;
  35087. private _stencilMask;
  35088. private _stencilFunc;
  35089. private _stencilFuncRef;
  35090. private _stencilFuncMask;
  35091. private _stencilOpStencilFail;
  35092. private _stencilOpDepthFail;
  35093. private _stencilOpStencilDepthPass;
  35094. get isDirty(): boolean;
  35095. get stencilFunc(): number;
  35096. set stencilFunc(value: number);
  35097. get stencilFuncRef(): number;
  35098. set stencilFuncRef(value: number);
  35099. get stencilFuncMask(): number;
  35100. set stencilFuncMask(value: number);
  35101. get stencilOpStencilFail(): number;
  35102. set stencilOpStencilFail(value: number);
  35103. get stencilOpDepthFail(): number;
  35104. set stencilOpDepthFail(value: number);
  35105. get stencilOpStencilDepthPass(): number;
  35106. set stencilOpStencilDepthPass(value: number);
  35107. get stencilMask(): number;
  35108. set stencilMask(value: number);
  35109. get stencilTest(): boolean;
  35110. set stencilTest(value: boolean);
  35111. constructor();
  35112. reset(): void;
  35113. apply(gl: WebGLRenderingContext): void;
  35114. }
  35115. }
  35116. declare module "babylonjs/States/alphaCullingState" {
  35117. /**
  35118. * @hidden
  35119. **/
  35120. export class AlphaState {
  35121. private _isAlphaBlendDirty;
  35122. private _isBlendFunctionParametersDirty;
  35123. private _isBlendEquationParametersDirty;
  35124. private _isBlendConstantsDirty;
  35125. private _alphaBlend;
  35126. private _blendFunctionParameters;
  35127. private _blendEquationParameters;
  35128. private _blendConstants;
  35129. /**
  35130. * Initializes the state.
  35131. */
  35132. constructor();
  35133. get isDirty(): boolean;
  35134. get alphaBlend(): boolean;
  35135. set alphaBlend(value: boolean);
  35136. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35137. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35138. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35139. reset(): void;
  35140. apply(gl: WebGLRenderingContext): void;
  35141. }
  35142. }
  35143. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35144. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35145. /** @hidden */
  35146. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35147. attributeProcessor(attribute: string): string;
  35148. varyingProcessor(varying: string, isFragment: boolean): string;
  35149. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35150. }
  35151. }
  35152. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35153. /**
  35154. * Interface for attribute information associated with buffer instanciation
  35155. */
  35156. export interface InstancingAttributeInfo {
  35157. /**
  35158. * Name of the GLSL attribute
  35159. * if attribute index is not specified, this is used to retrieve the index from the effect
  35160. */
  35161. attributeName: string;
  35162. /**
  35163. * Index/offset of the attribute in the vertex shader
  35164. * if not specified, this will be computes from the name.
  35165. */
  35166. index?: number;
  35167. /**
  35168. * size of the attribute, 1, 2, 3 or 4
  35169. */
  35170. attributeSize: number;
  35171. /**
  35172. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35173. */
  35174. offset: number;
  35175. /**
  35176. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35177. * default to 1
  35178. */
  35179. divisor?: number;
  35180. /**
  35181. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35182. * default is FLOAT
  35183. */
  35184. attributeType?: number;
  35185. /**
  35186. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35187. */
  35188. normalized?: boolean;
  35189. }
  35190. }
  35191. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35193. import { Nullable } from "babylonjs/types";
  35194. module "babylonjs/Engines/thinEngine" {
  35195. interface ThinEngine {
  35196. /**
  35197. * Update a video texture
  35198. * @param texture defines the texture to update
  35199. * @param video defines the video element to use
  35200. * @param invertY defines if data must be stored with Y axis inverted
  35201. */
  35202. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35203. }
  35204. }
  35205. }
  35206. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35208. import { Nullable } from "babylonjs/types";
  35209. module "babylonjs/Engines/thinEngine" {
  35210. interface ThinEngine {
  35211. /**
  35212. * Creates a dynamic texture
  35213. * @param width defines the width of the texture
  35214. * @param height defines the height of the texture
  35215. * @param generateMipMaps defines if the engine should generate the mip levels
  35216. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35217. * @returns the dynamic texture inside an InternalTexture
  35218. */
  35219. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35220. /**
  35221. * Update the content of a dynamic texture
  35222. * @param texture defines the texture to update
  35223. * @param canvas defines the canvas containing the source
  35224. * @param invertY defines if data must be stored with Y axis inverted
  35225. * @param premulAlpha defines if alpha is stored as premultiplied
  35226. * @param format defines the format of the data
  35227. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35228. */
  35229. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35230. }
  35231. }
  35232. }
  35233. declare module "babylonjs/Materials/Textures/videoTexture" {
  35234. import { Observable } from "babylonjs/Misc/observable";
  35235. import { Nullable } from "babylonjs/types";
  35236. import { Scene } from "babylonjs/scene";
  35237. import { Texture } from "babylonjs/Materials/Textures/texture";
  35238. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35239. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35240. /**
  35241. * Settings for finer control over video usage
  35242. */
  35243. export interface VideoTextureSettings {
  35244. /**
  35245. * Applies `autoplay` to video, if specified
  35246. */
  35247. autoPlay?: boolean;
  35248. /**
  35249. * Applies `loop` to video, if specified
  35250. */
  35251. loop?: boolean;
  35252. /**
  35253. * Automatically updates internal texture from video at every frame in the render loop
  35254. */
  35255. autoUpdateTexture: boolean;
  35256. /**
  35257. * Image src displayed during the video loading or until the user interacts with the video.
  35258. */
  35259. poster?: string;
  35260. }
  35261. /**
  35262. * If you want to display a video in your scene, this is the special texture for that.
  35263. * This special texture works similar to other textures, with the exception of a few parameters.
  35264. * @see https://doc.babylonjs.com/how_to/video_texture
  35265. */
  35266. export class VideoTexture extends Texture {
  35267. /**
  35268. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35269. */
  35270. readonly autoUpdateTexture: boolean;
  35271. /**
  35272. * The video instance used by the texture internally
  35273. */
  35274. readonly video: HTMLVideoElement;
  35275. private _onUserActionRequestedObservable;
  35276. /**
  35277. * Event triggerd when a dom action is required by the user to play the video.
  35278. * This happens due to recent changes in browser policies preventing video to auto start.
  35279. */
  35280. get onUserActionRequestedObservable(): Observable<Texture>;
  35281. private _generateMipMaps;
  35282. private _stillImageCaptured;
  35283. private _displayingPosterTexture;
  35284. private _settings;
  35285. private _createInternalTextureOnEvent;
  35286. private _frameId;
  35287. private _currentSrc;
  35288. /**
  35289. * Creates a video texture.
  35290. * If you want to display a video in your scene, this is the special texture for that.
  35291. * This special texture works similar to other textures, with the exception of a few parameters.
  35292. * @see https://doc.babylonjs.com/how_to/video_texture
  35293. * @param name optional name, will detect from video source, if not defined
  35294. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35295. * @param scene is obviously the current scene.
  35296. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35297. * @param invertY is false by default but can be used to invert video on Y axis
  35298. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35299. * @param settings allows finer control over video usage
  35300. */
  35301. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35302. private _getName;
  35303. private _getVideo;
  35304. private _createInternalTexture;
  35305. private reset;
  35306. /**
  35307. * @hidden Internal method to initiate `update`.
  35308. */
  35309. _rebuild(): void;
  35310. /**
  35311. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35312. */
  35313. update(): void;
  35314. /**
  35315. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35316. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35317. */
  35318. updateTexture(isVisible: boolean): void;
  35319. protected _updateInternalTexture: () => void;
  35320. /**
  35321. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35322. * @param url New url.
  35323. */
  35324. updateURL(url: string): void;
  35325. /**
  35326. * Clones the texture.
  35327. * @returns the cloned texture
  35328. */
  35329. clone(): VideoTexture;
  35330. /**
  35331. * Dispose the texture and release its associated resources.
  35332. */
  35333. dispose(): void;
  35334. /**
  35335. * Creates a video texture straight from a stream.
  35336. * @param scene Define the scene the texture should be created in
  35337. * @param stream Define the stream the texture should be created from
  35338. * @returns The created video texture as a promise
  35339. */
  35340. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35341. /**
  35342. * Creates a video texture straight from your WebCam video feed.
  35343. * @param scene Define the scene the texture should be created in
  35344. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35345. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35346. * @returns The created video texture as a promise
  35347. */
  35348. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35349. minWidth: number;
  35350. maxWidth: number;
  35351. minHeight: number;
  35352. maxHeight: number;
  35353. deviceId: string;
  35354. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35355. /**
  35356. * Creates a video texture straight from your WebCam video feed.
  35357. * @param scene Define the scene the texture should be created in
  35358. * @param onReady Define a callback to triggered once the texture will be ready
  35359. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35360. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35361. */
  35362. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35363. minWidth: number;
  35364. maxWidth: number;
  35365. minHeight: number;
  35366. maxHeight: number;
  35367. deviceId: string;
  35368. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35369. }
  35370. }
  35371. declare module "babylonjs/Engines/thinEngine" {
  35372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35373. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35374. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35376. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35377. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35378. import { Observable } from "babylonjs/Misc/observable";
  35379. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35380. import { StencilState } from "babylonjs/States/stencilState";
  35381. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35383. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35385. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35386. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35387. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35389. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35392. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35393. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35394. import { WebRequest } from "babylonjs/Misc/webRequest";
  35395. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35396. /**
  35397. * Defines the interface used by objects working like Scene
  35398. * @hidden
  35399. */
  35400. export interface ISceneLike {
  35401. _addPendingData(data: any): void;
  35402. _removePendingData(data: any): void;
  35403. offlineProvider: IOfflineProvider;
  35404. }
  35405. /** Interface defining initialization parameters for Engine class */
  35406. export interface EngineOptions extends WebGLContextAttributes {
  35407. /**
  35408. * Defines if the engine should no exceed a specified device ratio
  35409. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35410. */
  35411. limitDeviceRatio?: number;
  35412. /**
  35413. * Defines if webvr should be enabled automatically
  35414. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35415. */
  35416. autoEnableWebVR?: boolean;
  35417. /**
  35418. * Defines if webgl2 should be turned off even if supported
  35419. * @see https://doc.babylonjs.com/features/webgl2
  35420. */
  35421. disableWebGL2Support?: boolean;
  35422. /**
  35423. * Defines if webaudio should be initialized as well
  35424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35425. */
  35426. audioEngine?: boolean;
  35427. /**
  35428. * Defines if animations should run using a deterministic lock step
  35429. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35430. */
  35431. deterministicLockstep?: boolean;
  35432. /** Defines the maximum steps to use with deterministic lock step mode */
  35433. lockstepMaxSteps?: number;
  35434. /** Defines the seconds between each deterministic lock step */
  35435. timeStep?: number;
  35436. /**
  35437. * Defines that engine should ignore context lost events
  35438. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35439. */
  35440. doNotHandleContextLost?: boolean;
  35441. /**
  35442. * Defines that engine should ignore modifying touch action attribute and style
  35443. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35444. */
  35445. doNotHandleTouchAction?: boolean;
  35446. /**
  35447. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35448. */
  35449. useHighPrecisionFloats?: boolean;
  35450. /**
  35451. * Make the canvas XR Compatible for XR sessions
  35452. */
  35453. xrCompatible?: boolean;
  35454. }
  35455. /**
  35456. * The base engine class (root of all engines)
  35457. */
  35458. export class ThinEngine {
  35459. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35460. static ExceptionList: ({
  35461. key: string;
  35462. capture: string;
  35463. captureConstraint: number;
  35464. targets: string[];
  35465. } | {
  35466. key: string;
  35467. capture: null;
  35468. captureConstraint: null;
  35469. targets: string[];
  35470. })[];
  35471. /** @hidden */
  35472. static _TextureLoaders: IInternalTextureLoader[];
  35473. /**
  35474. * Returns the current npm package of the sdk
  35475. */
  35476. static get NpmPackage(): string;
  35477. /**
  35478. * Returns the current version of the framework
  35479. */
  35480. static get Version(): string;
  35481. /**
  35482. * Returns a string describing the current engine
  35483. */
  35484. get description(): string;
  35485. /**
  35486. * Gets or sets the epsilon value used by collision engine
  35487. */
  35488. static CollisionsEpsilon: number;
  35489. /**
  35490. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35491. */
  35492. static get ShadersRepository(): string;
  35493. static set ShadersRepository(value: string);
  35494. /** @hidden */
  35495. _shaderProcessor: IShaderProcessor;
  35496. /**
  35497. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35498. */
  35499. forcePOTTextures: boolean;
  35500. /**
  35501. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35502. */
  35503. isFullscreen: boolean;
  35504. /**
  35505. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35506. */
  35507. cullBackFaces: boolean;
  35508. /**
  35509. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35510. */
  35511. renderEvenInBackground: boolean;
  35512. /**
  35513. * Gets or sets a boolean indicating that cache can be kept between frames
  35514. */
  35515. preventCacheWipeBetweenFrames: boolean;
  35516. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35517. validateShaderPrograms: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35520. * This can provide greater z depth for distant objects.
  35521. */
  35522. useReverseDepthBuffer: boolean;
  35523. /**
  35524. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35525. */
  35526. disableUniformBuffers: boolean;
  35527. /** @hidden */
  35528. _uniformBuffers: UniformBuffer[];
  35529. /**
  35530. * Gets a boolean indicating that the engine supports uniform buffers
  35531. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35532. */
  35533. get supportsUniformBuffers(): boolean;
  35534. /** @hidden */
  35535. _gl: WebGLRenderingContext;
  35536. /** @hidden */
  35537. _webGLVersion: number;
  35538. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35539. protected _windowIsBackground: boolean;
  35540. protected _creationOptions: EngineOptions;
  35541. protected _highPrecisionShadersAllowed: boolean;
  35542. /** @hidden */
  35543. get _shouldUseHighPrecisionShader(): boolean;
  35544. /**
  35545. * Gets a boolean indicating that only power of 2 textures are supported
  35546. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35547. */
  35548. get needPOTTextures(): boolean;
  35549. /** @hidden */
  35550. _badOS: boolean;
  35551. /** @hidden */
  35552. _badDesktopOS: boolean;
  35553. private _hardwareScalingLevel;
  35554. /** @hidden */
  35555. _caps: EngineCapabilities;
  35556. private _isStencilEnable;
  35557. private _glVersion;
  35558. private _glRenderer;
  35559. private _glVendor;
  35560. /** @hidden */
  35561. _videoTextureSupported: boolean;
  35562. protected _renderingQueueLaunched: boolean;
  35563. protected _activeRenderLoops: (() => void)[];
  35564. /**
  35565. * Observable signaled when a context lost event is raised
  35566. */
  35567. onContextLostObservable: Observable<ThinEngine>;
  35568. /**
  35569. * Observable signaled when a context restored event is raised
  35570. */
  35571. onContextRestoredObservable: Observable<ThinEngine>;
  35572. private _onContextLost;
  35573. private _onContextRestored;
  35574. protected _contextWasLost: boolean;
  35575. /** @hidden */
  35576. _doNotHandleContextLost: boolean;
  35577. /**
  35578. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35580. */
  35581. get doNotHandleContextLost(): boolean;
  35582. set doNotHandleContextLost(value: boolean);
  35583. /**
  35584. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35585. */
  35586. disableVertexArrayObjects: boolean;
  35587. /** @hidden */
  35588. protected _colorWrite: boolean;
  35589. /** @hidden */
  35590. protected _colorWriteChanged: boolean;
  35591. /** @hidden */
  35592. protected _depthCullingState: DepthCullingState;
  35593. /** @hidden */
  35594. protected _stencilState: StencilState;
  35595. /** @hidden */
  35596. _alphaState: AlphaState;
  35597. /** @hidden */
  35598. _alphaMode: number;
  35599. /** @hidden */
  35600. _alphaEquation: number;
  35601. /** @hidden */
  35602. _internalTexturesCache: InternalTexture[];
  35603. /** @hidden */
  35604. protected _activeChannel: number;
  35605. private _currentTextureChannel;
  35606. /** @hidden */
  35607. protected _boundTexturesCache: {
  35608. [key: string]: Nullable<InternalTexture>;
  35609. };
  35610. /** @hidden */
  35611. protected _currentEffect: Nullable<Effect>;
  35612. /** @hidden */
  35613. protected _currentProgram: Nullable<WebGLProgram>;
  35614. private _compiledEffects;
  35615. private _vertexAttribArraysEnabled;
  35616. /** @hidden */
  35617. protected _cachedViewport: Nullable<IViewportLike>;
  35618. private _cachedVertexArrayObject;
  35619. /** @hidden */
  35620. protected _cachedVertexBuffers: any;
  35621. /** @hidden */
  35622. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35623. /** @hidden */
  35624. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35625. /** @hidden */
  35626. _currentRenderTarget: Nullable<InternalTexture>;
  35627. private _uintIndicesCurrentlySet;
  35628. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35629. /** @hidden */
  35630. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35631. /** @hidden */
  35632. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35633. private _currentBufferPointers;
  35634. private _currentInstanceLocations;
  35635. private _currentInstanceBuffers;
  35636. private _textureUnits;
  35637. /** @hidden */
  35638. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35639. /** @hidden */
  35640. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35641. /** @hidden */
  35642. _boundRenderFunction: any;
  35643. private _vaoRecordInProgress;
  35644. private _mustWipeVertexAttributes;
  35645. private _emptyTexture;
  35646. private _emptyCubeTexture;
  35647. private _emptyTexture3D;
  35648. private _emptyTexture2DArray;
  35649. /** @hidden */
  35650. _frameHandler: number;
  35651. private _nextFreeTextureSlots;
  35652. private _maxSimultaneousTextures;
  35653. private _activeRequests;
  35654. /** @hidden */
  35655. _transformTextureUrl: Nullable<(url: string) => string>;
  35656. protected get _supportsHardwareTextureRescaling(): boolean;
  35657. private _framebufferDimensionsObject;
  35658. /**
  35659. * sets the object from which width and height will be taken from when getting render width and height
  35660. * Will fallback to the gl object
  35661. * @param dimensions the framebuffer width and height that will be used.
  35662. */
  35663. set framebufferDimensionsObject(dimensions: Nullable<{
  35664. framebufferWidth: number;
  35665. framebufferHeight: number;
  35666. }>);
  35667. /**
  35668. * Gets the current viewport
  35669. */
  35670. get currentViewport(): Nullable<IViewportLike>;
  35671. /**
  35672. * Gets the default empty texture
  35673. */
  35674. get emptyTexture(): InternalTexture;
  35675. /**
  35676. * Gets the default empty 3D texture
  35677. */
  35678. get emptyTexture3D(): InternalTexture;
  35679. /**
  35680. * Gets the default empty 2D array texture
  35681. */
  35682. get emptyTexture2DArray(): InternalTexture;
  35683. /**
  35684. * Gets the default empty cube texture
  35685. */
  35686. get emptyCubeTexture(): InternalTexture;
  35687. /**
  35688. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35689. */
  35690. readonly premultipliedAlpha: boolean;
  35691. /**
  35692. * Observable event triggered before each texture is initialized
  35693. */
  35694. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35695. /**
  35696. * Creates a new engine
  35697. * @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
  35698. * @param antialias defines enable antialiasing (default: false)
  35699. * @param options defines further options to be sent to the getContext() function
  35700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35701. */
  35702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35703. private _rebuildInternalTextures;
  35704. private _rebuildEffects;
  35705. /**
  35706. * Gets a boolean indicating if all created effects are ready
  35707. * @returns true if all effects are ready
  35708. */
  35709. areAllEffectsReady(): boolean;
  35710. protected _rebuildBuffers(): void;
  35711. protected _initGLContext(): void;
  35712. /**
  35713. * Gets version of the current webGL context
  35714. */
  35715. get webGLVersion(): number;
  35716. /**
  35717. * Gets a string idenfifying the name of the class
  35718. * @returns "Engine" string
  35719. */
  35720. getClassName(): string;
  35721. /**
  35722. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35723. */
  35724. get isStencilEnable(): boolean;
  35725. /** @hidden */
  35726. _prepareWorkingCanvas(): void;
  35727. /**
  35728. * Reset the texture cache to empty state
  35729. */
  35730. resetTextureCache(): void;
  35731. /**
  35732. * Gets an object containing information about the current webGL context
  35733. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35734. */
  35735. getGlInfo(): {
  35736. vendor: string;
  35737. renderer: string;
  35738. version: string;
  35739. };
  35740. /**
  35741. * Defines the hardware scaling level.
  35742. * By default the hardware scaling level is computed from the window device ratio.
  35743. * 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.
  35744. * @param level defines the level to use
  35745. */
  35746. setHardwareScalingLevel(level: number): void;
  35747. /**
  35748. * Gets the current hardware scaling level.
  35749. * By default the hardware scaling level is computed from the window device ratio.
  35750. * 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.
  35751. * @returns a number indicating the current hardware scaling level
  35752. */
  35753. getHardwareScalingLevel(): number;
  35754. /**
  35755. * Gets the list of loaded textures
  35756. * @returns an array containing all loaded textures
  35757. */
  35758. getLoadedTexturesCache(): InternalTexture[];
  35759. /**
  35760. * Gets the object containing all engine capabilities
  35761. * @returns the EngineCapabilities object
  35762. */
  35763. getCaps(): EngineCapabilities;
  35764. /**
  35765. * stop executing a render loop function and remove it from the execution array
  35766. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35767. */
  35768. stopRenderLoop(renderFunction?: () => void): void;
  35769. /** @hidden */
  35770. _renderLoop(): void;
  35771. /**
  35772. * Gets the HTML canvas attached with the current webGL context
  35773. * @returns a HTML canvas
  35774. */
  35775. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35776. /**
  35777. * Gets host window
  35778. * @returns the host window object
  35779. */
  35780. getHostWindow(): Nullable<Window>;
  35781. /**
  35782. * Gets the current render width
  35783. * @param useScreen defines if screen size must be used (or the current render target if any)
  35784. * @returns a number defining the current render width
  35785. */
  35786. getRenderWidth(useScreen?: boolean): number;
  35787. /**
  35788. * Gets the current render height
  35789. * @param useScreen defines if screen size must be used (or the current render target if any)
  35790. * @returns a number defining the current render height
  35791. */
  35792. getRenderHeight(useScreen?: boolean): number;
  35793. /**
  35794. * Can be used to override the current requestAnimationFrame requester.
  35795. * @hidden
  35796. */
  35797. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35798. /**
  35799. * Register and execute a render loop. The engine can have more than one render function
  35800. * @param renderFunction defines the function to continuously execute
  35801. */
  35802. runRenderLoop(renderFunction: () => void): void;
  35803. /**
  35804. * Clear the current render buffer or the current render target (if any is set up)
  35805. * @param color defines the color to use
  35806. * @param backBuffer defines if the back buffer must be cleared
  35807. * @param depth defines if the depth buffer must be cleared
  35808. * @param stencil defines if the stencil buffer must be cleared
  35809. */
  35810. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35811. private _viewportCached;
  35812. /** @hidden */
  35813. _viewport(x: number, y: number, width: number, height: number): void;
  35814. /**
  35815. * Set the WebGL's viewport
  35816. * @param viewport defines the viewport element to be used
  35817. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35818. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35819. */
  35820. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35821. /**
  35822. * Begin a new frame
  35823. */
  35824. beginFrame(): void;
  35825. /**
  35826. * Enf the current frame
  35827. */
  35828. endFrame(): void;
  35829. /**
  35830. * Resize the view according to the canvas' size
  35831. */
  35832. resize(): void;
  35833. /**
  35834. * Force a specific size of the canvas
  35835. * @param width defines the new canvas' width
  35836. * @param height defines the new canvas' height
  35837. * @returns true if the size was changed
  35838. */
  35839. setSize(width: number, height: number): boolean;
  35840. /**
  35841. * Binds the frame buffer to the specified texture.
  35842. * @param texture The texture to render to or null for the default canvas
  35843. * @param faceIndex The face of the texture to render to in case of cube texture
  35844. * @param requiredWidth The width of the target to render to
  35845. * @param requiredHeight The height of the target to render to
  35846. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35847. * @param lodLevel defines the lod level to bind to the frame buffer
  35848. * @param layer defines the 2d array index to bind to frame buffer to
  35849. */
  35850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35851. /** @hidden */
  35852. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35853. /**
  35854. * Unbind the current render target texture from the webGL context
  35855. * @param texture defines the render target texture to unbind
  35856. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35857. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35858. */
  35859. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35860. /**
  35861. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35862. */
  35863. flushFramebuffer(): void;
  35864. /**
  35865. * Unbind the current render target and bind the default framebuffer
  35866. */
  35867. restoreDefaultFramebuffer(): void;
  35868. /** @hidden */
  35869. protected _resetVertexBufferBinding(): void;
  35870. /**
  35871. * Creates a vertex buffer
  35872. * @param data the data for the vertex buffer
  35873. * @returns the new WebGL static buffer
  35874. */
  35875. createVertexBuffer(data: DataArray): DataBuffer;
  35876. private _createVertexBuffer;
  35877. /**
  35878. * Creates a dynamic vertex buffer
  35879. * @param data the data for the dynamic vertex buffer
  35880. * @returns the new WebGL dynamic buffer
  35881. */
  35882. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35883. protected _resetIndexBufferBinding(): void;
  35884. /**
  35885. * Creates a new index buffer
  35886. * @param indices defines the content of the index buffer
  35887. * @param updatable defines if the index buffer must be updatable
  35888. * @returns a new webGL buffer
  35889. */
  35890. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35891. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35892. /**
  35893. * Bind a webGL buffer to the webGL context
  35894. * @param buffer defines the buffer to bind
  35895. */
  35896. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35897. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35898. private bindBuffer;
  35899. /**
  35900. * update the bound buffer with the given data
  35901. * @param data defines the data to update
  35902. */
  35903. updateArrayBuffer(data: Float32Array): void;
  35904. private _vertexAttribPointer;
  35905. /** @hidden */
  35906. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35907. private _bindVertexBuffersAttributes;
  35908. /**
  35909. * Records a vertex array object
  35910. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35911. * @param vertexBuffers defines the list of vertex buffers to store
  35912. * @param indexBuffer defines the index buffer to store
  35913. * @param effect defines the effect to store
  35914. * @returns the new vertex array object
  35915. */
  35916. recordVertexArrayObject(vertexBuffers: {
  35917. [key: string]: VertexBuffer;
  35918. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35919. /**
  35920. * Bind a specific vertex array object
  35921. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35922. * @param vertexArrayObject defines the vertex array object to bind
  35923. * @param indexBuffer defines the index buffer to bind
  35924. */
  35925. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35926. /**
  35927. * Bind webGl buffers directly to the webGL context
  35928. * @param vertexBuffer defines the vertex buffer to bind
  35929. * @param indexBuffer defines the index buffer to bind
  35930. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35931. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35932. * @param effect defines the effect associated with the vertex buffer
  35933. */
  35934. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35935. private _unbindVertexArrayObject;
  35936. /**
  35937. * Bind a list of vertex buffers to the webGL context
  35938. * @param vertexBuffers defines the list of vertex buffers to bind
  35939. * @param indexBuffer defines the index buffer to bind
  35940. * @param effect defines the effect associated with the vertex buffers
  35941. */
  35942. bindBuffers(vertexBuffers: {
  35943. [key: string]: Nullable<VertexBuffer>;
  35944. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35945. /**
  35946. * Unbind all instance attributes
  35947. */
  35948. unbindInstanceAttributes(): void;
  35949. /**
  35950. * Release and free the memory of a vertex array object
  35951. * @param vao defines the vertex array object to delete
  35952. */
  35953. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35954. /** @hidden */
  35955. _releaseBuffer(buffer: DataBuffer): boolean;
  35956. protected _deleteBuffer(buffer: DataBuffer): void;
  35957. /**
  35958. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35959. * @param instancesBuffer defines the webGL buffer to update and bind
  35960. * @param data defines the data to store in the buffer
  35961. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35962. */
  35963. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35964. /**
  35965. * Bind the content of a webGL buffer used with instantiation
  35966. * @param instancesBuffer defines the webGL buffer to bind
  35967. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35968. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35969. */
  35970. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35971. /**
  35972. * Disable the instance attribute corresponding to the name in parameter
  35973. * @param name defines the name of the attribute to disable
  35974. */
  35975. disableInstanceAttributeByName(name: string): void;
  35976. /**
  35977. * Disable the instance attribute corresponding to the location in parameter
  35978. * @param attributeLocation defines the attribute location of the attribute to disable
  35979. */
  35980. disableInstanceAttribute(attributeLocation: number): void;
  35981. /**
  35982. * Disable the attribute corresponding to the location in parameter
  35983. * @param attributeLocation defines the attribute location of the attribute to disable
  35984. */
  35985. disableAttributeByIndex(attributeLocation: number): void;
  35986. /**
  35987. * Send a draw order
  35988. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35989. * @param indexStart defines the starting index
  35990. * @param indexCount defines the number of index to draw
  35991. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35992. */
  35993. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35994. /**
  35995. * Draw a list of points
  35996. * @param verticesStart defines the index of first vertex to draw
  35997. * @param verticesCount defines the count of vertices to draw
  35998. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35999. */
  36000. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36001. /**
  36002. * Draw a list of unindexed primitives
  36003. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36004. * @param verticesStart defines the index of first vertex to draw
  36005. * @param verticesCount defines the count of vertices to draw
  36006. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36007. */
  36008. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36009. /**
  36010. * Draw a list of indexed primitives
  36011. * @param fillMode defines the primitive to use
  36012. * @param indexStart defines the starting index
  36013. * @param indexCount defines the number of index to draw
  36014. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36015. */
  36016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36017. /**
  36018. * Draw a list of unindexed primitives
  36019. * @param fillMode defines the primitive to use
  36020. * @param verticesStart defines the index of first vertex to draw
  36021. * @param verticesCount defines the count of vertices to draw
  36022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36023. */
  36024. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36025. private _drawMode;
  36026. /** @hidden */
  36027. protected _reportDrawCall(): void;
  36028. /** @hidden */
  36029. _releaseEffect(effect: Effect): void;
  36030. /** @hidden */
  36031. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36032. /**
  36033. * Create a new effect (used to store vertex/fragment shaders)
  36034. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36035. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36036. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36037. * @param samplers defines an array of string used to represent textures
  36038. * @param defines defines the string containing the defines to use to compile the shaders
  36039. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36040. * @param onCompiled defines a function to call when the effect creation is successful
  36041. * @param onError defines a function to call when the effect creation has failed
  36042. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36043. * @returns the new Effect
  36044. */
  36045. 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;
  36046. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36047. private _compileShader;
  36048. private _compileRawShader;
  36049. /** @hidden */
  36050. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36051. /**
  36052. * Directly creates a webGL program
  36053. * @param pipelineContext defines the pipeline context to attach to
  36054. * @param vertexCode defines the vertex shader code to use
  36055. * @param fragmentCode defines the fragment shader code to use
  36056. * @param context defines the webGL context to use (if not set, the current one will be used)
  36057. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36058. * @returns the new webGL program
  36059. */
  36060. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36061. /**
  36062. * Creates a webGL program
  36063. * @param pipelineContext defines the pipeline context to attach to
  36064. * @param vertexCode defines the vertex shader code to use
  36065. * @param fragmentCode defines the fragment shader code to use
  36066. * @param defines defines the string containing the defines to use to compile the shaders
  36067. * @param context defines the webGL context to use (if not set, the current one will be used)
  36068. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36069. * @returns the new webGL program
  36070. */
  36071. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36072. /**
  36073. * Creates a new pipeline context
  36074. * @returns the new pipeline
  36075. */
  36076. createPipelineContext(): IPipelineContext;
  36077. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36078. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36079. /** @hidden */
  36080. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36081. /** @hidden */
  36082. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36083. /** @hidden */
  36084. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36085. /**
  36086. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36087. * @param pipelineContext defines the pipeline context to use
  36088. * @param uniformsNames defines the list of uniform names
  36089. * @returns an array of webGL uniform locations
  36090. */
  36091. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36092. /**
  36093. * Gets the lsit of active attributes for a given webGL program
  36094. * @param pipelineContext defines the pipeline context to use
  36095. * @param attributesNames defines the list of attribute names to get
  36096. * @returns an array of indices indicating the offset of each attribute
  36097. */
  36098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36099. /**
  36100. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36101. * @param effect defines the effect to activate
  36102. */
  36103. enableEffect(effect: Nullable<Effect>): void;
  36104. /**
  36105. * Set the value of an uniform to a number (int)
  36106. * @param uniform defines the webGL uniform location where to store the value
  36107. * @param value defines the int number to store
  36108. */
  36109. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36110. /**
  36111. * Set the value of an uniform to an array of int32
  36112. * @param uniform defines the webGL uniform location where to store the value
  36113. * @param array defines the array of int32 to store
  36114. */
  36115. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36116. /**
  36117. * Set the value of an uniform to an array of int32 (stored as vec2)
  36118. * @param uniform defines the webGL uniform location where to store the value
  36119. * @param array defines the array of int32 to store
  36120. */
  36121. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36122. /**
  36123. * Set the value of an uniform to an array of int32 (stored as vec3)
  36124. * @param uniform defines the webGL uniform location where to store the value
  36125. * @param array defines the array of int32 to store
  36126. */
  36127. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36128. /**
  36129. * Set the value of an uniform to an array of int32 (stored as vec4)
  36130. * @param uniform defines the webGL uniform location where to store the value
  36131. * @param array defines the array of int32 to store
  36132. */
  36133. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36134. /**
  36135. * Set the value of an uniform to an array of number
  36136. * @param uniform defines the webGL uniform location where to store the value
  36137. * @param array defines the array of number to store
  36138. */
  36139. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36140. /**
  36141. * Set the value of an uniform to an array of number (stored as vec2)
  36142. * @param uniform defines the webGL uniform location where to store the value
  36143. * @param array defines the array of number to store
  36144. */
  36145. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36146. /**
  36147. * Set the value of an uniform to an array of number (stored as vec3)
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param array defines the array of number to store
  36150. */
  36151. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36152. /**
  36153. * Set the value of an uniform to an array of number (stored as vec4)
  36154. * @param uniform defines the webGL uniform location where to store the value
  36155. * @param array defines the array of number to store
  36156. */
  36157. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36158. /**
  36159. * Set the value of an uniform to an array of float32 (stored as matrices)
  36160. * @param uniform defines the webGL uniform location where to store the value
  36161. * @param matrices defines the array of float32 to store
  36162. */
  36163. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36164. /**
  36165. * Set the value of an uniform to a matrix (3x3)
  36166. * @param uniform defines the webGL uniform location where to store the value
  36167. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36168. */
  36169. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36170. /**
  36171. * Set the value of an uniform to a matrix (2x2)
  36172. * @param uniform defines the webGL uniform location where to store the value
  36173. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36174. */
  36175. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36176. /**
  36177. * Set the value of an uniform to a number (float)
  36178. * @param uniform defines the webGL uniform location where to store the value
  36179. * @param value defines the float number to store
  36180. */
  36181. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36182. /**
  36183. * Set the value of an uniform to a vec2
  36184. * @param uniform defines the webGL uniform location where to store the value
  36185. * @param x defines the 1st component of the value
  36186. * @param y defines the 2nd component of the value
  36187. */
  36188. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36189. /**
  36190. * Set the value of an uniform to a vec3
  36191. * @param uniform defines the webGL uniform location where to store the value
  36192. * @param x defines the 1st component of the value
  36193. * @param y defines the 2nd component of the value
  36194. * @param z defines the 3rd component of the value
  36195. */
  36196. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36197. /**
  36198. * Set the value of an uniform to a vec4
  36199. * @param uniform defines the webGL uniform location where to store the value
  36200. * @param x defines the 1st component of the value
  36201. * @param y defines the 2nd component of the value
  36202. * @param z defines the 3rd component of the value
  36203. * @param w defines the 4th component of the value
  36204. */
  36205. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36206. /**
  36207. * Apply all cached states (depth, culling, stencil and alpha)
  36208. */
  36209. applyStates(): void;
  36210. /**
  36211. * Enable or disable color writing
  36212. * @param enable defines the state to set
  36213. */
  36214. setColorWrite(enable: boolean): void;
  36215. /**
  36216. * Gets a boolean indicating if color writing is enabled
  36217. * @returns the current color writing state
  36218. */
  36219. getColorWrite(): boolean;
  36220. /**
  36221. * Gets the depth culling state manager
  36222. */
  36223. get depthCullingState(): DepthCullingState;
  36224. /**
  36225. * Gets the alpha state manager
  36226. */
  36227. get alphaState(): AlphaState;
  36228. /**
  36229. * Gets the stencil state manager
  36230. */
  36231. get stencilState(): StencilState;
  36232. /**
  36233. * Clears the list of texture accessible through engine.
  36234. * This can help preventing texture load conflict due to name collision.
  36235. */
  36236. clearInternalTexturesCache(): void;
  36237. /**
  36238. * Force the entire cache to be cleared
  36239. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36240. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36241. */
  36242. wipeCaches(bruteForce?: boolean): void;
  36243. /** @hidden */
  36244. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36245. min: number;
  36246. mag: number;
  36247. };
  36248. /** @hidden */
  36249. _createTexture(): WebGLTexture;
  36250. /**
  36251. * Usually called from Texture.ts.
  36252. * Passed information to create a WebGLTexture
  36253. * @param url defines a value which contains one of the following:
  36254. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36255. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36256. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36257. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36258. * @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)
  36259. * @param scene needed for loading to the correct scene
  36260. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36261. * @param onLoad optional callback to be called upon successful completion
  36262. * @param onError optional callback to be called upon failure
  36263. * @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
  36264. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36265. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36266. * @param forcedExtension defines the extension to use to pick the right loader
  36267. * @param mimeType defines an optional mime type
  36268. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36269. */
  36270. 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;
  36271. /**
  36272. * Loads an image as an HTMLImageElement.
  36273. * @param input url string, ArrayBuffer, or Blob to load
  36274. * @param onLoad callback called when the image successfully loads
  36275. * @param onError callback called when the image fails to load
  36276. * @param offlineProvider offline provider for caching
  36277. * @param mimeType optional mime type
  36278. * @returns the HTMLImageElement of the loaded image
  36279. * @hidden
  36280. */
  36281. 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>;
  36282. /**
  36283. * @hidden
  36284. */
  36285. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36286. private _unpackFlipYCached;
  36287. /**
  36288. * In case you are sharing the context with other applications, it might
  36289. * be interested to not cache the unpack flip y state to ensure a consistent
  36290. * value would be set.
  36291. */
  36292. enableUnpackFlipYCached: boolean;
  36293. /** @hidden */
  36294. _unpackFlipY(value: boolean): void;
  36295. /** @hidden */
  36296. _getUnpackAlignement(): number;
  36297. private _getTextureTarget;
  36298. /**
  36299. * Update the sampling mode of a given texture
  36300. * @param samplingMode defines the required sampling mode
  36301. * @param texture defines the texture to update
  36302. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36303. */
  36304. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36305. /**
  36306. * Update the sampling mode of a given texture
  36307. * @param texture defines the texture to update
  36308. * @param wrapU defines the texture wrap mode of the u coordinates
  36309. * @param wrapV defines the texture wrap mode of the v coordinates
  36310. * @param wrapR defines the texture wrap mode of the r coordinates
  36311. */
  36312. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36313. /** @hidden */
  36314. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36315. width: number;
  36316. height: number;
  36317. layers?: number;
  36318. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36319. /** @hidden */
  36320. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36321. /** @hidden */
  36322. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36323. /**
  36324. * Update a portion of an internal texture
  36325. * @param texture defines the texture to update
  36326. * @param imageData defines the data to store into the texture
  36327. * @param xOffset defines the x coordinates of the update rectangle
  36328. * @param yOffset defines the y coordinates of the update rectangle
  36329. * @param width defines the width of the update rectangle
  36330. * @param height defines the height of the update rectangle
  36331. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36332. * @param lod defines the lod level to update (0 by default)
  36333. */
  36334. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36335. /** @hidden */
  36336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36337. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36338. private _prepareWebGLTexture;
  36339. /** @hidden */
  36340. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36341. private _getDepthStencilBuffer;
  36342. /** @hidden */
  36343. _releaseFramebufferObjects(texture: InternalTexture): void;
  36344. /** @hidden */
  36345. _releaseTexture(texture: InternalTexture): void;
  36346. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36347. protected _setProgram(program: WebGLProgram): void;
  36348. protected _boundUniforms: {
  36349. [key: number]: WebGLUniformLocation;
  36350. };
  36351. /**
  36352. * Binds an effect to the webGL context
  36353. * @param effect defines the effect to bind
  36354. */
  36355. bindSamplers(effect: Effect): void;
  36356. private _activateCurrentTexture;
  36357. /** @hidden */
  36358. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36359. /** @hidden */
  36360. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36361. /**
  36362. * Unbind all textures from the webGL context
  36363. */
  36364. unbindAllTextures(): void;
  36365. /**
  36366. * Sets a texture to the according uniform.
  36367. * @param channel The texture channel
  36368. * @param uniform The uniform to set
  36369. * @param texture The texture to apply
  36370. */
  36371. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36372. private _bindSamplerUniformToChannel;
  36373. private _getTextureWrapMode;
  36374. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36375. /**
  36376. * Sets an array of texture to the webGL context
  36377. * @param channel defines the channel where the texture array must be set
  36378. * @param uniform defines the associated uniform location
  36379. * @param textures defines the array of textures to bind
  36380. */
  36381. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36382. /** @hidden */
  36383. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36384. private _setTextureParameterFloat;
  36385. private _setTextureParameterInteger;
  36386. /**
  36387. * Unbind all vertex attributes from the webGL context
  36388. */
  36389. unbindAllAttributes(): void;
  36390. /**
  36391. * 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
  36392. */
  36393. releaseEffects(): void;
  36394. /**
  36395. * Dispose and release all associated resources
  36396. */
  36397. dispose(): void;
  36398. /**
  36399. * Attach a new callback raised when context lost event is fired
  36400. * @param callback defines the callback to call
  36401. */
  36402. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36403. /**
  36404. * Attach a new callback raised when context restored event is fired
  36405. * @param callback defines the callback to call
  36406. */
  36407. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36408. /**
  36409. * Get the current error code of the webGL context
  36410. * @returns the error code
  36411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36412. */
  36413. getError(): number;
  36414. private _canRenderToFloatFramebuffer;
  36415. private _canRenderToHalfFloatFramebuffer;
  36416. private _canRenderToFramebuffer;
  36417. /** @hidden */
  36418. _getWebGLTextureType(type: number): number;
  36419. /** @hidden */
  36420. _getInternalFormat(format: number): number;
  36421. /** @hidden */
  36422. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36423. /** @hidden */
  36424. _getRGBAMultiSampleBufferFormat(type: number): number;
  36425. /** @hidden */
  36426. _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;
  36427. /**
  36428. * Loads a file from a url
  36429. * @param url url to load
  36430. * @param onSuccess callback called when the file successfully loads
  36431. * @param onProgress callback called while file is loading (if the server supports this mode)
  36432. * @param offlineProvider defines the offline provider for caching
  36433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36434. * @param onError callback called when the file fails to load
  36435. * @returns a file request object
  36436. * @hidden
  36437. */
  36438. 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;
  36439. /**
  36440. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36441. * @param x defines the x coordinate of the rectangle where pixels must be read
  36442. * @param y defines the y coordinate of the rectangle where pixels must be read
  36443. * @param width defines the width of the rectangle where pixels must be read
  36444. * @param height defines the height of the rectangle where pixels must be read
  36445. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36446. * @returns a Uint8Array containing RGBA colors
  36447. */
  36448. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36449. private static _isSupported;
  36450. /**
  36451. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36452. * @returns true if the engine can be created
  36453. * @ignorenaming
  36454. */
  36455. static isSupported(): boolean;
  36456. /**
  36457. * Find the next highest power of two.
  36458. * @param x Number to start search from.
  36459. * @return Next highest power of two.
  36460. */
  36461. static CeilingPOT(x: number): number;
  36462. /**
  36463. * Find the next lowest power of two.
  36464. * @param x Number to start search from.
  36465. * @return Next lowest power of two.
  36466. */
  36467. static FloorPOT(x: number): number;
  36468. /**
  36469. * Find the nearest power of two.
  36470. * @param x Number to start search from.
  36471. * @return Next nearest power of two.
  36472. */
  36473. static NearestPOT(x: number): number;
  36474. /**
  36475. * Get the closest exponent of two
  36476. * @param value defines the value to approximate
  36477. * @param max defines the maximum value to return
  36478. * @param mode defines how to define the closest value
  36479. * @returns closest exponent of two of the given value
  36480. */
  36481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36482. /**
  36483. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36484. * @param func - the function to be called
  36485. * @param requester - the object that will request the next frame. Falls back to window.
  36486. * @returns frame number
  36487. */
  36488. static QueueNewFrame(func: () => void, requester?: any): number;
  36489. /**
  36490. * Gets host document
  36491. * @returns the host document object
  36492. */
  36493. getHostDocument(): Nullable<Document>;
  36494. }
  36495. }
  36496. declare module "babylonjs/Maths/sphericalPolynomial" {
  36497. import { Vector3 } from "babylonjs/Maths/math.vector";
  36498. import { Color3 } from "babylonjs/Maths/math.color";
  36499. /**
  36500. * Class representing spherical harmonics coefficients to the 3rd degree
  36501. */
  36502. export class SphericalHarmonics {
  36503. /**
  36504. * Defines whether or not the harmonics have been prescaled for rendering.
  36505. */
  36506. preScaled: boolean;
  36507. /**
  36508. * The l0,0 coefficients of the spherical harmonics
  36509. */
  36510. l00: Vector3;
  36511. /**
  36512. * The l1,-1 coefficients of the spherical harmonics
  36513. */
  36514. l1_1: Vector3;
  36515. /**
  36516. * The l1,0 coefficients of the spherical harmonics
  36517. */
  36518. l10: Vector3;
  36519. /**
  36520. * The l1,1 coefficients of the spherical harmonics
  36521. */
  36522. l11: Vector3;
  36523. /**
  36524. * The l2,-2 coefficients of the spherical harmonics
  36525. */
  36526. l2_2: Vector3;
  36527. /**
  36528. * The l2,-1 coefficients of the spherical harmonics
  36529. */
  36530. l2_1: Vector3;
  36531. /**
  36532. * The l2,0 coefficients of the spherical harmonics
  36533. */
  36534. l20: Vector3;
  36535. /**
  36536. * The l2,1 coefficients of the spherical harmonics
  36537. */
  36538. l21: Vector3;
  36539. /**
  36540. * The l2,2 coefficients of the spherical harmonics
  36541. */
  36542. l22: Vector3;
  36543. /**
  36544. * Adds a light to the spherical harmonics
  36545. * @param direction the direction of the light
  36546. * @param color the color of the light
  36547. * @param deltaSolidAngle the delta solid angle of the light
  36548. */
  36549. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36550. /**
  36551. * Scales the spherical harmonics by the given amount
  36552. * @param scale the amount to scale
  36553. */
  36554. scaleInPlace(scale: number): void;
  36555. /**
  36556. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36557. *
  36558. * ```
  36559. * E_lm = A_l * L_lm
  36560. * ```
  36561. *
  36562. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36563. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36564. * the scaling factors are given in equation 9.
  36565. */
  36566. convertIncidentRadianceToIrradiance(): void;
  36567. /**
  36568. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36569. *
  36570. * ```
  36571. * L = (1/pi) * E * rho
  36572. * ```
  36573. *
  36574. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36575. */
  36576. convertIrradianceToLambertianRadiance(): void;
  36577. /**
  36578. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36579. * required operations at run time.
  36580. *
  36581. * This is simply done by scaling back the SH with Ylm constants parameter.
  36582. * The trigonometric part being applied by the shader at run time.
  36583. */
  36584. preScaleForRendering(): void;
  36585. /**
  36586. * Constructs a spherical harmonics from an array.
  36587. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36588. * @returns the spherical harmonics
  36589. */
  36590. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36591. /**
  36592. * Gets the spherical harmonics from polynomial
  36593. * @param polynomial the spherical polynomial
  36594. * @returns the spherical harmonics
  36595. */
  36596. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36597. }
  36598. /**
  36599. * Class representing spherical polynomial coefficients to the 3rd degree
  36600. */
  36601. export class SphericalPolynomial {
  36602. private _harmonics;
  36603. /**
  36604. * The spherical harmonics used to create the polynomials.
  36605. */
  36606. get preScaledHarmonics(): SphericalHarmonics;
  36607. /**
  36608. * The x coefficients of the spherical polynomial
  36609. */
  36610. x: Vector3;
  36611. /**
  36612. * The y coefficients of the spherical polynomial
  36613. */
  36614. y: Vector3;
  36615. /**
  36616. * The z coefficients of the spherical polynomial
  36617. */
  36618. z: Vector3;
  36619. /**
  36620. * The xx coefficients of the spherical polynomial
  36621. */
  36622. xx: Vector3;
  36623. /**
  36624. * The yy coefficients of the spherical polynomial
  36625. */
  36626. yy: Vector3;
  36627. /**
  36628. * The zz coefficients of the spherical polynomial
  36629. */
  36630. zz: Vector3;
  36631. /**
  36632. * The xy coefficients of the spherical polynomial
  36633. */
  36634. xy: Vector3;
  36635. /**
  36636. * The yz coefficients of the spherical polynomial
  36637. */
  36638. yz: Vector3;
  36639. /**
  36640. * The zx coefficients of the spherical polynomial
  36641. */
  36642. zx: Vector3;
  36643. /**
  36644. * Adds an ambient color to the spherical polynomial
  36645. * @param color the color to add
  36646. */
  36647. addAmbient(color: Color3): void;
  36648. /**
  36649. * Scales the spherical polynomial by the given amount
  36650. * @param scale the amount to scale
  36651. */
  36652. scaleInPlace(scale: number): void;
  36653. /**
  36654. * Gets the spherical polynomial from harmonics
  36655. * @param harmonics the spherical harmonics
  36656. * @returns the spherical polynomial
  36657. */
  36658. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36659. /**
  36660. * Constructs a spherical polynomial from an array.
  36661. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36662. * @returns the spherical polynomial
  36663. */
  36664. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36665. }
  36666. }
  36667. declare module "babylonjs/Materials/Textures/internalTexture" {
  36668. import { Observable } from "babylonjs/Misc/observable";
  36669. import { Nullable, int } from "babylonjs/types";
  36670. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36671. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36672. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36673. /**
  36674. * Defines the source of the internal texture
  36675. */
  36676. export enum InternalTextureSource {
  36677. /**
  36678. * The source of the texture data is unknown
  36679. */
  36680. Unknown = 0,
  36681. /**
  36682. * Texture data comes from an URL
  36683. */
  36684. Url = 1,
  36685. /**
  36686. * Texture data is only used for temporary storage
  36687. */
  36688. Temp = 2,
  36689. /**
  36690. * Texture data comes from raw data (ArrayBuffer)
  36691. */
  36692. Raw = 3,
  36693. /**
  36694. * Texture content is dynamic (video or dynamic texture)
  36695. */
  36696. Dynamic = 4,
  36697. /**
  36698. * Texture content is generated by rendering to it
  36699. */
  36700. RenderTarget = 5,
  36701. /**
  36702. * Texture content is part of a multi render target process
  36703. */
  36704. MultiRenderTarget = 6,
  36705. /**
  36706. * Texture data comes from a cube data file
  36707. */
  36708. Cube = 7,
  36709. /**
  36710. * Texture data comes from a raw cube data
  36711. */
  36712. CubeRaw = 8,
  36713. /**
  36714. * Texture data come from a prefiltered cube data file
  36715. */
  36716. CubePrefiltered = 9,
  36717. /**
  36718. * Texture content is raw 3D data
  36719. */
  36720. Raw3D = 10,
  36721. /**
  36722. * Texture content is raw 2D array data
  36723. */
  36724. Raw2DArray = 11,
  36725. /**
  36726. * Texture content is a depth texture
  36727. */
  36728. Depth = 12,
  36729. /**
  36730. * Texture data comes from a raw cube data encoded with RGBD
  36731. */
  36732. CubeRawRGBD = 13
  36733. }
  36734. /**
  36735. * Class used to store data associated with WebGL texture data for the engine
  36736. * This class should not be used directly
  36737. */
  36738. export class InternalTexture {
  36739. /** @hidden */
  36740. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36741. /**
  36742. * Defines if the texture is ready
  36743. */
  36744. isReady: boolean;
  36745. /**
  36746. * Defines if the texture is a cube texture
  36747. */
  36748. isCube: boolean;
  36749. /**
  36750. * Defines if the texture contains 3D data
  36751. */
  36752. is3D: boolean;
  36753. /**
  36754. * Defines if the texture contains 2D array data
  36755. */
  36756. is2DArray: boolean;
  36757. /**
  36758. * Defines if the texture contains multiview data
  36759. */
  36760. isMultiview: boolean;
  36761. /**
  36762. * Gets the URL used to load this texture
  36763. */
  36764. url: string;
  36765. /**
  36766. * Gets the sampling mode of the texture
  36767. */
  36768. samplingMode: number;
  36769. /**
  36770. * Gets a boolean indicating if the texture needs mipmaps generation
  36771. */
  36772. generateMipMaps: boolean;
  36773. /**
  36774. * Gets the number of samples used by the texture (WebGL2+ only)
  36775. */
  36776. samples: number;
  36777. /**
  36778. * Gets the type of the texture (int, float...)
  36779. */
  36780. type: number;
  36781. /**
  36782. * Gets the format of the texture (RGB, RGBA...)
  36783. */
  36784. format: number;
  36785. /**
  36786. * Observable called when the texture is loaded
  36787. */
  36788. onLoadedObservable: Observable<InternalTexture>;
  36789. /**
  36790. * Gets the width of the texture
  36791. */
  36792. width: number;
  36793. /**
  36794. * Gets the height of the texture
  36795. */
  36796. height: number;
  36797. /**
  36798. * Gets the depth of the texture
  36799. */
  36800. depth: number;
  36801. /**
  36802. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36803. */
  36804. baseWidth: number;
  36805. /**
  36806. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36807. */
  36808. baseHeight: number;
  36809. /**
  36810. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36811. */
  36812. baseDepth: number;
  36813. /**
  36814. * Gets a boolean indicating if the texture is inverted on Y axis
  36815. */
  36816. invertY: boolean;
  36817. /** @hidden */
  36818. _invertVScale: boolean;
  36819. /** @hidden */
  36820. _associatedChannel: number;
  36821. /** @hidden */
  36822. _source: InternalTextureSource;
  36823. /** @hidden */
  36824. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36825. /** @hidden */
  36826. _bufferView: Nullable<ArrayBufferView>;
  36827. /** @hidden */
  36828. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36829. /** @hidden */
  36830. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36831. /** @hidden */
  36832. _size: number;
  36833. /** @hidden */
  36834. _extension: string;
  36835. /** @hidden */
  36836. _files: Nullable<string[]>;
  36837. /** @hidden */
  36838. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36839. /** @hidden */
  36840. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36841. /** @hidden */
  36842. _framebuffer: Nullable<WebGLFramebuffer>;
  36843. /** @hidden */
  36844. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36845. /** @hidden */
  36846. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36847. /** @hidden */
  36848. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36849. /** @hidden */
  36850. _attachments: Nullable<number[]>;
  36851. /** @hidden */
  36852. _textureArray: Nullable<InternalTexture[]>;
  36853. /** @hidden */
  36854. _cachedCoordinatesMode: Nullable<number>;
  36855. /** @hidden */
  36856. _cachedWrapU: Nullable<number>;
  36857. /** @hidden */
  36858. _cachedWrapV: Nullable<number>;
  36859. /** @hidden */
  36860. _cachedWrapR: Nullable<number>;
  36861. /** @hidden */
  36862. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36863. /** @hidden */
  36864. _isDisabled: boolean;
  36865. /** @hidden */
  36866. _compression: Nullable<string>;
  36867. /** @hidden */
  36868. _generateStencilBuffer: boolean;
  36869. /** @hidden */
  36870. _generateDepthBuffer: boolean;
  36871. /** @hidden */
  36872. _comparisonFunction: number;
  36873. /** @hidden */
  36874. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36875. /** @hidden */
  36876. _lodGenerationScale: number;
  36877. /** @hidden */
  36878. _lodGenerationOffset: number;
  36879. /** @hidden */
  36880. _depthStencilTexture: Nullable<InternalTexture>;
  36881. /** @hidden */
  36882. _colorTextureArray: Nullable<WebGLTexture>;
  36883. /** @hidden */
  36884. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36885. /** @hidden */
  36886. _lodTextureHigh: Nullable<BaseTexture>;
  36887. /** @hidden */
  36888. _lodTextureMid: Nullable<BaseTexture>;
  36889. /** @hidden */
  36890. _lodTextureLow: Nullable<BaseTexture>;
  36891. /** @hidden */
  36892. _isRGBD: boolean;
  36893. /** @hidden */
  36894. _linearSpecularLOD: boolean;
  36895. /** @hidden */
  36896. _irradianceTexture: Nullable<BaseTexture>;
  36897. /** @hidden */
  36898. _webGLTexture: Nullable<WebGLTexture>;
  36899. /** @hidden */
  36900. _references: number;
  36901. private _engine;
  36902. /**
  36903. * Gets the Engine the texture belongs to.
  36904. * @returns The babylon engine
  36905. */
  36906. getEngine(): ThinEngine;
  36907. /**
  36908. * Gets the data source type of the texture
  36909. */
  36910. get source(): InternalTextureSource;
  36911. /**
  36912. * Creates a new InternalTexture
  36913. * @param engine defines the engine to use
  36914. * @param source defines the type of data that will be used
  36915. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36916. */
  36917. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36918. /**
  36919. * Increments the number of references (ie. the number of Texture that point to it)
  36920. */
  36921. incrementReferences(): void;
  36922. /**
  36923. * Change the size of the texture (not the size of the content)
  36924. * @param width defines the new width
  36925. * @param height defines the new height
  36926. * @param depth defines the new depth (1 by default)
  36927. */
  36928. updateSize(width: int, height: int, depth?: int): void;
  36929. /** @hidden */
  36930. _rebuild(): void;
  36931. /** @hidden */
  36932. _swapAndDie(target: InternalTexture): void;
  36933. /**
  36934. * Dispose the current allocated resources
  36935. */
  36936. dispose(): void;
  36937. }
  36938. }
  36939. declare module "babylonjs/Audio/analyser" {
  36940. import { Scene } from "babylonjs/scene";
  36941. /**
  36942. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36943. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36944. */
  36945. export class Analyser {
  36946. /**
  36947. * Gets or sets the smoothing
  36948. * @ignorenaming
  36949. */
  36950. SMOOTHING: number;
  36951. /**
  36952. * Gets or sets the FFT table size
  36953. * @ignorenaming
  36954. */
  36955. FFT_SIZE: number;
  36956. /**
  36957. * Gets or sets the bar graph amplitude
  36958. * @ignorenaming
  36959. */
  36960. BARGRAPHAMPLITUDE: number;
  36961. /**
  36962. * Gets or sets the position of the debug canvas
  36963. * @ignorenaming
  36964. */
  36965. DEBUGCANVASPOS: {
  36966. x: number;
  36967. y: number;
  36968. };
  36969. /**
  36970. * Gets or sets the debug canvas size
  36971. * @ignorenaming
  36972. */
  36973. DEBUGCANVASSIZE: {
  36974. width: number;
  36975. height: number;
  36976. };
  36977. private _byteFreqs;
  36978. private _byteTime;
  36979. private _floatFreqs;
  36980. private _webAudioAnalyser;
  36981. private _debugCanvas;
  36982. private _debugCanvasContext;
  36983. private _scene;
  36984. private _registerFunc;
  36985. private _audioEngine;
  36986. /**
  36987. * Creates a new analyser
  36988. * @param scene defines hosting scene
  36989. */
  36990. constructor(scene: Scene);
  36991. /**
  36992. * Get the number of data values you will have to play with for the visualization
  36993. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36994. * @returns a number
  36995. */
  36996. getFrequencyBinCount(): number;
  36997. /**
  36998. * Gets the current frequency data as a byte array
  36999. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37000. * @returns a Uint8Array
  37001. */
  37002. getByteFrequencyData(): Uint8Array;
  37003. /**
  37004. * Gets the current waveform as a byte array
  37005. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37006. * @returns a Uint8Array
  37007. */
  37008. getByteTimeDomainData(): Uint8Array;
  37009. /**
  37010. * Gets the current frequency data as a float array
  37011. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37012. * @returns a Float32Array
  37013. */
  37014. getFloatFrequencyData(): Float32Array;
  37015. /**
  37016. * Renders the debug canvas
  37017. */
  37018. drawDebugCanvas(): void;
  37019. /**
  37020. * Stops rendering the debug canvas and removes it
  37021. */
  37022. stopDebugCanvas(): void;
  37023. /**
  37024. * Connects two audio nodes
  37025. * @param inputAudioNode defines first node to connect
  37026. * @param outputAudioNode defines second node to connect
  37027. */
  37028. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37029. /**
  37030. * Releases all associated resources
  37031. */
  37032. dispose(): void;
  37033. }
  37034. }
  37035. declare module "babylonjs/Audio/audioEngine" {
  37036. import { IDisposable } from "babylonjs/scene";
  37037. import { Analyser } from "babylonjs/Audio/analyser";
  37038. import { Nullable } from "babylonjs/types";
  37039. import { Observable } from "babylonjs/Misc/observable";
  37040. /**
  37041. * This represents an audio engine and it is responsible
  37042. * to play, synchronize and analyse sounds throughout the application.
  37043. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37044. */
  37045. export interface IAudioEngine extends IDisposable {
  37046. /**
  37047. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37048. */
  37049. readonly canUseWebAudio: boolean;
  37050. /**
  37051. * Gets the current AudioContext if available.
  37052. */
  37053. readonly audioContext: Nullable<AudioContext>;
  37054. /**
  37055. * The master gain node defines the global audio volume of your audio engine.
  37056. */
  37057. readonly masterGain: GainNode;
  37058. /**
  37059. * Gets whether or not mp3 are supported by your browser.
  37060. */
  37061. readonly isMP3supported: boolean;
  37062. /**
  37063. * Gets whether or not ogg are supported by your browser.
  37064. */
  37065. readonly isOGGsupported: boolean;
  37066. /**
  37067. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37068. * @ignoreNaming
  37069. */
  37070. WarnedWebAudioUnsupported: boolean;
  37071. /**
  37072. * Defines if the audio engine relies on a custom unlocked button.
  37073. * In this case, the embedded button will not be displayed.
  37074. */
  37075. useCustomUnlockedButton: boolean;
  37076. /**
  37077. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37078. */
  37079. readonly unlocked: boolean;
  37080. /**
  37081. * Event raised when audio has been unlocked on the browser.
  37082. */
  37083. onAudioUnlockedObservable: Observable<AudioEngine>;
  37084. /**
  37085. * Event raised when audio has been locked on the browser.
  37086. */
  37087. onAudioLockedObservable: Observable<AudioEngine>;
  37088. /**
  37089. * Flags the audio engine in Locked state.
  37090. * This happens due to new browser policies preventing audio to autoplay.
  37091. */
  37092. lock(): void;
  37093. /**
  37094. * Unlocks the audio engine once a user action has been done on the dom.
  37095. * This is helpful to resume play once browser policies have been satisfied.
  37096. */
  37097. unlock(): void;
  37098. /**
  37099. * Gets the global volume sets on the master gain.
  37100. * @returns the global volume if set or -1 otherwise
  37101. */
  37102. getGlobalVolume(): number;
  37103. /**
  37104. * Sets the global volume of your experience (sets on the master gain).
  37105. * @param newVolume Defines the new global volume of the application
  37106. */
  37107. setGlobalVolume(newVolume: number): void;
  37108. /**
  37109. * Connect the audio engine to an audio analyser allowing some amazing
  37110. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37112. * @param analyser The analyser to connect to the engine
  37113. */
  37114. connectToAnalyser(analyser: Analyser): void;
  37115. }
  37116. /**
  37117. * This represents the default audio engine used in babylon.
  37118. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37120. */
  37121. export class AudioEngine implements IAudioEngine {
  37122. private _audioContext;
  37123. private _audioContextInitialized;
  37124. private _muteButton;
  37125. private _hostElement;
  37126. /**
  37127. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37128. */
  37129. canUseWebAudio: boolean;
  37130. /**
  37131. * The master gain node defines the global audio volume of your audio engine.
  37132. */
  37133. masterGain: GainNode;
  37134. /**
  37135. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37136. * @ignoreNaming
  37137. */
  37138. WarnedWebAudioUnsupported: boolean;
  37139. /**
  37140. * Gets whether or not mp3 are supported by your browser.
  37141. */
  37142. isMP3supported: boolean;
  37143. /**
  37144. * Gets whether or not ogg are supported by your browser.
  37145. */
  37146. isOGGsupported: boolean;
  37147. /**
  37148. * Gets whether audio has been unlocked on the device.
  37149. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37150. * a user interaction has happened.
  37151. */
  37152. unlocked: boolean;
  37153. /**
  37154. * Defines if the audio engine relies on a custom unlocked button.
  37155. * In this case, the embedded button will not be displayed.
  37156. */
  37157. useCustomUnlockedButton: boolean;
  37158. /**
  37159. * Event raised when audio has been unlocked on the browser.
  37160. */
  37161. onAudioUnlockedObservable: Observable<AudioEngine>;
  37162. /**
  37163. * Event raised when audio has been locked on the browser.
  37164. */
  37165. onAudioLockedObservable: Observable<AudioEngine>;
  37166. /**
  37167. * Gets the current AudioContext if available.
  37168. */
  37169. get audioContext(): Nullable<AudioContext>;
  37170. private _connectedAnalyser;
  37171. /**
  37172. * Instantiates a new audio engine.
  37173. *
  37174. * There should be only one per page as some browsers restrict the number
  37175. * of audio contexts you can create.
  37176. * @param hostElement defines the host element where to display the mute icon if necessary
  37177. */
  37178. constructor(hostElement?: Nullable<HTMLElement>);
  37179. /**
  37180. * Flags the audio engine in Locked state.
  37181. * This happens due to new browser policies preventing audio to autoplay.
  37182. */
  37183. lock(): void;
  37184. /**
  37185. * Unlocks the audio engine once a user action has been done on the dom.
  37186. * This is helpful to resume play once browser policies have been satisfied.
  37187. */
  37188. unlock(): void;
  37189. private _resumeAudioContext;
  37190. private _initializeAudioContext;
  37191. private _tryToRun;
  37192. private _triggerRunningState;
  37193. private _triggerSuspendedState;
  37194. private _displayMuteButton;
  37195. private _moveButtonToTopLeft;
  37196. private _onResize;
  37197. private _hideMuteButton;
  37198. /**
  37199. * Destroy and release the resources associated with the audio ccontext.
  37200. */
  37201. dispose(): void;
  37202. /**
  37203. * Gets the global volume sets on the master gain.
  37204. * @returns the global volume if set or -1 otherwise
  37205. */
  37206. getGlobalVolume(): number;
  37207. /**
  37208. * Sets the global volume of your experience (sets on the master gain).
  37209. * @param newVolume Defines the new global volume of the application
  37210. */
  37211. setGlobalVolume(newVolume: number): void;
  37212. /**
  37213. * Connect the audio engine to an audio analyser allowing some amazing
  37214. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37216. * @param analyser The analyser to connect to the engine
  37217. */
  37218. connectToAnalyser(analyser: Analyser): void;
  37219. }
  37220. }
  37221. declare module "babylonjs/Loading/loadingScreen" {
  37222. /**
  37223. * Interface used to present a loading screen while loading a scene
  37224. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37225. */
  37226. export interface ILoadingScreen {
  37227. /**
  37228. * Function called to display the loading screen
  37229. */
  37230. displayLoadingUI: () => void;
  37231. /**
  37232. * Function called to hide the loading screen
  37233. */
  37234. hideLoadingUI: () => void;
  37235. /**
  37236. * Gets or sets the color to use for the background
  37237. */
  37238. loadingUIBackgroundColor: string;
  37239. /**
  37240. * Gets or sets the text to display while loading
  37241. */
  37242. loadingUIText: string;
  37243. }
  37244. /**
  37245. * Class used for the default loading screen
  37246. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37247. */
  37248. export class DefaultLoadingScreen implements ILoadingScreen {
  37249. private _renderingCanvas;
  37250. private _loadingText;
  37251. private _loadingDivBackgroundColor;
  37252. private _loadingDiv;
  37253. private _loadingTextDiv;
  37254. /** Gets or sets the logo url to use for the default loading screen */
  37255. static DefaultLogoUrl: string;
  37256. /** Gets or sets the spinner url to use for the default loading screen */
  37257. static DefaultSpinnerUrl: string;
  37258. /**
  37259. * Creates a new default loading screen
  37260. * @param _renderingCanvas defines the canvas used to render the scene
  37261. * @param _loadingText defines the default text to display
  37262. * @param _loadingDivBackgroundColor defines the default background color
  37263. */
  37264. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37265. /**
  37266. * Function called to display the loading screen
  37267. */
  37268. displayLoadingUI(): void;
  37269. /**
  37270. * Function called to hide the loading screen
  37271. */
  37272. hideLoadingUI(): void;
  37273. /**
  37274. * Gets or sets the text to display while loading
  37275. */
  37276. set loadingUIText(text: string);
  37277. get loadingUIText(): string;
  37278. /**
  37279. * Gets or sets the color to use for the background
  37280. */
  37281. get loadingUIBackgroundColor(): string;
  37282. set loadingUIBackgroundColor(color: string);
  37283. private _resizeLoadingUI;
  37284. }
  37285. }
  37286. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37287. /**
  37288. * Interface for any object that can request an animation frame
  37289. */
  37290. export interface ICustomAnimationFrameRequester {
  37291. /**
  37292. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37293. */
  37294. renderFunction?: Function;
  37295. /**
  37296. * Called to request the next frame to render to
  37297. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37298. */
  37299. requestAnimationFrame: Function;
  37300. /**
  37301. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37302. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37303. */
  37304. requestID?: number;
  37305. }
  37306. }
  37307. declare module "babylonjs/Misc/performanceMonitor" {
  37308. /**
  37309. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37310. */
  37311. export class PerformanceMonitor {
  37312. private _enabled;
  37313. private _rollingFrameTime;
  37314. private _lastFrameTimeMs;
  37315. /**
  37316. * constructor
  37317. * @param frameSampleSize The number of samples required to saturate the sliding window
  37318. */
  37319. constructor(frameSampleSize?: number);
  37320. /**
  37321. * Samples current frame
  37322. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37323. */
  37324. sampleFrame(timeMs?: number): void;
  37325. /**
  37326. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37327. */
  37328. get averageFrameTime(): number;
  37329. /**
  37330. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37331. */
  37332. get averageFrameTimeVariance(): number;
  37333. /**
  37334. * Returns the frame time of the most recent frame
  37335. */
  37336. get instantaneousFrameTime(): number;
  37337. /**
  37338. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37339. */
  37340. get averageFPS(): number;
  37341. /**
  37342. * Returns the average framerate in frames per second using the most recent frame time
  37343. */
  37344. get instantaneousFPS(): number;
  37345. /**
  37346. * Returns true if enough samples have been taken to completely fill the sliding window
  37347. */
  37348. get isSaturated(): boolean;
  37349. /**
  37350. * Enables contributions to the sliding window sample set
  37351. */
  37352. enable(): void;
  37353. /**
  37354. * Disables contributions to the sliding window sample set
  37355. * Samples will not be interpolated over the disabled period
  37356. */
  37357. disable(): void;
  37358. /**
  37359. * Returns true if sampling is enabled
  37360. */
  37361. get isEnabled(): boolean;
  37362. /**
  37363. * Resets performance monitor
  37364. */
  37365. reset(): void;
  37366. }
  37367. /**
  37368. * RollingAverage
  37369. *
  37370. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37371. */
  37372. export class RollingAverage {
  37373. /**
  37374. * Current average
  37375. */
  37376. average: number;
  37377. /**
  37378. * Current variance
  37379. */
  37380. variance: number;
  37381. protected _samples: Array<number>;
  37382. protected _sampleCount: number;
  37383. protected _pos: number;
  37384. protected _m2: number;
  37385. /**
  37386. * constructor
  37387. * @param length The number of samples required to saturate the sliding window
  37388. */
  37389. constructor(length: number);
  37390. /**
  37391. * Adds a sample to the sample set
  37392. * @param v The sample value
  37393. */
  37394. add(v: number): void;
  37395. /**
  37396. * Returns previously added values or null if outside of history or outside the sliding window domain
  37397. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37398. * @return Value previously recorded with add() or null if outside of range
  37399. */
  37400. history(i: number): number;
  37401. /**
  37402. * Returns true if enough samples have been taken to completely fill the sliding window
  37403. * @return true if sample-set saturated
  37404. */
  37405. isSaturated(): boolean;
  37406. /**
  37407. * Resets the rolling average (equivalent to 0 samples taken so far)
  37408. */
  37409. reset(): void;
  37410. /**
  37411. * Wraps a value around the sample range boundaries
  37412. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37413. * @return Wrapped position in sample range
  37414. */
  37415. protected _wrapPosition(i: number): number;
  37416. }
  37417. }
  37418. declare module "babylonjs/Misc/perfCounter" {
  37419. /**
  37420. * This class is used to track a performance counter which is number based.
  37421. * The user has access to many properties which give statistics of different nature.
  37422. *
  37423. * The implementer can track two kinds of Performance Counter: time and count.
  37424. * 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.
  37425. * 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.
  37426. */
  37427. export class PerfCounter {
  37428. /**
  37429. * Gets or sets a global boolean to turn on and off all the counters
  37430. */
  37431. static Enabled: boolean;
  37432. /**
  37433. * Returns the smallest value ever
  37434. */
  37435. get min(): number;
  37436. /**
  37437. * Returns the biggest value ever
  37438. */
  37439. get max(): number;
  37440. /**
  37441. * Returns the average value since the performance counter is running
  37442. */
  37443. get average(): number;
  37444. /**
  37445. * Returns the average value of the last second the counter was monitored
  37446. */
  37447. get lastSecAverage(): number;
  37448. /**
  37449. * Returns the current value
  37450. */
  37451. get current(): number;
  37452. /**
  37453. * Gets the accumulated total
  37454. */
  37455. get total(): number;
  37456. /**
  37457. * Gets the total value count
  37458. */
  37459. get count(): number;
  37460. /**
  37461. * Creates a new counter
  37462. */
  37463. constructor();
  37464. /**
  37465. * Call this method to start monitoring a new frame.
  37466. * 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.
  37467. */
  37468. fetchNewFrame(): void;
  37469. /**
  37470. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37471. * @param newCount the count value to add to the monitored count
  37472. * @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.
  37473. */
  37474. addCount(newCount: number, fetchResult: boolean): void;
  37475. /**
  37476. * Start monitoring this performance counter
  37477. */
  37478. beginMonitoring(): void;
  37479. /**
  37480. * Compute the time lapsed since the previous beginMonitoring() call.
  37481. * @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
  37482. */
  37483. endMonitoring(newFrame?: boolean): void;
  37484. private _fetchResult;
  37485. private _startMonitoringTime;
  37486. private _min;
  37487. private _max;
  37488. private _average;
  37489. private _current;
  37490. private _totalValueCount;
  37491. private _totalAccumulated;
  37492. private _lastSecAverage;
  37493. private _lastSecAccumulated;
  37494. private _lastSecTime;
  37495. private _lastSecValueCount;
  37496. }
  37497. }
  37498. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37499. module "babylonjs/Engines/thinEngine" {
  37500. interface ThinEngine {
  37501. /**
  37502. * Sets alpha constants used by some alpha blending modes
  37503. * @param r defines the red component
  37504. * @param g defines the green component
  37505. * @param b defines the blue component
  37506. * @param a defines the alpha component
  37507. */
  37508. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37509. /**
  37510. * Sets the current alpha mode
  37511. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37514. */
  37515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37516. /**
  37517. * Gets the current alpha mode
  37518. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37519. * @returns the current alpha mode
  37520. */
  37521. getAlphaMode(): number;
  37522. /**
  37523. * Sets the current alpha equation
  37524. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37525. */
  37526. setAlphaEquation(equation: number): void;
  37527. /**
  37528. * Gets the current alpha equation.
  37529. * @returns the current alpha equation
  37530. */
  37531. getAlphaEquation(): number;
  37532. }
  37533. }
  37534. }
  37535. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37537. import { Nullable } from "babylonjs/types";
  37538. module "babylonjs/Engines/thinEngine" {
  37539. interface ThinEngine {
  37540. /** @hidden */
  37541. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37542. }
  37543. }
  37544. }
  37545. declare module "babylonjs/Engines/engine" {
  37546. import { Observable } from "babylonjs/Misc/observable";
  37547. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37548. import { Scene } from "babylonjs/scene";
  37549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37550. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37552. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37553. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37554. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37555. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37556. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37557. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37559. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37560. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37561. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37562. import "babylonjs/Engines/Extensions/engine.alpha";
  37563. import "babylonjs/Engines/Extensions/engine.readTexture";
  37564. import { Material } from "babylonjs/Materials/material";
  37565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37566. /**
  37567. * Defines the interface used by display changed events
  37568. */
  37569. export interface IDisplayChangedEventArgs {
  37570. /** Gets the vrDisplay object (if any) */
  37571. vrDisplay: Nullable<any>;
  37572. /** Gets a boolean indicating if webVR is supported */
  37573. vrSupported: boolean;
  37574. }
  37575. /**
  37576. * Defines the interface used by objects containing a viewport (like a camera)
  37577. */
  37578. interface IViewportOwnerLike {
  37579. /**
  37580. * Gets or sets the viewport
  37581. */
  37582. viewport: IViewportLike;
  37583. }
  37584. /**
  37585. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37586. */
  37587. export class Engine extends ThinEngine {
  37588. /** Defines that alpha blending is disabled */
  37589. static readonly ALPHA_DISABLE: number;
  37590. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37591. static readonly ALPHA_ADD: number;
  37592. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37593. static readonly ALPHA_COMBINE: number;
  37594. /** Defines that alpha blending to DEST - SRC * DEST */
  37595. static readonly ALPHA_SUBTRACT: number;
  37596. /** Defines that alpha blending to SRC * DEST */
  37597. static readonly ALPHA_MULTIPLY: number;
  37598. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37599. static readonly ALPHA_MAXIMIZED: number;
  37600. /** Defines that alpha blending to SRC + DEST */
  37601. static readonly ALPHA_ONEONE: number;
  37602. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37603. static readonly ALPHA_PREMULTIPLIED: number;
  37604. /**
  37605. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37607. */
  37608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37609. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37610. static readonly ALPHA_INTERPOLATE: number;
  37611. /**
  37612. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37614. */
  37615. static readonly ALPHA_SCREENMODE: number;
  37616. /** Defines that the ressource is not delayed*/
  37617. static readonly DELAYLOADSTATE_NONE: number;
  37618. /** Defines that the ressource was successfully delay loaded */
  37619. static readonly DELAYLOADSTATE_LOADED: number;
  37620. /** Defines that the ressource is currently delay loading */
  37621. static readonly DELAYLOADSTATE_LOADING: number;
  37622. /** Defines that the ressource is delayed and has not started loading */
  37623. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37625. static readonly NEVER: number;
  37626. /** 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 */
  37627. static readonly ALWAYS: number;
  37628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37629. static readonly LESS: number;
  37630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37631. static readonly EQUAL: number;
  37632. /** 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 */
  37633. static readonly LEQUAL: number;
  37634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37635. static readonly GREATER: number;
  37636. /** 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 */
  37637. static readonly GEQUAL: number;
  37638. /** 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 */
  37639. static readonly NOTEQUAL: number;
  37640. /** Passed to stencilOperation to specify that stencil value must be kept */
  37641. static readonly KEEP: number;
  37642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37643. static readonly REPLACE: number;
  37644. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37645. static readonly INCR: number;
  37646. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37647. static readonly DECR: number;
  37648. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37649. static readonly INVERT: number;
  37650. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37651. static readonly INCR_WRAP: number;
  37652. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37653. static readonly DECR_WRAP: number;
  37654. /** Texture is not repeating outside of 0..1 UVs */
  37655. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37656. /** Texture is repeating outside of 0..1 UVs */
  37657. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37658. /** Texture is repeating and mirrored */
  37659. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37660. /** ALPHA */
  37661. static readonly TEXTUREFORMAT_ALPHA: number;
  37662. /** LUMINANCE */
  37663. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37664. /** LUMINANCE_ALPHA */
  37665. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37666. /** RGB */
  37667. static readonly TEXTUREFORMAT_RGB: number;
  37668. /** RGBA */
  37669. static readonly TEXTUREFORMAT_RGBA: number;
  37670. /** RED */
  37671. static readonly TEXTUREFORMAT_RED: number;
  37672. /** RED (2nd reference) */
  37673. static readonly TEXTUREFORMAT_R: number;
  37674. /** RG */
  37675. static readonly TEXTUREFORMAT_RG: number;
  37676. /** RED_INTEGER */
  37677. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37678. /** RED_INTEGER (2nd reference) */
  37679. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37680. /** RG_INTEGER */
  37681. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37682. /** RGB_INTEGER */
  37683. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37684. /** RGBA_INTEGER */
  37685. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37686. /** UNSIGNED_BYTE */
  37687. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37688. /** UNSIGNED_BYTE (2nd reference) */
  37689. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37690. /** FLOAT */
  37691. static readonly TEXTURETYPE_FLOAT: number;
  37692. /** HALF_FLOAT */
  37693. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37694. /** BYTE */
  37695. static readonly TEXTURETYPE_BYTE: number;
  37696. /** SHORT */
  37697. static readonly TEXTURETYPE_SHORT: number;
  37698. /** UNSIGNED_SHORT */
  37699. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37700. /** INT */
  37701. static readonly TEXTURETYPE_INT: number;
  37702. /** UNSIGNED_INT */
  37703. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37704. /** UNSIGNED_SHORT_4_4_4_4 */
  37705. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37706. /** UNSIGNED_SHORT_5_5_5_1 */
  37707. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37708. /** UNSIGNED_SHORT_5_6_5 */
  37709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37710. /** UNSIGNED_INT_2_10_10_10_REV */
  37711. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37712. /** UNSIGNED_INT_24_8 */
  37713. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37714. /** UNSIGNED_INT_10F_11F_11F_REV */
  37715. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37716. /** UNSIGNED_INT_5_9_9_9_REV */
  37717. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37718. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37719. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37720. /** nearest is mag = nearest and min = nearest and mip = linear */
  37721. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37723. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37724. /** Trilinear is mag = linear and min = linear and mip = linear */
  37725. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37726. /** nearest is mag = nearest and min = nearest and mip = linear */
  37727. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37729. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37730. /** Trilinear is mag = linear and min = linear and mip = linear */
  37731. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37732. /** mag = nearest and min = nearest and mip = nearest */
  37733. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37734. /** mag = nearest and min = linear and mip = nearest */
  37735. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37736. /** mag = nearest and min = linear and mip = linear */
  37737. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37738. /** mag = nearest and min = linear and mip = none */
  37739. static readonly TEXTURE_NEAREST_LINEAR: number;
  37740. /** mag = nearest and min = nearest and mip = none */
  37741. static readonly TEXTURE_NEAREST_NEAREST: number;
  37742. /** mag = linear and min = nearest and mip = nearest */
  37743. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37744. /** mag = linear and min = nearest and mip = linear */
  37745. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37746. /** mag = linear and min = linear and mip = none */
  37747. static readonly TEXTURE_LINEAR_LINEAR: number;
  37748. /** mag = linear and min = nearest and mip = none */
  37749. static readonly TEXTURE_LINEAR_NEAREST: number;
  37750. /** Explicit coordinates mode */
  37751. static readonly TEXTURE_EXPLICIT_MODE: number;
  37752. /** Spherical coordinates mode */
  37753. static readonly TEXTURE_SPHERICAL_MODE: number;
  37754. /** Planar coordinates mode */
  37755. static readonly TEXTURE_PLANAR_MODE: number;
  37756. /** Cubic coordinates mode */
  37757. static readonly TEXTURE_CUBIC_MODE: number;
  37758. /** Projection coordinates mode */
  37759. static readonly TEXTURE_PROJECTION_MODE: number;
  37760. /** Skybox coordinates mode */
  37761. static readonly TEXTURE_SKYBOX_MODE: number;
  37762. /** Inverse Cubic coordinates mode */
  37763. static readonly TEXTURE_INVCUBIC_MODE: number;
  37764. /** Equirectangular coordinates mode */
  37765. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37766. /** Equirectangular Fixed coordinates mode */
  37767. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37768. /** Equirectangular Fixed Mirrored coordinates mode */
  37769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37770. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37771. static readonly SCALEMODE_FLOOR: number;
  37772. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37773. static readonly SCALEMODE_NEAREST: number;
  37774. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37775. static readonly SCALEMODE_CEILING: number;
  37776. /**
  37777. * Returns the current npm package of the sdk
  37778. */
  37779. static get NpmPackage(): string;
  37780. /**
  37781. * Returns the current version of the framework
  37782. */
  37783. static get Version(): string;
  37784. /** Gets the list of created engines */
  37785. static get Instances(): Engine[];
  37786. /**
  37787. * Gets the latest created engine
  37788. */
  37789. static get LastCreatedEngine(): Nullable<Engine>;
  37790. /**
  37791. * Gets the latest created scene
  37792. */
  37793. static get LastCreatedScene(): Nullable<Scene>;
  37794. /**
  37795. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37796. * @param flag defines which part of the materials must be marked as dirty
  37797. * @param predicate defines a predicate used to filter which materials should be affected
  37798. */
  37799. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37800. /**
  37801. * Method called to create the default loading screen.
  37802. * This can be overriden in your own app.
  37803. * @param canvas The rendering canvas element
  37804. * @returns The loading screen
  37805. */
  37806. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37807. /**
  37808. * Method called to create the default rescale post process on each engine.
  37809. */
  37810. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37811. /**
  37812. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37813. **/
  37814. enableOfflineSupport: boolean;
  37815. /**
  37816. * 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)
  37817. **/
  37818. disableManifestCheck: boolean;
  37819. /**
  37820. * Gets the list of created scenes
  37821. */
  37822. scenes: Scene[];
  37823. /**
  37824. * Event raised when a new scene is created
  37825. */
  37826. onNewSceneAddedObservable: Observable<Scene>;
  37827. /**
  37828. * Gets the list of created postprocesses
  37829. */
  37830. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37831. /**
  37832. * Gets a boolean indicating if the pointer is currently locked
  37833. */
  37834. isPointerLock: boolean;
  37835. /**
  37836. * Observable event triggered each time the rendering canvas is resized
  37837. */
  37838. onResizeObservable: Observable<Engine>;
  37839. /**
  37840. * Observable event triggered each time the canvas loses focus
  37841. */
  37842. onCanvasBlurObservable: Observable<Engine>;
  37843. /**
  37844. * Observable event triggered each time the canvas gains focus
  37845. */
  37846. onCanvasFocusObservable: Observable<Engine>;
  37847. /**
  37848. * Observable event triggered each time the canvas receives pointerout event
  37849. */
  37850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37851. /**
  37852. * Observable raised when the engine begins a new frame
  37853. */
  37854. onBeginFrameObservable: Observable<Engine>;
  37855. /**
  37856. * If set, will be used to request the next animation frame for the render loop
  37857. */
  37858. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37859. /**
  37860. * Observable raised when the engine ends the current frame
  37861. */
  37862. onEndFrameObservable: Observable<Engine>;
  37863. /**
  37864. * Observable raised when the engine is about to compile a shader
  37865. */
  37866. onBeforeShaderCompilationObservable: Observable<Engine>;
  37867. /**
  37868. * Observable raised when the engine has jsut compiled a shader
  37869. */
  37870. onAfterShaderCompilationObservable: Observable<Engine>;
  37871. /**
  37872. * Gets the audio engine
  37873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37874. * @ignorenaming
  37875. */
  37876. static audioEngine: IAudioEngine;
  37877. /**
  37878. * Default AudioEngine factory responsible of creating the Audio Engine.
  37879. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37880. */
  37881. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37882. /**
  37883. * Default offline support factory responsible of creating a tool used to store data locally.
  37884. * By default, this will create a Database object if the workload has been embedded.
  37885. */
  37886. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37887. private _loadingScreen;
  37888. private _pointerLockRequested;
  37889. private _rescalePostProcess;
  37890. private _deterministicLockstep;
  37891. private _lockstepMaxSteps;
  37892. private _timeStep;
  37893. protected get _supportsHardwareTextureRescaling(): boolean;
  37894. private _fps;
  37895. private _deltaTime;
  37896. /** @hidden */
  37897. _drawCalls: PerfCounter;
  37898. /** 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 */
  37899. canvasTabIndex: number;
  37900. /**
  37901. * Turn this value on if you want to pause FPS computation when in background
  37902. */
  37903. disablePerformanceMonitorInBackground: boolean;
  37904. private _performanceMonitor;
  37905. /**
  37906. * Gets the performance monitor attached to this engine
  37907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37908. */
  37909. get performanceMonitor(): PerformanceMonitor;
  37910. private _onFocus;
  37911. private _onBlur;
  37912. private _onCanvasPointerOut;
  37913. private _onCanvasBlur;
  37914. private _onCanvasFocus;
  37915. private _onFullscreenChange;
  37916. private _onPointerLockChange;
  37917. /**
  37918. * Gets the HTML element used to attach event listeners
  37919. * @returns a HTML element
  37920. */
  37921. getInputElement(): Nullable<HTMLElement>;
  37922. /**
  37923. * Creates a new engine
  37924. * @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
  37925. * @param antialias defines enable antialiasing (default: false)
  37926. * @param options defines further options to be sent to the getContext() function
  37927. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37928. */
  37929. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37930. /**
  37931. * Gets current aspect ratio
  37932. * @param viewportOwner defines the camera to use to get the aspect ratio
  37933. * @param useScreen defines if screen size must be used (or the current render target if any)
  37934. * @returns a number defining the aspect ratio
  37935. */
  37936. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37937. /**
  37938. * Gets current screen aspect ratio
  37939. * @returns a number defining the aspect ratio
  37940. */
  37941. getScreenAspectRatio(): number;
  37942. /**
  37943. * Gets the client rect of the HTML canvas attached with the current webGL context
  37944. * @returns a client rectanglee
  37945. */
  37946. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37947. /**
  37948. * Gets the client rect of the HTML element used for events
  37949. * @returns a client rectanglee
  37950. */
  37951. getInputElementClientRect(): Nullable<ClientRect>;
  37952. /**
  37953. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37955. * @returns true if engine is in deterministic lock step mode
  37956. */
  37957. isDeterministicLockStep(): boolean;
  37958. /**
  37959. * Gets the max steps when engine is running in deterministic lock step
  37960. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37961. * @returns the max steps
  37962. */
  37963. getLockstepMaxSteps(): number;
  37964. /**
  37965. * Returns the time in ms between steps when using deterministic lock step.
  37966. * @returns time step in (ms)
  37967. */
  37968. getTimeStep(): number;
  37969. /**
  37970. * Force the mipmap generation for the given render target texture
  37971. * @param texture defines the render target texture to use
  37972. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37973. */
  37974. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37975. /** States */
  37976. /**
  37977. * Set various states to the webGL context
  37978. * @param culling defines backface culling state
  37979. * @param zOffset defines the value to apply to zOffset (0 by default)
  37980. * @param force defines if states must be applied even if cache is up to date
  37981. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37982. */
  37983. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37984. /**
  37985. * Set the z offset to apply to current rendering
  37986. * @param value defines the offset to apply
  37987. */
  37988. setZOffset(value: number): void;
  37989. /**
  37990. * Gets the current value of the zOffset
  37991. * @returns the current zOffset state
  37992. */
  37993. getZOffset(): number;
  37994. /**
  37995. * Enable or disable depth buffering
  37996. * @param enable defines the state to set
  37997. */
  37998. setDepthBuffer(enable: boolean): void;
  37999. /**
  38000. * Gets a boolean indicating if depth writing is enabled
  38001. * @returns the current depth writing state
  38002. */
  38003. getDepthWrite(): boolean;
  38004. /**
  38005. * Enable or disable depth writing
  38006. * @param enable defines the state to set
  38007. */
  38008. setDepthWrite(enable: boolean): void;
  38009. /**
  38010. * Gets a boolean indicating if stencil buffer is enabled
  38011. * @returns the current stencil buffer state
  38012. */
  38013. getStencilBuffer(): boolean;
  38014. /**
  38015. * Enable or disable the stencil buffer
  38016. * @param enable defines if the stencil buffer must be enabled or disabled
  38017. */
  38018. setStencilBuffer(enable: boolean): void;
  38019. /**
  38020. * Gets the current stencil mask
  38021. * @returns a number defining the new stencil mask to use
  38022. */
  38023. getStencilMask(): number;
  38024. /**
  38025. * Sets the current stencil mask
  38026. * @param mask defines the new stencil mask to use
  38027. */
  38028. setStencilMask(mask: number): void;
  38029. /**
  38030. * Gets the current stencil function
  38031. * @returns a number defining the stencil function to use
  38032. */
  38033. getStencilFunction(): number;
  38034. /**
  38035. * Gets the current stencil reference value
  38036. * @returns a number defining the stencil reference value to use
  38037. */
  38038. getStencilFunctionReference(): number;
  38039. /**
  38040. * Gets the current stencil mask
  38041. * @returns a number defining the stencil mask to use
  38042. */
  38043. getStencilFunctionMask(): number;
  38044. /**
  38045. * Sets the current stencil function
  38046. * @param stencilFunc defines the new stencil function to use
  38047. */
  38048. setStencilFunction(stencilFunc: number): void;
  38049. /**
  38050. * Sets the current stencil reference
  38051. * @param reference defines the new stencil reference to use
  38052. */
  38053. setStencilFunctionReference(reference: number): void;
  38054. /**
  38055. * Sets the current stencil mask
  38056. * @param mask defines the new stencil mask to use
  38057. */
  38058. setStencilFunctionMask(mask: number): void;
  38059. /**
  38060. * Gets the current stencil operation when stencil fails
  38061. * @returns a number defining stencil operation to use when stencil fails
  38062. */
  38063. getStencilOperationFail(): number;
  38064. /**
  38065. * Gets the current stencil operation when depth fails
  38066. * @returns a number defining stencil operation to use when depth fails
  38067. */
  38068. getStencilOperationDepthFail(): number;
  38069. /**
  38070. * Gets the current stencil operation when stencil passes
  38071. * @returns a number defining stencil operation to use when stencil passes
  38072. */
  38073. getStencilOperationPass(): number;
  38074. /**
  38075. * Sets the stencil operation to use when stencil fails
  38076. * @param operation defines the stencil operation to use when stencil fails
  38077. */
  38078. setStencilOperationFail(operation: number): void;
  38079. /**
  38080. * Sets the stencil operation to use when depth fails
  38081. * @param operation defines the stencil operation to use when depth fails
  38082. */
  38083. setStencilOperationDepthFail(operation: number): void;
  38084. /**
  38085. * Sets the stencil operation to use when stencil passes
  38086. * @param operation defines the stencil operation to use when stencil passes
  38087. */
  38088. setStencilOperationPass(operation: number): void;
  38089. /**
  38090. * Sets a boolean indicating if the dithering state is enabled or disabled
  38091. * @param value defines the dithering state
  38092. */
  38093. setDitheringState(value: boolean): void;
  38094. /**
  38095. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38096. * @param value defines the rasterizer state
  38097. */
  38098. setRasterizerState(value: boolean): void;
  38099. /**
  38100. * Gets the current depth function
  38101. * @returns a number defining the depth function
  38102. */
  38103. getDepthFunction(): Nullable<number>;
  38104. /**
  38105. * Sets the current depth function
  38106. * @param depthFunc defines the function to use
  38107. */
  38108. setDepthFunction(depthFunc: number): void;
  38109. /**
  38110. * Sets the current depth function to GREATER
  38111. */
  38112. setDepthFunctionToGreater(): void;
  38113. /**
  38114. * Sets the current depth function to GEQUAL
  38115. */
  38116. setDepthFunctionToGreaterOrEqual(): void;
  38117. /**
  38118. * Sets the current depth function to LESS
  38119. */
  38120. setDepthFunctionToLess(): void;
  38121. /**
  38122. * Sets the current depth function to LEQUAL
  38123. */
  38124. setDepthFunctionToLessOrEqual(): void;
  38125. private _cachedStencilBuffer;
  38126. private _cachedStencilFunction;
  38127. private _cachedStencilMask;
  38128. private _cachedStencilOperationPass;
  38129. private _cachedStencilOperationFail;
  38130. private _cachedStencilOperationDepthFail;
  38131. private _cachedStencilReference;
  38132. /**
  38133. * Caches the the state of the stencil buffer
  38134. */
  38135. cacheStencilState(): void;
  38136. /**
  38137. * Restores the state of the stencil buffer
  38138. */
  38139. restoreStencilState(): void;
  38140. /**
  38141. * Directly set the WebGL Viewport
  38142. * @param x defines the x coordinate of the viewport (in screen space)
  38143. * @param y defines the y coordinate of the viewport (in screen space)
  38144. * @param width defines the width of the viewport (in screen space)
  38145. * @param height defines the height of the viewport (in screen space)
  38146. * @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
  38147. */
  38148. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38149. /**
  38150. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38151. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38152. * @param y defines the y-coordinate of the corner of the clear rectangle
  38153. * @param width defines the width of the clear rectangle
  38154. * @param height defines the height of the clear rectangle
  38155. * @param clearColor defines the clear color
  38156. */
  38157. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38158. /**
  38159. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38160. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38161. * @param y defines the y-coordinate of the corner of the clear rectangle
  38162. * @param width defines the width of the clear rectangle
  38163. * @param height defines the height of the clear rectangle
  38164. */
  38165. enableScissor(x: number, y: number, width: number, height: number): void;
  38166. /**
  38167. * Disable previously set scissor test rectangle
  38168. */
  38169. disableScissor(): void;
  38170. protected _reportDrawCall(): void;
  38171. /**
  38172. * Initializes a webVR display and starts listening to display change events
  38173. * The onVRDisplayChangedObservable will be notified upon these changes
  38174. * @returns The onVRDisplayChangedObservable
  38175. */
  38176. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38177. /** @hidden */
  38178. _prepareVRComponent(): void;
  38179. /** @hidden */
  38180. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38181. /** @hidden */
  38182. _submitVRFrame(): void;
  38183. /**
  38184. * Call this function to leave webVR mode
  38185. * Will do nothing if webVR is not supported or if there is no webVR device
  38186. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38187. */
  38188. disableVR(): void;
  38189. /**
  38190. * Gets a boolean indicating that the system is in VR mode and is presenting
  38191. * @returns true if VR mode is engaged
  38192. */
  38193. isVRPresenting(): boolean;
  38194. /** @hidden */
  38195. _requestVRFrame(): void;
  38196. /** @hidden */
  38197. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38198. /**
  38199. * Gets the source code of the vertex shader associated with a specific webGL program
  38200. * @param program defines the program to use
  38201. * @returns a string containing the source code of the vertex shader associated with the program
  38202. */
  38203. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38204. /**
  38205. * Gets the source code of the fragment shader associated with a specific webGL program
  38206. * @param program defines the program to use
  38207. * @returns a string containing the source code of the fragment shader associated with the program
  38208. */
  38209. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38210. /**
  38211. * Sets a depth stencil texture from a render target to the according uniform.
  38212. * @param channel The texture channel
  38213. * @param uniform The uniform to set
  38214. * @param texture The render target texture containing the depth stencil texture to apply
  38215. */
  38216. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38217. /**
  38218. * Sets a texture to the webGL context from a postprocess
  38219. * @param channel defines the channel to use
  38220. * @param postProcess defines the source postprocess
  38221. */
  38222. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38223. /**
  38224. * Binds the output of the passed in post process to the texture channel specified
  38225. * @param channel The channel the texture should be bound to
  38226. * @param postProcess The post process which's output should be bound
  38227. */
  38228. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38229. protected _rebuildBuffers(): void;
  38230. /** @hidden */
  38231. _renderFrame(): void;
  38232. _renderLoop(): void;
  38233. /** @hidden */
  38234. _renderViews(): boolean;
  38235. /**
  38236. * Toggle full screen mode
  38237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38238. */
  38239. switchFullscreen(requestPointerLock: boolean): void;
  38240. /**
  38241. * Enters full screen mode
  38242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38243. */
  38244. enterFullscreen(requestPointerLock: boolean): void;
  38245. /**
  38246. * Exits full screen mode
  38247. */
  38248. exitFullscreen(): void;
  38249. /**
  38250. * Enters Pointerlock mode
  38251. */
  38252. enterPointerlock(): void;
  38253. /**
  38254. * Exits Pointerlock mode
  38255. */
  38256. exitPointerlock(): void;
  38257. /**
  38258. * Begin a new frame
  38259. */
  38260. beginFrame(): void;
  38261. /**
  38262. * Enf the current frame
  38263. */
  38264. endFrame(): void;
  38265. resize(): void;
  38266. /**
  38267. * Force a specific size of the canvas
  38268. * @param width defines the new canvas' width
  38269. * @param height defines the new canvas' height
  38270. * @returns true if the size was changed
  38271. */
  38272. setSize(width: number, height: number): boolean;
  38273. /**
  38274. * Updates a dynamic vertex buffer.
  38275. * @param vertexBuffer the vertex buffer to update
  38276. * @param data the data used to update the vertex buffer
  38277. * @param byteOffset the byte offset of the data
  38278. * @param byteLength the byte length of the data
  38279. */
  38280. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38281. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38282. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38283. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38284. _releaseTexture(texture: InternalTexture): void;
  38285. /**
  38286. * @hidden
  38287. * Rescales a texture
  38288. * @param source input texutre
  38289. * @param destination destination texture
  38290. * @param scene scene to use to render the resize
  38291. * @param internalFormat format to use when resizing
  38292. * @param onComplete callback to be called when resize has completed
  38293. */
  38294. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38295. /**
  38296. * Gets the current framerate
  38297. * @returns a number representing the framerate
  38298. */
  38299. getFps(): number;
  38300. /**
  38301. * Gets the time spent between current and previous frame
  38302. * @returns a number representing the delta time in ms
  38303. */
  38304. getDeltaTime(): number;
  38305. private _measureFps;
  38306. /** @hidden */
  38307. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38308. /**
  38309. * Update a dynamic index buffer
  38310. * @param indexBuffer defines the target index buffer
  38311. * @param indices defines the data to update
  38312. * @param offset defines the offset in the target index buffer where update should start
  38313. */
  38314. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38315. /**
  38316. * Updates the sample count of a render target texture
  38317. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38318. * @param texture defines the texture to update
  38319. * @param samples defines the sample count to set
  38320. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38321. */
  38322. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38323. /**
  38324. * Updates a depth texture Comparison Mode and Function.
  38325. * If the comparison Function is equal to 0, the mode will be set to none.
  38326. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38327. * @param texture The texture to set the comparison function for
  38328. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38329. */
  38330. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38331. /**
  38332. * Creates a webGL buffer to use with instanciation
  38333. * @param capacity defines the size of the buffer
  38334. * @returns the webGL buffer
  38335. */
  38336. createInstancesBuffer(capacity: number): DataBuffer;
  38337. /**
  38338. * Delete a webGL buffer used with instanciation
  38339. * @param buffer defines the webGL buffer to delete
  38340. */
  38341. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38342. private _clientWaitAsync;
  38343. /** @hidden */
  38344. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38345. dispose(): void;
  38346. private _disableTouchAction;
  38347. /**
  38348. * Display the loading screen
  38349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38350. */
  38351. displayLoadingUI(): void;
  38352. /**
  38353. * Hide the loading screen
  38354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38355. */
  38356. hideLoadingUI(): void;
  38357. /**
  38358. * Gets the current loading screen object
  38359. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38360. */
  38361. get loadingScreen(): ILoadingScreen;
  38362. /**
  38363. * Sets the current loading screen object
  38364. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38365. */
  38366. set loadingScreen(loadingScreen: ILoadingScreen);
  38367. /**
  38368. * Sets the current loading screen text
  38369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38370. */
  38371. set loadingUIText(text: string);
  38372. /**
  38373. * Sets the current loading screen background color
  38374. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38375. */
  38376. set loadingUIBackgroundColor(color: string);
  38377. /** Pointerlock and fullscreen */
  38378. /**
  38379. * Ask the browser to promote the current element to pointerlock mode
  38380. * @param element defines the DOM element to promote
  38381. */
  38382. static _RequestPointerlock(element: HTMLElement): void;
  38383. /**
  38384. * Asks the browser to exit pointerlock mode
  38385. */
  38386. static _ExitPointerlock(): void;
  38387. /**
  38388. * Ask the browser to promote the current element to fullscreen rendering mode
  38389. * @param element defines the DOM element to promote
  38390. */
  38391. static _RequestFullscreen(element: HTMLElement): void;
  38392. /**
  38393. * Asks the browser to exit fullscreen mode
  38394. */
  38395. static _ExitFullscreen(): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Engines/engineStore" {
  38399. import { Nullable } from "babylonjs/types";
  38400. import { Engine } from "babylonjs/Engines/engine";
  38401. import { Scene } from "babylonjs/scene";
  38402. /**
  38403. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38404. * during the life time of the application.
  38405. */
  38406. export class EngineStore {
  38407. /** Gets the list of created engines */
  38408. static Instances: import("babylonjs/Engines/engine").Engine[];
  38409. /** @hidden */
  38410. static _LastCreatedScene: Nullable<Scene>;
  38411. /**
  38412. * Gets the latest created engine
  38413. */
  38414. static get LastCreatedEngine(): Nullable<Engine>;
  38415. /**
  38416. * Gets the latest created scene
  38417. */
  38418. static get LastCreatedScene(): Nullable<Scene>;
  38419. /**
  38420. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38421. * @ignorenaming
  38422. */
  38423. static UseFallbackTexture: boolean;
  38424. /**
  38425. * Texture content used if a texture cannot loaded
  38426. * @ignorenaming
  38427. */
  38428. static FallbackTexture: string;
  38429. }
  38430. }
  38431. declare module "babylonjs/Misc/promise" {
  38432. /**
  38433. * Helper class that provides a small promise polyfill
  38434. */
  38435. export class PromisePolyfill {
  38436. /**
  38437. * Static function used to check if the polyfill is required
  38438. * If this is the case then the function will inject the polyfill to window.Promise
  38439. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38440. */
  38441. static Apply(force?: boolean): void;
  38442. }
  38443. }
  38444. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38445. /**
  38446. * Interface for screenshot methods with describe argument called `size` as object with options
  38447. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38448. */
  38449. export interface IScreenshotSize {
  38450. /**
  38451. * number in pixels for canvas height
  38452. */
  38453. height?: number;
  38454. /**
  38455. * multiplier allowing render at a higher or lower resolution
  38456. * If value is defined then height and width will be ignored and taken from camera
  38457. */
  38458. precision?: number;
  38459. /**
  38460. * number in pixels for canvas width
  38461. */
  38462. width?: number;
  38463. }
  38464. }
  38465. declare module "babylonjs/Misc/tools" {
  38466. import { Nullable, float } from "babylonjs/types";
  38467. import { DomManagement } from "babylonjs/Misc/domManagement";
  38468. import { WebRequest } from "babylonjs/Misc/webRequest";
  38469. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38470. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38471. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38472. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38473. import { Camera } from "babylonjs/Cameras/camera";
  38474. import { Engine } from "babylonjs/Engines/engine";
  38475. interface IColor4Like {
  38476. r: float;
  38477. g: float;
  38478. b: float;
  38479. a: float;
  38480. }
  38481. /**
  38482. * Class containing a set of static utilities functions
  38483. */
  38484. export class Tools {
  38485. /**
  38486. * Gets or sets the base URL to use to load assets
  38487. */
  38488. static get BaseUrl(): string;
  38489. static set BaseUrl(value: string);
  38490. /**
  38491. * Enable/Disable Custom HTTP Request Headers globally.
  38492. * default = false
  38493. * @see CustomRequestHeaders
  38494. */
  38495. static UseCustomRequestHeaders: boolean;
  38496. /**
  38497. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38498. * i.e. when loading files, where the server/service expects an Authorization header
  38499. */
  38500. static CustomRequestHeaders: {
  38501. [key: string]: string;
  38502. };
  38503. /**
  38504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38505. */
  38506. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38507. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38508. /**
  38509. * Default behaviour for cors in the application.
  38510. * It can be a string if the expected behavior is identical in the entire app.
  38511. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38512. */
  38513. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38514. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38515. /**
  38516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38517. * @ignorenaming
  38518. */
  38519. static get UseFallbackTexture(): boolean;
  38520. static set UseFallbackTexture(value: boolean);
  38521. /**
  38522. * Use this object to register external classes like custom textures or material
  38523. * to allow the laoders to instantiate them
  38524. */
  38525. static get RegisteredExternalClasses(): {
  38526. [key: string]: Object;
  38527. };
  38528. static set RegisteredExternalClasses(classes: {
  38529. [key: string]: Object;
  38530. });
  38531. /**
  38532. * Texture content used if a texture cannot loaded
  38533. * @ignorenaming
  38534. */
  38535. static get fallbackTexture(): string;
  38536. static set fallbackTexture(value: string);
  38537. /**
  38538. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38539. * @param u defines the coordinate on X axis
  38540. * @param v defines the coordinate on Y axis
  38541. * @param width defines the width of the source data
  38542. * @param height defines the height of the source data
  38543. * @param pixels defines the source byte array
  38544. * @param color defines the output color
  38545. */
  38546. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38547. /**
  38548. * Interpolates between a and b via alpha
  38549. * @param a The lower value (returned when alpha = 0)
  38550. * @param b The upper value (returned when alpha = 1)
  38551. * @param alpha The interpolation-factor
  38552. * @return The mixed value
  38553. */
  38554. static Mix(a: number, b: number, alpha: number): number;
  38555. /**
  38556. * Tries to instantiate a new object from a given class name
  38557. * @param className defines the class name to instantiate
  38558. * @returns the new object or null if the system was not able to do the instantiation
  38559. */
  38560. static Instantiate(className: string): any;
  38561. /**
  38562. * Provides a slice function that will work even on IE
  38563. * @param data defines the array to slice
  38564. * @param start defines the start of the data (optional)
  38565. * @param end defines the end of the data (optional)
  38566. * @returns the new sliced array
  38567. */
  38568. static Slice<T>(data: T, start?: number, end?: number): T;
  38569. /**
  38570. * Polyfill for setImmediate
  38571. * @param action defines the action to execute after the current execution block
  38572. */
  38573. static SetImmediate(action: () => void): void;
  38574. /**
  38575. * Function indicating if a number is an exponent of 2
  38576. * @param value defines the value to test
  38577. * @returns true if the value is an exponent of 2
  38578. */
  38579. static IsExponentOfTwo(value: number): boolean;
  38580. private static _tmpFloatArray;
  38581. /**
  38582. * Returns the nearest 32-bit single precision float representation of a Number
  38583. * @param value A Number. If the parameter is of a different type, it will get converted
  38584. * to a number or to NaN if it cannot be converted
  38585. * @returns number
  38586. */
  38587. static FloatRound(value: number): number;
  38588. /**
  38589. * Extracts the filename from a path
  38590. * @param path defines the path to use
  38591. * @returns the filename
  38592. */
  38593. static GetFilename(path: string): string;
  38594. /**
  38595. * Extracts the "folder" part of a path (everything before the filename).
  38596. * @param uri The URI to extract the info from
  38597. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38598. * @returns The "folder" part of the path
  38599. */
  38600. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38601. /**
  38602. * Extracts text content from a DOM element hierarchy
  38603. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38604. */
  38605. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38606. /**
  38607. * Convert an angle in radians to degrees
  38608. * @param angle defines the angle to convert
  38609. * @returns the angle in degrees
  38610. */
  38611. static ToDegrees(angle: number): number;
  38612. /**
  38613. * Convert an angle in degrees to radians
  38614. * @param angle defines the angle to convert
  38615. * @returns the angle in radians
  38616. */
  38617. static ToRadians(angle: number): number;
  38618. /**
  38619. * Returns an array if obj is not an array
  38620. * @param obj defines the object to evaluate as an array
  38621. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38622. * @returns either obj directly if obj is an array or a new array containing obj
  38623. */
  38624. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38625. /**
  38626. * Gets the pointer prefix to use
  38627. * @param engine defines the engine we are finding the prefix for
  38628. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38629. */
  38630. static GetPointerPrefix(engine: Engine): string;
  38631. /**
  38632. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38633. * @param url define the url we are trying
  38634. * @param element define the dom element where to configure the cors policy
  38635. */
  38636. static SetCorsBehavior(url: string | string[], element: {
  38637. crossOrigin: string | null;
  38638. }): void;
  38639. /**
  38640. * Removes unwanted characters from an url
  38641. * @param url defines the url to clean
  38642. * @returns the cleaned url
  38643. */
  38644. static CleanUrl(url: string): string;
  38645. /**
  38646. * Gets or sets a function used to pre-process url before using them to load assets
  38647. */
  38648. static get PreprocessUrl(): (url: string) => string;
  38649. static set PreprocessUrl(processor: (url: string) => string);
  38650. /**
  38651. * Loads an image as an HTMLImageElement.
  38652. * @param input url string, ArrayBuffer, or Blob to load
  38653. * @param onLoad callback called when the image successfully loads
  38654. * @param onError callback called when the image fails to load
  38655. * @param offlineProvider offline provider for caching
  38656. * @param mimeType optional mime type
  38657. * @returns the HTMLImageElement of the loaded image
  38658. */
  38659. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38660. /**
  38661. * Loads a file from a url
  38662. * @param url url string, ArrayBuffer, or Blob to load
  38663. * @param onSuccess callback called when the file successfully loads
  38664. * @param onProgress callback called while file is loading (if the server supports this mode)
  38665. * @param offlineProvider defines the offline provider for caching
  38666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38667. * @param onError callback called when the file fails to load
  38668. * @returns a file request object
  38669. */
  38670. 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;
  38671. /**
  38672. * Loads a file from a url
  38673. * @param url the file url to load
  38674. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38675. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38676. */
  38677. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38678. /**
  38679. * Load a script (identified by an url). When the url returns, the
  38680. * content of this file is added into a new script element, attached to the DOM (body element)
  38681. * @param scriptUrl defines the url of the script to laod
  38682. * @param onSuccess defines the callback called when the script is loaded
  38683. * @param onError defines the callback to call if an error occurs
  38684. * @param scriptId defines the id of the script element
  38685. */
  38686. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38687. /**
  38688. * Load an asynchronous script (identified by an url). When the url returns, the
  38689. * content of this file is added into a new script element, attached to the DOM (body element)
  38690. * @param scriptUrl defines the url of the script to laod
  38691. * @param scriptId defines the id of the script element
  38692. * @returns a promise request object
  38693. */
  38694. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38695. /**
  38696. * Loads a file from a blob
  38697. * @param fileToLoad defines the blob to use
  38698. * @param callback defines the callback to call when data is loaded
  38699. * @param progressCallback defines the callback to call during loading process
  38700. * @returns a file request object
  38701. */
  38702. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38703. /**
  38704. * Reads a file from a File object
  38705. * @param file defines the file to load
  38706. * @param onSuccess defines the callback to call when data is loaded
  38707. * @param onProgress defines the callback to call during loading process
  38708. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38709. * @param onError defines the callback to call when an error occurs
  38710. * @returns a file request object
  38711. */
  38712. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38713. /**
  38714. * Creates a data url from a given string content
  38715. * @param content defines the content to convert
  38716. * @returns the new data url link
  38717. */
  38718. static FileAsURL(content: string): string;
  38719. /**
  38720. * Format the given number to a specific decimal format
  38721. * @param value defines the number to format
  38722. * @param decimals defines the number of decimals to use
  38723. * @returns the formatted string
  38724. */
  38725. static Format(value: number, decimals?: number): string;
  38726. /**
  38727. * Tries to copy an object by duplicating every property
  38728. * @param source defines the source object
  38729. * @param destination defines the target object
  38730. * @param doNotCopyList defines a list of properties to avoid
  38731. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38732. */
  38733. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38734. /**
  38735. * Gets a boolean indicating if the given object has no own property
  38736. * @param obj defines the object to test
  38737. * @returns true if object has no own property
  38738. */
  38739. static IsEmpty(obj: any): boolean;
  38740. /**
  38741. * Function used to register events at window level
  38742. * @param windowElement defines the Window object to use
  38743. * @param events defines the events to register
  38744. */
  38745. static RegisterTopRootEvents(windowElement: Window, events: {
  38746. name: string;
  38747. handler: Nullable<(e: FocusEvent) => any>;
  38748. }[]): void;
  38749. /**
  38750. * Function used to unregister events from window level
  38751. * @param windowElement defines the Window object to use
  38752. * @param events defines the events to unregister
  38753. */
  38754. static UnregisterTopRootEvents(windowElement: Window, events: {
  38755. name: string;
  38756. handler: Nullable<(e: FocusEvent) => any>;
  38757. }[]): void;
  38758. /**
  38759. * @ignore
  38760. */
  38761. static _ScreenshotCanvas: HTMLCanvasElement;
  38762. /**
  38763. * Dumps the current bound framebuffer
  38764. * @param width defines the rendering width
  38765. * @param height defines the rendering height
  38766. * @param engine defines the hosting engine
  38767. * @param successCallback defines the callback triggered once the data are available
  38768. * @param mimeType defines the mime type of the result
  38769. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38770. */
  38771. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38772. /**
  38773. * Converts the canvas data to blob.
  38774. * This acts as a polyfill for browsers not supporting the to blob function.
  38775. * @param canvas Defines the canvas to extract the data from
  38776. * @param successCallback Defines the callback triggered once the data are available
  38777. * @param mimeType Defines the mime type of the result
  38778. */
  38779. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38780. /**
  38781. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38782. * @param successCallback defines the callback triggered once the data are available
  38783. * @param mimeType defines the mime type of the result
  38784. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38785. */
  38786. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38787. /**
  38788. * Downloads a blob in the browser
  38789. * @param blob defines the blob to download
  38790. * @param fileName defines the name of the downloaded file
  38791. */
  38792. static Download(blob: Blob, fileName: string): void;
  38793. /**
  38794. * Captures a screenshot of the current rendering
  38795. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38796. * @param engine defines the rendering engine
  38797. * @param camera defines the source camera
  38798. * @param size This parameter can be set to a single number or to an object with the
  38799. * following (optional) properties: precision, width, height. If a single number is passed,
  38800. * it will be used for both width and height. If an object is passed, the screenshot size
  38801. * will be derived from the parameters. The precision property is a multiplier allowing
  38802. * rendering at a higher or lower resolution
  38803. * @param successCallback defines the callback receives a single parameter which contains the
  38804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38805. * src parameter of an <img> to display it
  38806. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38807. * Check your browser for supported MIME types
  38808. */
  38809. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38810. /**
  38811. * Captures a screenshot of the current rendering
  38812. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38813. * @param engine defines the rendering engine
  38814. * @param camera defines the source camera
  38815. * @param size This parameter can be set to a single number or to an object with the
  38816. * following (optional) properties: precision, width, height. If a single number is passed,
  38817. * it will be used for both width and height. If an object is passed, the screenshot size
  38818. * will be derived from the parameters. The precision property is a multiplier allowing
  38819. * rendering at a higher or lower resolution
  38820. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38821. * Check your browser for supported MIME types
  38822. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38823. * to the src parameter of an <img> to display it
  38824. */
  38825. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38826. /**
  38827. * Generates an image screenshot from the specified camera.
  38828. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38829. * @param engine The engine to use for rendering
  38830. * @param camera The camera to use for rendering
  38831. * @param size This parameter can be set to a single number or to an object with the
  38832. * following (optional) properties: precision, width, height. If a single number is passed,
  38833. * it will be used for both width and height. If an object is passed, the screenshot size
  38834. * will be derived from the parameters. The precision property is a multiplier allowing
  38835. * rendering at a higher or lower resolution
  38836. * @param successCallback The callback receives a single parameter which contains the
  38837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38838. * src parameter of an <img> to display it
  38839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38840. * Check your browser for supported MIME types
  38841. * @param samples Texture samples (default: 1)
  38842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38843. * @param fileName A name for for the downloaded file.
  38844. */
  38845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38846. /**
  38847. * Generates an image screenshot from the specified camera.
  38848. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38849. * @param engine The engine to use for rendering
  38850. * @param camera The camera to use for rendering
  38851. * @param size This parameter can be set to a single number or to an object with the
  38852. * following (optional) properties: precision, width, height. If a single number is passed,
  38853. * it will be used for both width and height. If an object is passed, the screenshot size
  38854. * will be derived from the parameters. The precision property is a multiplier allowing
  38855. * rendering at a higher or lower resolution
  38856. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38857. * Check your browser for supported MIME types
  38858. * @param samples Texture samples (default: 1)
  38859. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38860. * @param fileName A name for for the downloaded file.
  38861. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38862. * to the src parameter of an <img> to display it
  38863. */
  38864. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38865. /**
  38866. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38867. * Be aware Math.random() could cause collisions, but:
  38868. * "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"
  38869. * @returns a pseudo random id
  38870. */
  38871. static RandomId(): string;
  38872. /**
  38873. * Test if the given uri is a base64 string
  38874. * @param uri The uri to test
  38875. * @return True if the uri is a base64 string or false otherwise
  38876. */
  38877. static IsBase64(uri: string): boolean;
  38878. /**
  38879. * Decode the given base64 uri.
  38880. * @param uri The uri to decode
  38881. * @return The decoded base64 data.
  38882. */
  38883. static DecodeBase64(uri: string): ArrayBuffer;
  38884. /**
  38885. * Gets the absolute url.
  38886. * @param url the input url
  38887. * @return the absolute url
  38888. */
  38889. static GetAbsoluteUrl(url: string): string;
  38890. /**
  38891. * No log
  38892. */
  38893. static readonly NoneLogLevel: number;
  38894. /**
  38895. * Only message logs
  38896. */
  38897. static readonly MessageLogLevel: number;
  38898. /**
  38899. * Only warning logs
  38900. */
  38901. static readonly WarningLogLevel: number;
  38902. /**
  38903. * Only error logs
  38904. */
  38905. static readonly ErrorLogLevel: number;
  38906. /**
  38907. * All logs
  38908. */
  38909. static readonly AllLogLevel: number;
  38910. /**
  38911. * Gets a value indicating the number of loading errors
  38912. * @ignorenaming
  38913. */
  38914. static get errorsCount(): number;
  38915. /**
  38916. * Callback called when a new log is added
  38917. */
  38918. static OnNewCacheEntry: (entry: string) => void;
  38919. /**
  38920. * Log a message to the console
  38921. * @param message defines the message to log
  38922. */
  38923. static Log(message: string): void;
  38924. /**
  38925. * Write a warning message to the console
  38926. * @param message defines the message to log
  38927. */
  38928. static Warn(message: string): void;
  38929. /**
  38930. * Write an error message to the console
  38931. * @param message defines the message to log
  38932. */
  38933. static Error(message: string): void;
  38934. /**
  38935. * Gets current log cache (list of logs)
  38936. */
  38937. static get LogCache(): string;
  38938. /**
  38939. * Clears the log cache
  38940. */
  38941. static ClearLogCache(): void;
  38942. /**
  38943. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38944. */
  38945. static set LogLevels(level: number);
  38946. /**
  38947. * Checks if the window object exists
  38948. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38949. */
  38950. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38951. /**
  38952. * No performance log
  38953. */
  38954. static readonly PerformanceNoneLogLevel: number;
  38955. /**
  38956. * Use user marks to log performance
  38957. */
  38958. static readonly PerformanceUserMarkLogLevel: number;
  38959. /**
  38960. * Log performance to the console
  38961. */
  38962. static readonly PerformanceConsoleLogLevel: number;
  38963. private static _performance;
  38964. /**
  38965. * Sets the current performance log level
  38966. */
  38967. static set PerformanceLogLevel(level: number);
  38968. private static _StartPerformanceCounterDisabled;
  38969. private static _EndPerformanceCounterDisabled;
  38970. private static _StartUserMark;
  38971. private static _EndUserMark;
  38972. private static _StartPerformanceConsole;
  38973. private static _EndPerformanceConsole;
  38974. /**
  38975. * Starts a performance counter
  38976. */
  38977. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38978. /**
  38979. * Ends a specific performance coutner
  38980. */
  38981. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38982. /**
  38983. * Gets either window.performance.now() if supported or Date.now() else
  38984. */
  38985. static get Now(): number;
  38986. /**
  38987. * This method will return the name of the class used to create the instance of the given object.
  38988. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38989. * @param object the object to get the class name from
  38990. * @param isType defines if the object is actually a type
  38991. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38992. */
  38993. static GetClassName(object: any, isType?: boolean): string;
  38994. /**
  38995. * Gets the first element of an array satisfying a given predicate
  38996. * @param array defines the array to browse
  38997. * @param predicate defines the predicate to use
  38998. * @returns null if not found or the element
  38999. */
  39000. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39001. /**
  39002. * This method will return the name of the full name of the class, including its owning module (if any).
  39003. * 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).
  39004. * @param object the object to get the class name from
  39005. * @param isType defines if the object is actually a type
  39006. * @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.
  39007. * @ignorenaming
  39008. */
  39009. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39010. /**
  39011. * Returns a promise that resolves after the given amount of time.
  39012. * @param delay Number of milliseconds to delay
  39013. * @returns Promise that resolves after the given amount of time
  39014. */
  39015. static DelayAsync(delay: number): Promise<void>;
  39016. /**
  39017. * Utility function to detect if the current user agent is Safari
  39018. * @returns whether or not the current user agent is safari
  39019. */
  39020. static IsSafari(): boolean;
  39021. }
  39022. /**
  39023. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39024. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39025. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39026. * @param name The name of the class, case should be preserved
  39027. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39028. */
  39029. export function className(name: string, module?: string): (target: Object) => void;
  39030. /**
  39031. * An implementation of a loop for asynchronous functions.
  39032. */
  39033. export class AsyncLoop {
  39034. /**
  39035. * Defines the number of iterations for the loop
  39036. */
  39037. iterations: number;
  39038. /**
  39039. * Defines the current index of the loop.
  39040. */
  39041. index: number;
  39042. private _done;
  39043. private _fn;
  39044. private _successCallback;
  39045. /**
  39046. * Constructor.
  39047. * @param iterations the number of iterations.
  39048. * @param func the function to run each iteration
  39049. * @param successCallback the callback that will be called upon succesful execution
  39050. * @param offset starting offset.
  39051. */
  39052. constructor(
  39053. /**
  39054. * Defines the number of iterations for the loop
  39055. */
  39056. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39057. /**
  39058. * Execute the next iteration. Must be called after the last iteration was finished.
  39059. */
  39060. executeNext(): void;
  39061. /**
  39062. * Break the loop and run the success callback.
  39063. */
  39064. breakLoop(): void;
  39065. /**
  39066. * Create and run an async loop.
  39067. * @param iterations the number of iterations.
  39068. * @param fn the function to run each iteration
  39069. * @param successCallback the callback that will be called upon succesful execution
  39070. * @param offset starting offset.
  39071. * @returns the created async loop object
  39072. */
  39073. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39074. /**
  39075. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39076. * @param iterations total number of iterations
  39077. * @param syncedIterations number of synchronous iterations in each async iteration.
  39078. * @param fn the function to call each iteration.
  39079. * @param callback a success call back that will be called when iterating stops.
  39080. * @param breakFunction a break condition (optional)
  39081. * @param timeout timeout settings for the setTimeout function. default - 0.
  39082. * @returns the created async loop object
  39083. */
  39084. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39085. }
  39086. }
  39087. declare module "babylonjs/Misc/stringDictionary" {
  39088. import { Nullable } from "babylonjs/types";
  39089. /**
  39090. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39091. * The underlying implementation relies on an associative array to ensure the best performances.
  39092. * The value can be anything including 'null' but except 'undefined'
  39093. */
  39094. export class StringDictionary<T> {
  39095. /**
  39096. * This will clear this dictionary and copy the content from the 'source' one.
  39097. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39098. * @param source the dictionary to take the content from and copy to this dictionary
  39099. */
  39100. copyFrom(source: StringDictionary<T>): void;
  39101. /**
  39102. * Get a value based from its key
  39103. * @param key the given key to get the matching value from
  39104. * @return the value if found, otherwise undefined is returned
  39105. */
  39106. get(key: string): T | undefined;
  39107. /**
  39108. * Get a value from its key or add it if it doesn't exist.
  39109. * This method will ensure you that a given key/data will be present in the dictionary.
  39110. * @param key the given key to get the matching value from
  39111. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39112. * The factory will only be invoked if there's no data for the given key.
  39113. * @return the value corresponding to the key.
  39114. */
  39115. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39116. /**
  39117. * Get a value from its key if present in the dictionary otherwise add it
  39118. * @param key the key to get the value from
  39119. * @param val if there's no such key/value pair in the dictionary add it with this value
  39120. * @return the value corresponding to the key
  39121. */
  39122. getOrAdd(key: string, val: T): T;
  39123. /**
  39124. * Check if there's a given key in the dictionary
  39125. * @param key the key to check for
  39126. * @return true if the key is present, false otherwise
  39127. */
  39128. contains(key: string): boolean;
  39129. /**
  39130. * Add a new key and its corresponding value
  39131. * @param key the key to add
  39132. * @param value the value corresponding to the key
  39133. * @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
  39134. */
  39135. add(key: string, value: T): boolean;
  39136. /**
  39137. * Update a specific value associated to a key
  39138. * @param key defines the key to use
  39139. * @param value defines the value to store
  39140. * @returns true if the value was updated (or false if the key was not found)
  39141. */
  39142. set(key: string, value: T): boolean;
  39143. /**
  39144. * Get the element of the given key and remove it from the dictionary
  39145. * @param key defines the key to search
  39146. * @returns the value associated with the key or null if not found
  39147. */
  39148. getAndRemove(key: string): Nullable<T>;
  39149. /**
  39150. * Remove a key/value from the dictionary.
  39151. * @param key the key to remove
  39152. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39153. */
  39154. remove(key: string): boolean;
  39155. /**
  39156. * Clear the whole content of the dictionary
  39157. */
  39158. clear(): void;
  39159. /**
  39160. * Gets the current count
  39161. */
  39162. get count(): number;
  39163. /**
  39164. * Execute a callback on each key/val of the dictionary.
  39165. * Note that you can remove any element in this dictionary in the callback implementation
  39166. * @param callback the callback to execute on a given key/value pair
  39167. */
  39168. forEach(callback: (key: string, val: T) => void): void;
  39169. /**
  39170. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39171. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39172. * Note that you can remove any element in this dictionary in the callback implementation
  39173. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39174. * @returns the first item
  39175. */
  39176. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39177. private _count;
  39178. private _data;
  39179. }
  39180. }
  39181. declare module "babylonjs/Collisions/collisionCoordinator" {
  39182. import { Nullable } from "babylonjs/types";
  39183. import { Scene } from "babylonjs/scene";
  39184. import { Vector3 } from "babylonjs/Maths/math.vector";
  39185. import { Collider } from "babylonjs/Collisions/collider";
  39186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39187. /** @hidden */
  39188. export interface ICollisionCoordinator {
  39189. createCollider(): Collider;
  39190. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39191. init(scene: Scene): void;
  39192. }
  39193. /** @hidden */
  39194. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39195. private _scene;
  39196. private _scaledPosition;
  39197. private _scaledVelocity;
  39198. private _finalPosition;
  39199. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39200. createCollider(): Collider;
  39201. init(scene: Scene): void;
  39202. private _collideWithWorld;
  39203. }
  39204. }
  39205. declare module "babylonjs/Inputs/scene.inputManager" {
  39206. import { Nullable } from "babylonjs/types";
  39207. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39208. import { Vector2 } from "babylonjs/Maths/math.vector";
  39209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39210. import { Scene } from "babylonjs/scene";
  39211. /**
  39212. * Class used to manage all inputs for the scene.
  39213. */
  39214. export class InputManager {
  39215. /** The distance in pixel that you have to move to prevent some events */
  39216. static DragMovementThreshold: number;
  39217. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39218. static LongPressDelay: number;
  39219. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39220. static DoubleClickDelay: number;
  39221. /** If you need to check double click without raising a single click at first click, enable this flag */
  39222. static ExclusiveDoubleClickMode: boolean;
  39223. private _wheelEventName;
  39224. private _onPointerMove;
  39225. private _onPointerDown;
  39226. private _onPointerUp;
  39227. private _initClickEvent;
  39228. private _initActionManager;
  39229. private _delayedSimpleClick;
  39230. private _delayedSimpleClickTimeout;
  39231. private _previousDelayedSimpleClickTimeout;
  39232. private _meshPickProceed;
  39233. private _previousButtonPressed;
  39234. private _currentPickResult;
  39235. private _previousPickResult;
  39236. private _totalPointersPressed;
  39237. private _doubleClickOccured;
  39238. private _pointerOverMesh;
  39239. private _pickedDownMesh;
  39240. private _pickedUpMesh;
  39241. private _pointerX;
  39242. private _pointerY;
  39243. private _unTranslatedPointerX;
  39244. private _unTranslatedPointerY;
  39245. private _startingPointerPosition;
  39246. private _previousStartingPointerPosition;
  39247. private _startingPointerTime;
  39248. private _previousStartingPointerTime;
  39249. private _pointerCaptures;
  39250. private _onKeyDown;
  39251. private _onKeyUp;
  39252. private _onCanvasFocusObserver;
  39253. private _onCanvasBlurObserver;
  39254. private _scene;
  39255. /**
  39256. * Creates a new InputManager
  39257. * @param scene defines the hosting scene
  39258. */
  39259. constructor(scene: Scene);
  39260. /**
  39261. * Gets the mesh that is currently under the pointer
  39262. */
  39263. get meshUnderPointer(): Nullable<AbstractMesh>;
  39264. /**
  39265. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39266. */
  39267. get unTranslatedPointer(): Vector2;
  39268. /**
  39269. * Gets or sets the current on-screen X position of the pointer
  39270. */
  39271. get pointerX(): number;
  39272. set pointerX(value: number);
  39273. /**
  39274. * Gets or sets the current on-screen Y position of the pointer
  39275. */
  39276. get pointerY(): number;
  39277. set pointerY(value: number);
  39278. private _updatePointerPosition;
  39279. private _processPointerMove;
  39280. private _setRayOnPointerInfo;
  39281. private _checkPrePointerObservable;
  39282. /**
  39283. * Use this method to simulate a pointer move on a mesh
  39284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39287. */
  39288. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39289. /**
  39290. * Use this method to simulate a pointer down on a mesh
  39291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39294. */
  39295. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39296. private _processPointerDown;
  39297. /** @hidden */
  39298. _isPointerSwiping(): boolean;
  39299. /**
  39300. * Use this method to simulate a pointer up on a mesh
  39301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39304. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39305. */
  39306. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39307. private _processPointerUp;
  39308. /**
  39309. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39310. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39311. * @returns true if the pointer was captured
  39312. */
  39313. isPointerCaptured(pointerId?: number): boolean;
  39314. /**
  39315. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39316. * @param attachUp defines if you want to attach events to pointerup
  39317. * @param attachDown defines if you want to attach events to pointerdown
  39318. * @param attachMove defines if you want to attach events to pointermove
  39319. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39320. */
  39321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39322. /**
  39323. * Detaches all event handlers
  39324. */
  39325. detachControl(): void;
  39326. /**
  39327. * Force the value of meshUnderPointer
  39328. * @param mesh defines the mesh to use
  39329. */
  39330. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39331. /**
  39332. * Gets the mesh under the pointer
  39333. * @returns a Mesh or null if no mesh is under the pointer
  39334. */
  39335. getPointerOverMesh(): Nullable<AbstractMesh>;
  39336. }
  39337. }
  39338. declare module "babylonjs/Animations/animationGroup" {
  39339. import { Animatable } from "babylonjs/Animations/animatable";
  39340. import { Animation } from "babylonjs/Animations/animation";
  39341. import { Scene, IDisposable } from "babylonjs/scene";
  39342. import { Observable } from "babylonjs/Misc/observable";
  39343. import { Nullable } from "babylonjs/types";
  39344. import "babylonjs/Animations/animatable";
  39345. /**
  39346. * This class defines the direct association between an animation and a target
  39347. */
  39348. export class TargetedAnimation {
  39349. /**
  39350. * Animation to perform
  39351. */
  39352. animation: Animation;
  39353. /**
  39354. * Target to animate
  39355. */
  39356. target: any;
  39357. /**
  39358. * Returns the string "TargetedAnimation"
  39359. * @returns "TargetedAnimation"
  39360. */
  39361. getClassName(): string;
  39362. /**
  39363. * Serialize the object
  39364. * @returns the JSON object representing the current entity
  39365. */
  39366. serialize(): any;
  39367. }
  39368. /**
  39369. * Use this class to create coordinated animations on multiple targets
  39370. */
  39371. export class AnimationGroup implements IDisposable {
  39372. /** The name of the animation group */
  39373. name: string;
  39374. private _scene;
  39375. private _targetedAnimations;
  39376. private _animatables;
  39377. private _from;
  39378. private _to;
  39379. private _isStarted;
  39380. private _isPaused;
  39381. private _speedRatio;
  39382. private _loopAnimation;
  39383. private _isAdditive;
  39384. /**
  39385. * Gets or sets the unique id of the node
  39386. */
  39387. uniqueId: number;
  39388. /**
  39389. * This observable will notify when one animation have ended
  39390. */
  39391. onAnimationEndObservable: Observable<TargetedAnimation>;
  39392. /**
  39393. * Observer raised when one animation loops
  39394. */
  39395. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39396. /**
  39397. * Observer raised when all animations have looped
  39398. */
  39399. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39400. /**
  39401. * This observable will notify when all animations have ended.
  39402. */
  39403. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39404. /**
  39405. * This observable will notify when all animations have paused.
  39406. */
  39407. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39408. /**
  39409. * This observable will notify when all animations are playing.
  39410. */
  39411. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39412. /**
  39413. * Gets the first frame
  39414. */
  39415. get from(): number;
  39416. /**
  39417. * Gets the last frame
  39418. */
  39419. get to(): number;
  39420. /**
  39421. * Define if the animations are started
  39422. */
  39423. get isStarted(): boolean;
  39424. /**
  39425. * Gets a value indicating that the current group is playing
  39426. */
  39427. get isPlaying(): boolean;
  39428. /**
  39429. * Gets or sets the speed ratio to use for all animations
  39430. */
  39431. get speedRatio(): number;
  39432. /**
  39433. * Gets or sets the speed ratio to use for all animations
  39434. */
  39435. set speedRatio(value: number);
  39436. /**
  39437. * Gets or sets if all animations should loop or not
  39438. */
  39439. get loopAnimation(): boolean;
  39440. set loopAnimation(value: boolean);
  39441. /**
  39442. * Gets or sets if all animations should be evaluated additively
  39443. */
  39444. get isAdditive(): boolean;
  39445. set isAdditive(value: boolean);
  39446. /**
  39447. * Gets the targeted animations for this animation group
  39448. */
  39449. get targetedAnimations(): Array<TargetedAnimation>;
  39450. /**
  39451. * returning the list of animatables controlled by this animation group.
  39452. */
  39453. get animatables(): Array<Animatable>;
  39454. /**
  39455. * Gets the list of target animations
  39456. */
  39457. get children(): TargetedAnimation[];
  39458. /**
  39459. * Instantiates a new Animation Group.
  39460. * This helps managing several animations at once.
  39461. * @see https://doc.babylonjs.com/how_to/group
  39462. * @param name Defines the name of the group
  39463. * @param scene Defines the scene the group belongs to
  39464. */
  39465. constructor(
  39466. /** The name of the animation group */
  39467. name: string, scene?: Nullable<Scene>);
  39468. /**
  39469. * Add an animation (with its target) in the group
  39470. * @param animation defines the animation we want to add
  39471. * @param target defines the target of the animation
  39472. * @returns the TargetedAnimation object
  39473. */
  39474. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39475. /**
  39476. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39477. * It can add constant keys at begin or end
  39478. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39479. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39480. * @returns the animation group
  39481. */
  39482. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39483. private _animationLoopCount;
  39484. private _animationLoopFlags;
  39485. private _processLoop;
  39486. /**
  39487. * Start all animations on given targets
  39488. * @param loop defines if animations must loop
  39489. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39490. * @param from defines the from key (optional)
  39491. * @param to defines the to key (optional)
  39492. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39493. * @returns the current animation group
  39494. */
  39495. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39496. /**
  39497. * Pause all animations
  39498. * @returns the animation group
  39499. */
  39500. pause(): AnimationGroup;
  39501. /**
  39502. * Play all animations to initial state
  39503. * This function will start() the animations if they were not started or will restart() them if they were paused
  39504. * @param loop defines if animations must loop
  39505. * @returns the animation group
  39506. */
  39507. play(loop?: boolean): AnimationGroup;
  39508. /**
  39509. * Reset all animations to initial state
  39510. * @returns the animation group
  39511. */
  39512. reset(): AnimationGroup;
  39513. /**
  39514. * Restart animations from key 0
  39515. * @returns the animation group
  39516. */
  39517. restart(): AnimationGroup;
  39518. /**
  39519. * Stop all animations
  39520. * @returns the animation group
  39521. */
  39522. stop(): AnimationGroup;
  39523. /**
  39524. * Set animation weight for all animatables
  39525. * @param weight defines the weight to use
  39526. * @return the animationGroup
  39527. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39528. */
  39529. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39530. /**
  39531. * Synchronize and normalize all animatables with a source animatable
  39532. * @param root defines the root animatable to synchronize with
  39533. * @return the animationGroup
  39534. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39535. */
  39536. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39537. /**
  39538. * Goes to a specific frame in this animation group
  39539. * @param frame the frame number to go to
  39540. * @return the animationGroup
  39541. */
  39542. goToFrame(frame: number): AnimationGroup;
  39543. /**
  39544. * Dispose all associated resources
  39545. */
  39546. dispose(): void;
  39547. private _checkAnimationGroupEnded;
  39548. /**
  39549. * Clone the current animation group and returns a copy
  39550. * @param newName defines the name of the new group
  39551. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39552. * @returns the new aniamtion group
  39553. */
  39554. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39555. /**
  39556. * Serializes the animationGroup to an object
  39557. * @returns Serialized object
  39558. */
  39559. serialize(): any;
  39560. /**
  39561. * Returns a new AnimationGroup object parsed from the source provided.
  39562. * @param parsedAnimationGroup defines the source
  39563. * @param scene defines the scene that will receive the animationGroup
  39564. * @returns a new AnimationGroup
  39565. */
  39566. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39567. /**
  39568. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39569. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39570. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39571. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39572. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39573. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39574. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39575. */
  39576. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39577. /**
  39578. * Returns the string "AnimationGroup"
  39579. * @returns "AnimationGroup"
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Creates a detailled string about the object
  39584. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39585. * @returns a string representing the object
  39586. */
  39587. toString(fullDetails?: boolean): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/scene" {
  39591. import { Nullable } from "babylonjs/types";
  39592. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39593. import { Observable } from "babylonjs/Misc/observable";
  39594. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39595. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39596. import { Geometry } from "babylonjs/Meshes/geometry";
  39597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39600. import { Mesh } from "babylonjs/Meshes/mesh";
  39601. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39602. import { Bone } from "babylonjs/Bones/bone";
  39603. import { Skeleton } from "babylonjs/Bones/skeleton";
  39604. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39605. import { Camera } from "babylonjs/Cameras/camera";
  39606. import { AbstractScene } from "babylonjs/abstractScene";
  39607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39609. import { Material } from "babylonjs/Materials/material";
  39610. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39611. import { Effect } from "babylonjs/Materials/effect";
  39612. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39613. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39614. import { Light } from "babylonjs/Lights/light";
  39615. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39616. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39617. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39618. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39620. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39621. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39622. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39623. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39624. import { Engine } from "babylonjs/Engines/engine";
  39625. import { Node } from "babylonjs/node";
  39626. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39627. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39628. import { WebRequest } from "babylonjs/Misc/webRequest";
  39629. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39630. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39631. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39632. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39633. import { Plane } from "babylonjs/Maths/math.plane";
  39634. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39635. import { Ray } from "babylonjs/Culling/ray";
  39636. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39637. import { Animation } from "babylonjs/Animations/animation";
  39638. import { Animatable } from "babylonjs/Animations/animatable";
  39639. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39641. import { Collider } from "babylonjs/Collisions/collider";
  39642. /**
  39643. * Define an interface for all classes that will hold resources
  39644. */
  39645. export interface IDisposable {
  39646. /**
  39647. * Releases all held resources
  39648. */
  39649. dispose(): void;
  39650. }
  39651. /** Interface defining initialization parameters for Scene class */
  39652. export interface SceneOptions {
  39653. /**
  39654. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39655. * It will improve performance when the number of geometries becomes important.
  39656. */
  39657. useGeometryUniqueIdsMap?: boolean;
  39658. /**
  39659. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  39663. /**
  39664. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39665. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39666. */
  39667. useClonedMeshMap?: boolean;
  39668. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39669. virtual?: boolean;
  39670. }
  39671. /**
  39672. * Represents a scene to be rendered by the engine.
  39673. * @see https://doc.babylonjs.com/features/scene
  39674. */
  39675. export class Scene extends AbstractScene implements IAnimatable {
  39676. /** The fog is deactivated */
  39677. static readonly FOGMODE_NONE: number;
  39678. /** The fog density is following an exponential function */
  39679. static readonly FOGMODE_EXP: number;
  39680. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39681. static readonly FOGMODE_EXP2: number;
  39682. /** The fog density is following a linear function. */
  39683. static readonly FOGMODE_LINEAR: number;
  39684. /**
  39685. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39686. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39687. */
  39688. static MinDeltaTime: number;
  39689. /**
  39690. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39692. */
  39693. static MaxDeltaTime: number;
  39694. /**
  39695. * Factory used to create the default material.
  39696. * @param name The name of the material to create
  39697. * @param scene The scene to create the material for
  39698. * @returns The default material
  39699. */
  39700. static DefaultMaterialFactory(scene: Scene): Material;
  39701. /**
  39702. * Factory used to create the a collision coordinator.
  39703. * @returns The collision coordinator
  39704. */
  39705. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39706. /** @hidden */
  39707. _inputManager: InputManager;
  39708. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39709. cameraToUseForPointers: Nullable<Camera>;
  39710. /** @hidden */
  39711. readonly _isScene: boolean;
  39712. /** @hidden */
  39713. _blockEntityCollection: boolean;
  39714. /**
  39715. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39716. */
  39717. autoClear: boolean;
  39718. /**
  39719. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39720. */
  39721. autoClearDepthAndStencil: boolean;
  39722. /**
  39723. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39724. */
  39725. clearColor: Color4;
  39726. /**
  39727. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39728. */
  39729. ambientColor: Color3;
  39730. /**
  39731. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39732. * It should only be one of the following (if not the default embedded one):
  39733. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39734. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39735. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39736. * The material properties need to be setup according to the type of texture in use.
  39737. */
  39738. environmentBRDFTexture: BaseTexture;
  39739. /** @hidden */
  39740. protected _environmentTexture: Nullable<BaseTexture>;
  39741. /**
  39742. * Texture used in all pbr material as the reflection texture.
  39743. * As in the majority of the scene they are the same (exception for multi room and so on),
  39744. * this is easier to reference from here than from all the materials.
  39745. */
  39746. get environmentTexture(): Nullable<BaseTexture>;
  39747. /**
  39748. * Texture used in all pbr material as the reflection texture.
  39749. * As in the majority of the scene they are the same (exception for multi room and so on),
  39750. * this is easier to set here than in all the materials.
  39751. */
  39752. set environmentTexture(value: Nullable<BaseTexture>);
  39753. /** @hidden */
  39754. protected _environmentIntensity: number;
  39755. /**
  39756. * Intensity of the environment in all pbr material.
  39757. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39758. * As in the majority of the scene they are the same (exception for multi room and so on),
  39759. * this is easier to reference from here than from all the materials.
  39760. */
  39761. get environmentIntensity(): number;
  39762. /**
  39763. * Intensity of the environment in all pbr material.
  39764. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39765. * As in the majority of the scene they are the same (exception for multi room and so on),
  39766. * this is easier to set here than in all the materials.
  39767. */
  39768. set environmentIntensity(value: number);
  39769. /** @hidden */
  39770. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39771. /**
  39772. * Default image processing configuration used either in the rendering
  39773. * Forward main pass or through the imageProcessingPostProcess if present.
  39774. * As in the majority of the scene they are the same (exception for multi camera),
  39775. * this is easier to reference from here than from all the materials and post process.
  39776. *
  39777. * No setter as we it is a shared configuration, you can set the values instead.
  39778. */
  39779. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39780. private _forceWireframe;
  39781. /**
  39782. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39783. */
  39784. set forceWireframe(value: boolean);
  39785. get forceWireframe(): boolean;
  39786. private _skipFrustumClipping;
  39787. /**
  39788. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39789. */
  39790. set skipFrustumClipping(value: boolean);
  39791. get skipFrustumClipping(): boolean;
  39792. private _forcePointsCloud;
  39793. /**
  39794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39795. */
  39796. set forcePointsCloud(value: boolean);
  39797. get forcePointsCloud(): boolean;
  39798. /**
  39799. * Gets or sets the active clipplane 1
  39800. */
  39801. clipPlane: Nullable<Plane>;
  39802. /**
  39803. * Gets or sets the active clipplane 2
  39804. */
  39805. clipPlane2: Nullable<Plane>;
  39806. /**
  39807. * Gets or sets the active clipplane 3
  39808. */
  39809. clipPlane3: Nullable<Plane>;
  39810. /**
  39811. * Gets or sets the active clipplane 4
  39812. */
  39813. clipPlane4: Nullable<Plane>;
  39814. /**
  39815. * Gets or sets the active clipplane 5
  39816. */
  39817. clipPlane5: Nullable<Plane>;
  39818. /**
  39819. * Gets or sets the active clipplane 6
  39820. */
  39821. clipPlane6: Nullable<Plane>;
  39822. /**
  39823. * Gets or sets a boolean indicating if animations are enabled
  39824. */
  39825. animationsEnabled: boolean;
  39826. private _animationPropertiesOverride;
  39827. /**
  39828. * Gets or sets the animation properties override
  39829. */
  39830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39831. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39832. /**
  39833. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39834. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39835. */
  39836. useConstantAnimationDeltaTime: boolean;
  39837. /**
  39838. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39839. * Please note that it requires to run a ray cast through the scene on every frame
  39840. */
  39841. constantlyUpdateMeshUnderPointer: boolean;
  39842. /**
  39843. * Defines the HTML cursor to use when hovering over interactive elements
  39844. */
  39845. hoverCursor: string;
  39846. /**
  39847. * Defines the HTML default cursor to use (empty by default)
  39848. */
  39849. defaultCursor: string;
  39850. /**
  39851. * Defines whether cursors are handled by the scene.
  39852. */
  39853. doNotHandleCursors: boolean;
  39854. /**
  39855. * This is used to call preventDefault() on pointer down
  39856. * in order to block unwanted artifacts like system double clicks
  39857. */
  39858. preventDefaultOnPointerDown: boolean;
  39859. /**
  39860. * This is used to call preventDefault() on pointer up
  39861. * in order to block unwanted artifacts like system double clicks
  39862. */
  39863. preventDefaultOnPointerUp: boolean;
  39864. /**
  39865. * Gets or sets user defined metadata
  39866. */
  39867. metadata: any;
  39868. /**
  39869. * For internal use only. Please do not use.
  39870. */
  39871. reservedDataStore: any;
  39872. /**
  39873. * Gets the name of the plugin used to load this scene (null by default)
  39874. */
  39875. loadingPluginName: string;
  39876. /**
  39877. * Use this array to add regular expressions used to disable offline support for specific urls
  39878. */
  39879. disableOfflineSupportExceptionRules: RegExp[];
  39880. /**
  39881. * An event triggered when the scene is disposed.
  39882. */
  39883. onDisposeObservable: Observable<Scene>;
  39884. private _onDisposeObserver;
  39885. /** Sets a function to be executed when this scene is disposed. */
  39886. set onDispose(callback: () => void);
  39887. /**
  39888. * An event triggered before rendering the scene (right after animations and physics)
  39889. */
  39890. onBeforeRenderObservable: Observable<Scene>;
  39891. private _onBeforeRenderObserver;
  39892. /** Sets a function to be executed before rendering this scene */
  39893. set beforeRender(callback: Nullable<() => void>);
  39894. /**
  39895. * An event triggered after rendering the scene
  39896. */
  39897. onAfterRenderObservable: Observable<Scene>;
  39898. /**
  39899. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39900. */
  39901. onAfterRenderCameraObservable: Observable<Camera>;
  39902. private _onAfterRenderObserver;
  39903. /** Sets a function to be executed after rendering this scene */
  39904. set afterRender(callback: Nullable<() => void>);
  39905. /**
  39906. * An event triggered before animating the scene
  39907. */
  39908. onBeforeAnimationsObservable: Observable<Scene>;
  39909. /**
  39910. * An event triggered after animations processing
  39911. */
  39912. onAfterAnimationsObservable: Observable<Scene>;
  39913. /**
  39914. * An event triggered before draw calls are ready to be sent
  39915. */
  39916. onBeforeDrawPhaseObservable: Observable<Scene>;
  39917. /**
  39918. * An event triggered after draw calls have been sent
  39919. */
  39920. onAfterDrawPhaseObservable: Observable<Scene>;
  39921. /**
  39922. * An event triggered when the scene is ready
  39923. */
  39924. onReadyObservable: Observable<Scene>;
  39925. /**
  39926. * An event triggered before rendering a camera
  39927. */
  39928. onBeforeCameraRenderObservable: Observable<Camera>;
  39929. private _onBeforeCameraRenderObserver;
  39930. /** Sets a function to be executed before rendering a camera*/
  39931. set beforeCameraRender(callback: () => void);
  39932. /**
  39933. * An event triggered after rendering a camera
  39934. */
  39935. onAfterCameraRenderObservable: Observable<Camera>;
  39936. private _onAfterCameraRenderObserver;
  39937. /** Sets a function to be executed after rendering a camera*/
  39938. set afterCameraRender(callback: () => void);
  39939. /**
  39940. * An event triggered when active meshes evaluation is about to start
  39941. */
  39942. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39943. /**
  39944. * An event triggered when active meshes evaluation is done
  39945. */
  39946. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39947. /**
  39948. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39952. /**
  39953. * An event triggered when particles rendering is done
  39954. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39955. */
  39956. onAfterParticlesRenderingObservable: Observable<Scene>;
  39957. /**
  39958. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39959. */
  39960. onDataLoadedObservable: Observable<Scene>;
  39961. /**
  39962. * An event triggered when a camera is created
  39963. */
  39964. onNewCameraAddedObservable: Observable<Camera>;
  39965. /**
  39966. * An event triggered when a camera is removed
  39967. */
  39968. onCameraRemovedObservable: Observable<Camera>;
  39969. /**
  39970. * An event triggered when a light is created
  39971. */
  39972. onNewLightAddedObservable: Observable<Light>;
  39973. /**
  39974. * An event triggered when a light is removed
  39975. */
  39976. onLightRemovedObservable: Observable<Light>;
  39977. /**
  39978. * An event triggered when a geometry is created
  39979. */
  39980. onNewGeometryAddedObservable: Observable<Geometry>;
  39981. /**
  39982. * An event triggered when a geometry is removed
  39983. */
  39984. onGeometryRemovedObservable: Observable<Geometry>;
  39985. /**
  39986. * An event triggered when a transform node is created
  39987. */
  39988. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39989. /**
  39990. * An event triggered when a transform node is removed
  39991. */
  39992. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39993. /**
  39994. * An event triggered when a mesh is created
  39995. */
  39996. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39997. /**
  39998. * An event triggered when a mesh is removed
  39999. */
  40000. onMeshRemovedObservable: Observable<AbstractMesh>;
  40001. /**
  40002. * An event triggered when a skeleton is created
  40003. */
  40004. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40005. /**
  40006. * An event triggered when a skeleton is removed
  40007. */
  40008. onSkeletonRemovedObservable: Observable<Skeleton>;
  40009. /**
  40010. * An event triggered when a material is created
  40011. */
  40012. onNewMaterialAddedObservable: Observable<Material>;
  40013. /**
  40014. * An event triggered when a material is removed
  40015. */
  40016. onMaterialRemovedObservable: Observable<Material>;
  40017. /**
  40018. * An event triggered when a texture is created
  40019. */
  40020. onNewTextureAddedObservable: Observable<BaseTexture>;
  40021. /**
  40022. * An event triggered when a texture is removed
  40023. */
  40024. onTextureRemovedObservable: Observable<BaseTexture>;
  40025. /**
  40026. * An event triggered when render targets are about to be rendered
  40027. * Can happen multiple times per frame.
  40028. */
  40029. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40030. /**
  40031. * An event triggered when render targets were rendered.
  40032. * Can happen multiple times per frame.
  40033. */
  40034. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40035. /**
  40036. * An event triggered before calculating deterministic simulation step
  40037. */
  40038. onBeforeStepObservable: Observable<Scene>;
  40039. /**
  40040. * An event triggered after calculating deterministic simulation step
  40041. */
  40042. onAfterStepObservable: Observable<Scene>;
  40043. /**
  40044. * An event triggered when the activeCamera property is updated
  40045. */
  40046. onActiveCameraChanged: Observable<Scene>;
  40047. /**
  40048. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40049. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40050. * 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)
  40051. */
  40052. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40053. /**
  40054. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40055. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40056. * 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)
  40057. */
  40058. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40059. /**
  40060. * This Observable will when a mesh has been imported into the scene.
  40061. */
  40062. onMeshImportedObservable: Observable<AbstractMesh>;
  40063. /**
  40064. * This Observable will when an animation file has been imported into the scene.
  40065. */
  40066. onAnimationFileImportedObservable: Observable<Scene>;
  40067. /**
  40068. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40069. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40070. */
  40071. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40072. /** @hidden */
  40073. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40074. /**
  40075. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40076. */
  40077. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40078. /**
  40079. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40080. */
  40081. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40082. /**
  40083. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40084. */
  40085. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40086. /** Callback called when a pointer move is detected */
  40087. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40088. /** Callback called when a pointer down is detected */
  40089. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40090. /** Callback called when a pointer up is detected */
  40091. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40092. /** Callback called when a pointer pick is detected */
  40093. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40094. /**
  40095. * 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).
  40096. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40097. */
  40098. onPrePointerObservable: Observable<PointerInfoPre>;
  40099. /**
  40100. * Observable event triggered each time an input event is received from the rendering canvas
  40101. */
  40102. onPointerObservable: Observable<PointerInfo>;
  40103. /**
  40104. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40105. */
  40106. get unTranslatedPointer(): Vector2;
  40107. /**
  40108. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40109. */
  40110. static get DragMovementThreshold(): number;
  40111. static set DragMovementThreshold(value: number);
  40112. /**
  40113. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40114. */
  40115. static get LongPressDelay(): number;
  40116. static set LongPressDelay(value: number);
  40117. /**
  40118. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40119. */
  40120. static get DoubleClickDelay(): number;
  40121. static set DoubleClickDelay(value: number);
  40122. /** If you need to check double click without raising a single click at first click, enable this flag */
  40123. static get ExclusiveDoubleClickMode(): boolean;
  40124. static set ExclusiveDoubleClickMode(value: boolean);
  40125. /** @hidden */
  40126. _mirroredCameraPosition: Nullable<Vector3>;
  40127. /**
  40128. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40129. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40130. */
  40131. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40132. /**
  40133. * Observable event triggered each time an keyboard event is received from the hosting window
  40134. */
  40135. onKeyboardObservable: Observable<KeyboardInfo>;
  40136. private _useRightHandedSystem;
  40137. /**
  40138. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40139. */
  40140. set useRightHandedSystem(value: boolean);
  40141. get useRightHandedSystem(): boolean;
  40142. private _timeAccumulator;
  40143. private _currentStepId;
  40144. private _currentInternalStep;
  40145. /**
  40146. * Sets the step Id used by deterministic lock step
  40147. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40148. * @param newStepId defines the step Id
  40149. */
  40150. setStepId(newStepId: number): void;
  40151. /**
  40152. * Gets the step Id used by deterministic lock step
  40153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40154. * @returns the step Id
  40155. */
  40156. getStepId(): number;
  40157. /**
  40158. * Gets the internal step used by deterministic lock step
  40159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40160. * @returns the internal step
  40161. */
  40162. getInternalStep(): number;
  40163. private _fogEnabled;
  40164. /**
  40165. * Gets or sets a boolean indicating if fog is enabled on this scene
  40166. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40167. * (Default is true)
  40168. */
  40169. set fogEnabled(value: boolean);
  40170. get fogEnabled(): boolean;
  40171. private _fogMode;
  40172. /**
  40173. * Gets or sets the fog mode to use
  40174. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40175. * | mode | value |
  40176. * | --- | --- |
  40177. * | FOGMODE_NONE | 0 |
  40178. * | FOGMODE_EXP | 1 |
  40179. * | FOGMODE_EXP2 | 2 |
  40180. * | FOGMODE_LINEAR | 3 |
  40181. */
  40182. set fogMode(value: number);
  40183. get fogMode(): number;
  40184. /**
  40185. * Gets or sets the fog color to use
  40186. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40187. * (Default is Color3(0.2, 0.2, 0.3))
  40188. */
  40189. fogColor: Color3;
  40190. /**
  40191. * Gets or sets the fog density to use
  40192. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40193. * (Default is 0.1)
  40194. */
  40195. fogDensity: number;
  40196. /**
  40197. * Gets or sets the fog start distance to use
  40198. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40199. * (Default is 0)
  40200. */
  40201. fogStart: number;
  40202. /**
  40203. * Gets or sets the fog end distance to use
  40204. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40205. * (Default is 1000)
  40206. */
  40207. fogEnd: number;
  40208. /**
  40209. * Flag indicating that the frame buffer binding is handled by another component
  40210. */
  40211. prePass: boolean;
  40212. private _shadowsEnabled;
  40213. /**
  40214. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40215. */
  40216. set shadowsEnabled(value: boolean);
  40217. get shadowsEnabled(): boolean;
  40218. private _lightsEnabled;
  40219. /**
  40220. * Gets or sets a boolean indicating if lights are enabled on this scene
  40221. */
  40222. set lightsEnabled(value: boolean);
  40223. get lightsEnabled(): boolean;
  40224. /** All of the active cameras added to this scene. */
  40225. activeCameras: Camera[];
  40226. /** @hidden */
  40227. _activeCamera: Nullable<Camera>;
  40228. /** Gets or sets the current active camera */
  40229. get activeCamera(): Nullable<Camera>;
  40230. set activeCamera(value: Nullable<Camera>);
  40231. private _defaultMaterial;
  40232. /** The default material used on meshes when no material is affected */
  40233. get defaultMaterial(): Material;
  40234. /** The default material used on meshes when no material is affected */
  40235. set defaultMaterial(value: Material);
  40236. private _texturesEnabled;
  40237. /**
  40238. * Gets or sets a boolean indicating if textures are enabled on this scene
  40239. */
  40240. set texturesEnabled(value: boolean);
  40241. get texturesEnabled(): boolean;
  40242. /**
  40243. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40244. */
  40245. physicsEnabled: boolean;
  40246. /**
  40247. * Gets or sets a boolean indicating if particles are enabled on this scene
  40248. */
  40249. particlesEnabled: boolean;
  40250. /**
  40251. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40252. */
  40253. spritesEnabled: boolean;
  40254. private _skeletonsEnabled;
  40255. /**
  40256. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40257. */
  40258. set skeletonsEnabled(value: boolean);
  40259. get skeletonsEnabled(): boolean;
  40260. /**
  40261. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40262. */
  40263. lensFlaresEnabled: boolean;
  40264. /**
  40265. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40266. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40267. */
  40268. collisionsEnabled: boolean;
  40269. private _collisionCoordinator;
  40270. /** @hidden */
  40271. get collisionCoordinator(): ICollisionCoordinator;
  40272. /**
  40273. * Defines the gravity applied to this scene (used only for collisions)
  40274. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40275. */
  40276. gravity: Vector3;
  40277. /**
  40278. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40279. */
  40280. postProcessesEnabled: boolean;
  40281. /**
  40282. * The list of postprocesses added to the scene
  40283. */
  40284. postProcesses: PostProcess[];
  40285. /**
  40286. * Gets the current postprocess manager
  40287. */
  40288. postProcessManager: PostProcessManager;
  40289. /**
  40290. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40291. */
  40292. renderTargetsEnabled: boolean;
  40293. /**
  40294. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40295. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40296. */
  40297. dumpNextRenderTargets: boolean;
  40298. /**
  40299. * The list of user defined render targets added to the scene
  40300. */
  40301. customRenderTargets: RenderTargetTexture[];
  40302. /**
  40303. * Defines if texture loading must be delayed
  40304. * If true, textures will only be loaded when they need to be rendered
  40305. */
  40306. useDelayedTextureLoading: boolean;
  40307. /**
  40308. * Gets the list of meshes imported to the scene through SceneLoader
  40309. */
  40310. importedMeshesFiles: String[];
  40311. /**
  40312. * Gets or sets a boolean indicating if probes are enabled on this scene
  40313. */
  40314. probesEnabled: boolean;
  40315. /**
  40316. * Gets or sets the current offline provider to use to store scene data
  40317. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40318. */
  40319. offlineProvider: IOfflineProvider;
  40320. /**
  40321. * Gets or sets the action manager associated with the scene
  40322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40323. */
  40324. actionManager: AbstractActionManager;
  40325. private _meshesForIntersections;
  40326. /**
  40327. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40328. */
  40329. proceduralTexturesEnabled: boolean;
  40330. private _engine;
  40331. private _totalVertices;
  40332. /** @hidden */
  40333. _activeIndices: PerfCounter;
  40334. /** @hidden */
  40335. _activeParticles: PerfCounter;
  40336. /** @hidden */
  40337. _activeBones: PerfCounter;
  40338. private _animationRatio;
  40339. /** @hidden */
  40340. _animationTimeLast: number;
  40341. /** @hidden */
  40342. _animationTime: number;
  40343. /**
  40344. * Gets or sets a general scale for animation speed
  40345. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40346. */
  40347. animationTimeScale: number;
  40348. /** @hidden */
  40349. _cachedMaterial: Nullable<Material>;
  40350. /** @hidden */
  40351. _cachedEffect: Nullable<Effect>;
  40352. /** @hidden */
  40353. _cachedVisibility: Nullable<number>;
  40354. private _renderId;
  40355. private _frameId;
  40356. private _executeWhenReadyTimeoutId;
  40357. private _intermediateRendering;
  40358. private _viewUpdateFlag;
  40359. private _projectionUpdateFlag;
  40360. /** @hidden */
  40361. _toBeDisposed: Nullable<IDisposable>[];
  40362. private _activeRequests;
  40363. /** @hidden */
  40364. _pendingData: any[];
  40365. private _isDisposed;
  40366. /**
  40367. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40368. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40369. */
  40370. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40371. private _activeMeshes;
  40372. private _processedMaterials;
  40373. private _renderTargets;
  40374. /** @hidden */
  40375. _activeParticleSystems: SmartArray<IParticleSystem>;
  40376. private _activeSkeletons;
  40377. private _softwareSkinnedMeshes;
  40378. private _renderingManager;
  40379. /** @hidden */
  40380. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40381. private _transformMatrix;
  40382. private _sceneUbo;
  40383. /** @hidden */
  40384. _viewMatrix: Matrix;
  40385. private _projectionMatrix;
  40386. /** @hidden */
  40387. _forcedViewPosition: Nullable<Vector3>;
  40388. /** @hidden */
  40389. _frustumPlanes: Plane[];
  40390. /**
  40391. * Gets the list of frustum planes (built from the active camera)
  40392. */
  40393. get frustumPlanes(): Plane[];
  40394. /**
  40395. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40396. * This is useful if there are more lights that the maximum simulteanous authorized
  40397. */
  40398. requireLightSorting: boolean;
  40399. /** @hidden */
  40400. readonly useMaterialMeshMap: boolean;
  40401. /** @hidden */
  40402. readonly useClonedMeshMap: boolean;
  40403. private _externalData;
  40404. private _uid;
  40405. /**
  40406. * @hidden
  40407. * Backing store of defined scene components.
  40408. */
  40409. _components: ISceneComponent[];
  40410. /**
  40411. * @hidden
  40412. * Backing store of defined scene components.
  40413. */
  40414. _serializableComponents: ISceneSerializableComponent[];
  40415. /**
  40416. * List of components to register on the next registration step.
  40417. */
  40418. private _transientComponents;
  40419. /**
  40420. * Registers the transient components if needed.
  40421. */
  40422. private _registerTransientComponents;
  40423. /**
  40424. * @hidden
  40425. * Add a component to the scene.
  40426. * Note that the ccomponent could be registered on th next frame if this is called after
  40427. * the register component stage.
  40428. * @param component Defines the component to add to the scene
  40429. */
  40430. _addComponent(component: ISceneComponent): void;
  40431. /**
  40432. * @hidden
  40433. * Gets a component from the scene.
  40434. * @param name defines the name of the component to retrieve
  40435. * @returns the component or null if not present
  40436. */
  40437. _getComponent(name: string): Nullable<ISceneComponent>;
  40438. /**
  40439. * @hidden
  40440. * Defines the actions happening before camera updates.
  40441. */
  40442. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40443. /**
  40444. * @hidden
  40445. * Defines the actions happening before clear the canvas.
  40446. */
  40447. _beforeClearStage: Stage<SimpleStageAction>;
  40448. /**
  40449. * @hidden
  40450. * Defines the actions when collecting render targets for the frame.
  40451. */
  40452. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40453. /**
  40454. * @hidden
  40455. * Defines the actions happening for one camera in the frame.
  40456. */
  40457. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40458. /**
  40459. * @hidden
  40460. * Defines the actions happening during the per mesh ready checks.
  40461. */
  40462. _isReadyForMeshStage: Stage<MeshStageAction>;
  40463. /**
  40464. * @hidden
  40465. * Defines the actions happening before evaluate active mesh checks.
  40466. */
  40467. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40468. /**
  40469. * @hidden
  40470. * Defines the actions happening during the evaluate sub mesh checks.
  40471. */
  40472. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40473. /**
  40474. * @hidden
  40475. * Defines the actions happening during the active mesh stage.
  40476. */
  40477. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40478. /**
  40479. * @hidden
  40480. * Defines the actions happening during the per camera render target step.
  40481. */
  40482. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40483. /**
  40484. * @hidden
  40485. * Defines the actions happening just before the active camera is drawing.
  40486. */
  40487. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40488. /**
  40489. * @hidden
  40490. * Defines the actions happening just before a render target is drawing.
  40491. */
  40492. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40493. /**
  40494. * @hidden
  40495. * Defines the actions happening just before a rendering group is drawing.
  40496. */
  40497. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40498. /**
  40499. * @hidden
  40500. * Defines the actions happening just before a mesh is drawing.
  40501. */
  40502. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40503. /**
  40504. * @hidden
  40505. * Defines the actions happening just after a mesh has been drawn.
  40506. */
  40507. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40508. /**
  40509. * @hidden
  40510. * Defines the actions happening just after a rendering group has been drawn.
  40511. */
  40512. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40513. /**
  40514. * @hidden
  40515. * Defines the actions happening just after the active camera has been drawn.
  40516. */
  40517. _afterCameraDrawStage: Stage<CameraStageAction>;
  40518. /**
  40519. * @hidden
  40520. * Defines the actions happening just after a render target has been drawn.
  40521. */
  40522. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40523. /**
  40524. * @hidden
  40525. * Defines the actions happening just after rendering all cameras and computing intersections.
  40526. */
  40527. _afterRenderStage: Stage<SimpleStageAction>;
  40528. /**
  40529. * @hidden
  40530. * Defines the actions happening when a pointer move event happens.
  40531. */
  40532. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40533. /**
  40534. * @hidden
  40535. * Defines the actions happening when a pointer down event happens.
  40536. */
  40537. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40538. /**
  40539. * @hidden
  40540. * Defines the actions happening when a pointer up event happens.
  40541. */
  40542. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40543. /**
  40544. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40545. */
  40546. private geometriesByUniqueId;
  40547. /**
  40548. * Creates a new Scene
  40549. * @param engine defines the engine to use to render this scene
  40550. * @param options defines the scene options
  40551. */
  40552. constructor(engine: Engine, options?: SceneOptions);
  40553. /**
  40554. * Gets a string idenfifying the name of the class
  40555. * @returns "Scene" string
  40556. */
  40557. getClassName(): string;
  40558. private _defaultMeshCandidates;
  40559. /**
  40560. * @hidden
  40561. */
  40562. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40563. private _defaultSubMeshCandidates;
  40564. /**
  40565. * @hidden
  40566. */
  40567. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40568. /**
  40569. * Sets the default candidate providers for the scene.
  40570. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40571. * and getCollidingSubMeshCandidates to their default function
  40572. */
  40573. setDefaultCandidateProviders(): void;
  40574. /**
  40575. * Gets the mesh that is currently under the pointer
  40576. */
  40577. get meshUnderPointer(): Nullable<AbstractMesh>;
  40578. /**
  40579. * Gets or sets the current on-screen X position of the pointer
  40580. */
  40581. get pointerX(): number;
  40582. set pointerX(value: number);
  40583. /**
  40584. * Gets or sets the current on-screen Y position of the pointer
  40585. */
  40586. get pointerY(): number;
  40587. set pointerY(value: number);
  40588. /**
  40589. * Gets the cached material (ie. the latest rendered one)
  40590. * @returns the cached material
  40591. */
  40592. getCachedMaterial(): Nullable<Material>;
  40593. /**
  40594. * Gets the cached effect (ie. the latest rendered one)
  40595. * @returns the cached effect
  40596. */
  40597. getCachedEffect(): Nullable<Effect>;
  40598. /**
  40599. * Gets the cached visibility state (ie. the latest rendered one)
  40600. * @returns the cached visibility state
  40601. */
  40602. getCachedVisibility(): Nullable<number>;
  40603. /**
  40604. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40605. * @param material defines the current material
  40606. * @param effect defines the current effect
  40607. * @param visibility defines the current visibility state
  40608. * @returns true if one parameter is not cached
  40609. */
  40610. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40611. /**
  40612. * Gets the engine associated with the scene
  40613. * @returns an Engine
  40614. */
  40615. getEngine(): Engine;
  40616. /**
  40617. * Gets the total number of vertices rendered per frame
  40618. * @returns the total number of vertices rendered per frame
  40619. */
  40620. getTotalVertices(): number;
  40621. /**
  40622. * Gets the performance counter for total vertices
  40623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40624. */
  40625. get totalVerticesPerfCounter(): PerfCounter;
  40626. /**
  40627. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40628. * @returns the total number of active indices rendered per frame
  40629. */
  40630. getActiveIndices(): number;
  40631. /**
  40632. * Gets the performance counter for active indices
  40633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40634. */
  40635. get totalActiveIndicesPerfCounter(): PerfCounter;
  40636. /**
  40637. * Gets the total number of active particles rendered per frame
  40638. * @returns the total number of active particles rendered per frame
  40639. */
  40640. getActiveParticles(): number;
  40641. /**
  40642. * Gets the performance counter for active particles
  40643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40644. */
  40645. get activeParticlesPerfCounter(): PerfCounter;
  40646. /**
  40647. * Gets the total number of active bones rendered per frame
  40648. * @returns the total number of active bones rendered per frame
  40649. */
  40650. getActiveBones(): number;
  40651. /**
  40652. * Gets the performance counter for active bones
  40653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40654. */
  40655. get activeBonesPerfCounter(): PerfCounter;
  40656. /**
  40657. * Gets the array of active meshes
  40658. * @returns an array of AbstractMesh
  40659. */
  40660. getActiveMeshes(): SmartArray<AbstractMesh>;
  40661. /**
  40662. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40663. * @returns a number
  40664. */
  40665. getAnimationRatio(): number;
  40666. /**
  40667. * Gets an unique Id for the current render phase
  40668. * @returns a number
  40669. */
  40670. getRenderId(): number;
  40671. /**
  40672. * Gets an unique Id for the current frame
  40673. * @returns a number
  40674. */
  40675. getFrameId(): number;
  40676. /** Call this function if you want to manually increment the render Id*/
  40677. incrementRenderId(): void;
  40678. private _createUbo;
  40679. /**
  40680. * Use this method to simulate a pointer move on a mesh
  40681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40684. * @returns the current scene
  40685. */
  40686. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40687. /**
  40688. * Use this method to simulate a pointer down on a mesh
  40689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40692. * @returns the current scene
  40693. */
  40694. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40695. /**
  40696. * Use this method to simulate a pointer up on a mesh
  40697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40701. * @returns the current scene
  40702. */
  40703. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40704. /**
  40705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40707. * @returns true if the pointer was captured
  40708. */
  40709. isPointerCaptured(pointerId?: number): boolean;
  40710. /**
  40711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40712. * @param attachUp defines if you want to attach events to pointerup
  40713. * @param attachDown defines if you want to attach events to pointerdown
  40714. * @param attachMove defines if you want to attach events to pointermove
  40715. */
  40716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40717. /** Detaches all event handlers*/
  40718. detachControl(): void;
  40719. /**
  40720. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40721. * Delay loaded resources are not taking in account
  40722. * @return true if all required resources are ready
  40723. */
  40724. isReady(): boolean;
  40725. /** Resets all cached information relative to material (including effect and visibility) */
  40726. resetCachedMaterial(): void;
  40727. /**
  40728. * Registers a function to be called before every frame render
  40729. * @param func defines the function to register
  40730. */
  40731. registerBeforeRender(func: () => void): void;
  40732. /**
  40733. * Unregisters a function called before every frame render
  40734. * @param func defines the function to unregister
  40735. */
  40736. unregisterBeforeRender(func: () => void): void;
  40737. /**
  40738. * Registers a function to be called after every frame render
  40739. * @param func defines the function to register
  40740. */
  40741. registerAfterRender(func: () => void): void;
  40742. /**
  40743. * Unregisters a function called after every frame render
  40744. * @param func defines the function to unregister
  40745. */
  40746. unregisterAfterRender(func: () => void): void;
  40747. private _executeOnceBeforeRender;
  40748. /**
  40749. * The provided function will run before render once and will be disposed afterwards.
  40750. * A timeout delay can be provided so that the function will be executed in N ms.
  40751. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40752. * @param func The function to be executed.
  40753. * @param timeout optional delay in ms
  40754. */
  40755. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40756. /** @hidden */
  40757. _addPendingData(data: any): void;
  40758. /** @hidden */
  40759. _removePendingData(data: any): void;
  40760. /**
  40761. * Returns the number of items waiting to be loaded
  40762. * @returns the number of items waiting to be loaded
  40763. */
  40764. getWaitingItemsCount(): number;
  40765. /**
  40766. * Returns a boolean indicating if the scene is still loading data
  40767. */
  40768. get isLoading(): boolean;
  40769. /**
  40770. * Registers a function to be executed when the scene is ready
  40771. * @param {Function} func - the function to be executed
  40772. */
  40773. executeWhenReady(func: () => void): void;
  40774. /**
  40775. * Returns a promise that resolves when the scene is ready
  40776. * @returns A promise that resolves when the scene is ready
  40777. */
  40778. whenReadyAsync(): Promise<void>;
  40779. /** @hidden */
  40780. _checkIsReady(): void;
  40781. /**
  40782. * Gets all animatable attached to the scene
  40783. */
  40784. get animatables(): Animatable[];
  40785. /**
  40786. * Resets the last animation time frame.
  40787. * Useful to override when animations start running when loading a scene for the first time.
  40788. */
  40789. resetLastAnimationTimeFrame(): void;
  40790. /**
  40791. * Gets the current view matrix
  40792. * @returns a Matrix
  40793. */
  40794. getViewMatrix(): Matrix;
  40795. /**
  40796. * Gets the current projection matrix
  40797. * @returns a Matrix
  40798. */
  40799. getProjectionMatrix(): Matrix;
  40800. /**
  40801. * Gets the current transform matrix
  40802. * @returns a Matrix made of View * Projection
  40803. */
  40804. getTransformMatrix(): Matrix;
  40805. /**
  40806. * Sets the current transform matrix
  40807. * @param viewL defines the View matrix to use
  40808. * @param projectionL defines the Projection matrix to use
  40809. * @param viewR defines the right View matrix to use (if provided)
  40810. * @param projectionR defines the right Projection matrix to use (if provided)
  40811. */
  40812. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40813. /**
  40814. * Gets the uniform buffer used to store scene data
  40815. * @returns a UniformBuffer
  40816. */
  40817. getSceneUniformBuffer(): UniformBuffer;
  40818. /**
  40819. * Gets an unique (relatively to the current scene) Id
  40820. * @returns an unique number for the scene
  40821. */
  40822. getUniqueId(): number;
  40823. /**
  40824. * Add a mesh to the list of scene's meshes
  40825. * @param newMesh defines the mesh to add
  40826. * @param recursive if all child meshes should also be added to the scene
  40827. */
  40828. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40829. /**
  40830. * Remove a mesh for the list of scene's meshes
  40831. * @param toRemove defines the mesh to remove
  40832. * @param recursive if all child meshes should also be removed from the scene
  40833. * @returns the index where the mesh was in the mesh list
  40834. */
  40835. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40836. /**
  40837. * Add a transform node to the list of scene's transform nodes
  40838. * @param newTransformNode defines the transform node to add
  40839. */
  40840. addTransformNode(newTransformNode: TransformNode): void;
  40841. /**
  40842. * Remove a transform node for the list of scene's transform nodes
  40843. * @param toRemove defines the transform node to remove
  40844. * @returns the index where the transform node was in the transform node list
  40845. */
  40846. removeTransformNode(toRemove: TransformNode): number;
  40847. /**
  40848. * Remove a skeleton for the list of scene's skeletons
  40849. * @param toRemove defines the skeleton to remove
  40850. * @returns the index where the skeleton was in the skeleton list
  40851. */
  40852. removeSkeleton(toRemove: Skeleton): number;
  40853. /**
  40854. * Remove a morph target for the list of scene's morph targets
  40855. * @param toRemove defines the morph target to remove
  40856. * @returns the index where the morph target was in the morph target list
  40857. */
  40858. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40859. /**
  40860. * Remove a light for the list of scene's lights
  40861. * @param toRemove defines the light to remove
  40862. * @returns the index where the light was in the light list
  40863. */
  40864. removeLight(toRemove: Light): number;
  40865. /**
  40866. * Remove a camera for the list of scene's cameras
  40867. * @param toRemove defines the camera to remove
  40868. * @returns the index where the camera was in the camera list
  40869. */
  40870. removeCamera(toRemove: Camera): number;
  40871. /**
  40872. * Remove a particle system for the list of scene's particle systems
  40873. * @param toRemove defines the particle system to remove
  40874. * @returns the index where the particle system was in the particle system list
  40875. */
  40876. removeParticleSystem(toRemove: IParticleSystem): number;
  40877. /**
  40878. * Remove a animation for the list of scene's animations
  40879. * @param toRemove defines the animation to remove
  40880. * @returns the index where the animation was in the animation list
  40881. */
  40882. removeAnimation(toRemove: Animation): number;
  40883. /**
  40884. * Will stop the animation of the given target
  40885. * @param target - the target
  40886. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40887. * @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)
  40888. */
  40889. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40890. /**
  40891. * Removes the given animation group from this scene.
  40892. * @param toRemove The animation group to remove
  40893. * @returns The index of the removed animation group
  40894. */
  40895. removeAnimationGroup(toRemove: AnimationGroup): number;
  40896. /**
  40897. * Removes the given multi-material from this scene.
  40898. * @param toRemove The multi-material to remove
  40899. * @returns The index of the removed multi-material
  40900. */
  40901. removeMultiMaterial(toRemove: MultiMaterial): number;
  40902. /**
  40903. * Removes the given material from this scene.
  40904. * @param toRemove The material to remove
  40905. * @returns The index of the removed material
  40906. */
  40907. removeMaterial(toRemove: Material): number;
  40908. /**
  40909. * Removes the given action manager from this scene.
  40910. * @param toRemove The action manager to remove
  40911. * @returns The index of the removed action manager
  40912. */
  40913. removeActionManager(toRemove: AbstractActionManager): number;
  40914. /**
  40915. * Removes the given texture from this scene.
  40916. * @param toRemove The texture to remove
  40917. * @returns The index of the removed texture
  40918. */
  40919. removeTexture(toRemove: BaseTexture): number;
  40920. /**
  40921. * Adds the given light to this scene
  40922. * @param newLight The light to add
  40923. */
  40924. addLight(newLight: Light): void;
  40925. /**
  40926. * Sorts the list list based on light priorities
  40927. */
  40928. sortLightsByPriority(): void;
  40929. /**
  40930. * Adds the given camera to this scene
  40931. * @param newCamera The camera to add
  40932. */
  40933. addCamera(newCamera: Camera): void;
  40934. /**
  40935. * Adds the given skeleton to this scene
  40936. * @param newSkeleton The skeleton to add
  40937. */
  40938. addSkeleton(newSkeleton: Skeleton): void;
  40939. /**
  40940. * Adds the given particle system to this scene
  40941. * @param newParticleSystem The particle system to add
  40942. */
  40943. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40944. /**
  40945. * Adds the given animation to this scene
  40946. * @param newAnimation The animation to add
  40947. */
  40948. addAnimation(newAnimation: Animation): void;
  40949. /**
  40950. * Adds the given animation group to this scene.
  40951. * @param newAnimationGroup The animation group to add
  40952. */
  40953. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40954. /**
  40955. * Adds the given multi-material to this scene
  40956. * @param newMultiMaterial The multi-material to add
  40957. */
  40958. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40959. /**
  40960. * Adds the given material to this scene
  40961. * @param newMaterial The material to add
  40962. */
  40963. addMaterial(newMaterial: Material): void;
  40964. /**
  40965. * Adds the given morph target to this scene
  40966. * @param newMorphTargetManager The morph target to add
  40967. */
  40968. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40969. /**
  40970. * Adds the given geometry to this scene
  40971. * @param newGeometry The geometry to add
  40972. */
  40973. addGeometry(newGeometry: Geometry): void;
  40974. /**
  40975. * Adds the given action manager to this scene
  40976. * @param newActionManager The action manager to add
  40977. */
  40978. addActionManager(newActionManager: AbstractActionManager): void;
  40979. /**
  40980. * Adds the given texture to this scene.
  40981. * @param newTexture The texture to add
  40982. */
  40983. addTexture(newTexture: BaseTexture): void;
  40984. /**
  40985. * Switch active camera
  40986. * @param newCamera defines the new active camera
  40987. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40988. */
  40989. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40990. /**
  40991. * sets the active camera of the scene using its ID
  40992. * @param id defines the camera's ID
  40993. * @return the new active camera or null if none found.
  40994. */
  40995. setActiveCameraByID(id: string): Nullable<Camera>;
  40996. /**
  40997. * sets the active camera of the scene using its name
  40998. * @param name defines the camera's name
  40999. * @returns the new active camera or null if none found.
  41000. */
  41001. setActiveCameraByName(name: string): Nullable<Camera>;
  41002. /**
  41003. * get an animation group using its name
  41004. * @param name defines the material's name
  41005. * @return the animation group or null if none found.
  41006. */
  41007. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41008. /**
  41009. * Get a material using its unique id
  41010. * @param uniqueId defines the material's unique id
  41011. * @return the material or null if none found.
  41012. */
  41013. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41014. /**
  41015. * get a material using its id
  41016. * @param id defines the material's ID
  41017. * @return the material or null if none found.
  41018. */
  41019. getMaterialByID(id: string): Nullable<Material>;
  41020. /**
  41021. * Gets a the last added material using a given id
  41022. * @param id defines the material's ID
  41023. * @return the last material with the given id or null if none found.
  41024. */
  41025. getLastMaterialByID(id: string): Nullable<Material>;
  41026. /**
  41027. * Gets a material using its name
  41028. * @param name defines the material's name
  41029. * @return the material or null if none found.
  41030. */
  41031. getMaterialByName(name: string): Nullable<Material>;
  41032. /**
  41033. * Get a texture using its unique id
  41034. * @param uniqueId defines the texture's unique id
  41035. * @return the texture or null if none found.
  41036. */
  41037. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41038. /**
  41039. * Gets a camera using its id
  41040. * @param id defines the id to look for
  41041. * @returns the camera or null if not found
  41042. */
  41043. getCameraByID(id: string): Nullable<Camera>;
  41044. /**
  41045. * Gets a camera using its unique id
  41046. * @param uniqueId defines the unique id to look for
  41047. * @returns the camera or null if not found
  41048. */
  41049. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41050. /**
  41051. * Gets a camera using its name
  41052. * @param name defines the camera's name
  41053. * @return the camera or null if none found.
  41054. */
  41055. getCameraByName(name: string): Nullable<Camera>;
  41056. /**
  41057. * Gets a bone using its id
  41058. * @param id defines the bone's id
  41059. * @return the bone or null if not found
  41060. */
  41061. getBoneByID(id: string): Nullable<Bone>;
  41062. /**
  41063. * Gets a bone using its id
  41064. * @param name defines the bone's name
  41065. * @return the bone or null if not found
  41066. */
  41067. getBoneByName(name: string): Nullable<Bone>;
  41068. /**
  41069. * Gets a light node using its name
  41070. * @param name defines the the light's name
  41071. * @return the light or null if none found.
  41072. */
  41073. getLightByName(name: string): Nullable<Light>;
  41074. /**
  41075. * Gets a light node using its id
  41076. * @param id defines the light's id
  41077. * @return the light or null if none found.
  41078. */
  41079. getLightByID(id: string): Nullable<Light>;
  41080. /**
  41081. * Gets a light node using its scene-generated unique ID
  41082. * @param uniqueId defines the light's unique id
  41083. * @return the light or null if none found.
  41084. */
  41085. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41086. /**
  41087. * Gets a particle system by id
  41088. * @param id defines the particle system id
  41089. * @return the corresponding system or null if none found
  41090. */
  41091. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41092. /**
  41093. * Gets a geometry using its ID
  41094. * @param id defines the geometry's id
  41095. * @return the geometry or null if none found.
  41096. */
  41097. getGeometryByID(id: string): Nullable<Geometry>;
  41098. private _getGeometryByUniqueID;
  41099. /**
  41100. * Add a new geometry to this scene
  41101. * @param geometry defines the geometry to be added to the scene.
  41102. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41103. * @return a boolean defining if the geometry was added or not
  41104. */
  41105. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41106. /**
  41107. * Removes an existing geometry
  41108. * @param geometry defines the geometry to be removed from the scene
  41109. * @return a boolean defining if the geometry was removed or not
  41110. */
  41111. removeGeometry(geometry: Geometry): boolean;
  41112. /**
  41113. * Gets the list of geometries attached to the scene
  41114. * @returns an array of Geometry
  41115. */
  41116. getGeometries(): Geometry[];
  41117. /**
  41118. * Gets the first added mesh found of a given ID
  41119. * @param id defines the id to search for
  41120. * @return the mesh found or null if not found at all
  41121. */
  41122. getMeshByID(id: string): Nullable<AbstractMesh>;
  41123. /**
  41124. * Gets a list of meshes using their id
  41125. * @param id defines the id to search for
  41126. * @returns a list of meshes
  41127. */
  41128. getMeshesByID(id: string): Array<AbstractMesh>;
  41129. /**
  41130. * Gets the first added transform node found of a given ID
  41131. * @param id defines the id to search for
  41132. * @return the found transform node or null if not found at all.
  41133. */
  41134. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41135. /**
  41136. * Gets a transform node with its auto-generated unique id
  41137. * @param uniqueId efines the unique id to search for
  41138. * @return the found transform node or null if not found at all.
  41139. */
  41140. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41141. /**
  41142. * Gets a list of transform nodes using their id
  41143. * @param id defines the id to search for
  41144. * @returns a list of transform nodes
  41145. */
  41146. getTransformNodesByID(id: string): Array<TransformNode>;
  41147. /**
  41148. * Gets a mesh with its auto-generated unique id
  41149. * @param uniqueId defines the unique id to search for
  41150. * @return the found mesh or null if not found at all.
  41151. */
  41152. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41153. /**
  41154. * Gets a the last added mesh using a given id
  41155. * @param id defines the id to search for
  41156. * @return the found mesh or null if not found at all.
  41157. */
  41158. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41159. /**
  41160. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41161. * @param id defines the id to search for
  41162. * @return the found node or null if not found at all
  41163. */
  41164. getLastEntryByID(id: string): Nullable<Node>;
  41165. /**
  41166. * Gets a node (Mesh, Camera, Light) using a given id
  41167. * @param id defines the id to search for
  41168. * @return the found node or null if not found at all
  41169. */
  41170. getNodeByID(id: string): Nullable<Node>;
  41171. /**
  41172. * Gets a node (Mesh, Camera, Light) using a given name
  41173. * @param name defines the name to search for
  41174. * @return the found node or null if not found at all.
  41175. */
  41176. getNodeByName(name: string): Nullable<Node>;
  41177. /**
  41178. * Gets a mesh using a given name
  41179. * @param name defines the name to search for
  41180. * @return the found mesh or null if not found at all.
  41181. */
  41182. getMeshByName(name: string): Nullable<AbstractMesh>;
  41183. /**
  41184. * Gets a transform node using a given name
  41185. * @param name defines the name to search for
  41186. * @return the found transform node or null if not found at all.
  41187. */
  41188. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41189. /**
  41190. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41191. * @param id defines the id to search for
  41192. * @return the found skeleton or null if not found at all.
  41193. */
  41194. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41195. /**
  41196. * Gets a skeleton using a given auto generated unique id
  41197. * @param uniqueId defines the unique id to search for
  41198. * @return the found skeleton or null if not found at all.
  41199. */
  41200. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41201. /**
  41202. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41203. * @param id defines the id to search for
  41204. * @return the found skeleton or null if not found at all.
  41205. */
  41206. getSkeletonById(id: string): Nullable<Skeleton>;
  41207. /**
  41208. * Gets a skeleton using a given name
  41209. * @param name defines the name to search for
  41210. * @return the found skeleton or null if not found at all.
  41211. */
  41212. getSkeletonByName(name: string): Nullable<Skeleton>;
  41213. /**
  41214. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41215. * @param id defines the id to search for
  41216. * @return the found morph target manager or null if not found at all.
  41217. */
  41218. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41219. /**
  41220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41221. * @param id defines the id to search for
  41222. * @return the found morph target or null if not found at all.
  41223. */
  41224. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41225. /**
  41226. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41227. * @param name defines the name to search for
  41228. * @return the found morph target or null if not found at all.
  41229. */
  41230. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41231. /**
  41232. * Gets a boolean indicating if the given mesh is active
  41233. * @param mesh defines the mesh to look for
  41234. * @returns true if the mesh is in the active list
  41235. */
  41236. isActiveMesh(mesh: AbstractMesh): boolean;
  41237. /**
  41238. * Return a unique id as a string which can serve as an identifier for the scene
  41239. */
  41240. get uid(): string;
  41241. /**
  41242. * Add an externaly attached data from its key.
  41243. * This method call will fail and return false, if such key already exists.
  41244. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41245. * @param key the unique key that identifies the data
  41246. * @param data the data object to associate to the key for this Engine instance
  41247. * @return true if no such key were already present and the data was added successfully, false otherwise
  41248. */
  41249. addExternalData<T>(key: string, data: T): boolean;
  41250. /**
  41251. * Get an externaly attached data from its key
  41252. * @param key the unique key that identifies the data
  41253. * @return the associated data, if present (can be null), or undefined if not present
  41254. */
  41255. getExternalData<T>(key: string): Nullable<T>;
  41256. /**
  41257. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41258. * @param key the unique key that identifies the data
  41259. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41260. * @return the associated data, can be null if the factory returned null.
  41261. */
  41262. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41263. /**
  41264. * Remove an externaly attached data from the Engine instance
  41265. * @param key the unique key that identifies the data
  41266. * @return true if the data was successfully removed, false if it doesn't exist
  41267. */
  41268. removeExternalData(key: string): boolean;
  41269. private _evaluateSubMesh;
  41270. /**
  41271. * Clear the processed materials smart array preventing retention point in material dispose.
  41272. */
  41273. freeProcessedMaterials(): void;
  41274. private _preventFreeActiveMeshesAndRenderingGroups;
  41275. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41276. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41277. * when disposing several meshes in a row or a hierarchy of meshes.
  41278. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41279. */
  41280. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41281. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41282. /**
  41283. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41284. */
  41285. freeActiveMeshes(): void;
  41286. /**
  41287. * Clear the info related to rendering groups preventing retention points during dispose.
  41288. */
  41289. freeRenderingGroups(): void;
  41290. /** @hidden */
  41291. _isInIntermediateRendering(): boolean;
  41292. /**
  41293. * Lambda returning the list of potentially active meshes.
  41294. */
  41295. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41296. /**
  41297. * Lambda returning the list of potentially active sub meshes.
  41298. */
  41299. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41300. /**
  41301. * Lambda returning the list of potentially intersecting sub meshes.
  41302. */
  41303. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41304. /**
  41305. * Lambda returning the list of potentially colliding sub meshes.
  41306. */
  41307. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41308. private _activeMeshesFrozen;
  41309. private _skipEvaluateActiveMeshesCompletely;
  41310. /**
  41311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41312. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41313. * @returns the current scene
  41314. */
  41315. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41316. /**
  41317. * Use this function to restart evaluating active meshes on every frame
  41318. * @returns the current scene
  41319. */
  41320. unfreezeActiveMeshes(): Scene;
  41321. private _evaluateActiveMeshes;
  41322. private _activeMesh;
  41323. /**
  41324. * Update the transform matrix to update from the current active camera
  41325. * @param force defines a boolean used to force the update even if cache is up to date
  41326. */
  41327. updateTransformMatrix(force?: boolean): void;
  41328. private _bindFrameBuffer;
  41329. /** @hidden */
  41330. _allowPostProcessClearColor: boolean;
  41331. /** @hidden */
  41332. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41333. private _processSubCameras;
  41334. private _checkIntersections;
  41335. /** @hidden */
  41336. _advancePhysicsEngineStep(step: number): void;
  41337. /**
  41338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41339. */
  41340. getDeterministicFrameTime: () => number;
  41341. /** @hidden */
  41342. _animate(): void;
  41343. /** Execute all animations (for a frame) */
  41344. animate(): void;
  41345. /**
  41346. * Render the scene
  41347. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41348. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41349. */
  41350. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41351. /**
  41352. * Freeze all materials
  41353. * A frozen material will not be updatable but should be faster to render
  41354. */
  41355. freezeMaterials(): void;
  41356. /**
  41357. * Unfreeze all materials
  41358. * A frozen material will not be updatable but should be faster to render
  41359. */
  41360. unfreezeMaterials(): void;
  41361. /**
  41362. * Releases all held ressources
  41363. */
  41364. dispose(): void;
  41365. /**
  41366. * Gets if the scene is already disposed
  41367. */
  41368. get isDisposed(): boolean;
  41369. /**
  41370. * Call this function to reduce memory footprint of the scene.
  41371. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41372. */
  41373. clearCachedVertexData(): void;
  41374. /**
  41375. * This function will remove the local cached buffer data from texture.
  41376. * It will save memory but will prevent the texture from being rebuilt
  41377. */
  41378. cleanCachedTextureBuffer(): void;
  41379. /**
  41380. * Get the world extend vectors with an optional filter
  41381. *
  41382. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41383. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41384. */
  41385. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41386. min: Vector3;
  41387. max: Vector3;
  41388. };
  41389. /**
  41390. * Creates a ray that can be used to pick in the scene
  41391. * @param x defines the x coordinate of the origin (on-screen)
  41392. * @param y defines the y coordinate of the origin (on-screen)
  41393. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41394. * @param camera defines the camera to use for the picking
  41395. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41396. * @returns a Ray
  41397. */
  41398. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41399. /**
  41400. * Creates a ray that can be used to pick in the scene
  41401. * @param x defines the x coordinate of the origin (on-screen)
  41402. * @param y defines the y coordinate of the origin (on-screen)
  41403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41404. * @param result defines the ray where to store the picking ray
  41405. * @param camera defines the camera to use for the picking
  41406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41407. * @returns the current scene
  41408. */
  41409. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41410. /**
  41411. * Creates a ray that can be used to pick in the scene
  41412. * @param x defines the x coordinate of the origin (on-screen)
  41413. * @param y defines the y coordinate of the origin (on-screen)
  41414. * @param camera defines the camera to use for the picking
  41415. * @returns a Ray
  41416. */
  41417. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41418. /**
  41419. * Creates a ray that can be used to pick in the scene
  41420. * @param x defines the x coordinate of the origin (on-screen)
  41421. * @param y defines the y coordinate of the origin (on-screen)
  41422. * @param result defines the ray where to store the picking ray
  41423. * @param camera defines the camera to use for the picking
  41424. * @returns the current scene
  41425. */
  41426. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41427. /** Launch a ray to try to pick a mesh in the scene
  41428. * @param x position on screen
  41429. * @param y position on screen
  41430. * @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
  41431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41432. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41434. * @returns a PickingInfo
  41435. */
  41436. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41437. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41438. * @param x position on screen
  41439. * @param y position on screen
  41440. * @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
  41441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41442. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41443. * @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)
  41444. */
  41445. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41446. /** Use the given ray to pick a mesh in the scene
  41447. * @param ray The ray to use to pick meshes
  41448. * @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
  41449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41451. * @returns a PickingInfo
  41452. */
  41453. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41454. /**
  41455. * Launch a ray to try to pick a mesh in the scene
  41456. * @param x X position on screen
  41457. * @param y Y position on screen
  41458. * @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
  41459. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41461. * @returns an array of PickingInfo
  41462. */
  41463. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41464. /**
  41465. * Launch a ray to try to pick a mesh in the scene
  41466. * @param ray Ray to use
  41467. * @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
  41468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41469. * @returns an array of PickingInfo
  41470. */
  41471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41472. /**
  41473. * Force the value of meshUnderPointer
  41474. * @param mesh defines the mesh to use
  41475. */
  41476. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41477. /**
  41478. * Gets the mesh under the pointer
  41479. * @returns a Mesh or null if no mesh is under the pointer
  41480. */
  41481. getPointerOverMesh(): Nullable<AbstractMesh>;
  41482. /** @hidden */
  41483. _rebuildGeometries(): void;
  41484. /** @hidden */
  41485. _rebuildTextures(): void;
  41486. private _getByTags;
  41487. /**
  41488. * Get a list of meshes by tags
  41489. * @param tagsQuery defines the tags query to use
  41490. * @param forEach defines a predicate used to filter results
  41491. * @returns an array of Mesh
  41492. */
  41493. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41494. /**
  41495. * Get a list of cameras by tags
  41496. * @param tagsQuery defines the tags query to use
  41497. * @param forEach defines a predicate used to filter results
  41498. * @returns an array of Camera
  41499. */
  41500. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41501. /**
  41502. * Get a list of lights by tags
  41503. * @param tagsQuery defines the tags query to use
  41504. * @param forEach defines a predicate used to filter results
  41505. * @returns an array of Light
  41506. */
  41507. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41508. /**
  41509. * Get a list of materials by tags
  41510. * @param tagsQuery defines the tags query to use
  41511. * @param forEach defines a predicate used to filter results
  41512. * @returns an array of Material
  41513. */
  41514. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41515. /**
  41516. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41517. * This allowed control for front to back rendering or reversly depending of the special needs.
  41518. *
  41519. * @param renderingGroupId The rendering group id corresponding to its index
  41520. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41521. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41522. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41523. */
  41524. 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;
  41525. /**
  41526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41527. *
  41528. * @param renderingGroupId The rendering group id corresponding to its index
  41529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41530. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41531. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41532. */
  41533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41534. /**
  41535. * Gets the current auto clear configuration for one rendering group of the rendering
  41536. * manager.
  41537. * @param index the rendering group index to get the information for
  41538. * @returns The auto clear setup for the requested rendering group
  41539. */
  41540. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41541. private _blockMaterialDirtyMechanism;
  41542. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41543. get blockMaterialDirtyMechanism(): boolean;
  41544. set blockMaterialDirtyMechanism(value: boolean);
  41545. /**
  41546. * Will flag all materials as dirty to trigger new shader compilation
  41547. * @param flag defines the flag used to specify which material part must be marked as dirty
  41548. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41549. */
  41550. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41551. /** @hidden */
  41552. _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;
  41553. /** @hidden */
  41554. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41555. /** @hidden */
  41556. _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;
  41557. /** @hidden */
  41558. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41559. /** @hidden */
  41560. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41561. /** @hidden */
  41562. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41563. }
  41564. }
  41565. declare module "babylonjs/assetContainer" {
  41566. import { AbstractScene } from "babylonjs/abstractScene";
  41567. import { Scene } from "babylonjs/scene";
  41568. import { Mesh } from "babylonjs/Meshes/mesh";
  41569. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41570. import { Skeleton } from "babylonjs/Bones/skeleton";
  41571. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41572. import { Animatable } from "babylonjs/Animations/animatable";
  41573. import { Nullable } from "babylonjs/types";
  41574. import { Node } from "babylonjs/node";
  41575. /**
  41576. * Set of assets to keep when moving a scene into an asset container.
  41577. */
  41578. export class KeepAssets extends AbstractScene {
  41579. }
  41580. /**
  41581. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41582. */
  41583. export class InstantiatedEntries {
  41584. /**
  41585. * List of new root nodes (eg. nodes with no parent)
  41586. */
  41587. rootNodes: TransformNode[];
  41588. /**
  41589. * List of new skeletons
  41590. */
  41591. skeletons: Skeleton[];
  41592. /**
  41593. * List of new animation groups
  41594. */
  41595. animationGroups: AnimationGroup[];
  41596. }
  41597. /**
  41598. * Container with a set of assets that can be added or removed from a scene.
  41599. */
  41600. export class AssetContainer extends AbstractScene {
  41601. private _wasAddedToScene;
  41602. /**
  41603. * The scene the AssetContainer belongs to.
  41604. */
  41605. scene: Scene;
  41606. /**
  41607. * Instantiates an AssetContainer.
  41608. * @param scene The scene the AssetContainer belongs to.
  41609. */
  41610. constructor(scene: Scene);
  41611. /**
  41612. * Instantiate or clone all meshes and add the new ones to the scene.
  41613. * Skeletons and animation groups will all be cloned
  41614. * @param nameFunction defines an optional function used to get new names for clones
  41615. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41616. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41617. */
  41618. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41619. /**
  41620. * Adds all the assets from the container to the scene.
  41621. */
  41622. addAllToScene(): void;
  41623. /**
  41624. * Removes all the assets in the container from the scene
  41625. */
  41626. removeAllFromScene(): void;
  41627. /**
  41628. * Disposes all the assets in the container
  41629. */
  41630. dispose(): void;
  41631. private _moveAssets;
  41632. /**
  41633. * Removes all the assets contained in the scene and adds them to the container.
  41634. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41635. */
  41636. moveAllFromScene(keepAssets?: KeepAssets): void;
  41637. /**
  41638. * 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.
  41639. * @returns the root mesh
  41640. */
  41641. createRootMesh(): Mesh;
  41642. /**
  41643. * Merge animations (direct and animation groups) from this asset container into a scene
  41644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41645. * @param animatables set of animatables to retarget to a node from the scene
  41646. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41647. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41648. */
  41649. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41650. }
  41651. }
  41652. declare module "babylonjs/abstractScene" {
  41653. import { Scene } from "babylonjs/scene";
  41654. import { Nullable } from "babylonjs/types";
  41655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41657. import { Geometry } from "babylonjs/Meshes/geometry";
  41658. import { Skeleton } from "babylonjs/Bones/skeleton";
  41659. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41660. import { AssetContainer } from "babylonjs/assetContainer";
  41661. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41662. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41664. import { Material } from "babylonjs/Materials/material";
  41665. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41666. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41667. import { Camera } from "babylonjs/Cameras/camera";
  41668. import { Light } from "babylonjs/Lights/light";
  41669. import { Node } from "babylonjs/node";
  41670. import { Animation } from "babylonjs/Animations/animation";
  41671. /**
  41672. * Defines how the parser contract is defined.
  41673. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41674. */
  41675. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41676. /**
  41677. * Defines how the individual parser contract is defined.
  41678. * These parser can parse an individual asset
  41679. */
  41680. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41681. /**
  41682. * Base class of the scene acting as a container for the different elements composing a scene.
  41683. * This class is dynamically extended by the different components of the scene increasing
  41684. * flexibility and reducing coupling
  41685. */
  41686. export abstract class AbstractScene {
  41687. /**
  41688. * Stores the list of available parsers in the application.
  41689. */
  41690. private static _BabylonFileParsers;
  41691. /**
  41692. * Stores the list of available individual parsers in the application.
  41693. */
  41694. private static _IndividualBabylonFileParsers;
  41695. /**
  41696. * Adds a parser in the list of available ones
  41697. * @param name Defines the name of the parser
  41698. * @param parser Defines the parser to add
  41699. */
  41700. static AddParser(name: string, parser: BabylonFileParser): void;
  41701. /**
  41702. * Gets a general parser from the list of avaialble ones
  41703. * @param name Defines the name of the parser
  41704. * @returns the requested parser or null
  41705. */
  41706. static GetParser(name: string): Nullable<BabylonFileParser>;
  41707. /**
  41708. * Adds n individual parser in the list of available ones
  41709. * @param name Defines the name of the parser
  41710. * @param parser Defines the parser to add
  41711. */
  41712. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41713. /**
  41714. * Gets an individual parser from the list of avaialble ones
  41715. * @param name Defines the name of the parser
  41716. * @returns the requested parser or null
  41717. */
  41718. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41719. /**
  41720. * Parser json data and populate both a scene and its associated container object
  41721. * @param jsonData Defines the data to parse
  41722. * @param scene Defines the scene to parse the data for
  41723. * @param container Defines the container attached to the parsing sequence
  41724. * @param rootUrl Defines the root url of the data
  41725. */
  41726. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41727. /**
  41728. * Gets the list of root nodes (ie. nodes with no parent)
  41729. */
  41730. rootNodes: Node[];
  41731. /** All of the cameras added to this scene
  41732. * @see https://doc.babylonjs.com/babylon101/cameras
  41733. */
  41734. cameras: Camera[];
  41735. /**
  41736. * All of the lights added to this scene
  41737. * @see https://doc.babylonjs.com/babylon101/lights
  41738. */
  41739. lights: Light[];
  41740. /**
  41741. * All of the (abstract) meshes added to this scene
  41742. */
  41743. meshes: AbstractMesh[];
  41744. /**
  41745. * The list of skeletons added to the scene
  41746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41747. */
  41748. skeletons: Skeleton[];
  41749. /**
  41750. * All of the particle systems added to this scene
  41751. * @see https://doc.babylonjs.com/babylon101/particles
  41752. */
  41753. particleSystems: IParticleSystem[];
  41754. /**
  41755. * Gets a list of Animations associated with the scene
  41756. */
  41757. animations: Animation[];
  41758. /**
  41759. * All of the animation groups added to this scene
  41760. * @see https://doc.babylonjs.com/how_to/group
  41761. */
  41762. animationGroups: AnimationGroup[];
  41763. /**
  41764. * All of the multi-materials added to this scene
  41765. * @see https://doc.babylonjs.com/how_to/multi_materials
  41766. */
  41767. multiMaterials: MultiMaterial[];
  41768. /**
  41769. * All of the materials added to this scene
  41770. * In the context of a Scene, it is not supposed to be modified manually.
  41771. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41772. * Note also that the order of the Material within the array is not significant and might change.
  41773. * @see https://doc.babylonjs.com/babylon101/materials
  41774. */
  41775. materials: Material[];
  41776. /**
  41777. * The list of morph target managers added to the scene
  41778. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41779. */
  41780. morphTargetManagers: MorphTargetManager[];
  41781. /**
  41782. * The list of geometries used in the scene.
  41783. */
  41784. geometries: Geometry[];
  41785. /**
  41786. * All of the tranform nodes added to this scene
  41787. * In the context of a Scene, it is not supposed to be modified manually.
  41788. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41789. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41790. * @see https://doc.babylonjs.com/how_to/transformnode
  41791. */
  41792. transformNodes: TransformNode[];
  41793. /**
  41794. * ActionManagers available on the scene.
  41795. */
  41796. actionManagers: AbstractActionManager[];
  41797. /**
  41798. * Textures to keep.
  41799. */
  41800. textures: BaseTexture[];
  41801. /**
  41802. * Environment texture for the scene
  41803. */
  41804. environmentTexture: Nullable<BaseTexture>;
  41805. /**
  41806. * @returns all meshes, lights, cameras, transformNodes and bones
  41807. */
  41808. getNodes(): Array<Node>;
  41809. }
  41810. }
  41811. declare module "babylonjs/Audio/sound" {
  41812. import { Observable } from "babylonjs/Misc/observable";
  41813. import { Vector3 } from "babylonjs/Maths/math.vector";
  41814. import { Nullable } from "babylonjs/types";
  41815. import { Scene } from "babylonjs/scene";
  41816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41817. /**
  41818. * Interface used to define options for Sound class
  41819. */
  41820. export interface ISoundOptions {
  41821. /**
  41822. * Does the sound autoplay once loaded.
  41823. */
  41824. autoplay?: boolean;
  41825. /**
  41826. * Does the sound loop after it finishes playing once.
  41827. */
  41828. loop?: boolean;
  41829. /**
  41830. * Sound's volume
  41831. */
  41832. volume?: number;
  41833. /**
  41834. * Is it a spatial sound?
  41835. */
  41836. spatialSound?: boolean;
  41837. /**
  41838. * Maximum distance to hear that sound
  41839. */
  41840. maxDistance?: number;
  41841. /**
  41842. * Uses user defined attenuation function
  41843. */
  41844. useCustomAttenuation?: boolean;
  41845. /**
  41846. * Define the roll off factor of spatial sounds.
  41847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41848. */
  41849. rolloffFactor?: number;
  41850. /**
  41851. * Define the reference distance the sound should be heard perfectly.
  41852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41853. */
  41854. refDistance?: number;
  41855. /**
  41856. * Define the distance attenuation model the sound will follow.
  41857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41858. */
  41859. distanceModel?: string;
  41860. /**
  41861. * Defines the playback speed (1 by default)
  41862. */
  41863. playbackRate?: number;
  41864. /**
  41865. * Defines if the sound is from a streaming source
  41866. */
  41867. streaming?: boolean;
  41868. /**
  41869. * Defines an optional length (in seconds) inside the sound file
  41870. */
  41871. length?: number;
  41872. /**
  41873. * Defines an optional offset (in seconds) inside the sound file
  41874. */
  41875. offset?: number;
  41876. /**
  41877. * If true, URLs will not be required to state the audio file codec to use.
  41878. */
  41879. skipCodecCheck?: boolean;
  41880. }
  41881. /**
  41882. * Defines a sound that can be played in the application.
  41883. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41885. */
  41886. export class Sound {
  41887. /**
  41888. * The name of the sound in the scene.
  41889. */
  41890. name: string;
  41891. /**
  41892. * Does the sound autoplay once loaded.
  41893. */
  41894. autoplay: boolean;
  41895. /**
  41896. * Does the sound loop after it finishes playing once.
  41897. */
  41898. loop: boolean;
  41899. /**
  41900. * Does the sound use a custom attenuation curve to simulate the falloff
  41901. * happening when the source gets further away from the camera.
  41902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41903. */
  41904. useCustomAttenuation: boolean;
  41905. /**
  41906. * The sound track id this sound belongs to.
  41907. */
  41908. soundTrackId: number;
  41909. /**
  41910. * Is this sound currently played.
  41911. */
  41912. isPlaying: boolean;
  41913. /**
  41914. * Is this sound currently paused.
  41915. */
  41916. isPaused: boolean;
  41917. /**
  41918. * Does this sound enables spatial sound.
  41919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41920. */
  41921. spatialSound: boolean;
  41922. /**
  41923. * Define the reference distance the sound should be heard perfectly.
  41924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41925. */
  41926. refDistance: number;
  41927. /**
  41928. * Define the roll off factor of spatial sounds.
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41930. */
  41931. rolloffFactor: number;
  41932. /**
  41933. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41935. */
  41936. maxDistance: number;
  41937. /**
  41938. * Define the distance attenuation model the sound will follow.
  41939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41940. */
  41941. distanceModel: string;
  41942. /**
  41943. * @hidden
  41944. * Back Compat
  41945. **/
  41946. onended: () => any;
  41947. /**
  41948. * Gets or sets an object used to store user defined information for the sound.
  41949. */
  41950. metadata: any;
  41951. /**
  41952. * Observable event when the current playing sound finishes.
  41953. */
  41954. onEndedObservable: Observable<Sound>;
  41955. private _panningModel;
  41956. private _playbackRate;
  41957. private _streaming;
  41958. private _startTime;
  41959. private _startOffset;
  41960. private _position;
  41961. /** @hidden */
  41962. _positionInEmitterSpace: boolean;
  41963. private _localDirection;
  41964. private _volume;
  41965. private _isReadyToPlay;
  41966. private _isDirectional;
  41967. private _readyToPlayCallback;
  41968. private _audioBuffer;
  41969. private _soundSource;
  41970. private _streamingSource;
  41971. private _soundPanner;
  41972. private _soundGain;
  41973. private _inputAudioNode;
  41974. private _outputAudioNode;
  41975. private _coneInnerAngle;
  41976. private _coneOuterAngle;
  41977. private _coneOuterGain;
  41978. private _scene;
  41979. private _connectedTransformNode;
  41980. private _customAttenuationFunction;
  41981. private _registerFunc;
  41982. private _isOutputConnected;
  41983. private _htmlAudioElement;
  41984. private _urlType;
  41985. private _length?;
  41986. private _offset?;
  41987. /** @hidden */
  41988. static _SceneComponentInitialization: (scene: Scene) => void;
  41989. /**
  41990. * Create a sound and attach it to a scene
  41991. * @param name Name of your sound
  41992. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41993. * @param scene defines the scene the sound belongs to
  41994. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41995. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41996. */
  41997. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41998. /**
  41999. * Release the sound and its associated resources
  42000. */
  42001. dispose(): void;
  42002. /**
  42003. * Gets if the sounds is ready to be played or not.
  42004. * @returns true if ready, otherwise false
  42005. */
  42006. isReady(): boolean;
  42007. private _soundLoaded;
  42008. /**
  42009. * Sets the data of the sound from an audiobuffer
  42010. * @param audioBuffer The audioBuffer containing the data
  42011. */
  42012. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42013. /**
  42014. * Updates the current sounds options such as maxdistance, loop...
  42015. * @param options A JSON object containing values named as the object properties
  42016. */
  42017. updateOptions(options: ISoundOptions): void;
  42018. private _createSpatialParameters;
  42019. private _updateSpatialParameters;
  42020. /**
  42021. * Switch the panning model to HRTF:
  42022. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42023. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42024. */
  42025. switchPanningModelToHRTF(): void;
  42026. /**
  42027. * Switch the panning model to Equal Power:
  42028. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42030. */
  42031. switchPanningModelToEqualPower(): void;
  42032. private _switchPanningModel;
  42033. /**
  42034. * Connect this sound to a sound track audio node like gain...
  42035. * @param soundTrackAudioNode the sound track audio node to connect to
  42036. */
  42037. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42038. /**
  42039. * Transform this sound into a directional source
  42040. * @param coneInnerAngle Size of the inner cone in degree
  42041. * @param coneOuterAngle Size of the outer cone in degree
  42042. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42043. */
  42044. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42045. /**
  42046. * Gets or sets the inner angle for the directional cone.
  42047. */
  42048. get directionalConeInnerAngle(): number;
  42049. /**
  42050. * Gets or sets the inner angle for the directional cone.
  42051. */
  42052. set directionalConeInnerAngle(value: number);
  42053. /**
  42054. * Gets or sets the outer angle for the directional cone.
  42055. */
  42056. get directionalConeOuterAngle(): number;
  42057. /**
  42058. * Gets or sets the outer angle for the directional cone.
  42059. */
  42060. set directionalConeOuterAngle(value: number);
  42061. /**
  42062. * Sets the position of the emitter if spatial sound is enabled
  42063. * @param newPosition Defines the new posisiton
  42064. */
  42065. setPosition(newPosition: Vector3): void;
  42066. /**
  42067. * Sets the local direction of the emitter if spatial sound is enabled
  42068. * @param newLocalDirection Defines the new local direction
  42069. */
  42070. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42071. private _updateDirection;
  42072. /** @hidden */
  42073. updateDistanceFromListener(): void;
  42074. /**
  42075. * Sets a new custom attenuation function for the sound.
  42076. * @param callback Defines the function used for the attenuation
  42077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42078. */
  42079. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42080. /**
  42081. * Play the sound
  42082. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42083. * @param offset (optional) Start the sound at a specific time in seconds
  42084. * @param length (optional) Sound duration (in seconds)
  42085. */
  42086. play(time?: number, offset?: number, length?: number): void;
  42087. private _onended;
  42088. /**
  42089. * Stop the sound
  42090. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42091. */
  42092. stop(time?: number): void;
  42093. /**
  42094. * Put the sound in pause
  42095. */
  42096. pause(): void;
  42097. /**
  42098. * Sets a dedicated volume for this sounds
  42099. * @param newVolume Define the new volume of the sound
  42100. * @param time Define time for gradual change to new volume
  42101. */
  42102. setVolume(newVolume: number, time?: number): void;
  42103. /**
  42104. * Set the sound play back rate
  42105. * @param newPlaybackRate Define the playback rate the sound should be played at
  42106. */
  42107. setPlaybackRate(newPlaybackRate: number): void;
  42108. /**
  42109. * Gets the volume of the sound.
  42110. * @returns the volume of the sound
  42111. */
  42112. getVolume(): number;
  42113. /**
  42114. * Attach the sound to a dedicated mesh
  42115. * @param transformNode The transform node to connect the sound with
  42116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42117. */
  42118. attachToMesh(transformNode: TransformNode): void;
  42119. /**
  42120. * Detach the sound from the previously attached mesh
  42121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42122. */
  42123. detachFromMesh(): void;
  42124. private _onRegisterAfterWorldMatrixUpdate;
  42125. /**
  42126. * Clone the current sound in the scene.
  42127. * @returns the new sound clone
  42128. */
  42129. clone(): Nullable<Sound>;
  42130. /**
  42131. * Gets the current underlying audio buffer containing the data
  42132. * @returns the audio buffer
  42133. */
  42134. getAudioBuffer(): Nullable<AudioBuffer>;
  42135. /**
  42136. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42137. * @returns the source node
  42138. */
  42139. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42140. /**
  42141. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42142. * @returns the gain node
  42143. */
  42144. getSoundGain(): Nullable<GainNode>;
  42145. /**
  42146. * Serializes the Sound in a JSON representation
  42147. * @returns the JSON representation of the sound
  42148. */
  42149. serialize(): any;
  42150. /**
  42151. * Parse a JSON representation of a sound to innstantiate in a given scene
  42152. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42153. * @param scene Define the scene the new parsed sound should be created in
  42154. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42155. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42156. * @returns the newly parsed sound
  42157. */
  42158. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42159. }
  42160. }
  42161. declare module "babylonjs/Actions/directAudioActions" {
  42162. import { Action } from "babylonjs/Actions/action";
  42163. import { Condition } from "babylonjs/Actions/condition";
  42164. import { Sound } from "babylonjs/Audio/sound";
  42165. /**
  42166. * This defines an action helpful to play a defined sound on a triggered action.
  42167. */
  42168. export class PlaySoundAction extends Action {
  42169. private _sound;
  42170. /**
  42171. * Instantiate the action
  42172. * @param triggerOptions defines the trigger options
  42173. * @param sound defines the sound to play
  42174. * @param condition defines the trigger related conditions
  42175. */
  42176. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42177. /** @hidden */
  42178. _prepare(): void;
  42179. /**
  42180. * Execute the action and play the sound.
  42181. */
  42182. execute(): void;
  42183. /**
  42184. * Serializes the actions and its related information.
  42185. * @param parent defines the object to serialize in
  42186. * @returns the serialized object
  42187. */
  42188. serialize(parent: any): any;
  42189. }
  42190. /**
  42191. * This defines an action helpful to stop a defined sound on a triggered action.
  42192. */
  42193. export class StopSoundAction extends Action {
  42194. private _sound;
  42195. /**
  42196. * Instantiate the action
  42197. * @param triggerOptions defines the trigger options
  42198. * @param sound defines the sound to stop
  42199. * @param condition defines the trigger related conditions
  42200. */
  42201. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42202. /** @hidden */
  42203. _prepare(): void;
  42204. /**
  42205. * Execute the action and stop the sound.
  42206. */
  42207. execute(): void;
  42208. /**
  42209. * Serializes the actions and its related information.
  42210. * @param parent defines the object to serialize in
  42211. * @returns the serialized object
  42212. */
  42213. serialize(parent: any): any;
  42214. }
  42215. }
  42216. declare module "babylonjs/Actions/interpolateValueAction" {
  42217. import { Action } from "babylonjs/Actions/action";
  42218. import { Condition } from "babylonjs/Actions/condition";
  42219. import { Observable } from "babylonjs/Misc/observable";
  42220. /**
  42221. * This defines an action responsible to change the value of a property
  42222. * by interpolating between its current value and the newly set one once triggered.
  42223. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42224. */
  42225. export class InterpolateValueAction extends Action {
  42226. /**
  42227. * Defines the path of the property where the value should be interpolated
  42228. */
  42229. propertyPath: string;
  42230. /**
  42231. * Defines the target value at the end of the interpolation.
  42232. */
  42233. value: any;
  42234. /**
  42235. * Defines the time it will take for the property to interpolate to the value.
  42236. */
  42237. duration: number;
  42238. /**
  42239. * Defines if the other scene animations should be stopped when the action has been triggered
  42240. */
  42241. stopOtherAnimations?: boolean;
  42242. /**
  42243. * Defines a callback raised once the interpolation animation has been done.
  42244. */
  42245. onInterpolationDone?: () => void;
  42246. /**
  42247. * Observable triggered once the interpolation animation has been done.
  42248. */
  42249. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42250. private _target;
  42251. private _effectiveTarget;
  42252. private _property;
  42253. /**
  42254. * Instantiate the action
  42255. * @param triggerOptions defines the trigger options
  42256. * @param target defines the object containing the value to interpolate
  42257. * @param propertyPath defines the path to the property in the target object
  42258. * @param value defines the target value at the end of the interpolation
  42259. * @param duration deines the time it will take for the property to interpolate to the value.
  42260. * @param condition defines the trigger related conditions
  42261. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42262. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42263. */
  42264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42265. /** @hidden */
  42266. _prepare(): void;
  42267. /**
  42268. * Execute the action starts the value interpolation.
  42269. */
  42270. execute(): void;
  42271. /**
  42272. * Serializes the actions and its related information.
  42273. * @param parent defines the object to serialize in
  42274. * @returns the serialized object
  42275. */
  42276. serialize(parent: any): any;
  42277. }
  42278. }
  42279. declare module "babylonjs/Actions/index" {
  42280. export * from "babylonjs/Actions/abstractActionManager";
  42281. export * from "babylonjs/Actions/action";
  42282. export * from "babylonjs/Actions/actionEvent";
  42283. export * from "babylonjs/Actions/actionManager";
  42284. export * from "babylonjs/Actions/condition";
  42285. export * from "babylonjs/Actions/directActions";
  42286. export * from "babylonjs/Actions/directAudioActions";
  42287. export * from "babylonjs/Actions/interpolateValueAction";
  42288. }
  42289. declare module "babylonjs/Animations/index" {
  42290. export * from "babylonjs/Animations/animatable";
  42291. export * from "babylonjs/Animations/animation";
  42292. export * from "babylonjs/Animations/animationGroup";
  42293. export * from "babylonjs/Animations/animationPropertiesOverride";
  42294. export * from "babylonjs/Animations/easing";
  42295. export * from "babylonjs/Animations/runtimeAnimation";
  42296. export * from "babylonjs/Animations/animationEvent";
  42297. export * from "babylonjs/Animations/animationGroup";
  42298. export * from "babylonjs/Animations/animationKey";
  42299. export * from "babylonjs/Animations/animationRange";
  42300. export * from "babylonjs/Animations/animatable.interface";
  42301. }
  42302. declare module "babylonjs/Audio/soundTrack" {
  42303. import { Sound } from "babylonjs/Audio/sound";
  42304. import { Analyser } from "babylonjs/Audio/analyser";
  42305. import { Scene } from "babylonjs/scene";
  42306. /**
  42307. * Options allowed during the creation of a sound track.
  42308. */
  42309. export interface ISoundTrackOptions {
  42310. /**
  42311. * The volume the sound track should take during creation
  42312. */
  42313. volume?: number;
  42314. /**
  42315. * Define if the sound track is the main sound track of the scene
  42316. */
  42317. mainTrack?: boolean;
  42318. }
  42319. /**
  42320. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42321. * It will be also used in a future release to apply effects on a specific track.
  42322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42323. */
  42324. export class SoundTrack {
  42325. /**
  42326. * The unique identifier of the sound track in the scene.
  42327. */
  42328. id: number;
  42329. /**
  42330. * The list of sounds included in the sound track.
  42331. */
  42332. soundCollection: Array<Sound>;
  42333. private _outputAudioNode;
  42334. private _scene;
  42335. private _connectedAnalyser;
  42336. private _options;
  42337. private _isInitialized;
  42338. /**
  42339. * Creates a new sound track.
  42340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42341. * @param scene Define the scene the sound track belongs to
  42342. * @param options
  42343. */
  42344. constructor(scene: Scene, options?: ISoundTrackOptions);
  42345. private _initializeSoundTrackAudioGraph;
  42346. /**
  42347. * Release the sound track and its associated resources
  42348. */
  42349. dispose(): void;
  42350. /**
  42351. * Adds a sound to this sound track
  42352. * @param sound define the cound to add
  42353. * @ignoreNaming
  42354. */
  42355. AddSound(sound: Sound): void;
  42356. /**
  42357. * Removes a sound to this sound track
  42358. * @param sound define the cound to remove
  42359. * @ignoreNaming
  42360. */
  42361. RemoveSound(sound: Sound): void;
  42362. /**
  42363. * Set a global volume for the full sound track.
  42364. * @param newVolume Define the new volume of the sound track
  42365. */
  42366. setVolume(newVolume: number): void;
  42367. /**
  42368. * Switch the panning model to HRTF:
  42369. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42371. */
  42372. switchPanningModelToHRTF(): void;
  42373. /**
  42374. * Switch the panning model to Equal Power:
  42375. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42377. */
  42378. switchPanningModelToEqualPower(): void;
  42379. /**
  42380. * Connect the sound track to an audio analyser allowing some amazing
  42381. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42383. * @param analyser The analyser to connect to the engine
  42384. */
  42385. connectToAnalyser(analyser: Analyser): void;
  42386. }
  42387. }
  42388. declare module "babylonjs/Audio/audioSceneComponent" {
  42389. import { Sound } from "babylonjs/Audio/sound";
  42390. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42391. import { Nullable } from "babylonjs/types";
  42392. import { Vector3 } from "babylonjs/Maths/math.vector";
  42393. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42394. import { Scene } from "babylonjs/scene";
  42395. import { AbstractScene } from "babylonjs/abstractScene";
  42396. import "babylonjs/Audio/audioEngine";
  42397. module "babylonjs/abstractScene" {
  42398. interface AbstractScene {
  42399. /**
  42400. * The list of sounds used in the scene.
  42401. */
  42402. sounds: Nullable<Array<Sound>>;
  42403. }
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _mainSoundTrack: SoundTrack;
  42412. /**
  42413. * The main sound track played by the scene.
  42414. * It cotains your primary collection of sounds.
  42415. */
  42416. mainSoundTrack: SoundTrack;
  42417. /**
  42418. * The list of sound tracks added to the scene
  42419. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42420. */
  42421. soundTracks: Nullable<Array<SoundTrack>>;
  42422. /**
  42423. * Gets a sound using a given name
  42424. * @param name defines the name to search for
  42425. * @return the found sound or null if not found at all.
  42426. */
  42427. getSoundByName(name: string): Nullable<Sound>;
  42428. /**
  42429. * Gets or sets if audio support is enabled
  42430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42431. */
  42432. audioEnabled: boolean;
  42433. /**
  42434. * Gets or sets if audio will be output to headphones
  42435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42436. */
  42437. headphone: boolean;
  42438. /**
  42439. * Gets or sets custom audio listener position provider
  42440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42441. */
  42442. audioListenerPositionProvider: Nullable<() => Vector3>;
  42443. /**
  42444. * Gets or sets a refresh rate when using 3D audio positioning
  42445. */
  42446. audioPositioningRefreshRate: number;
  42447. }
  42448. }
  42449. /**
  42450. * Defines the sound scene component responsible to manage any sounds
  42451. * in a given scene.
  42452. */
  42453. export class AudioSceneComponent implements ISceneSerializableComponent {
  42454. /**
  42455. * The component name helpfull to identify the component in the list of scene components.
  42456. */
  42457. readonly name: string;
  42458. /**
  42459. * The scene the component belongs to.
  42460. */
  42461. scene: Scene;
  42462. private _audioEnabled;
  42463. /**
  42464. * Gets whether audio is enabled or not.
  42465. * Please use related enable/disable method to switch state.
  42466. */
  42467. get audioEnabled(): boolean;
  42468. private _headphone;
  42469. /**
  42470. * Gets whether audio is outputing to headphone or not.
  42471. * Please use the according Switch methods to change output.
  42472. */
  42473. get headphone(): boolean;
  42474. /**
  42475. * Gets or sets a refresh rate when using 3D audio positioning
  42476. */
  42477. audioPositioningRefreshRate: number;
  42478. private _audioListenerPositionProvider;
  42479. /**
  42480. * Gets the current audio listener position provider
  42481. */
  42482. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42483. /**
  42484. * Sets a custom listener position for all sounds in the scene
  42485. * By default, this is the position of the first active camera
  42486. */
  42487. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42488. /**
  42489. * Creates a new instance of the component for the given scene
  42490. * @param scene Defines the scene to register the component in
  42491. */
  42492. constructor(scene: Scene);
  42493. /**
  42494. * Registers the component in a given scene
  42495. */
  42496. register(): void;
  42497. /**
  42498. * Rebuilds the elements related to this component in case of
  42499. * context lost for instance.
  42500. */
  42501. rebuild(): void;
  42502. /**
  42503. * Serializes the component data to the specified json object
  42504. * @param serializationObject The object to serialize to
  42505. */
  42506. serialize(serializationObject: any): void;
  42507. /**
  42508. * Adds all the elements from the container to the scene
  42509. * @param container the container holding the elements
  42510. */
  42511. addFromContainer(container: AbstractScene): void;
  42512. /**
  42513. * Removes all the elements in the container from the scene
  42514. * @param container contains the elements to remove
  42515. * @param dispose if the removed element should be disposed (default: false)
  42516. */
  42517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42518. /**
  42519. * Disposes the component and the associated ressources.
  42520. */
  42521. dispose(): void;
  42522. /**
  42523. * Disables audio in the associated scene.
  42524. */
  42525. disableAudio(): void;
  42526. /**
  42527. * Enables audio in the associated scene.
  42528. */
  42529. enableAudio(): void;
  42530. /**
  42531. * Switch audio to headphone output.
  42532. */
  42533. switchAudioModeForHeadphones(): void;
  42534. /**
  42535. * Switch audio to normal speakers.
  42536. */
  42537. switchAudioModeForNormalSpeakers(): void;
  42538. private _cachedCameraDirection;
  42539. private _cachedCameraPosition;
  42540. private _lastCheck;
  42541. private _afterRender;
  42542. }
  42543. }
  42544. declare module "babylonjs/Audio/weightedsound" {
  42545. import { Sound } from "babylonjs/Audio/sound";
  42546. /**
  42547. * Wraps one or more Sound objects and selects one with random weight for playback.
  42548. */
  42549. export class WeightedSound {
  42550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42551. loop: boolean;
  42552. private _coneInnerAngle;
  42553. private _coneOuterAngle;
  42554. private _volume;
  42555. /** A Sound is currently playing. */
  42556. isPlaying: boolean;
  42557. /** A Sound is currently paused. */
  42558. isPaused: boolean;
  42559. private _sounds;
  42560. private _weights;
  42561. private _currentIndex?;
  42562. /**
  42563. * Creates a new WeightedSound from the list of sounds given.
  42564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42565. * @param sounds Array of Sounds that will be selected from.
  42566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42567. */
  42568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42569. /**
  42570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42571. */
  42572. get directionalConeInnerAngle(): number;
  42573. /**
  42574. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42575. */
  42576. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  42582. /**
  42583. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42584. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42585. */
  42586. set directionalConeOuterAngle(value: number);
  42587. /**
  42588. * Playback volume.
  42589. */
  42590. get volume(): number;
  42591. /**
  42592. * Playback volume.
  42593. */
  42594. set volume(value: number);
  42595. private _onended;
  42596. /**
  42597. * Suspend playback
  42598. */
  42599. pause(): void;
  42600. /**
  42601. * Stop playback
  42602. */
  42603. stop(): void;
  42604. /**
  42605. * Start playback.
  42606. * @param startOffset Position the clip head at a specific time in seconds.
  42607. */
  42608. play(startOffset?: number): void;
  42609. }
  42610. }
  42611. declare module "babylonjs/Audio/index" {
  42612. export * from "babylonjs/Audio/analyser";
  42613. export * from "babylonjs/Audio/audioEngine";
  42614. export * from "babylonjs/Audio/audioSceneComponent";
  42615. export * from "babylonjs/Audio/sound";
  42616. export * from "babylonjs/Audio/soundTrack";
  42617. export * from "babylonjs/Audio/weightedsound";
  42618. }
  42619. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42620. import { Behavior } from "babylonjs/Behaviors/behavior";
  42621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42622. import { BackEase } from "babylonjs/Animations/easing";
  42623. /**
  42624. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42625. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42626. */
  42627. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42628. /**
  42629. * Gets the name of the behavior.
  42630. */
  42631. get name(): string;
  42632. /**
  42633. * The easing function used by animations
  42634. */
  42635. static EasingFunction: BackEase;
  42636. /**
  42637. * The easing mode used by animations
  42638. */
  42639. static EasingMode: number;
  42640. /**
  42641. * The duration of the animation, in milliseconds
  42642. */
  42643. transitionDuration: number;
  42644. /**
  42645. * Length of the distance animated by the transition when lower radius is reached
  42646. */
  42647. lowerRadiusTransitionRange: number;
  42648. /**
  42649. * Length of the distance animated by the transition when upper radius is reached
  42650. */
  42651. upperRadiusTransitionRange: number;
  42652. private _autoTransitionRange;
  42653. /**
  42654. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42655. */
  42656. get autoTransitionRange(): boolean;
  42657. /**
  42658. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42659. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42660. */
  42661. set autoTransitionRange(value: boolean);
  42662. private _attachedCamera;
  42663. private _onAfterCheckInputsObserver;
  42664. private _onMeshTargetChangedObserver;
  42665. /**
  42666. * Initializes the behavior.
  42667. */
  42668. init(): void;
  42669. /**
  42670. * Attaches the behavior to its arc rotate camera.
  42671. * @param camera Defines the camera to attach the behavior to
  42672. */
  42673. attach(camera: ArcRotateCamera): void;
  42674. /**
  42675. * Detaches the behavior from its current arc rotate camera.
  42676. */
  42677. detach(): void;
  42678. private _radiusIsAnimating;
  42679. private _radiusBounceTransition;
  42680. private _animatables;
  42681. private _cachedWheelPrecision;
  42682. /**
  42683. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42684. * @param radiusLimit The limit to check against.
  42685. * @return Bool to indicate if at limit.
  42686. */
  42687. private _isRadiusAtLimit;
  42688. /**
  42689. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42690. * @param radiusDelta The delta by which to animate to. Can be negative.
  42691. */
  42692. private _applyBoundRadiusAnimation;
  42693. /**
  42694. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42695. */
  42696. protected _clearAnimationLocks(): void;
  42697. /**
  42698. * Stops and removes all animations that have been applied to the camera
  42699. */
  42700. stopAllAnimations(): void;
  42701. }
  42702. }
  42703. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42704. import { Behavior } from "babylonjs/Behaviors/behavior";
  42705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42706. import { ExponentialEase } from "babylonjs/Animations/easing";
  42707. import { Nullable } from "babylonjs/types";
  42708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42709. import { Vector3 } from "babylonjs/Maths/math.vector";
  42710. /**
  42711. * 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.
  42712. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42713. */
  42714. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42715. /**
  42716. * Gets the name of the behavior.
  42717. */
  42718. get name(): string;
  42719. private _mode;
  42720. private _radiusScale;
  42721. private _positionScale;
  42722. private _defaultElevation;
  42723. private _elevationReturnTime;
  42724. private _elevationReturnWaitTime;
  42725. private _zoomStopsAnimation;
  42726. private _framingTime;
  42727. /**
  42728. * The easing function used by animations
  42729. */
  42730. static EasingFunction: ExponentialEase;
  42731. /**
  42732. * The easing mode used by animations
  42733. */
  42734. static EasingMode: number;
  42735. /**
  42736. * Sets the current mode used by the behavior
  42737. */
  42738. set mode(mode: number);
  42739. /**
  42740. * Gets current mode used by the behavior.
  42741. */
  42742. get mode(): number;
  42743. /**
  42744. * Sets the scale applied to the radius (1 by default)
  42745. */
  42746. set radiusScale(radius: number);
  42747. /**
  42748. * Gets the scale applied to the radius
  42749. */
  42750. get radiusScale(): number;
  42751. /**
  42752. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42753. */
  42754. set positionScale(scale: number);
  42755. /**
  42756. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42757. */
  42758. get positionScale(): number;
  42759. /**
  42760. * Sets 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. set defaultElevation(elevation: number);
  42764. /**
  42765. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42766. * behaviour is triggered, in radians.
  42767. */
  42768. get defaultElevation(): number;
  42769. /**
  42770. * Sets the time (in milliseconds) taken to return to the default beta position.
  42771. * Negative value indicates camera should not return to default.
  42772. */
  42773. set elevationReturnTime(speed: number);
  42774. /**
  42775. * Gets the time (in milliseconds) taken to return to the default beta position.
  42776. * Negative value indicates camera should not return to default.
  42777. */
  42778. get elevationReturnTime(): number;
  42779. /**
  42780. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42781. */
  42782. set elevationReturnWaitTime(time: number);
  42783. /**
  42784. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42785. */
  42786. get elevationReturnWaitTime(): number;
  42787. /**
  42788. * Sets the flag that indicates if user zooming should stop animation.
  42789. */
  42790. set zoomStopsAnimation(flag: boolean);
  42791. /**
  42792. * Gets the flag that indicates if user zooming should stop animation.
  42793. */
  42794. get zoomStopsAnimation(): boolean;
  42795. /**
  42796. * Sets the transition time when framing the mesh, in milliseconds
  42797. */
  42798. set framingTime(time: number);
  42799. /**
  42800. * Gets the transition time when framing the mesh, in milliseconds
  42801. */
  42802. get framingTime(): number;
  42803. /**
  42804. * Define if the behavior should automatically change the configured
  42805. * camera limits and sensibilities.
  42806. */
  42807. autoCorrectCameraLimitsAndSensibility: boolean;
  42808. private _onPrePointerObservableObserver;
  42809. private _onAfterCheckInputsObserver;
  42810. private _onMeshTargetChangedObserver;
  42811. private _attachedCamera;
  42812. private _isPointerDown;
  42813. private _lastInteractionTime;
  42814. /**
  42815. * Initializes the behavior.
  42816. */
  42817. init(): void;
  42818. /**
  42819. * Attaches the behavior to its arc rotate camera.
  42820. * @param camera Defines the camera to attach the behavior to
  42821. */
  42822. attach(camera: ArcRotateCamera): void;
  42823. /**
  42824. * Detaches the behavior from its current arc rotate camera.
  42825. */
  42826. detach(): void;
  42827. private _animatables;
  42828. private _betaIsAnimating;
  42829. private _betaTransition;
  42830. private _radiusTransition;
  42831. private _vectorTransition;
  42832. /**
  42833. * Targets the given mesh and updates zoom level accordingly.
  42834. * @param mesh The mesh to target.
  42835. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42836. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42837. */
  42838. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42839. /**
  42840. * Targets the given mesh with its children and updates zoom level accordingly.
  42841. * @param mesh The mesh to target.
  42842. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42843. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42844. */
  42845. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42846. /**
  42847. * Targets the given meshes with their children and updates zoom level accordingly.
  42848. * @param meshes The mesh to target.
  42849. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42850. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42851. */
  42852. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42853. /**
  42854. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42855. * @param minimumWorld Determines the smaller position of the bounding box extend
  42856. * @param maximumWorld Determines the bigger position of the bounding box extend
  42857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42859. */
  42860. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42861. /**
  42862. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42863. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42864. * frustum width.
  42865. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42866. * to fully enclose the mesh in the viewing frustum.
  42867. */
  42868. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42869. /**
  42870. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42871. * is automatically returned to its default position (expected to be above ground plane).
  42872. */
  42873. private _maintainCameraAboveGround;
  42874. /**
  42875. * Returns the frustum slope based on the canvas ratio and camera FOV
  42876. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42877. */
  42878. private _getFrustumSlope;
  42879. /**
  42880. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42881. */
  42882. private _clearAnimationLocks;
  42883. /**
  42884. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42885. */
  42886. private _applyUserInteraction;
  42887. /**
  42888. * Stops and removes all animations that have been applied to the camera
  42889. */
  42890. stopAllAnimations(): void;
  42891. /**
  42892. * Gets a value indicating if the user is moving the camera
  42893. */
  42894. get isUserIsMoving(): boolean;
  42895. /**
  42896. * The camera can move all the way towards the mesh.
  42897. */
  42898. static IgnoreBoundsSizeMode: number;
  42899. /**
  42900. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42901. */
  42902. static FitFrustumSidesMode: number;
  42903. }
  42904. }
  42905. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42906. import { Nullable } from "babylonjs/types";
  42907. import { Camera } from "babylonjs/Cameras/camera";
  42908. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42909. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42910. /**
  42911. * Base class for Camera Pointer Inputs.
  42912. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42913. * for example usage.
  42914. */
  42915. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42916. /**
  42917. * Defines the camera the input is attached to.
  42918. */
  42919. abstract camera: Camera;
  42920. /**
  42921. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42922. */
  42923. protected _altKey: boolean;
  42924. protected _ctrlKey: boolean;
  42925. protected _metaKey: boolean;
  42926. protected _shiftKey: boolean;
  42927. /**
  42928. * Which mouse buttons were pressed at time of last mouse event.
  42929. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42930. */
  42931. protected _buttonsPressed: number;
  42932. /**
  42933. * Defines the buttons associated with the input to handle camera move.
  42934. */
  42935. buttons: number[];
  42936. /**
  42937. * Attach the input controls to a specific dom element to get the input from.
  42938. * @param element Defines the element the controls should be listened from
  42939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42940. */
  42941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42942. /**
  42943. * Detach the current controls from the specified dom element.
  42944. * @param element Defines the element to stop listening the inputs from
  42945. */
  42946. detachControl(element: Nullable<HTMLElement>): void;
  42947. /**
  42948. * Gets the class name of the current input.
  42949. * @returns the class name
  42950. */
  42951. getClassName(): string;
  42952. /**
  42953. * Get the friendly name associated with the input class.
  42954. * @returns the input friendly name
  42955. */
  42956. getSimpleName(): string;
  42957. /**
  42958. * Called on pointer POINTERDOUBLETAP event.
  42959. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42960. */
  42961. protected onDoubleTap(type: string): void;
  42962. /**
  42963. * Called on pointer POINTERMOVE event if only a single touch is active.
  42964. * Override this method to provide functionality.
  42965. */
  42966. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42967. /**
  42968. * Called on pointer POINTERMOVE event if multiple touches are active.
  42969. * Override this method to provide functionality.
  42970. */
  42971. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42972. /**
  42973. * Called on JS contextmenu event.
  42974. * Override this method to provide functionality.
  42975. */
  42976. protected onContextMenu(evt: PointerEvent): void;
  42977. /**
  42978. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42979. * press.
  42980. * Override this method to provide functionality.
  42981. */
  42982. protected onButtonDown(evt: PointerEvent): void;
  42983. /**
  42984. * Called each time a new POINTERUP event occurs. Ie, for each button
  42985. * release.
  42986. * Override this method to provide functionality.
  42987. */
  42988. protected onButtonUp(evt: PointerEvent): void;
  42989. /**
  42990. * Called when window becomes inactive.
  42991. * Override this method to provide functionality.
  42992. */
  42993. protected onLostFocus(): void;
  42994. private _pointerInput;
  42995. private _observer;
  42996. private _onLostFocus;
  42997. private pointA;
  42998. private pointB;
  42999. }
  43000. }
  43001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43004. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43005. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43006. /**
  43007. * Manage the pointers inputs to control an arc rotate camera.
  43008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43009. */
  43010. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43011. /**
  43012. * Defines the camera the input is attached to.
  43013. */
  43014. camera: ArcRotateCamera;
  43015. /**
  43016. * Gets the class name of the current input.
  43017. * @returns the class name
  43018. */
  43019. getClassName(): string;
  43020. /**
  43021. * Defines the buttons associated with the input to handle camera move.
  43022. */
  43023. buttons: number[];
  43024. /**
  43025. * Defines the pointer angular sensibility along the X axis or how fast is
  43026. * the camera rotating.
  43027. */
  43028. angularSensibilityX: number;
  43029. /**
  43030. * Defines the pointer angular sensibility along the Y axis or how fast is
  43031. * the camera rotating.
  43032. */
  43033. angularSensibilityY: number;
  43034. /**
  43035. * Defines the pointer pinch precision or how fast is the camera zooming.
  43036. */
  43037. pinchPrecision: number;
  43038. /**
  43039. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43040. * from 0.
  43041. * It defines the percentage of current camera.radius to use as delta when
  43042. * pinch zoom is used.
  43043. */
  43044. pinchDeltaPercentage: number;
  43045. /**
  43046. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43047. * that any object in the plane at the camera's target point will scale
  43048. * perfectly with finger motion.
  43049. * Overrides pinchDeltaPercentage and pinchPrecision.
  43050. */
  43051. useNaturalPinchZoom: boolean;
  43052. /**
  43053. * Defines the pointer panning sensibility or how fast is the camera moving.
  43054. */
  43055. panningSensibility: number;
  43056. /**
  43057. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43058. */
  43059. multiTouchPanning: boolean;
  43060. /**
  43061. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43062. * zoom (pinch) through multitouch.
  43063. */
  43064. multiTouchPanAndZoom: boolean;
  43065. /**
  43066. * Revers pinch action direction.
  43067. */
  43068. pinchInwards: boolean;
  43069. private _isPanClick;
  43070. private _twoFingerActivityCount;
  43071. private _isPinching;
  43072. /**
  43073. * Called on pointer POINTERMOVE event if only a single touch is active.
  43074. */
  43075. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43076. /**
  43077. * Called on pointer POINTERDOUBLETAP event.
  43078. */
  43079. protected onDoubleTap(type: string): void;
  43080. /**
  43081. * Called on pointer POINTERMOVE event if multiple touches are active.
  43082. */
  43083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43084. /**
  43085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43086. * press.
  43087. */
  43088. protected onButtonDown(evt: PointerEvent): void;
  43089. /**
  43090. * Called each time a new POINTERUP event occurs. Ie, for each button
  43091. * release.
  43092. */
  43093. protected onButtonUp(evt: PointerEvent): void;
  43094. /**
  43095. * Called when window becomes inactive.
  43096. */
  43097. protected onLostFocus(): void;
  43098. }
  43099. }
  43100. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43101. import { Nullable } from "babylonjs/types";
  43102. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43103. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43104. /**
  43105. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43107. */
  43108. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43109. /**
  43110. * Defines the camera the input is attached to.
  43111. */
  43112. camera: ArcRotateCamera;
  43113. /**
  43114. * Defines the list of key codes associated with the up action (increase alpha)
  43115. */
  43116. keysUp: number[];
  43117. /**
  43118. * Defines the list of key codes associated with the down action (decrease alpha)
  43119. */
  43120. keysDown: number[];
  43121. /**
  43122. * Defines the list of key codes associated with the left action (increase beta)
  43123. */
  43124. keysLeft: number[];
  43125. /**
  43126. * Defines the list of key codes associated with the right action (decrease beta)
  43127. */
  43128. keysRight: number[];
  43129. /**
  43130. * Defines the list of key codes associated with the reset action.
  43131. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43132. */
  43133. keysReset: number[];
  43134. /**
  43135. * Defines the panning sensibility of the inputs.
  43136. * (How fast is the camera panning)
  43137. */
  43138. panningSensibility: number;
  43139. /**
  43140. * Defines the zooming sensibility of the inputs.
  43141. * (How fast is the camera zooming)
  43142. */
  43143. zoomingSensibility: number;
  43144. /**
  43145. * Defines whether maintaining the alt key down switch the movement mode from
  43146. * orientation to zoom.
  43147. */
  43148. useAltToZoom: boolean;
  43149. /**
  43150. * Rotation speed of the camera
  43151. */
  43152. angularSpeed: number;
  43153. private _keys;
  43154. private _ctrlPressed;
  43155. private _altPressed;
  43156. private _onCanvasBlurObserver;
  43157. private _onKeyboardObserver;
  43158. private _engine;
  43159. private _scene;
  43160. /**
  43161. * Attach the input controls to a specific dom element to get the input from.
  43162. * @param element Defines the element the controls should be listened from
  43163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43164. */
  43165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43166. /**
  43167. * Detach the current controls from the specified dom element.
  43168. * @param element Defines the element to stop listening the inputs from
  43169. */
  43170. detachControl(element: Nullable<HTMLElement>): void;
  43171. /**
  43172. * Update the current camera state depending on the inputs that have been used this frame.
  43173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43174. */
  43175. checkInputs(): void;
  43176. /**
  43177. * Gets the class name of the current intput.
  43178. * @returns the class name
  43179. */
  43180. getClassName(): string;
  43181. /**
  43182. * Get the friendly name associated with the input class.
  43183. * @returns the input friendly name
  43184. */
  43185. getSimpleName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43189. import { Nullable } from "babylonjs/types";
  43190. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43192. /**
  43193. * Manage the mouse wheel inputs to control an arc rotate camera.
  43194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43195. */
  43196. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43197. /**
  43198. * Defines the camera the input is attached to.
  43199. */
  43200. camera: ArcRotateCamera;
  43201. /**
  43202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43203. */
  43204. wheelPrecision: number;
  43205. /**
  43206. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43207. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43208. */
  43209. wheelDeltaPercentage: number;
  43210. private _wheel;
  43211. private _observer;
  43212. private computeDeltaFromMouseWheelLegacyEvent;
  43213. /**
  43214. * Attach the input controls to a specific dom element to get the input from.
  43215. * @param element Defines the element the controls should be listened from
  43216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43217. */
  43218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43219. /**
  43220. * Detach the current controls from the specified dom element.
  43221. * @param element Defines the element to stop listening the inputs from
  43222. */
  43223. detachControl(element: Nullable<HTMLElement>): void;
  43224. /**
  43225. * Gets the class name of the current intput.
  43226. * @returns the class name
  43227. */
  43228. getClassName(): string;
  43229. /**
  43230. * Get the friendly name associated with the input class.
  43231. * @returns the input friendly name
  43232. */
  43233. getSimpleName(): string;
  43234. }
  43235. }
  43236. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43237. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43238. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43239. /**
  43240. * Default Inputs manager for the ArcRotateCamera.
  43241. * It groups all the default supported inputs for ease of use.
  43242. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43243. */
  43244. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43245. /**
  43246. * Instantiates a new ArcRotateCameraInputsManager.
  43247. * @param camera Defines the camera the inputs belong to
  43248. */
  43249. constructor(camera: ArcRotateCamera);
  43250. /**
  43251. * Add mouse wheel input support to the input manager.
  43252. * @returns the current input manager
  43253. */
  43254. addMouseWheel(): ArcRotateCameraInputsManager;
  43255. /**
  43256. * Add pointers input support to the input manager.
  43257. * @returns the current input manager
  43258. */
  43259. addPointers(): ArcRotateCameraInputsManager;
  43260. /**
  43261. * Add keyboard input support to the input manager.
  43262. * @returns the current input manager
  43263. */
  43264. addKeyboard(): ArcRotateCameraInputsManager;
  43265. }
  43266. }
  43267. declare module "babylonjs/Cameras/arcRotateCamera" {
  43268. import { Observable } from "babylonjs/Misc/observable";
  43269. import { Nullable } from "babylonjs/types";
  43270. import { Scene } from "babylonjs/scene";
  43271. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43273. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43274. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43275. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43276. import { Camera } from "babylonjs/Cameras/camera";
  43277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43278. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43279. import { Collider } from "babylonjs/Collisions/collider";
  43280. /**
  43281. * This represents an orbital type of camera.
  43282. *
  43283. * 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.
  43284. * 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.
  43285. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43286. */
  43287. export class ArcRotateCamera extends TargetCamera {
  43288. /**
  43289. * Defines the rotation angle of the camera along the longitudinal axis.
  43290. */
  43291. alpha: number;
  43292. /**
  43293. * Defines the rotation angle of the camera along the latitudinal axis.
  43294. */
  43295. beta: number;
  43296. /**
  43297. * Defines the radius of the camera from it s target point.
  43298. */
  43299. radius: number;
  43300. protected _target: Vector3;
  43301. protected _targetHost: Nullable<AbstractMesh>;
  43302. /**
  43303. * Defines the target point of the camera.
  43304. * The camera looks towards it form the radius distance.
  43305. */
  43306. get target(): Vector3;
  43307. set target(value: Vector3);
  43308. /**
  43309. * Define the current local position of the camera in the scene
  43310. */
  43311. get position(): Vector3;
  43312. set position(newPosition: Vector3);
  43313. protected _upVector: Vector3;
  43314. protected _upToYMatrix: Matrix;
  43315. protected _YToUpMatrix: Matrix;
  43316. /**
  43317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43320. */
  43321. set upVector(vec: Vector3);
  43322. get upVector(): Vector3;
  43323. /**
  43324. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43325. */
  43326. setMatUp(): void;
  43327. /**
  43328. * Current inertia value on the longitudinal axis.
  43329. * The bigger this number the longer it will take for the camera to stop.
  43330. */
  43331. inertialAlphaOffset: number;
  43332. /**
  43333. * Current inertia value on the latitudinal axis.
  43334. * The bigger this number the longer it will take for the camera to stop.
  43335. */
  43336. inertialBetaOffset: number;
  43337. /**
  43338. * Current inertia value on the radius axis.
  43339. * The bigger this number the longer it will take for the camera to stop.
  43340. */
  43341. inertialRadiusOffset: number;
  43342. /**
  43343. * Minimum allowed angle on the longitudinal axis.
  43344. * This can help limiting how the Camera is able to move in the scene.
  43345. */
  43346. lowerAlphaLimit: Nullable<number>;
  43347. /**
  43348. * Maximum allowed angle on the longitudinal axis.
  43349. * This can help limiting how the Camera is able to move in the scene.
  43350. */
  43351. upperAlphaLimit: Nullable<number>;
  43352. /**
  43353. * Minimum allowed angle on the latitudinal axis.
  43354. * This can help limiting how the Camera is able to move in the scene.
  43355. */
  43356. lowerBetaLimit: number;
  43357. /**
  43358. * Maximum allowed angle on the latitudinal axis.
  43359. * This can help limiting how the Camera is able to move in the scene.
  43360. */
  43361. upperBetaLimit: number;
  43362. /**
  43363. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43364. * This can help limiting how the Camera is able to move in the scene.
  43365. */
  43366. lowerRadiusLimit: Nullable<number>;
  43367. /**
  43368. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43369. * This can help limiting how the Camera is able to move in the scene.
  43370. */
  43371. upperRadiusLimit: Nullable<number>;
  43372. /**
  43373. * Defines the current inertia value used during panning of the camera along the X axis.
  43374. */
  43375. inertialPanningX: number;
  43376. /**
  43377. * Defines the current inertia value used during panning of the camera along the Y axis.
  43378. */
  43379. inertialPanningY: number;
  43380. /**
  43381. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43382. * Basically if your fingers moves away from more than this distance you will be considered
  43383. * in pinch mode.
  43384. */
  43385. pinchToPanMaxDistance: number;
  43386. /**
  43387. * Defines the maximum distance the camera can pan.
  43388. * This could help keeping the cammera always in your scene.
  43389. */
  43390. panningDistanceLimit: Nullable<number>;
  43391. /**
  43392. * Defines the target of the camera before paning.
  43393. */
  43394. panningOriginTarget: Vector3;
  43395. /**
  43396. * Defines the value of the inertia used during panning.
  43397. * 0 would mean stop inertia and one would mean no decelleration at all.
  43398. */
  43399. panningInertia: number;
  43400. /**
  43401. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43402. */
  43403. get angularSensibilityX(): number;
  43404. set angularSensibilityX(value: number);
  43405. /**
  43406. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43407. */
  43408. get angularSensibilityY(): number;
  43409. set angularSensibilityY(value: number);
  43410. /**
  43411. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43412. */
  43413. get pinchPrecision(): number;
  43414. set pinchPrecision(value: number);
  43415. /**
  43416. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43417. * It will be used instead of pinchDeltaPrecision if different from 0.
  43418. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43419. */
  43420. get pinchDeltaPercentage(): number;
  43421. set pinchDeltaPercentage(value: number);
  43422. /**
  43423. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43424. * and pinch delta percentage.
  43425. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43426. * that any object in the plane at the camera's target point will scale
  43427. * perfectly with finger motion.
  43428. */
  43429. get useNaturalPinchZoom(): boolean;
  43430. set useNaturalPinchZoom(value: boolean);
  43431. /**
  43432. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43433. */
  43434. get panningSensibility(): number;
  43435. set panningSensibility(value: number);
  43436. /**
  43437. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43438. */
  43439. get keysUp(): number[];
  43440. set keysUp(value: number[]);
  43441. /**
  43442. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43443. */
  43444. get keysDown(): number[];
  43445. set keysDown(value: number[]);
  43446. /**
  43447. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43448. */
  43449. get keysLeft(): number[];
  43450. set keysLeft(value: number[]);
  43451. /**
  43452. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43453. */
  43454. get keysRight(): number[];
  43455. set keysRight(value: number[]);
  43456. /**
  43457. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43458. */
  43459. get wheelPrecision(): number;
  43460. set wheelPrecision(value: number);
  43461. /**
  43462. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43463. * It will be used instead of pinchDeltaPrecision if different from 0.
  43464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43465. */
  43466. get wheelDeltaPercentage(): number;
  43467. set wheelDeltaPercentage(value: number);
  43468. /**
  43469. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43470. */
  43471. zoomOnFactor: number;
  43472. /**
  43473. * Defines a screen offset for the camera position.
  43474. */
  43475. targetScreenOffset: Vector2;
  43476. /**
  43477. * Allows the camera to be completely reversed.
  43478. * If false the camera can not arrive upside down.
  43479. */
  43480. allowUpsideDown: boolean;
  43481. /**
  43482. * Define if double tap/click is used to restore the previously saved state of the camera.
  43483. */
  43484. useInputToRestoreState: boolean;
  43485. /** @hidden */
  43486. _viewMatrix: Matrix;
  43487. /** @hidden */
  43488. _useCtrlForPanning: boolean;
  43489. /** @hidden */
  43490. _panningMouseButton: number;
  43491. /**
  43492. * Defines the input associated to the camera.
  43493. */
  43494. inputs: ArcRotateCameraInputsManager;
  43495. /** @hidden */
  43496. _reset: () => void;
  43497. /**
  43498. * Defines the allowed panning axis.
  43499. */
  43500. panningAxis: Vector3;
  43501. protected _localDirection: Vector3;
  43502. protected _transformedDirection: Vector3;
  43503. private _bouncingBehavior;
  43504. /**
  43505. * Gets the bouncing behavior of the camera if it has been enabled.
  43506. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43507. */
  43508. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43509. /**
  43510. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43511. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43512. */
  43513. get useBouncingBehavior(): boolean;
  43514. set useBouncingBehavior(value: boolean);
  43515. private _framingBehavior;
  43516. /**
  43517. * Gets the framing behavior of the camera if it has been enabled.
  43518. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43519. */
  43520. get framingBehavior(): Nullable<FramingBehavior>;
  43521. /**
  43522. * Defines if the framing behavior of the camera is enabled on the camera.
  43523. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43524. */
  43525. get useFramingBehavior(): boolean;
  43526. set useFramingBehavior(value: boolean);
  43527. private _autoRotationBehavior;
  43528. /**
  43529. * Gets the auto rotation behavior of the camera if it has been enabled.
  43530. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43531. */
  43532. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43533. /**
  43534. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43535. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43536. */
  43537. get useAutoRotationBehavior(): boolean;
  43538. set useAutoRotationBehavior(value: boolean);
  43539. /**
  43540. * Observable triggered when the mesh target has been changed on the camera.
  43541. */
  43542. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43543. /**
  43544. * Event raised when the camera is colliding with a mesh.
  43545. */
  43546. onCollide: (collidedMesh: AbstractMesh) => void;
  43547. /**
  43548. * Defines whether the camera should check collision with the objects oh the scene.
  43549. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43550. */
  43551. checkCollisions: boolean;
  43552. /**
  43553. * Defines the collision radius of the camera.
  43554. * This simulates a sphere around the camera.
  43555. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43556. */
  43557. collisionRadius: Vector3;
  43558. protected _collider: Collider;
  43559. protected _previousPosition: Vector3;
  43560. protected _collisionVelocity: Vector3;
  43561. protected _newPosition: Vector3;
  43562. protected _previousAlpha: number;
  43563. protected _previousBeta: number;
  43564. protected _previousRadius: number;
  43565. protected _collisionTriggered: boolean;
  43566. protected _targetBoundingCenter: Nullable<Vector3>;
  43567. private _computationVector;
  43568. /**
  43569. * Instantiates a new ArcRotateCamera in a given scene
  43570. * @param name Defines the name of the camera
  43571. * @param alpha Defines the camera rotation along the logitudinal axis
  43572. * @param beta Defines the camera rotation along the latitudinal axis
  43573. * @param radius Defines the camera distance from its target
  43574. * @param target Defines the camera target
  43575. * @param scene Defines the scene the camera belongs to
  43576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43577. */
  43578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43579. /** @hidden */
  43580. _initCache(): void;
  43581. /** @hidden */
  43582. _updateCache(ignoreParentClass?: boolean): void;
  43583. protected _getTargetPosition(): Vector3;
  43584. private _storedAlpha;
  43585. private _storedBeta;
  43586. private _storedRadius;
  43587. private _storedTarget;
  43588. private _storedTargetScreenOffset;
  43589. /**
  43590. * Stores the current state of the camera (alpha, beta, radius and target)
  43591. * @returns the camera itself
  43592. */
  43593. storeState(): Camera;
  43594. /**
  43595. * @hidden
  43596. * Restored camera state. You must call storeState() first
  43597. */
  43598. _restoreStateValues(): boolean;
  43599. /** @hidden */
  43600. _isSynchronizedViewMatrix(): boolean;
  43601. /**
  43602. * Attached controls to the current camera.
  43603. * @param element Defines the element the controls should be listened from
  43604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43605. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43606. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43607. */
  43608. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43609. /**
  43610. * Detach the current controls from the camera.
  43611. * The camera will stop reacting to inputs.
  43612. * @param element Defines the element to stop listening the inputs from
  43613. */
  43614. detachControl(element: HTMLElement): void;
  43615. /** @hidden */
  43616. _checkInputs(): void;
  43617. protected _checkLimits(): void;
  43618. /**
  43619. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43620. */
  43621. rebuildAnglesAndRadius(): void;
  43622. /**
  43623. * Use a position to define the current camera related information like alpha, beta and radius
  43624. * @param position Defines the position to set the camera at
  43625. */
  43626. setPosition(position: Vector3): void;
  43627. /**
  43628. * Defines the target the camera should look at.
  43629. * This will automatically adapt alpha beta and radius to fit within the new target.
  43630. * @param target Defines the new target as a Vector or a mesh
  43631. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43632. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43633. */
  43634. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43635. /** @hidden */
  43636. _getViewMatrix(): Matrix;
  43637. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43638. /**
  43639. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43640. * @param meshes Defines the mesh to zoom on
  43641. * @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)
  43642. */
  43643. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43644. /**
  43645. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43646. * The target will be changed but the radius
  43647. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43648. * @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)
  43649. */
  43650. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43651. min: Vector3;
  43652. max: Vector3;
  43653. distance: number;
  43654. }, doNotUpdateMaxZ?: boolean): void;
  43655. /**
  43656. * @override
  43657. * Override Camera.createRigCamera
  43658. */
  43659. createRigCamera(name: string, cameraIndex: number): Camera;
  43660. /**
  43661. * @hidden
  43662. * @override
  43663. * Override Camera._updateRigCameras
  43664. */
  43665. _updateRigCameras(): void;
  43666. /**
  43667. * Destroy the camera and release the current resources hold by it.
  43668. */
  43669. dispose(): void;
  43670. /**
  43671. * Gets the current object class name.
  43672. * @return the class name
  43673. */
  43674. getClassName(): string;
  43675. }
  43676. }
  43677. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43678. import { Behavior } from "babylonjs/Behaviors/behavior";
  43679. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43680. /**
  43681. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43683. */
  43684. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43685. /**
  43686. * Gets the name of the behavior.
  43687. */
  43688. get name(): string;
  43689. private _zoomStopsAnimation;
  43690. private _idleRotationSpeed;
  43691. private _idleRotationWaitTime;
  43692. private _idleRotationSpinupTime;
  43693. /**
  43694. * Sets the flag that indicates if user zooming should stop animation.
  43695. */
  43696. set zoomStopsAnimation(flag: boolean);
  43697. /**
  43698. * Gets the flag that indicates if user zooming should stop animation.
  43699. */
  43700. get zoomStopsAnimation(): boolean;
  43701. /**
  43702. * Sets the default speed at which the camera rotates around the model.
  43703. */
  43704. set idleRotationSpeed(speed: number);
  43705. /**
  43706. * Gets the default speed at which the camera rotates around the model.
  43707. */
  43708. get idleRotationSpeed(): number;
  43709. /**
  43710. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43711. */
  43712. set idleRotationWaitTime(time: number);
  43713. /**
  43714. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43715. */
  43716. get idleRotationWaitTime(): number;
  43717. /**
  43718. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43719. */
  43720. set idleRotationSpinupTime(time: number);
  43721. /**
  43722. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43723. */
  43724. get idleRotationSpinupTime(): number;
  43725. /**
  43726. * Gets a value indicating if the camera is currently rotating because of this behavior
  43727. */
  43728. get rotationInProgress(): boolean;
  43729. private _onPrePointerObservableObserver;
  43730. private _onAfterCheckInputsObserver;
  43731. private _attachedCamera;
  43732. private _isPointerDown;
  43733. private _lastFrameTime;
  43734. private _lastInteractionTime;
  43735. private _cameraRotationSpeed;
  43736. /**
  43737. * Initializes the behavior.
  43738. */
  43739. init(): void;
  43740. /**
  43741. * Attaches the behavior to its arc rotate camera.
  43742. * @param camera Defines the camera to attach the behavior to
  43743. */
  43744. attach(camera: ArcRotateCamera): void;
  43745. /**
  43746. * Detaches the behavior from its current arc rotate camera.
  43747. */
  43748. detach(): void;
  43749. /**
  43750. * Returns true if user is scrolling.
  43751. * @return true if user is scrolling.
  43752. */
  43753. private _userIsZooming;
  43754. private _lastFrameRadius;
  43755. private _shouldAnimationStopForInteraction;
  43756. /**
  43757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43758. */
  43759. private _applyUserInteraction;
  43760. private _userIsMoving;
  43761. }
  43762. }
  43763. declare module "babylonjs/Behaviors/Cameras/index" {
  43764. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43765. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43766. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43767. }
  43768. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43769. import { Mesh } from "babylonjs/Meshes/mesh";
  43770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43771. import { Behavior } from "babylonjs/Behaviors/behavior";
  43772. /**
  43773. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43774. */
  43775. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43776. private ui;
  43777. /**
  43778. * The name of the behavior
  43779. */
  43780. name: string;
  43781. /**
  43782. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43783. */
  43784. distanceAwayFromFace: number;
  43785. /**
  43786. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43787. */
  43788. distanceAwayFromBottomOfFace: number;
  43789. private _faceVectors;
  43790. private _target;
  43791. private _scene;
  43792. private _onRenderObserver;
  43793. private _tmpMatrix;
  43794. private _tmpVector;
  43795. /**
  43796. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43797. * @param ui The transform node that should be attched to the mesh
  43798. */
  43799. constructor(ui: TransformNode);
  43800. /**
  43801. * Initializes the behavior
  43802. */
  43803. init(): void;
  43804. private _closestFace;
  43805. private _zeroVector;
  43806. private _lookAtTmpMatrix;
  43807. private _lookAtToRef;
  43808. /**
  43809. * Attaches the AttachToBoxBehavior to the passed in mesh
  43810. * @param target The mesh that the specified node will be attached to
  43811. */
  43812. attach(target: Mesh): void;
  43813. /**
  43814. * Detaches the behavior from the mesh
  43815. */
  43816. detach(): void;
  43817. }
  43818. }
  43819. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43820. import { Behavior } from "babylonjs/Behaviors/behavior";
  43821. import { Mesh } from "babylonjs/Meshes/mesh";
  43822. /**
  43823. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43824. */
  43825. export class FadeInOutBehavior implements Behavior<Mesh> {
  43826. /**
  43827. * Time in milliseconds to delay before fading in (Default: 0)
  43828. */
  43829. delay: number;
  43830. /**
  43831. * Time in milliseconds for the mesh to fade in (Default: 300)
  43832. */
  43833. fadeInTime: number;
  43834. private _millisecondsPerFrame;
  43835. private _hovered;
  43836. private _hoverValue;
  43837. private _ownerNode;
  43838. /**
  43839. * Instatiates the FadeInOutBehavior
  43840. */
  43841. constructor();
  43842. /**
  43843. * The name of the behavior
  43844. */
  43845. get name(): string;
  43846. /**
  43847. * Initializes the behavior
  43848. */
  43849. init(): void;
  43850. /**
  43851. * Attaches the fade behavior on the passed in mesh
  43852. * @param ownerNode The mesh that will be faded in/out once attached
  43853. */
  43854. attach(ownerNode: Mesh): void;
  43855. /**
  43856. * Detaches the behavior from the mesh
  43857. */
  43858. detach(): void;
  43859. /**
  43860. * Triggers the mesh to begin fading in or out
  43861. * @param value if the object should fade in or out (true to fade in)
  43862. */
  43863. fadeIn(value: boolean): void;
  43864. private _update;
  43865. private _setAllVisibility;
  43866. }
  43867. }
  43868. declare module "babylonjs/Misc/pivotTools" {
  43869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43870. /**
  43871. * Class containing a set of static utilities functions for managing Pivots
  43872. * @hidden
  43873. */
  43874. export class PivotTools {
  43875. private static _PivotCached;
  43876. private static _OldPivotPoint;
  43877. private static _PivotTranslation;
  43878. private static _PivotTmpVector;
  43879. /** @hidden */
  43880. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43881. /** @hidden */
  43882. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43883. }
  43884. }
  43885. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43886. import { Scene } from "babylonjs/scene";
  43887. import { Vector4 } from "babylonjs/Maths/math.vector";
  43888. import { Mesh } from "babylonjs/Meshes/mesh";
  43889. import { Nullable } from "babylonjs/types";
  43890. import { Plane } from "babylonjs/Maths/math.plane";
  43891. /**
  43892. * Class containing static functions to help procedurally build meshes
  43893. */
  43894. export class PlaneBuilder {
  43895. /**
  43896. * Creates a plane mesh
  43897. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43898. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43899. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43901. * * 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
  43902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43903. * @param name defines the name of the mesh
  43904. * @param options defines the options used to create the mesh
  43905. * @param scene defines the hosting scene
  43906. * @returns the plane mesh
  43907. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43908. */
  43909. static CreatePlane(name: string, options: {
  43910. size?: number;
  43911. width?: number;
  43912. height?: number;
  43913. sideOrientation?: number;
  43914. frontUVs?: Vector4;
  43915. backUVs?: Vector4;
  43916. updatable?: boolean;
  43917. sourcePlane?: Plane;
  43918. }, scene?: Nullable<Scene>): Mesh;
  43919. }
  43920. }
  43921. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43922. import { Behavior } from "babylonjs/Behaviors/behavior";
  43923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43924. import { Observable } from "babylonjs/Misc/observable";
  43925. import { Vector3 } from "babylonjs/Maths/math.vector";
  43926. import { Ray } from "babylonjs/Culling/ray";
  43927. import "babylonjs/Meshes/Builders/planeBuilder";
  43928. /**
  43929. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43930. */
  43931. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43932. private static _AnyMouseID;
  43933. /**
  43934. * Abstract mesh the behavior is set on
  43935. */
  43936. attachedNode: AbstractMesh;
  43937. private _dragPlane;
  43938. private _scene;
  43939. private _pointerObserver;
  43940. private _beforeRenderObserver;
  43941. private static _planeScene;
  43942. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43943. /**
  43944. * 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)
  43945. */
  43946. maxDragAngle: number;
  43947. /**
  43948. * @hidden
  43949. */
  43950. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43951. /**
  43952. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43953. */
  43954. currentDraggingPointerID: number;
  43955. /**
  43956. * The last position where the pointer hit the drag plane in world space
  43957. */
  43958. lastDragPosition: Vector3;
  43959. /**
  43960. * If the behavior is currently in a dragging state
  43961. */
  43962. dragging: boolean;
  43963. /**
  43964. * 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)
  43965. */
  43966. dragDeltaRatio: number;
  43967. /**
  43968. * If the drag plane orientation should be updated during the dragging (Default: true)
  43969. */
  43970. updateDragPlane: boolean;
  43971. private _debugMode;
  43972. private _moving;
  43973. /**
  43974. * Fires each time the attached mesh is dragged with the pointer
  43975. * * delta between last drag position and current drag position in world space
  43976. * * dragDistance along the drag axis
  43977. * * dragPlaneNormal normal of the current drag plane used during the drag
  43978. * * dragPlanePoint in world space where the drag intersects the drag plane
  43979. */
  43980. onDragObservable: Observable<{
  43981. delta: Vector3;
  43982. dragPlanePoint: Vector3;
  43983. dragPlaneNormal: Vector3;
  43984. dragDistance: number;
  43985. pointerId: number;
  43986. }>;
  43987. /**
  43988. * Fires each time a drag begins (eg. mouse down on mesh)
  43989. */
  43990. onDragStartObservable: Observable<{
  43991. dragPlanePoint: Vector3;
  43992. pointerId: number;
  43993. }>;
  43994. /**
  43995. * Fires each time a drag ends (eg. mouse release after drag)
  43996. */
  43997. onDragEndObservable: Observable<{
  43998. dragPlanePoint: Vector3;
  43999. pointerId: number;
  44000. }>;
  44001. /**
  44002. * If the attached mesh should be moved when dragged
  44003. */
  44004. moveAttached: boolean;
  44005. /**
  44006. * If the drag behavior will react to drag events (Default: true)
  44007. */
  44008. enabled: boolean;
  44009. /**
  44010. * If pointer events should start and release the drag (Default: true)
  44011. */
  44012. startAndReleaseDragOnPointerEvents: boolean;
  44013. /**
  44014. * If camera controls should be detached during the drag
  44015. */
  44016. detachCameraControls: boolean;
  44017. /**
  44018. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44019. */
  44020. useObjectOrientationForDragging: boolean;
  44021. private _options;
  44022. /**
  44023. * Gets the options used by the behavior
  44024. */
  44025. get options(): {
  44026. dragAxis?: Vector3;
  44027. dragPlaneNormal?: Vector3;
  44028. };
  44029. /**
  44030. * Sets the options used by the behavior
  44031. */
  44032. set options(options: {
  44033. dragAxis?: Vector3;
  44034. dragPlaneNormal?: Vector3;
  44035. });
  44036. /**
  44037. * Creates a pointer drag behavior that can be attached to a mesh
  44038. * @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)
  44039. */
  44040. constructor(options?: {
  44041. dragAxis?: Vector3;
  44042. dragPlaneNormal?: Vector3;
  44043. });
  44044. /**
  44045. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44046. */
  44047. validateDrag: (targetPosition: Vector3) => boolean;
  44048. /**
  44049. * The name of the behavior
  44050. */
  44051. get name(): string;
  44052. /**
  44053. * Initializes the behavior
  44054. */
  44055. init(): void;
  44056. private _tmpVector;
  44057. private _alternatePickedPoint;
  44058. private _worldDragAxis;
  44059. private _targetPosition;
  44060. private _attachedElement;
  44061. /**
  44062. * Attaches the drag behavior the passed in mesh
  44063. * @param ownerNode The mesh that will be dragged around once attached
  44064. * @param predicate Predicate to use for pick filtering
  44065. */
  44066. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44067. /**
  44068. * Force relase the drag action by code.
  44069. */
  44070. releaseDrag(): void;
  44071. private _startDragRay;
  44072. private _lastPointerRay;
  44073. /**
  44074. * Simulates the start of a pointer drag event on the behavior
  44075. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44076. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44077. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44078. */
  44079. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44080. private _startDrag;
  44081. private _dragDelta;
  44082. private _moveDrag;
  44083. private _pickWithRayOnDragPlane;
  44084. private _pointA;
  44085. private _pointB;
  44086. private _pointC;
  44087. private _lineA;
  44088. private _lineB;
  44089. private _localAxis;
  44090. private _lookAt;
  44091. private _updateDragPlanePosition;
  44092. /**
  44093. * Detaches the behavior from the mesh
  44094. */
  44095. detach(): void;
  44096. }
  44097. }
  44098. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44099. import { Mesh } from "babylonjs/Meshes/mesh";
  44100. import { Behavior } from "babylonjs/Behaviors/behavior";
  44101. /**
  44102. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44103. */
  44104. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44105. private _dragBehaviorA;
  44106. private _dragBehaviorB;
  44107. private _startDistance;
  44108. private _initialScale;
  44109. private _targetScale;
  44110. private _ownerNode;
  44111. private _sceneRenderObserver;
  44112. /**
  44113. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44114. */
  44115. constructor();
  44116. /**
  44117. * The name of the behavior
  44118. */
  44119. get name(): string;
  44120. /**
  44121. * Initializes the behavior
  44122. */
  44123. init(): void;
  44124. private _getCurrentDistance;
  44125. /**
  44126. * Attaches the scale behavior the passed in mesh
  44127. * @param ownerNode The mesh that will be scaled around once attached
  44128. */
  44129. attach(ownerNode: Mesh): void;
  44130. /**
  44131. * Detaches the behavior from the mesh
  44132. */
  44133. detach(): void;
  44134. }
  44135. }
  44136. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44137. import { Behavior } from "babylonjs/Behaviors/behavior";
  44138. import { Mesh } from "babylonjs/Meshes/mesh";
  44139. import { Observable } from "babylonjs/Misc/observable";
  44140. /**
  44141. * 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
  44142. */
  44143. export class SixDofDragBehavior implements Behavior<Mesh> {
  44144. private static _virtualScene;
  44145. private _ownerNode;
  44146. private _sceneRenderObserver;
  44147. private _scene;
  44148. private _targetPosition;
  44149. private _virtualOriginMesh;
  44150. private _virtualDragMesh;
  44151. private _pointerObserver;
  44152. private _moving;
  44153. private _startingOrientation;
  44154. private _attachedElement;
  44155. /**
  44156. * 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)
  44157. */
  44158. private zDragFactor;
  44159. /**
  44160. * If the object should rotate to face the drag origin
  44161. */
  44162. rotateDraggedObject: boolean;
  44163. /**
  44164. * If the behavior is currently in a dragging state
  44165. */
  44166. dragging: boolean;
  44167. /**
  44168. * 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)
  44169. */
  44170. dragDeltaRatio: number;
  44171. /**
  44172. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44173. */
  44174. currentDraggingPointerID: number;
  44175. /**
  44176. * If camera controls should be detached during the drag
  44177. */
  44178. detachCameraControls: boolean;
  44179. /**
  44180. * Fires each time a drag starts
  44181. */
  44182. onDragStartObservable: Observable<{}>;
  44183. /**
  44184. * Fires each time a drag ends (eg. mouse release after drag)
  44185. */
  44186. onDragEndObservable: Observable<{}>;
  44187. /**
  44188. * 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
  44189. */
  44190. constructor();
  44191. /**
  44192. * The name of the behavior
  44193. */
  44194. get name(): string;
  44195. /**
  44196. * Initializes the behavior
  44197. */
  44198. init(): void;
  44199. /**
  44200. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44201. */
  44202. private get _pointerCamera();
  44203. /**
  44204. * Attaches the scale behavior the passed in mesh
  44205. * @param ownerNode The mesh that will be scaled around once attached
  44206. */
  44207. attach(ownerNode: Mesh): void;
  44208. /**
  44209. * Detaches the behavior from the mesh
  44210. */
  44211. detach(): void;
  44212. }
  44213. }
  44214. declare module "babylonjs/Behaviors/Meshes/index" {
  44215. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44216. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44217. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44218. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44219. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44220. }
  44221. declare module "babylonjs/Behaviors/index" {
  44222. export * from "babylonjs/Behaviors/behavior";
  44223. export * from "babylonjs/Behaviors/Cameras/index";
  44224. export * from "babylonjs/Behaviors/Meshes/index";
  44225. }
  44226. declare module "babylonjs/Bones/boneIKController" {
  44227. import { Bone } from "babylonjs/Bones/bone";
  44228. import { Vector3 } from "babylonjs/Maths/math.vector";
  44229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44230. import { Nullable } from "babylonjs/types";
  44231. /**
  44232. * Class used to apply inverse kinematics to bones
  44233. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44234. */
  44235. export class BoneIKController {
  44236. private static _tmpVecs;
  44237. private static _tmpQuat;
  44238. private static _tmpMats;
  44239. /**
  44240. * Gets or sets the target mesh
  44241. */
  44242. targetMesh: AbstractMesh;
  44243. /** Gets or sets the mesh used as pole */
  44244. poleTargetMesh: AbstractMesh;
  44245. /**
  44246. * Gets or sets the bone used as pole
  44247. */
  44248. poleTargetBone: Nullable<Bone>;
  44249. /**
  44250. * Gets or sets the target position
  44251. */
  44252. targetPosition: Vector3;
  44253. /**
  44254. * Gets or sets the pole target position
  44255. */
  44256. poleTargetPosition: Vector3;
  44257. /**
  44258. * Gets or sets the pole target local offset
  44259. */
  44260. poleTargetLocalOffset: Vector3;
  44261. /**
  44262. * Gets or sets the pole angle
  44263. */
  44264. poleAngle: number;
  44265. /**
  44266. * Gets or sets the mesh associated with the controller
  44267. */
  44268. mesh: AbstractMesh;
  44269. /**
  44270. * 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)
  44271. */
  44272. slerpAmount: number;
  44273. private _bone1Quat;
  44274. private _bone1Mat;
  44275. private _bone2Ang;
  44276. private _bone1;
  44277. private _bone2;
  44278. private _bone1Length;
  44279. private _bone2Length;
  44280. private _maxAngle;
  44281. private _maxReach;
  44282. private _rightHandedSystem;
  44283. private _bendAxis;
  44284. private _slerping;
  44285. private _adjustRoll;
  44286. /**
  44287. * Gets or sets maximum allowed angle
  44288. */
  44289. get maxAngle(): number;
  44290. set maxAngle(value: number);
  44291. /**
  44292. * Creates a new BoneIKController
  44293. * @param mesh defines the mesh to control
  44294. * @param bone defines the bone to control
  44295. * @param options defines options to set up the controller
  44296. */
  44297. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44298. targetMesh?: AbstractMesh;
  44299. poleTargetMesh?: AbstractMesh;
  44300. poleTargetBone?: Bone;
  44301. poleTargetLocalOffset?: Vector3;
  44302. poleAngle?: number;
  44303. bendAxis?: Vector3;
  44304. maxAngle?: number;
  44305. slerpAmount?: number;
  44306. });
  44307. private _setMaxAngle;
  44308. /**
  44309. * Force the controller to update the bones
  44310. */
  44311. update(): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Bones/boneLookController" {
  44315. import { Vector3 } from "babylonjs/Maths/math.vector";
  44316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44317. import { Bone } from "babylonjs/Bones/bone";
  44318. import { Space } from "babylonjs/Maths/math.axis";
  44319. /**
  44320. * Class used to make a bone look toward a point in space
  44321. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44322. */
  44323. export class BoneLookController {
  44324. private static _tmpVecs;
  44325. private static _tmpQuat;
  44326. private static _tmpMats;
  44327. /**
  44328. * The target Vector3 that the bone will look at
  44329. */
  44330. target: Vector3;
  44331. /**
  44332. * The mesh that the bone is attached to
  44333. */
  44334. mesh: AbstractMesh;
  44335. /**
  44336. * The bone that will be looking to the target
  44337. */
  44338. bone: Bone;
  44339. /**
  44340. * The up axis of the coordinate system that is used when the bone is rotated
  44341. */
  44342. upAxis: Vector3;
  44343. /**
  44344. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44345. */
  44346. upAxisSpace: Space;
  44347. /**
  44348. * Used to make an adjustment to the yaw of the bone
  44349. */
  44350. adjustYaw: number;
  44351. /**
  44352. * Used to make an adjustment to the pitch of the bone
  44353. */
  44354. adjustPitch: number;
  44355. /**
  44356. * Used to make an adjustment to the roll of the bone
  44357. */
  44358. adjustRoll: number;
  44359. /**
  44360. * 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)
  44361. */
  44362. slerpAmount: number;
  44363. private _minYaw;
  44364. private _maxYaw;
  44365. private _minPitch;
  44366. private _maxPitch;
  44367. private _minYawSin;
  44368. private _minYawCos;
  44369. private _maxYawSin;
  44370. private _maxYawCos;
  44371. private _midYawConstraint;
  44372. private _minPitchTan;
  44373. private _maxPitchTan;
  44374. private _boneQuat;
  44375. private _slerping;
  44376. private _transformYawPitch;
  44377. private _transformYawPitchInv;
  44378. private _firstFrameSkipped;
  44379. private _yawRange;
  44380. private _fowardAxis;
  44381. /**
  44382. * Gets or sets the minimum yaw angle that the bone can look to
  44383. */
  44384. get minYaw(): number;
  44385. set minYaw(value: number);
  44386. /**
  44387. * Gets or sets the maximum yaw angle that the bone can look to
  44388. */
  44389. get maxYaw(): number;
  44390. set maxYaw(value: number);
  44391. /**
  44392. * Gets or sets the minimum pitch angle that the bone can look to
  44393. */
  44394. get minPitch(): number;
  44395. set minPitch(value: number);
  44396. /**
  44397. * Gets or sets the maximum pitch angle that the bone can look to
  44398. */
  44399. get maxPitch(): number;
  44400. set maxPitch(value: number);
  44401. /**
  44402. * Create a BoneLookController
  44403. * @param mesh the mesh that the bone belongs to
  44404. * @param bone the bone that will be looking to the target
  44405. * @param target the target Vector3 to look at
  44406. * @param options optional settings:
  44407. * * maxYaw: the maximum angle the bone will yaw to
  44408. * * minYaw: the minimum angle the bone will yaw to
  44409. * * maxPitch: the maximum angle the bone will pitch to
  44410. * * minPitch: the minimum angle the bone will yaw to
  44411. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44412. * * upAxis: the up axis of the coordinate system
  44413. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44414. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44415. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44416. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44417. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44418. * * adjustRoll: used to make an adjustment to the roll of the bone
  44419. **/
  44420. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44421. maxYaw?: number;
  44422. minYaw?: number;
  44423. maxPitch?: number;
  44424. minPitch?: number;
  44425. slerpAmount?: number;
  44426. upAxis?: Vector3;
  44427. upAxisSpace?: Space;
  44428. yawAxis?: Vector3;
  44429. pitchAxis?: Vector3;
  44430. adjustYaw?: number;
  44431. adjustPitch?: number;
  44432. adjustRoll?: number;
  44433. });
  44434. /**
  44435. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44436. */
  44437. update(): void;
  44438. private _getAngleDiff;
  44439. private _getAngleBetween;
  44440. private _isAngleBetween;
  44441. }
  44442. }
  44443. declare module "babylonjs/Bones/index" {
  44444. export * from "babylonjs/Bones/bone";
  44445. export * from "babylonjs/Bones/boneIKController";
  44446. export * from "babylonjs/Bones/boneLookController";
  44447. export * from "babylonjs/Bones/skeleton";
  44448. }
  44449. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44450. import { Nullable } from "babylonjs/types";
  44451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44454. /**
  44455. * Manage the gamepad inputs to control an arc rotate camera.
  44456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44457. */
  44458. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44459. /**
  44460. * Defines the camera the input is attached to.
  44461. */
  44462. camera: ArcRotateCamera;
  44463. /**
  44464. * Defines the gamepad the input is gathering event from.
  44465. */
  44466. gamepad: Nullable<Gamepad>;
  44467. /**
  44468. * Defines the gamepad rotation sensiblity.
  44469. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44470. */
  44471. gamepadRotationSensibility: number;
  44472. /**
  44473. * Defines the gamepad move sensiblity.
  44474. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44475. */
  44476. gamepadMoveSensibility: number;
  44477. private _yAxisScale;
  44478. /**
  44479. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44480. */
  44481. get invertYAxis(): boolean;
  44482. set invertYAxis(value: boolean);
  44483. private _onGamepadConnectedObserver;
  44484. private _onGamepadDisconnectedObserver;
  44485. /**
  44486. * Attach the input controls to a specific dom element to get the input from.
  44487. * @param element Defines the element the controls should be listened from
  44488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44489. */
  44490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44491. /**
  44492. * Detach the current controls from the specified dom element.
  44493. * @param element Defines the element to stop listening the inputs from
  44494. */
  44495. detachControl(element: Nullable<HTMLElement>): void;
  44496. /**
  44497. * Update the current camera state depending on the inputs that have been used this frame.
  44498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44499. */
  44500. checkInputs(): void;
  44501. /**
  44502. * Gets the class name of the current intput.
  44503. * @returns the class name
  44504. */
  44505. getClassName(): string;
  44506. /**
  44507. * Get the friendly name associated with the input class.
  44508. * @returns the input friendly name
  44509. */
  44510. getSimpleName(): string;
  44511. }
  44512. }
  44513. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44514. import { Nullable } from "babylonjs/types";
  44515. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44516. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44517. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44518. interface ArcRotateCameraInputsManager {
  44519. /**
  44520. * Add orientation input support to the input manager.
  44521. * @returns the current input manager
  44522. */
  44523. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44524. }
  44525. }
  44526. /**
  44527. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44528. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44529. */
  44530. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44531. /**
  44532. * Defines the camera the input is attached to.
  44533. */
  44534. camera: ArcRotateCamera;
  44535. /**
  44536. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44537. */
  44538. alphaCorrection: number;
  44539. /**
  44540. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44541. */
  44542. gammaCorrection: number;
  44543. private _alpha;
  44544. private _gamma;
  44545. private _dirty;
  44546. private _deviceOrientationHandler;
  44547. /**
  44548. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44549. */
  44550. constructor();
  44551. /**
  44552. * Attach the input controls to a specific dom element to get the input from.
  44553. * @param element Defines the element the controls should be listened from
  44554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44555. */
  44556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44557. /** @hidden */
  44558. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44559. /**
  44560. * Update the current camera state depending on the inputs that have been used this frame.
  44561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44562. */
  44563. checkInputs(): void;
  44564. /**
  44565. * Detach the current controls from the specified dom element.
  44566. * @param element Defines the element to stop listening the inputs from
  44567. */
  44568. detachControl(element: Nullable<HTMLElement>): void;
  44569. /**
  44570. * Gets the class name of the current intput.
  44571. * @returns the class name
  44572. */
  44573. getClassName(): string;
  44574. /**
  44575. * Get the friendly name associated with the input class.
  44576. * @returns the input friendly name
  44577. */
  44578. getSimpleName(): string;
  44579. }
  44580. }
  44581. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44582. import { Nullable } from "babylonjs/types";
  44583. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44584. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44585. /**
  44586. * Listen to mouse events to control the camera.
  44587. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44588. */
  44589. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44590. /**
  44591. * Defines the camera the input is attached to.
  44592. */
  44593. camera: FlyCamera;
  44594. /**
  44595. * Defines if touch is enabled. (Default is true.)
  44596. */
  44597. touchEnabled: boolean;
  44598. /**
  44599. * Defines the buttons associated with the input to handle camera rotation.
  44600. */
  44601. buttons: number[];
  44602. /**
  44603. * Assign buttons for Yaw control.
  44604. */
  44605. buttonsYaw: number[];
  44606. /**
  44607. * Assign buttons for Pitch control.
  44608. */
  44609. buttonsPitch: number[];
  44610. /**
  44611. * Assign buttons for Roll control.
  44612. */
  44613. buttonsRoll: number[];
  44614. /**
  44615. * Detect if any button is being pressed while mouse is moved.
  44616. * -1 = Mouse locked.
  44617. * 0 = Left button.
  44618. * 1 = Middle Button.
  44619. * 2 = Right Button.
  44620. */
  44621. activeButton: number;
  44622. /**
  44623. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44624. * Higher values reduce its sensitivity.
  44625. */
  44626. angularSensibility: number;
  44627. private _mousemoveCallback;
  44628. private _observer;
  44629. private _rollObserver;
  44630. private previousPosition;
  44631. private noPreventDefault;
  44632. private element;
  44633. /**
  44634. * Listen to mouse events to control the camera.
  44635. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44637. */
  44638. constructor(touchEnabled?: boolean);
  44639. /**
  44640. * Attach the mouse control to the HTML DOM element.
  44641. * @param element Defines the element that listens to the input events.
  44642. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44645. /**
  44646. * Detach the current controls from the specified dom element.
  44647. * @param element Defines the element to stop listening the inputs from
  44648. */
  44649. detachControl(element: Nullable<HTMLElement>): void;
  44650. /**
  44651. * Gets the class name of the current input.
  44652. * @returns the class name.
  44653. */
  44654. getClassName(): string;
  44655. /**
  44656. * Get the friendly name associated with the input class.
  44657. * @returns the input's friendly name.
  44658. */
  44659. getSimpleName(): string;
  44660. private _pointerInput;
  44661. private _onMouseMove;
  44662. /**
  44663. * Rotate camera by mouse offset.
  44664. */
  44665. private rotateCamera;
  44666. }
  44667. }
  44668. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44669. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44670. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44671. /**
  44672. * Default Inputs manager for the FlyCamera.
  44673. * It groups all the default supported inputs for ease of use.
  44674. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44675. */
  44676. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44677. /**
  44678. * Instantiates a new FlyCameraInputsManager.
  44679. * @param camera Defines the camera the inputs belong to.
  44680. */
  44681. constructor(camera: FlyCamera);
  44682. /**
  44683. * Add keyboard input support to the input manager.
  44684. * @returns the new FlyCameraKeyboardMoveInput().
  44685. */
  44686. addKeyboard(): FlyCameraInputsManager;
  44687. /**
  44688. * Add mouse input support to the input manager.
  44689. * @param touchEnabled Enable touch screen support.
  44690. * @returns the new FlyCameraMouseInput().
  44691. */
  44692. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44693. }
  44694. }
  44695. declare module "babylonjs/Cameras/flyCamera" {
  44696. import { Scene } from "babylonjs/scene";
  44697. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44699. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44700. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44701. /**
  44702. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44703. * such as in a 3D Space Shooter or a Flight Simulator.
  44704. */
  44705. export class FlyCamera extends TargetCamera {
  44706. /**
  44707. * Define the collision ellipsoid of the camera.
  44708. * This is helpful for simulating a camera body, like a player's body.
  44709. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44710. */
  44711. ellipsoid: Vector3;
  44712. /**
  44713. * Define an offset for the position of the ellipsoid around the camera.
  44714. * This can be helpful if the camera is attached away from the player's body center,
  44715. * such as at its head.
  44716. */
  44717. ellipsoidOffset: Vector3;
  44718. /**
  44719. * Enable or disable collisions of the camera with the rest of the scene objects.
  44720. */
  44721. checkCollisions: boolean;
  44722. /**
  44723. * Enable or disable gravity on the camera.
  44724. */
  44725. applyGravity: boolean;
  44726. /**
  44727. * Define the current direction the camera is moving to.
  44728. */
  44729. cameraDirection: Vector3;
  44730. /**
  44731. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44732. * This overrides and empties cameraRotation.
  44733. */
  44734. rotationQuaternion: Quaternion;
  44735. /**
  44736. * Track Roll to maintain the wanted Rolling when looking around.
  44737. */
  44738. _trackRoll: number;
  44739. /**
  44740. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44741. */
  44742. rollCorrect: number;
  44743. /**
  44744. * Mimic a banked turn, Rolling the camera when Yawing.
  44745. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44746. */
  44747. bankedTurn: boolean;
  44748. /**
  44749. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44750. */
  44751. bankedTurnLimit: number;
  44752. /**
  44753. * Value of 0 disables the banked Roll.
  44754. * Value of 1 is equal to the Yaw angle in radians.
  44755. */
  44756. bankedTurnMultiplier: number;
  44757. /**
  44758. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44759. */
  44760. inputs: FlyCameraInputsManager;
  44761. /**
  44762. * Gets the input sensibility for mouse input.
  44763. * Higher values reduce sensitivity.
  44764. */
  44765. get angularSensibility(): number;
  44766. /**
  44767. * Sets the input sensibility for a mouse input.
  44768. * Higher values reduce sensitivity.
  44769. */
  44770. set angularSensibility(value: number);
  44771. /**
  44772. * Get the keys for camera movement forward.
  44773. */
  44774. get keysForward(): number[];
  44775. /**
  44776. * Set the keys for camera movement forward.
  44777. */
  44778. set keysForward(value: number[]);
  44779. /**
  44780. * Get the keys for camera movement backward.
  44781. */
  44782. get keysBackward(): number[];
  44783. set keysBackward(value: number[]);
  44784. /**
  44785. * Get the keys for camera movement up.
  44786. */
  44787. get keysUp(): number[];
  44788. /**
  44789. * Set the keys for camera movement up.
  44790. */
  44791. set keysUp(value: number[]);
  44792. /**
  44793. * Get the keys for camera movement down.
  44794. */
  44795. get keysDown(): number[];
  44796. /**
  44797. * Set the keys for camera movement down.
  44798. */
  44799. set keysDown(value: number[]);
  44800. /**
  44801. * Get the keys for camera movement left.
  44802. */
  44803. get keysLeft(): number[];
  44804. /**
  44805. * Set the keys for camera movement left.
  44806. */
  44807. set keysLeft(value: number[]);
  44808. /**
  44809. * Set the keys for camera movement right.
  44810. */
  44811. get keysRight(): number[];
  44812. /**
  44813. * Set the keys for camera movement right.
  44814. */
  44815. set keysRight(value: number[]);
  44816. /**
  44817. * Event raised when the camera collides with a mesh in the scene.
  44818. */
  44819. onCollide: (collidedMesh: AbstractMesh) => void;
  44820. private _collider;
  44821. private _needMoveForGravity;
  44822. private _oldPosition;
  44823. private _diffPosition;
  44824. private _newPosition;
  44825. /** @hidden */
  44826. _localDirection: Vector3;
  44827. /** @hidden */
  44828. _transformedDirection: Vector3;
  44829. /**
  44830. * Instantiates a FlyCamera.
  44831. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44832. * such as in a 3D Space Shooter or a Flight Simulator.
  44833. * @param name Define the name of the camera in the scene.
  44834. * @param position Define the starting position of the camera in the scene.
  44835. * @param scene Define the scene the camera belongs to.
  44836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44837. */
  44838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44839. /**
  44840. * Attach a control to the HTML DOM element.
  44841. * @param element Defines the element that listens to the input events.
  44842. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44843. */
  44844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44845. /**
  44846. * Detach a control from the HTML DOM element.
  44847. * The camera will stop reacting to that input.
  44848. * @param element Defines the element that listens to the input events.
  44849. */
  44850. detachControl(element: HTMLElement): void;
  44851. private _collisionMask;
  44852. /**
  44853. * Get the mask that the camera ignores in collision events.
  44854. */
  44855. get collisionMask(): number;
  44856. /**
  44857. * Set the mask that the camera ignores in collision events.
  44858. */
  44859. set collisionMask(mask: number);
  44860. /** @hidden */
  44861. _collideWithWorld(displacement: Vector3): void;
  44862. /** @hidden */
  44863. private _onCollisionPositionChange;
  44864. /** @hidden */
  44865. _checkInputs(): void;
  44866. /** @hidden */
  44867. _decideIfNeedsToMove(): boolean;
  44868. /** @hidden */
  44869. _updatePosition(): void;
  44870. /**
  44871. * Restore the Roll to its target value at the rate specified.
  44872. * @param rate - Higher means slower restoring.
  44873. * @hidden
  44874. */
  44875. restoreRoll(rate: number): void;
  44876. /**
  44877. * Destroy the camera and release the current resources held by it.
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * Get the current object class name.
  44882. * @returns the class name.
  44883. */
  44884. getClassName(): string;
  44885. }
  44886. }
  44887. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44888. import { Nullable } from "babylonjs/types";
  44889. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44890. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44891. /**
  44892. * Listen to keyboard events to control the camera.
  44893. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44894. */
  44895. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44896. /**
  44897. * Defines the camera the input is attached to.
  44898. */
  44899. camera: FlyCamera;
  44900. /**
  44901. * The list of keyboard keys used to control the forward move of the camera.
  44902. */
  44903. keysForward: number[];
  44904. /**
  44905. * The list of keyboard keys used to control the backward move of the camera.
  44906. */
  44907. keysBackward: number[];
  44908. /**
  44909. * The list of keyboard keys used to control the forward move of the camera.
  44910. */
  44911. keysUp: number[];
  44912. /**
  44913. * The list of keyboard keys used to control the backward move of the camera.
  44914. */
  44915. keysDown: number[];
  44916. /**
  44917. * The list of keyboard keys used to control the right strafe move of the camera.
  44918. */
  44919. keysRight: number[];
  44920. /**
  44921. * The list of keyboard keys used to control the left strafe move of the camera.
  44922. */
  44923. keysLeft: number[];
  44924. private _keys;
  44925. private _onCanvasBlurObserver;
  44926. private _onKeyboardObserver;
  44927. private _engine;
  44928. private _scene;
  44929. /**
  44930. * Attach the input controls to a specific dom element to get the input from.
  44931. * @param element Defines the element the controls should be listened from
  44932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44933. */
  44934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44935. /**
  44936. * Detach the current controls from the specified dom element.
  44937. * @param element Defines the element to stop listening the inputs from
  44938. */
  44939. detachControl(element: Nullable<HTMLElement>): void;
  44940. /**
  44941. * Gets the class name of the current intput.
  44942. * @returns the class name
  44943. */
  44944. getClassName(): string;
  44945. /** @hidden */
  44946. _onLostFocus(e: FocusEvent): void;
  44947. /**
  44948. * Get the friendly name associated with the input class.
  44949. * @returns the input friendly name
  44950. */
  44951. getSimpleName(): string;
  44952. /**
  44953. * Update the current camera state depending on the inputs that have been used this frame.
  44954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44955. */
  44956. checkInputs(): void;
  44957. }
  44958. }
  44959. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44960. import { Nullable } from "babylonjs/types";
  44961. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44963. /**
  44964. * Manage the mouse wheel inputs to control a follow camera.
  44965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44966. */
  44967. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44968. /**
  44969. * Defines the camera the input is attached to.
  44970. */
  44971. camera: FollowCamera;
  44972. /**
  44973. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44974. */
  44975. axisControlRadius: boolean;
  44976. /**
  44977. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44978. */
  44979. axisControlHeight: boolean;
  44980. /**
  44981. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44982. */
  44983. axisControlRotation: boolean;
  44984. /**
  44985. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44986. * relation to mouseWheel events.
  44987. */
  44988. wheelPrecision: number;
  44989. /**
  44990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44992. */
  44993. wheelDeltaPercentage: number;
  44994. private _wheel;
  44995. private _observer;
  44996. /**
  44997. * Attach the input controls to a specific dom element to get the input from.
  44998. * @param element Defines the element the controls should be listened from
  44999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45000. */
  45001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45002. /**
  45003. * Detach the current controls from the specified dom element.
  45004. * @param element Defines the element to stop listening the inputs from
  45005. */
  45006. detachControl(element: Nullable<HTMLElement>): void;
  45007. /**
  45008. * Gets the class name of the current intput.
  45009. * @returns the class name
  45010. */
  45011. getClassName(): string;
  45012. /**
  45013. * Get the friendly name associated with the input class.
  45014. * @returns the input friendly name
  45015. */
  45016. getSimpleName(): string;
  45017. }
  45018. }
  45019. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45020. import { Nullable } from "babylonjs/types";
  45021. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45022. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45023. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45024. /**
  45025. * Manage the pointers inputs to control an follow camera.
  45026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45027. */
  45028. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45029. /**
  45030. * Defines the camera the input is attached to.
  45031. */
  45032. camera: FollowCamera;
  45033. /**
  45034. * Gets the class name of the current input.
  45035. * @returns the class name
  45036. */
  45037. getClassName(): string;
  45038. /**
  45039. * Defines the pointer angular sensibility along the X axis or how fast is
  45040. * the camera rotating.
  45041. * A negative number will reverse the axis direction.
  45042. */
  45043. angularSensibilityX: number;
  45044. /**
  45045. * Defines the pointer angular sensibility along the Y axis or how fast is
  45046. * the camera rotating.
  45047. * A negative number will reverse the axis direction.
  45048. */
  45049. angularSensibilityY: number;
  45050. /**
  45051. * Defines the pointer pinch precision or how fast is the camera zooming.
  45052. * A negative number will reverse the axis direction.
  45053. */
  45054. pinchPrecision: number;
  45055. /**
  45056. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45057. * from 0.
  45058. * It defines the percentage of current camera.radius to use as delta when
  45059. * pinch zoom is used.
  45060. */
  45061. pinchDeltaPercentage: number;
  45062. /**
  45063. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45064. */
  45065. axisXControlRadius: boolean;
  45066. /**
  45067. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45068. */
  45069. axisXControlHeight: boolean;
  45070. /**
  45071. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45072. */
  45073. axisXControlRotation: boolean;
  45074. /**
  45075. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45076. */
  45077. axisYControlRadius: boolean;
  45078. /**
  45079. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45080. */
  45081. axisYControlHeight: boolean;
  45082. /**
  45083. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45084. */
  45085. axisYControlRotation: boolean;
  45086. /**
  45087. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45088. */
  45089. axisPinchControlRadius: boolean;
  45090. /**
  45091. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45092. */
  45093. axisPinchControlHeight: boolean;
  45094. /**
  45095. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45096. */
  45097. axisPinchControlRotation: boolean;
  45098. /**
  45099. * Log error messages if basic misconfiguration has occurred.
  45100. */
  45101. warningEnable: boolean;
  45102. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45103. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45104. private _warningCounter;
  45105. private _warning;
  45106. }
  45107. }
  45108. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45109. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45110. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45111. /**
  45112. * Default Inputs manager for the FollowCamera.
  45113. * It groups all the default supported inputs for ease of use.
  45114. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45115. */
  45116. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45117. /**
  45118. * Instantiates a new FollowCameraInputsManager.
  45119. * @param camera Defines the camera the inputs belong to
  45120. */
  45121. constructor(camera: FollowCamera);
  45122. /**
  45123. * Add keyboard input support to the input manager.
  45124. * @returns the current input manager
  45125. */
  45126. addKeyboard(): FollowCameraInputsManager;
  45127. /**
  45128. * Add mouse wheel input support to the input manager.
  45129. * @returns the current input manager
  45130. */
  45131. addMouseWheel(): FollowCameraInputsManager;
  45132. /**
  45133. * Add pointers input support to the input manager.
  45134. * @returns the current input manager
  45135. */
  45136. addPointers(): FollowCameraInputsManager;
  45137. /**
  45138. * Add orientation input support to the input manager.
  45139. * @returns the current input manager
  45140. */
  45141. addVRDeviceOrientation(): FollowCameraInputsManager;
  45142. }
  45143. }
  45144. declare module "babylonjs/Cameras/followCamera" {
  45145. import { Nullable } from "babylonjs/types";
  45146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45147. import { Scene } from "babylonjs/scene";
  45148. import { Vector3 } from "babylonjs/Maths/math.vector";
  45149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45150. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45151. /**
  45152. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45153. * an arc rotate version arcFollowCamera are available.
  45154. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45155. */
  45156. export class FollowCamera extends TargetCamera {
  45157. /**
  45158. * Distance the follow camera should follow an object at
  45159. */
  45160. radius: number;
  45161. /**
  45162. * Minimum allowed distance of the camera to the axis of rotation
  45163. * (The camera can not get closer).
  45164. * This can help limiting how the Camera is able to move in the scene.
  45165. */
  45166. lowerRadiusLimit: Nullable<number>;
  45167. /**
  45168. * Maximum allowed distance of the camera to the axis of rotation
  45169. * (The camera can not get further).
  45170. * This can help limiting how the Camera is able to move in the scene.
  45171. */
  45172. upperRadiusLimit: Nullable<number>;
  45173. /**
  45174. * Define a rotation offset between the camera and the object it follows
  45175. */
  45176. rotationOffset: number;
  45177. /**
  45178. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  45182. /**
  45183. * Maximum allowed angle to camera position relative to target object.
  45184. * This can help limiting how the Camera is able to move in the scene.
  45185. */
  45186. upperRotationOffsetLimit: Nullable<number>;
  45187. /**
  45188. * Define a height offset between the camera and the object it follows.
  45189. * It can help following an object from the top (like a car chaing a plane)
  45190. */
  45191. heightOffset: number;
  45192. /**
  45193. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  45197. /**
  45198. * Maximum allowed height of camera position relative to target object.
  45199. * This can help limiting how the Camera is able to move in the scene.
  45200. */
  45201. upperHeightOffsetLimit: Nullable<number>;
  45202. /**
  45203. * Define how fast the camera can accelerate to follow it s target.
  45204. */
  45205. cameraAcceleration: number;
  45206. /**
  45207. * Define the speed limit of the camera following an object.
  45208. */
  45209. maxCameraSpeed: number;
  45210. /**
  45211. * Define the target of the camera.
  45212. */
  45213. lockedTarget: Nullable<AbstractMesh>;
  45214. /**
  45215. * Defines the input associated with the camera.
  45216. */
  45217. inputs: FollowCameraInputsManager;
  45218. /**
  45219. * Instantiates the follow camera.
  45220. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45221. * @param name Define the name of the camera in the scene
  45222. * @param position Define the position of the camera
  45223. * @param scene Define the scene the camera belong to
  45224. * @param lockedTarget Define the target of the camera
  45225. */
  45226. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45227. private _follow;
  45228. /**
  45229. * Attached controls to the current camera.
  45230. * @param element Defines the element the controls should be listened from
  45231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45232. */
  45233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45234. /**
  45235. * Detach the current controls from the camera.
  45236. * The camera will stop reacting to inputs.
  45237. * @param element Defines the element to stop listening the inputs from
  45238. */
  45239. detachControl(element: HTMLElement): void;
  45240. /** @hidden */
  45241. _checkInputs(): void;
  45242. private _checkLimits;
  45243. /**
  45244. * Gets the camera class name.
  45245. * @returns the class name
  45246. */
  45247. getClassName(): string;
  45248. }
  45249. /**
  45250. * Arc Rotate version of the follow camera.
  45251. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45252. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45253. */
  45254. export class ArcFollowCamera extends TargetCamera {
  45255. /** The longitudinal angle of the camera */
  45256. alpha: number;
  45257. /** The latitudinal angle of the camera */
  45258. beta: number;
  45259. /** The radius of the camera from its target */
  45260. radius: number;
  45261. /** Define the camera target (the mesh it should follow) */
  45262. target: Nullable<AbstractMesh>;
  45263. private _cartesianCoordinates;
  45264. /**
  45265. * Instantiates a new ArcFollowCamera
  45266. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45267. * @param name Define the name of the camera
  45268. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45269. * @param beta Define the rotation angle of the camera around the elevation axis
  45270. * @param radius Define the radius of the camera from its target point
  45271. * @param target Define the target of the camera
  45272. * @param scene Define the scene the camera belongs to
  45273. */
  45274. constructor(name: string,
  45275. /** The longitudinal angle of the camera */
  45276. alpha: number,
  45277. /** The latitudinal angle of the camera */
  45278. beta: number,
  45279. /** The radius of the camera from its target */
  45280. radius: number,
  45281. /** Define the camera target (the mesh it should follow) */
  45282. target: Nullable<AbstractMesh>, scene: Scene);
  45283. private _follow;
  45284. /** @hidden */
  45285. _checkInputs(): void;
  45286. /**
  45287. * Returns the class name of the object.
  45288. * It is mostly used internally for serialization purposes.
  45289. */
  45290. getClassName(): string;
  45291. }
  45292. }
  45293. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45294. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45295. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45296. import { Nullable } from "babylonjs/types";
  45297. /**
  45298. * Manage the keyboard inputs to control the movement of a follow camera.
  45299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45300. */
  45301. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45302. /**
  45303. * Defines the camera the input is attached to.
  45304. */
  45305. camera: FollowCamera;
  45306. /**
  45307. * Defines the list of key codes associated with the up action (increase heightOffset)
  45308. */
  45309. keysHeightOffsetIncr: number[];
  45310. /**
  45311. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45312. */
  45313. keysHeightOffsetDecr: number[];
  45314. /**
  45315. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45316. */
  45317. keysHeightOffsetModifierAlt: boolean;
  45318. /**
  45319. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45320. */
  45321. keysHeightOffsetModifierCtrl: boolean;
  45322. /**
  45323. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45324. */
  45325. keysHeightOffsetModifierShift: boolean;
  45326. /**
  45327. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45328. */
  45329. keysRotationOffsetIncr: number[];
  45330. /**
  45331. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45332. */
  45333. keysRotationOffsetDecr: number[];
  45334. /**
  45335. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45336. */
  45337. keysRotationOffsetModifierAlt: boolean;
  45338. /**
  45339. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45340. */
  45341. keysRotationOffsetModifierCtrl: boolean;
  45342. /**
  45343. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45344. */
  45345. keysRotationOffsetModifierShift: boolean;
  45346. /**
  45347. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45348. */
  45349. keysRadiusIncr: number[];
  45350. /**
  45351. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45352. */
  45353. keysRadiusDecr: number[];
  45354. /**
  45355. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45356. */
  45357. keysRadiusModifierAlt: boolean;
  45358. /**
  45359. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45360. */
  45361. keysRadiusModifierCtrl: boolean;
  45362. /**
  45363. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45364. */
  45365. keysRadiusModifierShift: boolean;
  45366. /**
  45367. * Defines the rate of change of heightOffset.
  45368. */
  45369. heightSensibility: number;
  45370. /**
  45371. * Defines the rate of change of rotationOffset.
  45372. */
  45373. rotationSensibility: number;
  45374. /**
  45375. * Defines the rate of change of radius.
  45376. */
  45377. radiusSensibility: number;
  45378. private _keys;
  45379. private _ctrlPressed;
  45380. private _altPressed;
  45381. private _shiftPressed;
  45382. private _onCanvasBlurObserver;
  45383. private _onKeyboardObserver;
  45384. private _engine;
  45385. private _scene;
  45386. /**
  45387. * Attach the input controls to a specific dom element to get the input from.
  45388. * @param element Defines the element the controls should be listened from
  45389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45390. */
  45391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45392. /**
  45393. * Detach the current controls from the specified dom element.
  45394. * @param element Defines the element to stop listening the inputs from
  45395. */
  45396. detachControl(element: Nullable<HTMLElement>): void;
  45397. /**
  45398. * Update the current camera state depending on the inputs that have been used this frame.
  45399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45400. */
  45401. checkInputs(): void;
  45402. /**
  45403. * Gets the class name of the current input.
  45404. * @returns the class name
  45405. */
  45406. getClassName(): string;
  45407. /**
  45408. * Get the friendly name associated with the input class.
  45409. * @returns the input friendly name
  45410. */
  45411. getSimpleName(): string;
  45412. /**
  45413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45414. * allow modification of the heightOffset value.
  45415. */
  45416. private _modifierHeightOffset;
  45417. /**
  45418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45419. * allow modification of the rotationOffset value.
  45420. */
  45421. private _modifierRotationOffset;
  45422. /**
  45423. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45424. * allow modification of the radius value.
  45425. */
  45426. private _modifierRadius;
  45427. }
  45428. }
  45429. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45430. import { Nullable } from "babylonjs/types";
  45431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45432. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45433. import { Observable } from "babylonjs/Misc/observable";
  45434. module "babylonjs/Cameras/freeCameraInputsManager" {
  45435. interface FreeCameraInputsManager {
  45436. /**
  45437. * @hidden
  45438. */
  45439. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45440. /**
  45441. * Add orientation input support to the input manager.
  45442. * @returns the current input manager
  45443. */
  45444. addDeviceOrientation(): FreeCameraInputsManager;
  45445. }
  45446. }
  45447. /**
  45448. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45449. * Screen rotation is taken into account.
  45450. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45451. */
  45452. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45453. private _camera;
  45454. private _screenOrientationAngle;
  45455. private _constantTranform;
  45456. private _screenQuaternion;
  45457. private _alpha;
  45458. private _beta;
  45459. private _gamma;
  45460. /**
  45461. * Can be used to detect if a device orientation sensor is available on a device
  45462. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45463. * @returns a promise that will resolve on orientation change
  45464. */
  45465. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45466. /**
  45467. * @hidden
  45468. */
  45469. _onDeviceOrientationChangedObservable: Observable<void>;
  45470. /**
  45471. * Instantiates a new input
  45472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45473. */
  45474. constructor();
  45475. /**
  45476. * Define the camera controlled by the input.
  45477. */
  45478. get camera(): FreeCamera;
  45479. set camera(camera: FreeCamera);
  45480. /**
  45481. * Attach the input controls to a specific dom element to get the input from.
  45482. * @param element Defines the element the controls should be listened from
  45483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45484. */
  45485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45486. private _orientationChanged;
  45487. private _deviceOrientation;
  45488. /**
  45489. * Detach the current controls from the specified dom element.
  45490. * @param element Defines the element to stop listening the inputs from
  45491. */
  45492. detachControl(element: Nullable<HTMLElement>): void;
  45493. /**
  45494. * Update the current camera state depending on the inputs that have been used this frame.
  45495. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45496. */
  45497. checkInputs(): void;
  45498. /**
  45499. * Gets the class name of the current intput.
  45500. * @returns the class name
  45501. */
  45502. getClassName(): string;
  45503. /**
  45504. * Get the friendly name associated with the input class.
  45505. * @returns the input friendly name
  45506. */
  45507. getSimpleName(): string;
  45508. }
  45509. }
  45510. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45511. import { Nullable } from "babylonjs/types";
  45512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45514. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45515. /**
  45516. * Manage the gamepad inputs to control a free camera.
  45517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45518. */
  45519. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45520. /**
  45521. * Define the camera the input is attached to.
  45522. */
  45523. camera: FreeCamera;
  45524. /**
  45525. * Define the Gamepad controlling the input
  45526. */
  45527. gamepad: Nullable<Gamepad>;
  45528. /**
  45529. * Defines the gamepad rotation sensiblity.
  45530. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45531. */
  45532. gamepadAngularSensibility: number;
  45533. /**
  45534. * Defines the gamepad move sensiblity.
  45535. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45536. */
  45537. gamepadMoveSensibility: number;
  45538. private _yAxisScale;
  45539. /**
  45540. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45541. */
  45542. get invertYAxis(): boolean;
  45543. set invertYAxis(value: boolean);
  45544. private _onGamepadConnectedObserver;
  45545. private _onGamepadDisconnectedObserver;
  45546. private _cameraTransform;
  45547. private _deltaTransform;
  45548. private _vector3;
  45549. private _vector2;
  45550. /**
  45551. * Attach the input controls to a specific dom element to get the input from.
  45552. * @param element Defines the element the controls should be listened from
  45553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45554. */
  45555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45556. /**
  45557. * Detach the current controls from the specified dom element.
  45558. * @param element Defines the element to stop listening the inputs from
  45559. */
  45560. detachControl(element: Nullable<HTMLElement>): void;
  45561. /**
  45562. * Update the current camera state depending on the inputs that have been used this frame.
  45563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45564. */
  45565. checkInputs(): void;
  45566. /**
  45567. * Gets the class name of the current intput.
  45568. * @returns the class name
  45569. */
  45570. getClassName(): string;
  45571. /**
  45572. * Get the friendly name associated with the input class.
  45573. * @returns the input friendly name
  45574. */
  45575. getSimpleName(): string;
  45576. }
  45577. }
  45578. declare module "babylonjs/Misc/virtualJoystick" {
  45579. import { Nullable } from "babylonjs/types";
  45580. import { Vector3 } from "babylonjs/Maths/math.vector";
  45581. /**
  45582. * Defines the potential axis of a Joystick
  45583. */
  45584. export enum JoystickAxis {
  45585. /** X axis */
  45586. X = 0,
  45587. /** Y axis */
  45588. Y = 1,
  45589. /** Z axis */
  45590. Z = 2
  45591. }
  45592. /**
  45593. * Represents the different customization options available
  45594. * for VirtualJoystick
  45595. */
  45596. interface VirtualJoystickCustomizations {
  45597. /**
  45598. * Size of the joystick's puck
  45599. */
  45600. puckSize: number;
  45601. /**
  45602. * Size of the joystick's container
  45603. */
  45604. containerSize: number;
  45605. /**
  45606. * Color of the joystick && puck
  45607. */
  45608. color: string;
  45609. /**
  45610. * Image URL for the joystick's puck
  45611. */
  45612. puckImage?: string;
  45613. /**
  45614. * Image URL for the joystick's container
  45615. */
  45616. containerImage?: string;
  45617. /**
  45618. * Defines the unmoving position of the joystick container
  45619. */
  45620. position?: {
  45621. x: number;
  45622. y: number;
  45623. };
  45624. /**
  45625. * Defines whether or not the joystick container is always visible
  45626. */
  45627. alwaysVisible: boolean;
  45628. /**
  45629. * Defines whether or not to limit the movement of the puck to the joystick's container
  45630. */
  45631. limitToContainer: boolean;
  45632. }
  45633. /**
  45634. * Class used to define virtual joystick (used in touch mode)
  45635. */
  45636. export class VirtualJoystick {
  45637. /**
  45638. * Gets or sets a boolean indicating that left and right values must be inverted
  45639. */
  45640. reverseLeftRight: boolean;
  45641. /**
  45642. * Gets or sets a boolean indicating that up and down values must be inverted
  45643. */
  45644. reverseUpDown: boolean;
  45645. /**
  45646. * Gets the offset value for the position (ie. the change of the position value)
  45647. */
  45648. deltaPosition: Vector3;
  45649. /**
  45650. * Gets a boolean indicating if the virtual joystick was pressed
  45651. */
  45652. pressed: boolean;
  45653. /**
  45654. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45655. */
  45656. static Canvas: Nullable<HTMLCanvasElement>;
  45657. /**
  45658. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45659. */
  45660. limitToContainer: boolean;
  45661. private static _globalJoystickIndex;
  45662. private static _alwaysVisibleSticks;
  45663. private static vjCanvasContext;
  45664. private static vjCanvasWidth;
  45665. private static vjCanvasHeight;
  45666. private static halfWidth;
  45667. private static _GetDefaultOptions;
  45668. private _action;
  45669. private _axisTargetedByLeftAndRight;
  45670. private _axisTargetedByUpAndDown;
  45671. private _joystickSensibility;
  45672. private _inversedSensibility;
  45673. private _joystickPointerID;
  45674. private _joystickColor;
  45675. private _joystickPointerPos;
  45676. private _joystickPreviousPointerPos;
  45677. private _joystickPointerStartPos;
  45678. private _deltaJoystickVector;
  45679. private _leftJoystick;
  45680. private _touches;
  45681. private _joystickPosition;
  45682. private _alwaysVisible;
  45683. private _puckImage;
  45684. private _containerImage;
  45685. private _joystickPuckSize;
  45686. private _joystickContainerSize;
  45687. private _clearPuckSize;
  45688. private _clearContainerSize;
  45689. private _clearPuckSizeOffset;
  45690. private _clearContainerSizeOffset;
  45691. private _onPointerDownHandlerRef;
  45692. private _onPointerMoveHandlerRef;
  45693. private _onPointerUpHandlerRef;
  45694. private _onResize;
  45695. /**
  45696. * Creates a new virtual joystick
  45697. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45698. * @param customizations Defines the options we want to customize the VirtualJoystick
  45699. */
  45700. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45701. /**
  45702. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45703. * @param newJoystickSensibility defines the new sensibility
  45704. */
  45705. setJoystickSensibility(newJoystickSensibility: number): void;
  45706. private _onPointerDown;
  45707. private _onPointerMove;
  45708. private _onPointerUp;
  45709. /**
  45710. * Change the color of the virtual joystick
  45711. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45712. */
  45713. setJoystickColor(newColor: string): void;
  45714. /**
  45715. * Size of the joystick's container
  45716. */
  45717. set containerSize(newSize: number);
  45718. get containerSize(): number;
  45719. /**
  45720. * Size of the joystick's puck
  45721. */
  45722. set puckSize(newSize: number);
  45723. get puckSize(): number;
  45724. /**
  45725. * Clears the set position of the joystick
  45726. */
  45727. clearPosition(): void;
  45728. /**
  45729. * Defines whether or not the joystick container is always visible
  45730. */
  45731. set alwaysVisible(value: boolean);
  45732. get alwaysVisible(): boolean;
  45733. /**
  45734. * Sets the constant position of the Joystick container
  45735. * @param x X axis coordinate
  45736. * @param y Y axis coordinate
  45737. */
  45738. setPosition(x: number, y: number): void;
  45739. /**
  45740. * Defines a callback to call when the joystick is touched
  45741. * @param action defines the callback
  45742. */
  45743. setActionOnTouch(action: () => any): void;
  45744. /**
  45745. * Defines which axis you'd like to control for left & right
  45746. * @param axis defines the axis to use
  45747. */
  45748. setAxisForLeftRight(axis: JoystickAxis): void;
  45749. /**
  45750. * Defines which axis you'd like to control for up & down
  45751. * @param axis defines the axis to use
  45752. */
  45753. setAxisForUpDown(axis: JoystickAxis): void;
  45754. /**
  45755. * Clears the canvas from the previous puck / container draw
  45756. */
  45757. private _clearPreviousDraw;
  45758. /**
  45759. * Loads `urlPath` to be used for the container's image
  45760. * @param urlPath defines the urlPath of an image to use
  45761. */
  45762. setContainerImage(urlPath: string): void;
  45763. /**
  45764. * Loads `urlPath` to be used for the puck's image
  45765. * @param urlPath defines the urlPath of an image to use
  45766. */
  45767. setPuckImage(urlPath: string): void;
  45768. /**
  45769. * Draws the Virtual Joystick's container
  45770. */
  45771. private _drawContainer;
  45772. /**
  45773. * Draws the Virtual Joystick's puck
  45774. */
  45775. private _drawPuck;
  45776. private _drawVirtualJoystick;
  45777. /**
  45778. * Release internal HTML canvas
  45779. */
  45780. releaseCanvas(): void;
  45781. }
  45782. }
  45783. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45784. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45785. import { Nullable } from "babylonjs/types";
  45786. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45788. module "babylonjs/Cameras/freeCameraInputsManager" {
  45789. interface FreeCameraInputsManager {
  45790. /**
  45791. * Add virtual joystick input support to the input manager.
  45792. * @returns the current input manager
  45793. */
  45794. addVirtualJoystick(): FreeCameraInputsManager;
  45795. }
  45796. }
  45797. /**
  45798. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45799. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45800. */
  45801. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45802. /**
  45803. * Defines the camera the input is attached to.
  45804. */
  45805. camera: FreeCamera;
  45806. private _leftjoystick;
  45807. private _rightjoystick;
  45808. /**
  45809. * Gets the left stick of the virtual joystick.
  45810. * @returns The virtual Joystick
  45811. */
  45812. getLeftJoystick(): VirtualJoystick;
  45813. /**
  45814. * Gets the right stick of the virtual joystick.
  45815. * @returns The virtual Joystick
  45816. */
  45817. getRightJoystick(): VirtualJoystick;
  45818. /**
  45819. * Update the current camera state depending on the inputs that have been used this frame.
  45820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45821. */
  45822. checkInputs(): void;
  45823. /**
  45824. * Attach the input controls to a specific dom element to get the input from.
  45825. * @param element Defines the element the controls should be listened from
  45826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45827. */
  45828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45829. /**
  45830. * Detach the current controls from the specified dom element.
  45831. * @param element Defines the element to stop listening the inputs from
  45832. */
  45833. detachControl(element: Nullable<HTMLElement>): void;
  45834. /**
  45835. * Gets the class name of the current intput.
  45836. * @returns the class name
  45837. */
  45838. getClassName(): string;
  45839. /**
  45840. * Get the friendly name associated with the input class.
  45841. * @returns the input friendly name
  45842. */
  45843. getSimpleName(): string;
  45844. }
  45845. }
  45846. declare module "babylonjs/Cameras/Inputs/index" {
  45847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45848. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45849. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45850. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45851. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45852. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45853. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45854. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45855. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45856. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45857. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45858. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45859. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45860. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45861. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45862. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45863. }
  45864. declare module "babylonjs/Cameras/touchCamera" {
  45865. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45866. import { Scene } from "babylonjs/scene";
  45867. import { Vector3 } from "babylonjs/Maths/math.vector";
  45868. /**
  45869. * This represents a FPS type of camera controlled by touch.
  45870. * This is like a universal camera minus the Gamepad controls.
  45871. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45872. */
  45873. export class TouchCamera extends FreeCamera {
  45874. /**
  45875. * Defines the touch sensibility for rotation.
  45876. * The higher the faster.
  45877. */
  45878. get touchAngularSensibility(): number;
  45879. set touchAngularSensibility(value: number);
  45880. /**
  45881. * Defines the touch sensibility for move.
  45882. * The higher the faster.
  45883. */
  45884. get touchMoveSensibility(): number;
  45885. set touchMoveSensibility(value: number);
  45886. /**
  45887. * Instantiates a new touch camera.
  45888. * This represents a FPS type of camera controlled by touch.
  45889. * This is like a universal camera minus the Gamepad controls.
  45890. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45891. * @param name Define the name of the camera in the scene
  45892. * @param position Define the start position of the camera in the scene
  45893. * @param scene Define the scene the camera belongs to
  45894. */
  45895. constructor(name: string, position: Vector3, scene: Scene);
  45896. /**
  45897. * Gets the current object class name.
  45898. * @return the class name
  45899. */
  45900. getClassName(): string;
  45901. /** @hidden */
  45902. _setupInputs(): void;
  45903. }
  45904. }
  45905. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45907. import { Scene } from "babylonjs/scene";
  45908. import { Vector3 } from "babylonjs/Maths/math.vector";
  45909. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45910. import { Axis } from "babylonjs/Maths/math.axis";
  45911. /**
  45912. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45913. * being tilted forward or back and left or right.
  45914. */
  45915. export class DeviceOrientationCamera extends FreeCamera {
  45916. private _initialQuaternion;
  45917. private _quaternionCache;
  45918. private _tmpDragQuaternion;
  45919. private _disablePointerInputWhenUsingDeviceOrientation;
  45920. /**
  45921. * Creates a new device orientation camera
  45922. * @param name The name of the camera
  45923. * @param position The start position camera
  45924. * @param scene The scene the camera belongs to
  45925. */
  45926. constructor(name: string, position: Vector3, scene: Scene);
  45927. /**
  45928. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45929. */
  45930. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45931. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45932. private _dragFactor;
  45933. /**
  45934. * Enabled turning on the y axis when the orientation sensor is active
  45935. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45936. */
  45937. enableHorizontalDragging(dragFactor?: number): void;
  45938. /**
  45939. * Gets the current instance class name ("DeviceOrientationCamera").
  45940. * This helps avoiding instanceof at run time.
  45941. * @returns the class name
  45942. */
  45943. getClassName(): string;
  45944. /**
  45945. * @hidden
  45946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45947. */
  45948. _checkInputs(): void;
  45949. /**
  45950. * Reset the camera to its default orientation on the specified axis only.
  45951. * @param axis The axis to reset
  45952. */
  45953. resetToCurrentRotation(axis?: Axis): void;
  45954. }
  45955. }
  45956. declare module "babylonjs/Gamepads/xboxGamepad" {
  45957. import { Observable } from "babylonjs/Misc/observable";
  45958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45959. /**
  45960. * Defines supported buttons for XBox360 compatible gamepads
  45961. */
  45962. export enum Xbox360Button {
  45963. /** A */
  45964. A = 0,
  45965. /** B */
  45966. B = 1,
  45967. /** X */
  45968. X = 2,
  45969. /** Y */
  45970. Y = 3,
  45971. /** Left button */
  45972. LB = 4,
  45973. /** Right button */
  45974. RB = 5,
  45975. /** Back */
  45976. Back = 8,
  45977. /** Start */
  45978. Start = 9,
  45979. /** Left stick */
  45980. LeftStick = 10,
  45981. /** Right stick */
  45982. RightStick = 11
  45983. }
  45984. /** Defines values for XBox360 DPad */
  45985. export enum Xbox360Dpad {
  45986. /** Up */
  45987. Up = 12,
  45988. /** Down */
  45989. Down = 13,
  45990. /** Left */
  45991. Left = 14,
  45992. /** Right */
  45993. Right = 15
  45994. }
  45995. /**
  45996. * Defines a XBox360 gamepad
  45997. */
  45998. export class Xbox360Pad extends Gamepad {
  45999. private _leftTrigger;
  46000. private _rightTrigger;
  46001. private _onlefttriggerchanged;
  46002. private _onrighttriggerchanged;
  46003. private _onbuttondown;
  46004. private _onbuttonup;
  46005. private _ondpaddown;
  46006. private _ondpadup;
  46007. /** Observable raised when a button is pressed */
  46008. onButtonDownObservable: Observable<Xbox360Button>;
  46009. /** Observable raised when a button is released */
  46010. onButtonUpObservable: Observable<Xbox360Button>;
  46011. /** Observable raised when a pad is pressed */
  46012. onPadDownObservable: Observable<Xbox360Dpad>;
  46013. /** Observable raised when a pad is released */
  46014. onPadUpObservable: Observable<Xbox360Dpad>;
  46015. private _buttonA;
  46016. private _buttonB;
  46017. private _buttonX;
  46018. private _buttonY;
  46019. private _buttonBack;
  46020. private _buttonStart;
  46021. private _buttonLB;
  46022. private _buttonRB;
  46023. private _buttonLeftStick;
  46024. private _buttonRightStick;
  46025. private _dPadUp;
  46026. private _dPadDown;
  46027. private _dPadLeft;
  46028. private _dPadRight;
  46029. private _isXboxOnePad;
  46030. /**
  46031. * Creates a new XBox360 gamepad object
  46032. * @param id defines the id of this gamepad
  46033. * @param index defines its index
  46034. * @param gamepad defines the internal HTML gamepad object
  46035. * @param xboxOne defines if it is a XBox One gamepad
  46036. */
  46037. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46038. /**
  46039. * Defines the callback to call when left trigger is pressed
  46040. * @param callback defines the callback to use
  46041. */
  46042. onlefttriggerchanged(callback: (value: number) => void): void;
  46043. /**
  46044. * Defines the callback to call when right trigger is pressed
  46045. * @param callback defines the callback to use
  46046. */
  46047. onrighttriggerchanged(callback: (value: number) => void): void;
  46048. /**
  46049. * Gets the left trigger value
  46050. */
  46051. get leftTrigger(): number;
  46052. /**
  46053. * Sets the left trigger value
  46054. */
  46055. set leftTrigger(newValue: number);
  46056. /**
  46057. * Gets the right trigger value
  46058. */
  46059. get rightTrigger(): number;
  46060. /**
  46061. * Sets the right trigger value
  46062. */
  46063. set rightTrigger(newValue: number);
  46064. /**
  46065. * Defines the callback to call when a button is pressed
  46066. * @param callback defines the callback to use
  46067. */
  46068. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46069. /**
  46070. * Defines the callback to call when a button is released
  46071. * @param callback defines the callback to use
  46072. */
  46073. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46074. /**
  46075. * Defines the callback to call when a pad is pressed
  46076. * @param callback defines the callback to use
  46077. */
  46078. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46079. /**
  46080. * Defines the callback to call when a pad is released
  46081. * @param callback defines the callback to use
  46082. */
  46083. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46084. private _setButtonValue;
  46085. private _setDPadValue;
  46086. /**
  46087. * Gets the value of the `A` button
  46088. */
  46089. get buttonA(): number;
  46090. /**
  46091. * Sets the value of the `A` button
  46092. */
  46093. set buttonA(value: number);
  46094. /**
  46095. * Gets the value of the `B` button
  46096. */
  46097. get buttonB(): number;
  46098. /**
  46099. * Sets the value of the `B` button
  46100. */
  46101. set buttonB(value: number);
  46102. /**
  46103. * Gets the value of the `X` button
  46104. */
  46105. get buttonX(): number;
  46106. /**
  46107. * Sets the value of the `X` button
  46108. */
  46109. set buttonX(value: number);
  46110. /**
  46111. * Gets the value of the `Y` button
  46112. */
  46113. get buttonY(): number;
  46114. /**
  46115. * Sets the value of the `Y` button
  46116. */
  46117. set buttonY(value: number);
  46118. /**
  46119. * Gets the value of the `Start` button
  46120. */
  46121. get buttonStart(): number;
  46122. /**
  46123. * Sets the value of the `Start` button
  46124. */
  46125. set buttonStart(value: number);
  46126. /**
  46127. * Gets the value of the `Back` button
  46128. */
  46129. get buttonBack(): number;
  46130. /**
  46131. * Sets the value of the `Back` button
  46132. */
  46133. set buttonBack(value: number);
  46134. /**
  46135. * Gets the value of the `Left` button
  46136. */
  46137. get buttonLB(): number;
  46138. /**
  46139. * Sets the value of the `Left` button
  46140. */
  46141. set buttonLB(value: number);
  46142. /**
  46143. * Gets the value of the `Right` button
  46144. */
  46145. get buttonRB(): number;
  46146. /**
  46147. * Sets the value of the `Right` button
  46148. */
  46149. set buttonRB(value: number);
  46150. /**
  46151. * Gets the value of the Left joystick
  46152. */
  46153. get buttonLeftStick(): number;
  46154. /**
  46155. * Sets the value of the Left joystick
  46156. */
  46157. set buttonLeftStick(value: number);
  46158. /**
  46159. * Gets the value of the Right joystick
  46160. */
  46161. get buttonRightStick(): number;
  46162. /**
  46163. * Sets the value of the Right joystick
  46164. */
  46165. set buttonRightStick(value: number);
  46166. /**
  46167. * Gets the value of D-pad up
  46168. */
  46169. get dPadUp(): number;
  46170. /**
  46171. * Sets the value of D-pad up
  46172. */
  46173. set dPadUp(value: number);
  46174. /**
  46175. * Gets the value of D-pad down
  46176. */
  46177. get dPadDown(): number;
  46178. /**
  46179. * Sets the value of D-pad down
  46180. */
  46181. set dPadDown(value: number);
  46182. /**
  46183. * Gets the value of D-pad left
  46184. */
  46185. get dPadLeft(): number;
  46186. /**
  46187. * Sets the value of D-pad left
  46188. */
  46189. set dPadLeft(value: number);
  46190. /**
  46191. * Gets the value of D-pad right
  46192. */
  46193. get dPadRight(): number;
  46194. /**
  46195. * Sets the value of D-pad right
  46196. */
  46197. set dPadRight(value: number);
  46198. /**
  46199. * Force the gamepad to synchronize with device values
  46200. */
  46201. update(): void;
  46202. /**
  46203. * Disposes the gamepad
  46204. */
  46205. dispose(): void;
  46206. }
  46207. }
  46208. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46209. import { Observable } from "babylonjs/Misc/observable";
  46210. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46211. /**
  46212. * Defines supported buttons for DualShock compatible gamepads
  46213. */
  46214. export enum DualShockButton {
  46215. /** Cross */
  46216. Cross = 0,
  46217. /** Circle */
  46218. Circle = 1,
  46219. /** Square */
  46220. Square = 2,
  46221. /** Triangle */
  46222. Triangle = 3,
  46223. /** L1 */
  46224. L1 = 4,
  46225. /** R1 */
  46226. R1 = 5,
  46227. /** Share */
  46228. Share = 8,
  46229. /** Options */
  46230. Options = 9,
  46231. /** Left stick */
  46232. LeftStick = 10,
  46233. /** Right stick */
  46234. RightStick = 11
  46235. }
  46236. /** Defines values for DualShock DPad */
  46237. export enum DualShockDpad {
  46238. /** Up */
  46239. Up = 12,
  46240. /** Down */
  46241. Down = 13,
  46242. /** Left */
  46243. Left = 14,
  46244. /** Right */
  46245. Right = 15
  46246. }
  46247. /**
  46248. * Defines a DualShock gamepad
  46249. */
  46250. export class DualShockPad extends Gamepad {
  46251. private _leftTrigger;
  46252. private _rightTrigger;
  46253. private _onlefttriggerchanged;
  46254. private _onrighttriggerchanged;
  46255. private _onbuttondown;
  46256. private _onbuttonup;
  46257. private _ondpaddown;
  46258. private _ondpadup;
  46259. /** Observable raised when a button is pressed */
  46260. onButtonDownObservable: Observable<DualShockButton>;
  46261. /** Observable raised when a button is released */
  46262. onButtonUpObservable: Observable<DualShockButton>;
  46263. /** Observable raised when a pad is pressed */
  46264. onPadDownObservable: Observable<DualShockDpad>;
  46265. /** Observable raised when a pad is released */
  46266. onPadUpObservable: Observable<DualShockDpad>;
  46267. private _buttonCross;
  46268. private _buttonCircle;
  46269. private _buttonSquare;
  46270. private _buttonTriangle;
  46271. private _buttonShare;
  46272. private _buttonOptions;
  46273. private _buttonL1;
  46274. private _buttonR1;
  46275. private _buttonLeftStick;
  46276. private _buttonRightStick;
  46277. private _dPadUp;
  46278. private _dPadDown;
  46279. private _dPadLeft;
  46280. private _dPadRight;
  46281. /**
  46282. * Creates a new DualShock gamepad object
  46283. * @param id defines the id of this gamepad
  46284. * @param index defines its index
  46285. * @param gamepad defines the internal HTML gamepad object
  46286. */
  46287. constructor(id: string, index: number, gamepad: any);
  46288. /**
  46289. * Defines the callback to call when left trigger is pressed
  46290. * @param callback defines the callback to use
  46291. */
  46292. onlefttriggerchanged(callback: (value: number) => void): void;
  46293. /**
  46294. * Defines the callback to call when right trigger is pressed
  46295. * @param callback defines the callback to use
  46296. */
  46297. onrighttriggerchanged(callback: (value: number) => void): void;
  46298. /**
  46299. * Gets the left trigger value
  46300. */
  46301. get leftTrigger(): number;
  46302. /**
  46303. * Sets the left trigger value
  46304. */
  46305. set leftTrigger(newValue: number);
  46306. /**
  46307. * Gets the right trigger value
  46308. */
  46309. get rightTrigger(): number;
  46310. /**
  46311. * Sets the right trigger value
  46312. */
  46313. set rightTrigger(newValue: number);
  46314. /**
  46315. * Defines the callback to call when a button is pressed
  46316. * @param callback defines the callback to use
  46317. */
  46318. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46319. /**
  46320. * Defines the callback to call when a button is released
  46321. * @param callback defines the callback to use
  46322. */
  46323. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46324. /**
  46325. * Defines the callback to call when a pad is pressed
  46326. * @param callback defines the callback to use
  46327. */
  46328. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46329. /**
  46330. * Defines the callback to call when a pad is released
  46331. * @param callback defines the callback to use
  46332. */
  46333. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46334. private _setButtonValue;
  46335. private _setDPadValue;
  46336. /**
  46337. * Gets the value of the `Cross` button
  46338. */
  46339. get buttonCross(): number;
  46340. /**
  46341. * Sets the value of the `Cross` button
  46342. */
  46343. set buttonCross(value: number);
  46344. /**
  46345. * Gets the value of the `Circle` button
  46346. */
  46347. get buttonCircle(): number;
  46348. /**
  46349. * Sets the value of the `Circle` button
  46350. */
  46351. set buttonCircle(value: number);
  46352. /**
  46353. * Gets the value of the `Square` button
  46354. */
  46355. get buttonSquare(): number;
  46356. /**
  46357. * Sets the value of the `Square` button
  46358. */
  46359. set buttonSquare(value: number);
  46360. /**
  46361. * Gets the value of the `Triangle` button
  46362. */
  46363. get buttonTriangle(): number;
  46364. /**
  46365. * Sets the value of the `Triangle` button
  46366. */
  46367. set buttonTriangle(value: number);
  46368. /**
  46369. * Gets the value of the `Options` button
  46370. */
  46371. get buttonOptions(): number;
  46372. /**
  46373. * Sets the value of the `Options` button
  46374. */
  46375. set buttonOptions(value: number);
  46376. /**
  46377. * Gets the value of the `Share` button
  46378. */
  46379. get buttonShare(): number;
  46380. /**
  46381. * Sets the value of the `Share` button
  46382. */
  46383. set buttonShare(value: number);
  46384. /**
  46385. * Gets the value of the `L1` button
  46386. */
  46387. get buttonL1(): number;
  46388. /**
  46389. * Sets the value of the `L1` button
  46390. */
  46391. set buttonL1(value: number);
  46392. /**
  46393. * Gets the value of the `R1` button
  46394. */
  46395. get buttonR1(): number;
  46396. /**
  46397. * Sets the value of the `R1` button
  46398. */
  46399. set buttonR1(value: number);
  46400. /**
  46401. * Gets the value of the Left joystick
  46402. */
  46403. get buttonLeftStick(): number;
  46404. /**
  46405. * Sets the value of the Left joystick
  46406. */
  46407. set buttonLeftStick(value: number);
  46408. /**
  46409. * Gets the value of the Right joystick
  46410. */
  46411. get buttonRightStick(): number;
  46412. /**
  46413. * Sets the value of the Right joystick
  46414. */
  46415. set buttonRightStick(value: number);
  46416. /**
  46417. * Gets the value of D-pad up
  46418. */
  46419. get dPadUp(): number;
  46420. /**
  46421. * Sets the value of D-pad up
  46422. */
  46423. set dPadUp(value: number);
  46424. /**
  46425. * Gets the value of D-pad down
  46426. */
  46427. get dPadDown(): number;
  46428. /**
  46429. * Sets the value of D-pad down
  46430. */
  46431. set dPadDown(value: number);
  46432. /**
  46433. * Gets the value of D-pad left
  46434. */
  46435. get dPadLeft(): number;
  46436. /**
  46437. * Sets the value of D-pad left
  46438. */
  46439. set dPadLeft(value: number);
  46440. /**
  46441. * Gets the value of D-pad right
  46442. */
  46443. get dPadRight(): number;
  46444. /**
  46445. * Sets the value of D-pad right
  46446. */
  46447. set dPadRight(value: number);
  46448. /**
  46449. * Force the gamepad to synchronize with device values
  46450. */
  46451. update(): void;
  46452. /**
  46453. * Disposes the gamepad
  46454. */
  46455. dispose(): void;
  46456. }
  46457. }
  46458. declare module "babylonjs/Gamepads/gamepadManager" {
  46459. import { Observable } from "babylonjs/Misc/observable";
  46460. import { Nullable } from "babylonjs/types";
  46461. import { Scene } from "babylonjs/scene";
  46462. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46463. /**
  46464. * Manager for handling gamepads
  46465. */
  46466. export class GamepadManager {
  46467. private _scene?;
  46468. private _babylonGamepads;
  46469. private _oneGamepadConnected;
  46470. /** @hidden */
  46471. _isMonitoring: boolean;
  46472. private _gamepadEventSupported;
  46473. private _gamepadSupport?;
  46474. /**
  46475. * observable to be triggered when the gamepad controller has been connected
  46476. */
  46477. onGamepadConnectedObservable: Observable<Gamepad>;
  46478. /**
  46479. * observable to be triggered when the gamepad controller has been disconnected
  46480. */
  46481. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46482. private _onGamepadConnectedEvent;
  46483. private _onGamepadDisconnectedEvent;
  46484. /**
  46485. * Initializes the gamepad manager
  46486. * @param _scene BabylonJS scene
  46487. */
  46488. constructor(_scene?: Scene | undefined);
  46489. /**
  46490. * The gamepads in the game pad manager
  46491. */
  46492. get gamepads(): Gamepad[];
  46493. /**
  46494. * Get the gamepad controllers based on type
  46495. * @param type The type of gamepad controller
  46496. * @returns Nullable gamepad
  46497. */
  46498. getGamepadByType(type?: number): Nullable<Gamepad>;
  46499. /**
  46500. * Disposes the gamepad manager
  46501. */
  46502. dispose(): void;
  46503. private _addNewGamepad;
  46504. private _startMonitoringGamepads;
  46505. private _stopMonitoringGamepads;
  46506. /** @hidden */
  46507. _checkGamepadsStatus(): void;
  46508. private _updateGamepadObjects;
  46509. }
  46510. }
  46511. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46512. import { Nullable } from "babylonjs/types";
  46513. import { Scene } from "babylonjs/scene";
  46514. import { ISceneComponent } from "babylonjs/sceneComponent";
  46515. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46516. module "babylonjs/scene" {
  46517. interface Scene {
  46518. /** @hidden */
  46519. _gamepadManager: Nullable<GamepadManager>;
  46520. /**
  46521. * Gets the gamepad manager associated with the scene
  46522. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46523. */
  46524. gamepadManager: GamepadManager;
  46525. }
  46526. }
  46527. module "babylonjs/Cameras/freeCameraInputsManager" {
  46528. /**
  46529. * Interface representing a free camera inputs manager
  46530. */
  46531. interface FreeCameraInputsManager {
  46532. /**
  46533. * Adds gamepad input support to the FreeCameraInputsManager.
  46534. * @returns the FreeCameraInputsManager
  46535. */
  46536. addGamepad(): FreeCameraInputsManager;
  46537. }
  46538. }
  46539. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46540. /**
  46541. * Interface representing an arc rotate camera inputs manager
  46542. */
  46543. interface ArcRotateCameraInputsManager {
  46544. /**
  46545. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46546. * @returns the camera inputs manager
  46547. */
  46548. addGamepad(): ArcRotateCameraInputsManager;
  46549. }
  46550. }
  46551. /**
  46552. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46553. */
  46554. export class GamepadSystemSceneComponent implements ISceneComponent {
  46555. /**
  46556. * The component name helpfull to identify the component in the list of scene components.
  46557. */
  46558. readonly name: string;
  46559. /**
  46560. * The scene the component belongs to.
  46561. */
  46562. scene: Scene;
  46563. /**
  46564. * Creates a new instance of the component for the given scene
  46565. * @param scene Defines the scene to register the component in
  46566. */
  46567. constructor(scene: Scene);
  46568. /**
  46569. * Registers the component in a given scene
  46570. */
  46571. register(): void;
  46572. /**
  46573. * Rebuilds the elements related to this component in case of
  46574. * context lost for instance.
  46575. */
  46576. rebuild(): void;
  46577. /**
  46578. * Disposes the component and the associated ressources
  46579. */
  46580. dispose(): void;
  46581. private _beforeCameraUpdate;
  46582. }
  46583. }
  46584. declare module "babylonjs/Cameras/universalCamera" {
  46585. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46586. import { Scene } from "babylonjs/scene";
  46587. import { Vector3 } from "babylonjs/Maths/math.vector";
  46588. import "babylonjs/Gamepads/gamepadSceneComponent";
  46589. /**
  46590. * 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,
  46591. * which still works and will still be found in many Playgrounds.
  46592. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46593. */
  46594. export class UniversalCamera extends TouchCamera {
  46595. /**
  46596. * Defines the gamepad rotation sensiblity.
  46597. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46598. */
  46599. get gamepadAngularSensibility(): number;
  46600. set gamepadAngularSensibility(value: number);
  46601. /**
  46602. * Defines the gamepad move sensiblity.
  46603. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46604. */
  46605. get gamepadMoveSensibility(): number;
  46606. set gamepadMoveSensibility(value: number);
  46607. /**
  46608. * 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,
  46609. * which still works and will still be found in many Playgrounds.
  46610. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46611. * @param name Define the name of the camera in the scene
  46612. * @param position Define the start position of the camera in the scene
  46613. * @param scene Define the scene the camera belongs to
  46614. */
  46615. constructor(name: string, position: Vector3, scene: Scene);
  46616. /**
  46617. * Gets the current object class name.
  46618. * @return the class name
  46619. */
  46620. getClassName(): string;
  46621. }
  46622. }
  46623. declare module "babylonjs/Cameras/gamepadCamera" {
  46624. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { Vector3 } from "babylonjs/Maths/math.vector";
  46627. /**
  46628. * This represents a FPS type of camera. This is only here for back compat purpose.
  46629. * Please use the UniversalCamera instead as both are identical.
  46630. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46631. */
  46632. export class GamepadCamera extends UniversalCamera {
  46633. /**
  46634. * Instantiates a new Gamepad Camera
  46635. * This represents a FPS type of camera. This is only here for back compat purpose.
  46636. * Please use the UniversalCamera instead as both are identical.
  46637. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46638. * @param name Define the name of the camera in the scene
  46639. * @param position Define the start position of the camera in the scene
  46640. * @param scene Define the scene the camera belongs to
  46641. */
  46642. constructor(name: string, position: Vector3, scene: Scene);
  46643. /**
  46644. * Gets the current object class name.
  46645. * @return the class name
  46646. */
  46647. getClassName(): string;
  46648. }
  46649. }
  46650. declare module "babylonjs/Shaders/pass.fragment" {
  46651. /** @hidden */
  46652. export var passPixelShader: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/passCube.fragment" {
  46658. /** @hidden */
  46659. export var passCubePixelShader: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/PostProcesses/passPostProcess" {
  46665. import { Nullable } from "babylonjs/types";
  46666. import { Camera } from "babylonjs/Cameras/camera";
  46667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46668. import { Engine } from "babylonjs/Engines/engine";
  46669. import "babylonjs/Shaders/pass.fragment";
  46670. import "babylonjs/Shaders/passCube.fragment";
  46671. /**
  46672. * PassPostProcess which produces an output the same as it's input
  46673. */
  46674. export class PassPostProcess extends PostProcess {
  46675. /**
  46676. * Creates the PassPostProcess
  46677. * @param name The name of the effect.
  46678. * @param options The required width/height ratio to downsize to before computing the render pass.
  46679. * @param camera The camera to apply the render pass to.
  46680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46681. * @param engine The engine which the post process will be applied. (default: current engine)
  46682. * @param reusable If the post process can be reused on the same frame. (default: false)
  46683. * @param textureType The type of texture to be used when performing the post processing.
  46684. * @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)
  46685. */
  46686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46687. }
  46688. /**
  46689. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46690. */
  46691. export class PassCubePostProcess extends PostProcess {
  46692. private _face;
  46693. /**
  46694. * Gets or sets the cube face to display.
  46695. * * 0 is +X
  46696. * * 1 is -X
  46697. * * 2 is +Y
  46698. * * 3 is -Y
  46699. * * 4 is +Z
  46700. * * 5 is -Z
  46701. */
  46702. get face(): number;
  46703. set face(value: number);
  46704. /**
  46705. * Creates the PassCubePostProcess
  46706. * @param name The name of the effect.
  46707. * @param options The required width/height ratio to downsize to before computing the render pass.
  46708. * @param camera The camera to apply the render pass to.
  46709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46710. * @param engine The engine which the post process will be applied. (default: current engine)
  46711. * @param reusable If the post process can be reused on the same frame. (default: false)
  46712. * @param textureType The type of texture to be used when performing the post processing.
  46713. * @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)
  46714. */
  46715. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46716. }
  46717. }
  46718. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46719. /** @hidden */
  46720. export var anaglyphPixelShader: {
  46721. name: string;
  46722. shader: string;
  46723. };
  46724. }
  46725. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46726. import { Engine } from "babylonjs/Engines/engine";
  46727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46728. import { Camera } from "babylonjs/Cameras/camera";
  46729. import "babylonjs/Shaders/anaglyph.fragment";
  46730. /**
  46731. * Postprocess used to generate anaglyphic rendering
  46732. */
  46733. export class AnaglyphPostProcess extends PostProcess {
  46734. private _passedProcess;
  46735. /**
  46736. * Creates a new AnaglyphPostProcess
  46737. * @param name defines postprocess name
  46738. * @param options defines creation options or target ratio scale
  46739. * @param rigCameras defines cameras using this postprocess
  46740. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46741. * @param engine defines hosting engine
  46742. * @param reusable defines if the postprocess will be reused multiple times per frame
  46743. */
  46744. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46745. }
  46746. }
  46747. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46749. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46750. import { Scene } from "babylonjs/scene";
  46751. import { Vector3 } from "babylonjs/Maths/math.vector";
  46752. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46753. /**
  46754. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46755. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46756. */
  46757. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46758. /**
  46759. * Creates a new AnaglyphArcRotateCamera
  46760. * @param name defines camera name
  46761. * @param alpha defines alpha angle (in radians)
  46762. * @param beta defines beta angle (in radians)
  46763. * @param radius defines radius
  46764. * @param target defines camera target
  46765. * @param interaxialDistance defines distance between each color axis
  46766. * @param scene defines the hosting scene
  46767. */
  46768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46769. /**
  46770. * Gets camera class name
  46771. * @returns AnaglyphArcRotateCamera
  46772. */
  46773. getClassName(): string;
  46774. }
  46775. }
  46776. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46777. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46778. import { Scene } from "babylonjs/scene";
  46779. import { Vector3 } from "babylonjs/Maths/math.vector";
  46780. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46781. /**
  46782. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46783. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46784. */
  46785. export class AnaglyphFreeCamera extends FreeCamera {
  46786. /**
  46787. * Creates a new AnaglyphFreeCamera
  46788. * @param name defines camera name
  46789. * @param position defines initial position
  46790. * @param interaxialDistance defines distance between each color axis
  46791. * @param scene defines the hosting scene
  46792. */
  46793. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46794. /**
  46795. * Gets camera class name
  46796. * @returns AnaglyphFreeCamera
  46797. */
  46798. getClassName(): string;
  46799. }
  46800. }
  46801. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46802. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46803. import { Scene } from "babylonjs/scene";
  46804. import { Vector3 } from "babylonjs/Maths/math.vector";
  46805. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46806. /**
  46807. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46809. */
  46810. export class AnaglyphGamepadCamera extends GamepadCamera {
  46811. /**
  46812. * Creates a new AnaglyphGamepadCamera
  46813. * @param name defines camera name
  46814. * @param position defines initial position
  46815. * @param interaxialDistance defines distance between each color axis
  46816. * @param scene defines the hosting scene
  46817. */
  46818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46819. /**
  46820. * Gets camera class name
  46821. * @returns AnaglyphGamepadCamera
  46822. */
  46823. getClassName(): string;
  46824. }
  46825. }
  46826. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46827. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46828. import { Scene } from "babylonjs/scene";
  46829. import { Vector3 } from "babylonjs/Maths/math.vector";
  46830. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46831. /**
  46832. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46833. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46834. */
  46835. export class AnaglyphUniversalCamera extends UniversalCamera {
  46836. /**
  46837. * Creates a new AnaglyphUniversalCamera
  46838. * @param name defines camera name
  46839. * @param position defines initial position
  46840. * @param interaxialDistance defines distance between each color axis
  46841. * @param scene defines the hosting scene
  46842. */
  46843. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46844. /**
  46845. * Gets camera class name
  46846. * @returns AnaglyphUniversalCamera
  46847. */
  46848. getClassName(): string;
  46849. }
  46850. }
  46851. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46852. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46854. import { Scene } from "babylonjs/scene";
  46855. import { Vector3 } from "babylonjs/Maths/math.vector";
  46856. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46857. /**
  46858. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46859. * @see https://doc.babylonjs.com/features/cameras
  46860. */
  46861. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46862. /**
  46863. * Creates a new StereoscopicArcRotateCamera
  46864. * @param name defines camera name
  46865. * @param alpha defines alpha angle (in radians)
  46866. * @param beta defines beta angle (in radians)
  46867. * @param radius defines radius
  46868. * @param target defines camera target
  46869. * @param interaxialDistance defines distance between each color axis
  46870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46871. * @param scene defines the hosting scene
  46872. */
  46873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46874. /**
  46875. * Gets camera class name
  46876. * @returns StereoscopicArcRotateCamera
  46877. */
  46878. getClassName(): string;
  46879. }
  46880. }
  46881. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46882. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46883. import { Scene } from "babylonjs/scene";
  46884. import { Vector3 } from "babylonjs/Maths/math.vector";
  46885. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46886. /**
  46887. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46888. * @see https://doc.babylonjs.com/features/cameras
  46889. */
  46890. export class StereoscopicFreeCamera extends FreeCamera {
  46891. /**
  46892. * Creates a new StereoscopicFreeCamera
  46893. * @param name defines camera name
  46894. * @param position defines initial position
  46895. * @param interaxialDistance defines distance between each color axis
  46896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46897. * @param scene defines the hosting scene
  46898. */
  46899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46900. /**
  46901. * Gets camera class name
  46902. * @returns StereoscopicFreeCamera
  46903. */
  46904. getClassName(): string;
  46905. }
  46906. }
  46907. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46908. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46909. import { Scene } from "babylonjs/scene";
  46910. import { Vector3 } from "babylonjs/Maths/math.vector";
  46911. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46912. /**
  46913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46914. * @see https://doc.babylonjs.com/features/cameras
  46915. */
  46916. export class StereoscopicGamepadCamera extends GamepadCamera {
  46917. /**
  46918. * Creates a new StereoscopicGamepadCamera
  46919. * @param name defines camera name
  46920. * @param position defines initial position
  46921. * @param interaxialDistance defines distance between each color axis
  46922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46923. * @param scene defines the hosting scene
  46924. */
  46925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46926. /**
  46927. * Gets camera class name
  46928. * @returns StereoscopicGamepadCamera
  46929. */
  46930. getClassName(): string;
  46931. }
  46932. }
  46933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46935. import { Scene } from "babylonjs/scene";
  46936. import { Vector3 } from "babylonjs/Maths/math.vector";
  46937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46938. /**
  46939. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46940. * @see https://doc.babylonjs.com/features/cameras
  46941. */
  46942. export class StereoscopicUniversalCamera extends UniversalCamera {
  46943. /**
  46944. * Creates a new StereoscopicUniversalCamera
  46945. * @param name defines camera name
  46946. * @param position defines initial position
  46947. * @param interaxialDistance defines distance between each color axis
  46948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46949. * @param scene defines the hosting scene
  46950. */
  46951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46952. /**
  46953. * Gets camera class name
  46954. * @returns StereoscopicUniversalCamera
  46955. */
  46956. getClassName(): string;
  46957. }
  46958. }
  46959. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46960. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46961. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46962. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46964. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46965. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46966. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46968. }
  46969. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46970. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46971. import { Scene } from "babylonjs/scene";
  46972. import { Vector3 } from "babylonjs/Maths/math.vector";
  46973. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46974. /**
  46975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46978. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46979. */
  46980. export class VirtualJoysticksCamera extends FreeCamera {
  46981. /**
  46982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46985. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46986. * @param name Define the name of the camera in the scene
  46987. * @param position Define the start position of the camera in the scene
  46988. * @param scene Define the scene the camera belongs to
  46989. */
  46990. constructor(name: string, position: Vector3, scene: Scene);
  46991. /**
  46992. * Gets the current object class name.
  46993. * @return the class name
  46994. */
  46995. getClassName(): string;
  46996. }
  46997. }
  46998. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46999. import { Matrix } from "babylonjs/Maths/math.vector";
  47000. /**
  47001. * This represents all the required metrics to create a VR camera.
  47002. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47003. */
  47004. export class VRCameraMetrics {
  47005. /**
  47006. * Define the horizontal resolution off the screen.
  47007. */
  47008. hResolution: number;
  47009. /**
  47010. * Define the vertical resolution off the screen.
  47011. */
  47012. vResolution: number;
  47013. /**
  47014. * Define the horizontal screen size.
  47015. */
  47016. hScreenSize: number;
  47017. /**
  47018. * Define the vertical screen size.
  47019. */
  47020. vScreenSize: number;
  47021. /**
  47022. * Define the vertical screen center position.
  47023. */
  47024. vScreenCenter: number;
  47025. /**
  47026. * Define the distance of the eyes to the screen.
  47027. */
  47028. eyeToScreenDistance: number;
  47029. /**
  47030. * Define the distance between both lenses
  47031. */
  47032. lensSeparationDistance: number;
  47033. /**
  47034. * Define the distance between both viewer's eyes.
  47035. */
  47036. interpupillaryDistance: number;
  47037. /**
  47038. * Define the distortion factor of the VR postprocess.
  47039. * Please, touch with care.
  47040. */
  47041. distortionK: number[];
  47042. /**
  47043. * Define the chromatic aberration correction factors for the VR post process.
  47044. */
  47045. chromaAbCorrection: number[];
  47046. /**
  47047. * Define the scale factor of the post process.
  47048. * The smaller the better but the slower.
  47049. */
  47050. postProcessScaleFactor: number;
  47051. /**
  47052. * Define an offset for the lens center.
  47053. */
  47054. lensCenterOffset: number;
  47055. /**
  47056. * Define if the current vr camera should compensate the distortion of the lense or not.
  47057. */
  47058. compensateDistortion: boolean;
  47059. /**
  47060. * Defines if multiview should be enabled when rendering (Default: false)
  47061. */
  47062. multiviewEnabled: boolean;
  47063. /**
  47064. * Gets the rendering aspect ratio based on the provided resolutions.
  47065. */
  47066. get aspectRatio(): number;
  47067. /**
  47068. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47069. */
  47070. get aspectRatioFov(): number;
  47071. /**
  47072. * @hidden
  47073. */
  47074. get leftHMatrix(): Matrix;
  47075. /**
  47076. * @hidden
  47077. */
  47078. get rightHMatrix(): Matrix;
  47079. /**
  47080. * @hidden
  47081. */
  47082. get leftPreViewMatrix(): Matrix;
  47083. /**
  47084. * @hidden
  47085. */
  47086. get rightPreViewMatrix(): Matrix;
  47087. /**
  47088. * Get the default VRMetrics based on the most generic setup.
  47089. * @returns the default vr metrics
  47090. */
  47091. static GetDefault(): VRCameraMetrics;
  47092. }
  47093. }
  47094. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47095. /** @hidden */
  47096. export var vrDistortionCorrectionPixelShader: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47102. import { Camera } from "babylonjs/Cameras/camera";
  47103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47105. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47106. /**
  47107. * VRDistortionCorrectionPostProcess used for mobile VR
  47108. */
  47109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47110. private _isRightEye;
  47111. private _distortionFactors;
  47112. private _postProcessScaleFactor;
  47113. private _lensCenterOffset;
  47114. private _scaleIn;
  47115. private _scaleFactor;
  47116. private _lensCenter;
  47117. /**
  47118. * Initializes the VRDistortionCorrectionPostProcess
  47119. * @param name The name of the effect.
  47120. * @param camera The camera to apply the render pass to.
  47121. * @param isRightEye If this is for the right eye distortion
  47122. * @param vrMetrics All the required metrics for the VR camera
  47123. */
  47124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47125. }
  47126. }
  47127. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47128. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47130. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47131. import { Scene } from "babylonjs/scene";
  47132. import { Vector3 } from "babylonjs/Maths/math.vector";
  47133. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47134. import "babylonjs/Cameras/RigModes/vrRigMode";
  47135. /**
  47136. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47137. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47138. */
  47139. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47140. /**
  47141. * Creates a new VRDeviceOrientationArcRotateCamera
  47142. * @param name defines camera name
  47143. * @param alpha defines the camera rotation along the logitudinal axis
  47144. * @param beta defines the camera rotation along the latitudinal axis
  47145. * @param radius defines the camera distance from its target
  47146. * @param target defines the camera target
  47147. * @param scene defines the scene the camera belongs to
  47148. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47149. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47150. */
  47151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47152. /**
  47153. * Gets camera class name
  47154. * @returns VRDeviceOrientationArcRotateCamera
  47155. */
  47156. getClassName(): string;
  47157. }
  47158. }
  47159. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47160. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47161. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47162. import { Scene } from "babylonjs/scene";
  47163. import { Vector3 } from "babylonjs/Maths/math.vector";
  47164. import "babylonjs/Cameras/RigModes/vrRigMode";
  47165. /**
  47166. * Camera used to simulate VR rendering (based on FreeCamera)
  47167. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47168. */
  47169. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47170. /**
  47171. * Creates a new VRDeviceOrientationFreeCamera
  47172. * @param name defines camera name
  47173. * @param position defines the start position of the camera
  47174. * @param scene defines the scene the camera belongs to
  47175. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47176. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47177. */
  47178. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47179. /**
  47180. * Gets camera class name
  47181. * @returns VRDeviceOrientationFreeCamera
  47182. */
  47183. getClassName(): string;
  47184. }
  47185. }
  47186. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47187. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47189. import { Scene } from "babylonjs/scene";
  47190. import { Vector3 } from "babylonjs/Maths/math.vector";
  47191. import "babylonjs/Gamepads/gamepadSceneComponent";
  47192. /**
  47193. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47194. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47195. */
  47196. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47197. /**
  47198. * Creates a new VRDeviceOrientationGamepadCamera
  47199. * @param name defines camera name
  47200. * @param position defines the start position of the camera
  47201. * @param scene defines the scene the camera belongs to
  47202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47204. */
  47205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47206. /**
  47207. * Gets camera class name
  47208. * @returns VRDeviceOrientationGamepadCamera
  47209. */
  47210. getClassName(): string;
  47211. }
  47212. }
  47213. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47214. import { Scene } from "babylonjs/scene";
  47215. import { Texture } from "babylonjs/Materials/Textures/texture";
  47216. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47217. /**
  47218. * A class extending Texture allowing drawing on a texture
  47219. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47220. */
  47221. export class DynamicTexture extends Texture {
  47222. private _generateMipMaps;
  47223. private _canvas;
  47224. private _context;
  47225. /**
  47226. * Creates a DynamicTexture
  47227. * @param name defines the name of the texture
  47228. * @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
  47229. * @param scene defines the scene where you want the texture
  47230. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47231. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47232. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47233. */
  47234. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47235. /**
  47236. * Get the current class name of the texture useful for serialization or dynamic coding.
  47237. * @returns "DynamicTexture"
  47238. */
  47239. getClassName(): string;
  47240. /**
  47241. * Gets the current state of canRescale
  47242. */
  47243. get canRescale(): boolean;
  47244. private _recreate;
  47245. /**
  47246. * Scales the texture
  47247. * @param ratio the scale factor to apply to both width and height
  47248. */
  47249. scale(ratio: number): void;
  47250. /**
  47251. * Resizes the texture
  47252. * @param width the new width
  47253. * @param height the new height
  47254. */
  47255. scaleTo(width: number, height: number): void;
  47256. /**
  47257. * Gets the context of the canvas used by the texture
  47258. * @returns the canvas context of the dynamic texture
  47259. */
  47260. getContext(): CanvasRenderingContext2D;
  47261. /**
  47262. * Clears the texture
  47263. */
  47264. clear(): void;
  47265. /**
  47266. * Updates the texture
  47267. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47268. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47269. */
  47270. update(invertY?: boolean, premulAlpha?: boolean): void;
  47271. /**
  47272. * Draws text onto the texture
  47273. * @param text defines the text to be drawn
  47274. * @param x defines the placement of the text from the left
  47275. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47276. * @param font defines the font to be used with font-style, font-size, font-name
  47277. * @param color defines the color used for the text
  47278. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47280. * @param update defines whether texture is immediately update (default is true)
  47281. */
  47282. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47283. /**
  47284. * Clones the texture
  47285. * @returns the clone of the texture.
  47286. */
  47287. clone(): DynamicTexture;
  47288. /**
  47289. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47290. * @returns a serialized dynamic texture object
  47291. */
  47292. serialize(): any;
  47293. private _IsCanvasElement;
  47294. /** @hidden */
  47295. _rebuild(): void;
  47296. }
  47297. }
  47298. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47299. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47301. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47302. /** @hidden */
  47303. export var imageProcessingPixelShader: {
  47304. name: string;
  47305. shader: string;
  47306. };
  47307. }
  47308. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47309. import { Nullable } from "babylonjs/types";
  47310. import { Color4 } from "babylonjs/Maths/math.color";
  47311. import { Camera } from "babylonjs/Cameras/camera";
  47312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47314. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47316. import { Engine } from "babylonjs/Engines/engine";
  47317. import "babylonjs/Shaders/imageProcessing.fragment";
  47318. import "babylonjs/Shaders/postprocess.vertex";
  47319. /**
  47320. * ImageProcessingPostProcess
  47321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47322. */
  47323. export class ImageProcessingPostProcess extends PostProcess {
  47324. /**
  47325. * Default configuration related to image processing available in the PBR Material.
  47326. */
  47327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47328. /**
  47329. * Gets the image processing configuration used either in this material.
  47330. */
  47331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47332. /**
  47333. * Sets the Default image processing configuration used either in the this material.
  47334. *
  47335. * If sets to null, the scene one is in use.
  47336. */
  47337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47338. /**
  47339. * Keep track of the image processing observer to allow dispose and replace.
  47340. */
  47341. private _imageProcessingObserver;
  47342. /**
  47343. * Attaches a new image processing configuration to the PBR Material.
  47344. * @param configuration
  47345. */
  47346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47347. /**
  47348. * If the post process is supported.
  47349. */
  47350. get isSupported(): boolean;
  47351. /**
  47352. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47353. */
  47354. get colorCurves(): Nullable<ColorCurves>;
  47355. /**
  47356. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47357. */
  47358. set colorCurves(value: Nullable<ColorCurves>);
  47359. /**
  47360. * Gets wether the color curves effect is enabled.
  47361. */
  47362. get colorCurvesEnabled(): boolean;
  47363. /**
  47364. * Sets wether the color curves effect is enabled.
  47365. */
  47366. set colorCurvesEnabled(value: boolean);
  47367. /**
  47368. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47369. */
  47370. get colorGradingTexture(): Nullable<BaseTexture>;
  47371. /**
  47372. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47373. */
  47374. set colorGradingTexture(value: Nullable<BaseTexture>);
  47375. /**
  47376. * Gets wether the color grading effect is enabled.
  47377. */
  47378. get colorGradingEnabled(): boolean;
  47379. /**
  47380. * Gets wether the color grading effect is enabled.
  47381. */
  47382. set colorGradingEnabled(value: boolean);
  47383. /**
  47384. * Gets exposure used in the effect.
  47385. */
  47386. get exposure(): number;
  47387. /**
  47388. * Sets exposure used in the effect.
  47389. */
  47390. set exposure(value: number);
  47391. /**
  47392. * Gets wether tonemapping is enabled or not.
  47393. */
  47394. get toneMappingEnabled(): boolean;
  47395. /**
  47396. * Sets wether tonemapping is enabled or not
  47397. */
  47398. set toneMappingEnabled(value: boolean);
  47399. /**
  47400. * Gets the type of tone mapping effect.
  47401. */
  47402. get toneMappingType(): number;
  47403. /**
  47404. * Sets the type of tone mapping effect.
  47405. */
  47406. set toneMappingType(value: number);
  47407. /**
  47408. * Gets contrast used in the effect.
  47409. */
  47410. get contrast(): number;
  47411. /**
  47412. * Sets contrast used in the effect.
  47413. */
  47414. set contrast(value: number);
  47415. /**
  47416. * Gets Vignette stretch size.
  47417. */
  47418. get vignetteStretch(): number;
  47419. /**
  47420. * Sets Vignette stretch size.
  47421. */
  47422. set vignetteStretch(value: number);
  47423. /**
  47424. * Gets Vignette centre X Offset.
  47425. */
  47426. get vignetteCentreX(): number;
  47427. /**
  47428. * Sets Vignette centre X Offset.
  47429. */
  47430. set vignetteCentreX(value: number);
  47431. /**
  47432. * Gets Vignette centre Y Offset.
  47433. */
  47434. get vignetteCentreY(): number;
  47435. /**
  47436. * Sets Vignette centre Y Offset.
  47437. */
  47438. set vignetteCentreY(value: number);
  47439. /**
  47440. * Gets Vignette weight or intensity of the vignette effect.
  47441. */
  47442. get vignetteWeight(): number;
  47443. /**
  47444. * Sets Vignette weight or intensity of the vignette effect.
  47445. */
  47446. set vignetteWeight(value: number);
  47447. /**
  47448. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47449. * if vignetteEnabled is set to true.
  47450. */
  47451. get vignetteColor(): Color4;
  47452. /**
  47453. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47454. * if vignetteEnabled is set to true.
  47455. */
  47456. set vignetteColor(value: Color4);
  47457. /**
  47458. * Gets Camera field of view used by the Vignette effect.
  47459. */
  47460. get vignetteCameraFov(): number;
  47461. /**
  47462. * Sets Camera field of view used by the Vignette effect.
  47463. */
  47464. set vignetteCameraFov(value: number);
  47465. /**
  47466. * Gets the vignette blend mode allowing different kind of effect.
  47467. */
  47468. get vignetteBlendMode(): number;
  47469. /**
  47470. * Sets the vignette blend mode allowing different kind of effect.
  47471. */
  47472. set vignetteBlendMode(value: number);
  47473. /**
  47474. * Gets wether the vignette effect is enabled.
  47475. */
  47476. get vignetteEnabled(): boolean;
  47477. /**
  47478. * Sets wether the vignette effect is enabled.
  47479. */
  47480. set vignetteEnabled(value: boolean);
  47481. private _fromLinearSpace;
  47482. /**
  47483. * Gets wether the input of the processing is in Gamma or Linear Space.
  47484. */
  47485. get fromLinearSpace(): boolean;
  47486. /**
  47487. * Sets wether the input of the processing is in Gamma or Linear Space.
  47488. */
  47489. set fromLinearSpace(value: boolean);
  47490. /**
  47491. * Defines cache preventing GC.
  47492. */
  47493. private _defines;
  47494. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47495. /**
  47496. * "ImageProcessingPostProcess"
  47497. * @returns "ImageProcessingPostProcess"
  47498. */
  47499. getClassName(): string;
  47500. protected _updateParameters(): void;
  47501. dispose(camera?: Camera): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47505. import { Scene } from "babylonjs/scene";
  47506. import { Color3 } from "babylonjs/Maths/math.color";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47509. import { Nullable } from "babylonjs/types";
  47510. /**
  47511. * Class containing static functions to help procedurally build meshes
  47512. */
  47513. export class GroundBuilder {
  47514. /**
  47515. * Creates a ground mesh
  47516. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47517. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47519. * @param name defines the name of the mesh
  47520. * @param options defines the options used to create the mesh
  47521. * @param scene defines the hosting scene
  47522. * @returns the ground mesh
  47523. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47524. */
  47525. static CreateGround(name: string, options: {
  47526. width?: number;
  47527. height?: number;
  47528. subdivisions?: number;
  47529. subdivisionsX?: number;
  47530. subdivisionsY?: number;
  47531. updatable?: boolean;
  47532. }, scene: any): Mesh;
  47533. /**
  47534. * Creates a tiled ground mesh
  47535. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47536. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47537. * * 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
  47538. * * 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
  47539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47540. * @param name defines the name of the mesh
  47541. * @param options defines the options used to create the mesh
  47542. * @param scene defines the hosting scene
  47543. * @returns the tiled ground mesh
  47544. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47545. */
  47546. static CreateTiledGround(name: string, options: {
  47547. xmin: number;
  47548. zmin: number;
  47549. xmax: number;
  47550. zmax: number;
  47551. subdivisions?: {
  47552. w: number;
  47553. h: number;
  47554. };
  47555. precision?: {
  47556. w: number;
  47557. h: number;
  47558. };
  47559. updatable?: boolean;
  47560. }, scene?: Nullable<Scene>): Mesh;
  47561. /**
  47562. * Creates a ground mesh from a height map
  47563. * * The parameter `url` sets the URL of the height map image resource.
  47564. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47565. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47566. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47567. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47568. * * 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.
  47569. * * 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).
  47570. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47572. * @param name defines the name of the mesh
  47573. * @param url defines the url to the height map
  47574. * @param options defines the options used to create the mesh
  47575. * @param scene defines the hosting scene
  47576. * @returns the ground mesh
  47577. * @see https://doc.babylonjs.com/babylon101/height_map
  47578. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47579. */
  47580. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47581. width?: number;
  47582. height?: number;
  47583. subdivisions?: number;
  47584. minHeight?: number;
  47585. maxHeight?: number;
  47586. colorFilter?: Color3;
  47587. alphaFilter?: number;
  47588. updatable?: boolean;
  47589. onReady?: (mesh: GroundMesh) => void;
  47590. }, scene?: Nullable<Scene>): GroundMesh;
  47591. }
  47592. }
  47593. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47594. import { Vector4 } from "babylonjs/Maths/math.vector";
  47595. import { Mesh } from "babylonjs/Meshes/mesh";
  47596. /**
  47597. * Class containing static functions to help procedurally build meshes
  47598. */
  47599. export class TorusBuilder {
  47600. /**
  47601. * Creates a torus mesh
  47602. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47603. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47604. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47606. * * 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
  47607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47608. * @param name defines the name of the mesh
  47609. * @param options defines the options used to create the mesh
  47610. * @param scene defines the hosting scene
  47611. * @returns the torus mesh
  47612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47613. */
  47614. static CreateTorus(name: string, options: {
  47615. diameter?: number;
  47616. thickness?: number;
  47617. tessellation?: number;
  47618. updatable?: boolean;
  47619. sideOrientation?: number;
  47620. frontUVs?: Vector4;
  47621. backUVs?: Vector4;
  47622. }, scene: any): Mesh;
  47623. }
  47624. }
  47625. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47626. import { Vector4 } from "babylonjs/Maths/math.vector";
  47627. import { Color4 } from "babylonjs/Maths/math.color";
  47628. import { Mesh } from "babylonjs/Meshes/mesh";
  47629. /**
  47630. * Class containing static functions to help procedurally build meshes
  47631. */
  47632. export class CylinderBuilder {
  47633. /**
  47634. * Creates a cylinder or a cone mesh
  47635. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47636. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47637. * * 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.
  47638. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47639. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47640. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47641. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47642. * * 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).
  47643. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47644. * * 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).
  47645. * * 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
  47646. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47647. * * 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
  47648. * * 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.
  47649. * * If `enclose` is false, a ring surface is one element.
  47650. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47651. * * 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
  47652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47653. * * 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
  47654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47655. * @param name defines the name of the mesh
  47656. * @param options defines the options used to create the mesh
  47657. * @param scene defines the hosting scene
  47658. * @returns the cylinder mesh
  47659. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47660. */
  47661. static CreateCylinder(name: string, options: {
  47662. height?: number;
  47663. diameterTop?: number;
  47664. diameterBottom?: number;
  47665. diameter?: number;
  47666. tessellation?: number;
  47667. subdivisions?: number;
  47668. arc?: number;
  47669. faceColors?: Color4[];
  47670. faceUV?: Vector4[];
  47671. updatable?: boolean;
  47672. hasRings?: boolean;
  47673. enclose?: boolean;
  47674. cap?: number;
  47675. sideOrientation?: number;
  47676. frontUVs?: Vector4;
  47677. backUVs?: Vector4;
  47678. }, scene: any): Mesh;
  47679. }
  47680. }
  47681. declare module "babylonjs/XR/webXRTypes" {
  47682. import { Nullable } from "babylonjs/types";
  47683. import { IDisposable } from "babylonjs/scene";
  47684. /**
  47685. * States of the webXR experience
  47686. */
  47687. export enum WebXRState {
  47688. /**
  47689. * Transitioning to being in XR mode
  47690. */
  47691. ENTERING_XR = 0,
  47692. /**
  47693. * Transitioning to non XR mode
  47694. */
  47695. EXITING_XR = 1,
  47696. /**
  47697. * In XR mode and presenting
  47698. */
  47699. IN_XR = 2,
  47700. /**
  47701. * Not entered XR mode
  47702. */
  47703. NOT_IN_XR = 3
  47704. }
  47705. /**
  47706. * Abstraction of the XR render target
  47707. */
  47708. export interface WebXRRenderTarget extends IDisposable {
  47709. /**
  47710. * xrpresent context of the canvas which can be used to display/mirror xr content
  47711. */
  47712. canvasContext: WebGLRenderingContext;
  47713. /**
  47714. * xr layer for the canvas
  47715. */
  47716. xrLayer: Nullable<XRWebGLLayer>;
  47717. /**
  47718. * Initializes the xr layer for the session
  47719. * @param xrSession xr session
  47720. * @returns a promise that will resolve once the XR Layer has been created
  47721. */
  47722. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47723. }
  47724. }
  47725. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47726. import { Nullable } from "babylonjs/types";
  47727. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47729. import { Observable } from "babylonjs/Misc/observable";
  47730. /**
  47731. * COnfiguration object for WebXR output canvas
  47732. */
  47733. export class WebXRManagedOutputCanvasOptions {
  47734. /**
  47735. * An optional canvas in case you wish to create it yourself and provide it here.
  47736. * If not provided, a new canvas will be created
  47737. */
  47738. canvasElement?: HTMLCanvasElement;
  47739. /**
  47740. * Options for this XR Layer output
  47741. */
  47742. canvasOptions?: XRWebGLLayerOptions;
  47743. /**
  47744. * CSS styling for a newly created canvas (if not provided)
  47745. */
  47746. newCanvasCssStyle?: string;
  47747. /**
  47748. * Get the default values of the configuration object
  47749. * @returns default values of this configuration object
  47750. */
  47751. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47752. }
  47753. /**
  47754. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47755. */
  47756. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47757. private _options;
  47758. private _canvas;
  47759. private _engine;
  47760. private _originalCanvasSize;
  47761. /**
  47762. * Rendering context of the canvas which can be used to display/mirror xr content
  47763. */
  47764. canvasContext: WebGLRenderingContext;
  47765. /**
  47766. * xr layer for the canvas
  47767. */
  47768. xrLayer: Nullable<XRWebGLLayer>;
  47769. /**
  47770. * Obseervers registered here will be triggered when the xr layer was initialized
  47771. */
  47772. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47773. /**
  47774. * Initializes the canvas to be added/removed upon entering/exiting xr
  47775. * @param _xrSessionManager The XR Session manager
  47776. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47777. */
  47778. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47779. /**
  47780. * Disposes of the object
  47781. */
  47782. dispose(): void;
  47783. /**
  47784. * Initializes the xr layer for the session
  47785. * @param xrSession xr session
  47786. * @returns a promise that will resolve once the XR Layer has been created
  47787. */
  47788. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47789. private _addCanvas;
  47790. private _removeCanvas;
  47791. private _setCanvasSize;
  47792. private _setManagedOutputCanvas;
  47793. }
  47794. }
  47795. declare module "babylonjs/XR/webXRSessionManager" {
  47796. import { Observable } from "babylonjs/Misc/observable";
  47797. import { Nullable } from "babylonjs/types";
  47798. import { IDisposable, Scene } from "babylonjs/scene";
  47799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47800. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47801. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47802. /**
  47803. * Manages an XRSession to work with Babylon's engine
  47804. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47805. */
  47806. export class WebXRSessionManager implements IDisposable {
  47807. /** The scene which the session should be created for */
  47808. scene: Scene;
  47809. private _referenceSpace;
  47810. private _rttProvider;
  47811. private _sessionEnded;
  47812. private _xrNavigator;
  47813. private baseLayer;
  47814. /**
  47815. * The base reference space from which the session started. good if you want to reset your
  47816. * reference space
  47817. */
  47818. baseReferenceSpace: XRReferenceSpace;
  47819. /**
  47820. * Current XR frame
  47821. */
  47822. currentFrame: Nullable<XRFrame>;
  47823. /** WebXR timestamp updated every frame */
  47824. currentTimestamp: number;
  47825. /**
  47826. * Used just in case of a failure to initialize an immersive session.
  47827. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47828. */
  47829. defaultHeightCompensation: number;
  47830. /**
  47831. * Fires every time a new xrFrame arrives which can be used to update the camera
  47832. */
  47833. onXRFrameObservable: Observable<XRFrame>;
  47834. /**
  47835. * Fires when the reference space changed
  47836. */
  47837. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47838. /**
  47839. * Fires when the xr session is ended either by the device or manually done
  47840. */
  47841. onXRSessionEnded: Observable<any>;
  47842. /**
  47843. * Fires when the xr session is ended either by the device or manually done
  47844. */
  47845. onXRSessionInit: Observable<XRSession>;
  47846. /**
  47847. * Underlying xr session
  47848. */
  47849. session: XRSession;
  47850. /**
  47851. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47852. * or get the offset the player is currently at.
  47853. */
  47854. viewerReferenceSpace: XRReferenceSpace;
  47855. /**
  47856. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47857. * @param scene The scene which the session should be created for
  47858. */
  47859. constructor(
  47860. /** The scene which the session should be created for */
  47861. scene: Scene);
  47862. /**
  47863. * The current reference space used in this session. This reference space can constantly change!
  47864. * It is mainly used to offset the camera's position.
  47865. */
  47866. get referenceSpace(): XRReferenceSpace;
  47867. /**
  47868. * Set a new reference space and triggers the observable
  47869. */
  47870. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47871. /**
  47872. * Disposes of the session manager
  47873. */
  47874. dispose(): void;
  47875. /**
  47876. * Stops the xrSession and restores the render loop
  47877. * @returns Promise which resolves after it exits XR
  47878. */
  47879. exitXRAsync(): Promise<void>;
  47880. /**
  47881. * Gets the correct render target texture to be rendered this frame for this eye
  47882. * @param eye the eye for which to get the render target
  47883. * @returns the render target for the specified eye
  47884. */
  47885. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47886. /**
  47887. * Creates a WebXRRenderTarget object for the XR session
  47888. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47889. * @param options optional options to provide when creating a new render target
  47890. * @returns a WebXR render target to which the session can render
  47891. */
  47892. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47893. /**
  47894. * Initializes the manager
  47895. * After initialization enterXR can be called to start an XR session
  47896. * @returns Promise which resolves after it is initialized
  47897. */
  47898. initializeAsync(): Promise<void>;
  47899. /**
  47900. * Initializes an xr session
  47901. * @param xrSessionMode mode to initialize
  47902. * @param xrSessionInit defines optional and required values to pass to the session builder
  47903. * @returns a promise which will resolve once the session has been initialized
  47904. */
  47905. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47906. /**
  47907. * Checks if a session would be supported for the creation options specified
  47908. * @param sessionMode session mode to check if supported eg. immersive-vr
  47909. * @returns A Promise that resolves to true if supported and false if not
  47910. */
  47911. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47912. /**
  47913. * Resets the reference space to the one started the session
  47914. */
  47915. resetReferenceSpace(): void;
  47916. /**
  47917. * Starts rendering to the xr layer
  47918. */
  47919. runXRRenderLoop(): void;
  47920. /**
  47921. * Sets the reference space on the xr session
  47922. * @param referenceSpaceType space to set
  47923. * @returns a promise that will resolve once the reference space has been set
  47924. */
  47925. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47926. /**
  47927. * Updates the render state of the session
  47928. * @param state state to set
  47929. * @returns a promise that resolves once the render state has been updated
  47930. */
  47931. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47932. /**
  47933. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47934. * @param sessionMode defines the session to test
  47935. * @returns a promise with boolean as final value
  47936. */
  47937. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47938. private _createRenderTargetTexture;
  47939. }
  47940. }
  47941. declare module "babylonjs/XR/webXRCamera" {
  47942. import { Scene } from "babylonjs/scene";
  47943. import { Camera } from "babylonjs/Cameras/camera";
  47944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47945. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47946. /**
  47947. * WebXR Camera which holds the views for the xrSession
  47948. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47949. */
  47950. export class WebXRCamera extends FreeCamera {
  47951. private _xrSessionManager;
  47952. private _firstFrame;
  47953. private _referenceQuaternion;
  47954. private _referencedPosition;
  47955. private _xrInvPositionCache;
  47956. private _xrInvQuaternionCache;
  47957. /**
  47958. * Should position compensation execute on first frame.
  47959. * This is used when copying the position from a native (non XR) camera
  47960. */
  47961. compensateOnFirstFrame: boolean;
  47962. /**
  47963. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47964. * @param name the name of the camera
  47965. * @param scene the scene to add the camera to
  47966. * @param _xrSessionManager a constructed xr session manager
  47967. */
  47968. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47969. /**
  47970. * Return the user's height, unrelated to the current ground.
  47971. * This will be the y position of this camera, when ground level is 0.
  47972. */
  47973. get realWorldHeight(): number;
  47974. /** @hidden */
  47975. _updateForDualEyeDebugging(): void;
  47976. /**
  47977. * Sets this camera's transformation based on a non-vr camera
  47978. * @param otherCamera the non-vr camera to copy the transformation from
  47979. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47980. */
  47981. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47982. /**
  47983. * Gets the current instance class name ("WebXRCamera").
  47984. * @returns the class name
  47985. */
  47986. getClassName(): string;
  47987. private _rotate180;
  47988. private _updateFromXRSession;
  47989. private _updateNumberOfRigCameras;
  47990. private _updateReferenceSpace;
  47991. private _updateReferenceSpaceOffset;
  47992. }
  47993. }
  47994. declare module "babylonjs/XR/webXRFeaturesManager" {
  47995. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47996. import { IDisposable } from "babylonjs/scene";
  47997. /**
  47998. * Defining the interface required for a (webxr) feature
  47999. */
  48000. export interface IWebXRFeature extends IDisposable {
  48001. /**
  48002. * Is this feature attached
  48003. */
  48004. attached: boolean;
  48005. /**
  48006. * Should auto-attach be disabled?
  48007. */
  48008. disableAutoAttach: boolean;
  48009. /**
  48010. * Attach the feature to the session
  48011. * Will usually be called by the features manager
  48012. *
  48013. * @param force should attachment be forced (even when already attached)
  48014. * @returns true if successful.
  48015. */
  48016. attach(force?: boolean): boolean;
  48017. /**
  48018. * Detach the feature from the session
  48019. * Will usually be called by the features manager
  48020. *
  48021. * @returns true if successful.
  48022. */
  48023. detach(): boolean;
  48024. }
  48025. /**
  48026. * A list of the currently available features without referencing them
  48027. */
  48028. export class WebXRFeatureName {
  48029. /**
  48030. * The name of the anchor system feature
  48031. */
  48032. static ANCHOR_SYSTEM: string;
  48033. /**
  48034. * The name of the background remover feature
  48035. */
  48036. static BACKGROUND_REMOVER: string;
  48037. /**
  48038. * The name of the hit test feature
  48039. */
  48040. static HIT_TEST: string;
  48041. /**
  48042. * physics impostors for xr controllers feature
  48043. */
  48044. static PHYSICS_CONTROLLERS: string;
  48045. /**
  48046. * The name of the plane detection feature
  48047. */
  48048. static PLANE_DETECTION: string;
  48049. /**
  48050. * The name of the pointer selection feature
  48051. */
  48052. static POINTER_SELECTION: string;
  48053. /**
  48054. * The name of the teleportation feature
  48055. */
  48056. static TELEPORTATION: string;
  48057. }
  48058. /**
  48059. * Defining the constructor of a feature. Used to register the modules.
  48060. */
  48061. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48062. /**
  48063. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48064. * It is mainly used in AR sessions.
  48065. *
  48066. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48067. */
  48068. export class WebXRFeaturesManager implements IDisposable {
  48069. private _xrSessionManager;
  48070. private static readonly _AvailableFeatures;
  48071. private _features;
  48072. /**
  48073. * constructs a new features manages.
  48074. *
  48075. * @param _xrSessionManager an instance of WebXRSessionManager
  48076. */
  48077. constructor(_xrSessionManager: WebXRSessionManager);
  48078. /**
  48079. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48080. * Mainly used internally.
  48081. *
  48082. * @param featureName the name of the feature to register
  48083. * @param constructorFunction the function used to construct the module
  48084. * @param version the (babylon) version of the module
  48085. * @param stable is that a stable version of this module
  48086. */
  48087. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48088. /**
  48089. * Returns a constructor of a specific feature.
  48090. *
  48091. * @param featureName the name of the feature to construct
  48092. * @param version the version of the feature to load
  48093. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48094. * @param options optional options provided to the module.
  48095. * @returns a function that, when called, will return a new instance of this feature
  48096. */
  48097. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48098. /**
  48099. * Can be used to return the list of features currently registered
  48100. *
  48101. * @returns an Array of available features
  48102. */
  48103. static GetAvailableFeatures(): string[];
  48104. /**
  48105. * Gets the versions available for a specific feature
  48106. * @param featureName the name of the feature
  48107. * @returns an array with the available versions
  48108. */
  48109. static GetAvailableVersions(featureName: string): string[];
  48110. /**
  48111. * Return the latest unstable version of this feature
  48112. * @param featureName the name of the feature to search
  48113. * @returns the version number. if not found will return -1
  48114. */
  48115. static GetLatestVersionOfFeature(featureName: string): number;
  48116. /**
  48117. * Return the latest stable version of this feature
  48118. * @param featureName the name of the feature to search
  48119. * @returns the version number. if not found will return -1
  48120. */
  48121. static GetStableVersionOfFeature(featureName: string): number;
  48122. /**
  48123. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48124. * Can be used during a session to start a feature
  48125. * @param featureName the name of feature to attach
  48126. */
  48127. attachFeature(featureName: string): void;
  48128. /**
  48129. * Can be used inside a session or when the session ends to detach a specific feature
  48130. * @param featureName the name of the feature to detach
  48131. */
  48132. detachFeature(featureName: string): void;
  48133. /**
  48134. * Used to disable an already-enabled feature
  48135. * The feature will be disposed and will be recreated once enabled.
  48136. * @param featureName the feature to disable
  48137. * @returns true if disable was successful
  48138. */
  48139. disableFeature(featureName: string | {
  48140. Name: string;
  48141. }): boolean;
  48142. /**
  48143. * dispose this features manager
  48144. */
  48145. dispose(): void;
  48146. /**
  48147. * 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.
  48148. * 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.
  48149. *
  48150. * @param featureName the name of the feature to load or the class of the feature
  48151. * @param version optional version to load. if not provided the latest version will be enabled
  48152. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48153. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48154. * @returns a new constructed feature or throws an error if feature not found.
  48155. */
  48156. enableFeature(featureName: string | {
  48157. Name: string;
  48158. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48159. /**
  48160. * get the implementation of an enabled feature.
  48161. * @param featureName the name of the feature to load
  48162. * @returns the feature class, if found
  48163. */
  48164. getEnabledFeature(featureName: string): IWebXRFeature;
  48165. /**
  48166. * Get the list of enabled features
  48167. * @returns an array of enabled features
  48168. */
  48169. getEnabledFeatures(): string[];
  48170. }
  48171. }
  48172. declare module "babylonjs/XR/webXRExperienceHelper" {
  48173. import { Observable } from "babylonjs/Misc/observable";
  48174. import { IDisposable, Scene } from "babylonjs/scene";
  48175. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48176. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48177. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48178. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48179. /**
  48180. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48181. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48182. */
  48183. export class WebXRExperienceHelper implements IDisposable {
  48184. private scene;
  48185. private _nonVRCamera;
  48186. private _originalSceneAutoClear;
  48187. private _supported;
  48188. /**
  48189. * Camera used to render xr content
  48190. */
  48191. camera: WebXRCamera;
  48192. /** A features manager for this xr session */
  48193. featuresManager: WebXRFeaturesManager;
  48194. /**
  48195. * Observers registered here will be triggered after the camera's initial transformation is set
  48196. * This can be used to set a different ground level or an extra rotation.
  48197. *
  48198. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48199. * to the position set after this observable is done executing.
  48200. */
  48201. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48202. /**
  48203. * Fires when the state of the experience helper has changed
  48204. */
  48205. onStateChangedObservable: Observable<WebXRState>;
  48206. /** Session manager used to keep track of xr session */
  48207. sessionManager: WebXRSessionManager;
  48208. /**
  48209. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48210. */
  48211. state: WebXRState;
  48212. /**
  48213. * Creates a WebXRExperienceHelper
  48214. * @param scene The scene the helper should be created in
  48215. */
  48216. private constructor();
  48217. /**
  48218. * Creates the experience helper
  48219. * @param scene the scene to attach the experience helper to
  48220. * @returns a promise for the experience helper
  48221. */
  48222. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48223. /**
  48224. * Disposes of the experience helper
  48225. */
  48226. dispose(): void;
  48227. /**
  48228. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48229. * @param sessionMode options for the XR session
  48230. * @param referenceSpaceType frame of reference of the XR session
  48231. * @param renderTarget the output canvas that will be used to enter XR mode
  48232. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48233. * @returns promise that resolves after xr mode has entered
  48234. */
  48235. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48236. /**
  48237. * Exits XR mode and returns the scene to its original state
  48238. * @returns promise that resolves after xr mode has exited
  48239. */
  48240. exitXRAsync(): Promise<void>;
  48241. private _nonXRToXRCamera;
  48242. private _setState;
  48243. }
  48244. }
  48245. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48246. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48247. import { Observable } from "babylonjs/Misc/observable";
  48248. import { IDisposable } from "babylonjs/scene";
  48249. /**
  48250. * X-Y values for axes in WebXR
  48251. */
  48252. export interface IWebXRMotionControllerAxesValue {
  48253. /**
  48254. * The value of the x axis
  48255. */
  48256. x: number;
  48257. /**
  48258. * The value of the y-axis
  48259. */
  48260. y: number;
  48261. }
  48262. /**
  48263. * changed / previous values for the values of this component
  48264. */
  48265. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48266. /**
  48267. * current (this frame) value
  48268. */
  48269. current: T;
  48270. /**
  48271. * previous (last change) value
  48272. */
  48273. previous: T;
  48274. }
  48275. /**
  48276. * Represents changes in the component between current frame and last values recorded
  48277. */
  48278. export interface IWebXRMotionControllerComponentChanges {
  48279. /**
  48280. * will be populated with previous and current values if axes changed
  48281. */
  48282. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48283. /**
  48284. * will be populated with previous and current values if pressed changed
  48285. */
  48286. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48287. /**
  48288. * will be populated with previous and current values if touched changed
  48289. */
  48290. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48291. /**
  48292. * will be populated with previous and current values if value changed
  48293. */
  48294. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48295. }
  48296. /**
  48297. * This class represents a single component (for example button or thumbstick) of a motion controller
  48298. */
  48299. export class WebXRControllerComponent implements IDisposable {
  48300. /**
  48301. * the id of this component
  48302. */
  48303. id: string;
  48304. /**
  48305. * the type of the component
  48306. */
  48307. type: MotionControllerComponentType;
  48308. private _buttonIndex;
  48309. private _axesIndices;
  48310. private _axes;
  48311. private _changes;
  48312. private _currentValue;
  48313. private _hasChanges;
  48314. private _pressed;
  48315. private _touched;
  48316. /**
  48317. * button component type
  48318. */
  48319. static BUTTON_TYPE: MotionControllerComponentType;
  48320. /**
  48321. * squeeze component type
  48322. */
  48323. static SQUEEZE_TYPE: MotionControllerComponentType;
  48324. /**
  48325. * Thumbstick component type
  48326. */
  48327. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48328. /**
  48329. * Touchpad component type
  48330. */
  48331. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48332. /**
  48333. * trigger component type
  48334. */
  48335. static TRIGGER_TYPE: MotionControllerComponentType;
  48336. /**
  48337. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48338. * the axes data changes
  48339. */
  48340. onAxisValueChangedObservable: Observable<{
  48341. x: number;
  48342. y: number;
  48343. }>;
  48344. /**
  48345. * Observers registered here will be triggered when the state of a button changes
  48346. * State change is either pressed / touched / value
  48347. */
  48348. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48349. /**
  48350. * Creates a new component for a motion controller.
  48351. * It is created by the motion controller itself
  48352. *
  48353. * @param id the id of this component
  48354. * @param type the type of the component
  48355. * @param _buttonIndex index in the buttons array of the gamepad
  48356. * @param _axesIndices indices of the values in the axes array of the gamepad
  48357. */
  48358. constructor(
  48359. /**
  48360. * the id of this component
  48361. */
  48362. id: string,
  48363. /**
  48364. * the type of the component
  48365. */
  48366. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48367. /**
  48368. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48369. */
  48370. get axes(): IWebXRMotionControllerAxesValue;
  48371. /**
  48372. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48373. */
  48374. get changes(): IWebXRMotionControllerComponentChanges;
  48375. /**
  48376. * Return whether or not the component changed the last frame
  48377. */
  48378. get hasChanges(): boolean;
  48379. /**
  48380. * is the button currently pressed
  48381. */
  48382. get pressed(): boolean;
  48383. /**
  48384. * is the button currently touched
  48385. */
  48386. get touched(): boolean;
  48387. /**
  48388. * Get the current value of this component
  48389. */
  48390. get value(): number;
  48391. /**
  48392. * Dispose this component
  48393. */
  48394. dispose(): void;
  48395. /**
  48396. * Are there axes correlating to this component
  48397. * @return true is axes data is available
  48398. */
  48399. isAxes(): boolean;
  48400. /**
  48401. * Is this component a button (hence - pressable)
  48402. * @returns true if can be pressed
  48403. */
  48404. isButton(): boolean;
  48405. /**
  48406. * update this component using the gamepad object it is in. Called on every frame
  48407. * @param nativeController the native gamepad controller object
  48408. */
  48409. update(nativeController: IMinimalMotionControllerObject): void;
  48410. }
  48411. }
  48412. declare module "babylonjs/Loading/sceneLoader" {
  48413. import { Observable } from "babylonjs/Misc/observable";
  48414. import { Nullable } from "babylonjs/types";
  48415. import { Scene } from "babylonjs/scene";
  48416. import { Engine } from "babylonjs/Engines/engine";
  48417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48418. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48419. import { AssetContainer } from "babylonjs/assetContainer";
  48420. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48421. import { Skeleton } from "babylonjs/Bones/skeleton";
  48422. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48423. import { WebRequest } from "babylonjs/Misc/webRequest";
  48424. /**
  48425. * Interface used to represent data loading progression
  48426. */
  48427. export interface ISceneLoaderProgressEvent {
  48428. /**
  48429. * Defines if data length to load can be evaluated
  48430. */
  48431. readonly lengthComputable: boolean;
  48432. /**
  48433. * Defines the loaded data length
  48434. */
  48435. readonly loaded: number;
  48436. /**
  48437. * Defines the data length to load
  48438. */
  48439. readonly total: number;
  48440. }
  48441. /**
  48442. * Interface used by SceneLoader plugins to define supported file extensions
  48443. */
  48444. export interface ISceneLoaderPluginExtensions {
  48445. /**
  48446. * Defines the list of supported extensions
  48447. */
  48448. [extension: string]: {
  48449. isBinary: boolean;
  48450. };
  48451. }
  48452. /**
  48453. * Interface used by SceneLoader plugin factory
  48454. */
  48455. export interface ISceneLoaderPluginFactory {
  48456. /**
  48457. * Defines the name of the factory
  48458. */
  48459. name: string;
  48460. /**
  48461. * Function called to create a new plugin
  48462. * @return the new plugin
  48463. */
  48464. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48465. /**
  48466. * The callback that returns true if the data can be directly loaded.
  48467. * @param data string containing the file data
  48468. * @returns if the data can be loaded directly
  48469. */
  48470. canDirectLoad?(data: string): boolean;
  48471. }
  48472. /**
  48473. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48474. */
  48475. export interface ISceneLoaderPluginBase {
  48476. /**
  48477. * The friendly name of this plugin.
  48478. */
  48479. name: string;
  48480. /**
  48481. * The file extensions supported by this plugin.
  48482. */
  48483. extensions: string | ISceneLoaderPluginExtensions;
  48484. /**
  48485. * The callback called when loading from a url.
  48486. * @param scene scene loading this url
  48487. * @param url url to load
  48488. * @param onSuccess callback called when the file successfully loads
  48489. * @param onProgress callback called while file is loading (if the server supports this mode)
  48490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48491. * @param onError callback called when the file fails to load
  48492. * @returns a file request object
  48493. */
  48494. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48495. /**
  48496. * The callback called when loading from a file object.
  48497. * @param scene scene loading this file
  48498. * @param file defines the file to load
  48499. * @param onSuccess defines the callback to call when data is loaded
  48500. * @param onProgress defines the callback to call during loading process
  48501. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48502. * @param onError defines the callback to call when an error occurs
  48503. * @returns a file request object
  48504. */
  48505. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48506. /**
  48507. * The callback that returns true if the data can be directly loaded.
  48508. * @param data string containing the file data
  48509. * @returns if the data can be loaded directly
  48510. */
  48511. canDirectLoad?(data: string): boolean;
  48512. /**
  48513. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48514. * @param scene scene loading this data
  48515. * @param data string containing the data
  48516. * @returns data to pass to the plugin
  48517. */
  48518. directLoad?(scene: Scene, data: string): any;
  48519. /**
  48520. * The callback that allows custom handling of the root url based on the response url.
  48521. * @param rootUrl the original root url
  48522. * @param responseURL the response url if available
  48523. * @returns the new root url
  48524. */
  48525. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48526. }
  48527. /**
  48528. * Interface used to define a SceneLoader plugin
  48529. */
  48530. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48531. /**
  48532. * Import meshes into a scene.
  48533. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48534. * @param scene The scene to import into
  48535. * @param data The data to import
  48536. * @param rootUrl The root url for scene and resources
  48537. * @param meshes The meshes array to import into
  48538. * @param particleSystems The particle systems array to import into
  48539. * @param skeletons The skeletons array to import into
  48540. * @param onError The callback when import fails
  48541. * @returns True if successful or false otherwise
  48542. */
  48543. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48544. /**
  48545. * Load into a scene.
  48546. * @param scene The scene to load into
  48547. * @param data The data to import
  48548. * @param rootUrl The root url for scene and resources
  48549. * @param onError The callback when import fails
  48550. * @returns True if successful or false otherwise
  48551. */
  48552. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48553. /**
  48554. * Load into an asset container.
  48555. * @param scene The scene to load into
  48556. * @param data The data to import
  48557. * @param rootUrl The root url for scene and resources
  48558. * @param onError The callback when import fails
  48559. * @returns The loaded asset container
  48560. */
  48561. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48562. }
  48563. /**
  48564. * Interface used to define an async SceneLoader plugin
  48565. */
  48566. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48567. /**
  48568. * Import meshes into a scene.
  48569. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48570. * @param scene The scene to import into
  48571. * @param data The data to import
  48572. * @param rootUrl The root url for scene and resources
  48573. * @param onProgress The callback when the load progresses
  48574. * @param fileName Defines the name of the file to load
  48575. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48576. */
  48577. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48578. meshes: AbstractMesh[];
  48579. particleSystems: IParticleSystem[];
  48580. skeletons: Skeleton[];
  48581. animationGroups: AnimationGroup[];
  48582. }>;
  48583. /**
  48584. * Load into a scene.
  48585. * @param scene The scene to load into
  48586. * @param data The data to import
  48587. * @param rootUrl The root url for scene and resources
  48588. * @param onProgress The callback when the load progresses
  48589. * @param fileName Defines the name of the file to load
  48590. * @returns Nothing
  48591. */
  48592. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48593. /**
  48594. * Load into an asset container.
  48595. * @param scene The scene to load into
  48596. * @param data The data to import
  48597. * @param rootUrl The root url for scene and resources
  48598. * @param onProgress The callback when the load progresses
  48599. * @param fileName Defines the name of the file to load
  48600. * @returns The loaded asset container
  48601. */
  48602. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48603. }
  48604. /**
  48605. * Mode that determines how to handle old animation groups before loading new ones.
  48606. */
  48607. export enum SceneLoaderAnimationGroupLoadingMode {
  48608. /**
  48609. * Reset all old animations to initial state then dispose them.
  48610. */
  48611. Clean = 0,
  48612. /**
  48613. * Stop all old animations.
  48614. */
  48615. Stop = 1,
  48616. /**
  48617. * Restart old animations from first frame.
  48618. */
  48619. Sync = 2,
  48620. /**
  48621. * Old animations remains untouched.
  48622. */
  48623. NoSync = 3
  48624. }
  48625. /**
  48626. * Class used to load scene from various file formats using registered plugins
  48627. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48628. */
  48629. export class SceneLoader {
  48630. /**
  48631. * No logging while loading
  48632. */
  48633. static readonly NO_LOGGING: number;
  48634. /**
  48635. * Minimal logging while loading
  48636. */
  48637. static readonly MINIMAL_LOGGING: number;
  48638. /**
  48639. * Summary logging while loading
  48640. */
  48641. static readonly SUMMARY_LOGGING: number;
  48642. /**
  48643. * Detailled logging while loading
  48644. */
  48645. static readonly DETAILED_LOGGING: number;
  48646. /**
  48647. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48648. */
  48649. static get ForceFullSceneLoadingForIncremental(): boolean;
  48650. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48651. /**
  48652. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48653. */
  48654. static get ShowLoadingScreen(): boolean;
  48655. static set ShowLoadingScreen(value: boolean);
  48656. /**
  48657. * Defines the current logging level (while loading the scene)
  48658. * @ignorenaming
  48659. */
  48660. static get loggingLevel(): number;
  48661. static set loggingLevel(value: number);
  48662. /**
  48663. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48664. */
  48665. static get CleanBoneMatrixWeights(): boolean;
  48666. static set CleanBoneMatrixWeights(value: boolean);
  48667. /**
  48668. * Event raised when a plugin is used to load a scene
  48669. */
  48670. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48671. private static _registeredPlugins;
  48672. private static _getDefaultPlugin;
  48673. private static _getPluginForExtension;
  48674. private static _getPluginForDirectLoad;
  48675. private static _getPluginForFilename;
  48676. private static _getDirectLoad;
  48677. private static _loadData;
  48678. private static _getFileInfo;
  48679. /**
  48680. * Gets a plugin that can load the given extension
  48681. * @param extension defines the extension to load
  48682. * @returns a plugin or null if none works
  48683. */
  48684. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48685. /**
  48686. * Gets a boolean indicating that the given extension can be loaded
  48687. * @param extension defines the extension to load
  48688. * @returns true if the extension is supported
  48689. */
  48690. static IsPluginForExtensionAvailable(extension: string): boolean;
  48691. /**
  48692. * Adds a new plugin to the list of registered plugins
  48693. * @param plugin defines the plugin to add
  48694. */
  48695. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48696. /**
  48697. * Import meshes into a scene
  48698. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48699. * @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)
  48700. * @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)
  48701. * @param scene the instance of BABYLON.Scene to append to
  48702. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48703. * @param onProgress a callback with a progress event for each file being loaded
  48704. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48705. * @param pluginExtension the extension used to determine the plugin
  48706. * @returns The loaded plugin
  48707. */
  48708. 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>;
  48709. /**
  48710. * Import meshes into a scene
  48711. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48712. * @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)
  48713. * @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)
  48714. * @param scene the instance of BABYLON.Scene to append to
  48715. * @param onProgress a callback with a progress event for each file being loaded
  48716. * @param pluginExtension the extension used to determine the plugin
  48717. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48718. */
  48719. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48720. meshes: AbstractMesh[];
  48721. particleSystems: IParticleSystem[];
  48722. skeletons: Skeleton[];
  48723. animationGroups: AnimationGroup[];
  48724. }>;
  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 onSuccess a callback with the scene when import succeeds
  48731. * @param onProgress a callback with a progress event for each file being loaded
  48732. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48733. * @param pluginExtension the extension used to determine the plugin
  48734. * @returns The loaded plugin
  48735. */
  48736. 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>;
  48737. /**
  48738. * Load a scene
  48739. * @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)
  48740. * @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)
  48741. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48742. * @param onProgress a callback with a progress event for each file being loaded
  48743. * @param pluginExtension the extension used to determine the plugin
  48744. * @returns The loaded scene
  48745. */
  48746. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  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 onSuccess a callback with the scene when import succeeds
  48753. * @param onProgress a callback with a progress event for each file being loaded
  48754. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48755. * @param pluginExtension the extension used to determine the plugin
  48756. * @returns The loaded plugin
  48757. */
  48758. 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>;
  48759. /**
  48760. * Append a scene
  48761. * @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)
  48762. * @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)
  48763. * @param scene is the instance of BABYLON.Scene to append to
  48764. * @param onProgress a callback with a progress event for each file being loaded
  48765. * @param pluginExtension the extension used to determine the plugin
  48766. * @returns The given scene
  48767. */
  48768. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  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 or a File object (default: empty string)
  48773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48774. * @param onSuccess a callback with the scene when import succeeds
  48775. * @param onProgress a callback with a progress event for each file being loaded
  48776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48777. * @param pluginExtension the extension used to determine the plugin
  48778. * @returns The loaded plugin
  48779. */
  48780. 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>;
  48781. /**
  48782. * Load a scene into an asset container
  48783. * @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)
  48784. * @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)
  48785. * @param scene is the instance of Scene to append to
  48786. * @param onProgress a callback with a progress event for each file being loaded
  48787. * @param pluginExtension the extension used to determine the plugin
  48788. * @returns The loaded asset container
  48789. */
  48790. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48791. /**
  48792. * Import animations from a file into a scene
  48793. * @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)
  48794. * @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)
  48795. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48796. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48797. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48798. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48799. * @param onSuccess a callback with the scene when import succeeds
  48800. * @param onProgress a callback with a progress event for each file being loaded
  48801. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48802. * @param pluginExtension the extension used to determine the plugin
  48803. */
  48804. 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;
  48805. /**
  48806. * Import animations from a file into a scene
  48807. * @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)
  48808. * @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)
  48809. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48810. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48811. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48812. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48813. * @param onSuccess a callback with the scene when import succeeds
  48814. * @param onProgress a callback with a progress event for each file being loaded
  48815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48816. * @param pluginExtension the extension used to determine the plugin
  48817. * @returns the updated scene with imported animations
  48818. */
  48819. 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>;
  48820. }
  48821. }
  48822. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48823. import { IDisposable, Scene } from "babylonjs/scene";
  48824. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48825. import { Observable } from "babylonjs/Misc/observable";
  48826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48827. import { Nullable } from "babylonjs/types";
  48828. /**
  48829. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48830. */
  48831. export type MotionControllerHandedness = "none" | "left" | "right";
  48832. /**
  48833. * The type of components available in motion controllers.
  48834. * This is not the name of the component.
  48835. */
  48836. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48837. /**
  48838. * The state of a controller component
  48839. */
  48840. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48841. /**
  48842. * The schema of motion controller layout.
  48843. * No object will be initialized using this interface
  48844. * This is used just to define the profile.
  48845. */
  48846. export interface IMotionControllerLayout {
  48847. /**
  48848. * Path to load the assets. Usually relative to the base path
  48849. */
  48850. assetPath: string;
  48851. /**
  48852. * Available components (unsorted)
  48853. */
  48854. components: {
  48855. /**
  48856. * A map of component Ids
  48857. */
  48858. [componentId: string]: {
  48859. /**
  48860. * The type of input the component outputs
  48861. */
  48862. type: MotionControllerComponentType;
  48863. /**
  48864. * The indices of this component in the gamepad object
  48865. */
  48866. gamepadIndices: {
  48867. /**
  48868. * Index of button
  48869. */
  48870. button?: number;
  48871. /**
  48872. * If available, index of x-axis
  48873. */
  48874. xAxis?: number;
  48875. /**
  48876. * If available, index of y-axis
  48877. */
  48878. yAxis?: number;
  48879. };
  48880. /**
  48881. * The mesh's root node name
  48882. */
  48883. rootNodeName: string;
  48884. /**
  48885. * Animation definitions for this model
  48886. */
  48887. visualResponses: {
  48888. [stateKey: string]: {
  48889. /**
  48890. * What property will be animated
  48891. */
  48892. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48893. /**
  48894. * What states influence this visual response
  48895. */
  48896. states: MotionControllerComponentStateType[];
  48897. /**
  48898. * Type of animation - movement or visibility
  48899. */
  48900. valueNodeProperty: "transform" | "visibility";
  48901. /**
  48902. * Base node name to move. Its position will be calculated according to the min and max nodes
  48903. */
  48904. valueNodeName?: string;
  48905. /**
  48906. * Minimum movement node
  48907. */
  48908. minNodeName?: string;
  48909. /**
  48910. * Max movement node
  48911. */
  48912. maxNodeName?: string;
  48913. };
  48914. };
  48915. /**
  48916. * If touch enabled, what is the name of node to display user feedback
  48917. */
  48918. touchPointNodeName?: string;
  48919. };
  48920. };
  48921. /**
  48922. * Is it xr standard mapping or not
  48923. */
  48924. gamepadMapping: "" | "xr-standard";
  48925. /**
  48926. * Base root node of this entire model
  48927. */
  48928. rootNodeName: string;
  48929. /**
  48930. * Defines the main button component id
  48931. */
  48932. selectComponentId: string;
  48933. }
  48934. /**
  48935. * A definition for the layout map in the input profile
  48936. */
  48937. export interface IMotionControllerLayoutMap {
  48938. /**
  48939. * Layouts with handedness type as a key
  48940. */
  48941. [handedness: string]: IMotionControllerLayout;
  48942. }
  48943. /**
  48944. * The XR Input profile schema
  48945. * Profiles can be found here:
  48946. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48947. */
  48948. export interface IMotionControllerProfile {
  48949. /**
  48950. * fallback profiles for this profileId
  48951. */
  48952. fallbackProfileIds: string[];
  48953. /**
  48954. * The layout map, with handedness as key
  48955. */
  48956. layouts: IMotionControllerLayoutMap;
  48957. /**
  48958. * The id of this profile
  48959. * correlates to the profile(s) in the xrInput.profiles array
  48960. */
  48961. profileId: string;
  48962. }
  48963. /**
  48964. * A helper-interface for the 3 meshes needed for controller button animation
  48965. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48966. */
  48967. export interface IMotionControllerButtonMeshMap {
  48968. /**
  48969. * the mesh that defines the pressed value mesh position.
  48970. * This is used to find the max-position of this button
  48971. */
  48972. pressedMesh: AbstractMesh;
  48973. /**
  48974. * the mesh that defines the unpressed value mesh position.
  48975. * This is used to find the min (or initial) position of this button
  48976. */
  48977. unpressedMesh: AbstractMesh;
  48978. /**
  48979. * The mesh that will be changed when value changes
  48980. */
  48981. valueMesh: AbstractMesh;
  48982. }
  48983. /**
  48984. * A helper-interface for the 3 meshes needed for controller axis animation.
  48985. * This will be expanded when touchpad animations are fully supported
  48986. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48987. */
  48988. export interface IMotionControllerMeshMap {
  48989. /**
  48990. * the mesh that defines the maximum value mesh position.
  48991. */
  48992. maxMesh?: AbstractMesh;
  48993. /**
  48994. * the mesh that defines the minimum value mesh position.
  48995. */
  48996. minMesh?: AbstractMesh;
  48997. /**
  48998. * The mesh that will be changed when axis value changes
  48999. */
  49000. valueMesh: AbstractMesh;
  49001. }
  49002. /**
  49003. * The elements needed for change-detection of the gamepad objects in motion controllers
  49004. */
  49005. export interface IMinimalMotionControllerObject {
  49006. /**
  49007. * Available axes of this controller
  49008. */
  49009. axes: number[];
  49010. /**
  49011. * An array of available buttons
  49012. */
  49013. buttons: Array<{
  49014. /**
  49015. * Value of the button/trigger
  49016. */
  49017. value: number;
  49018. /**
  49019. * If the button/trigger is currently touched
  49020. */
  49021. touched: boolean;
  49022. /**
  49023. * If the button/trigger is currently pressed
  49024. */
  49025. pressed: boolean;
  49026. }>;
  49027. /**
  49028. * EXPERIMENTAL haptic support.
  49029. */
  49030. hapticActuators?: Array<{
  49031. pulse: (value: number, duration: number) => Promise<boolean>;
  49032. }>;
  49033. }
  49034. /**
  49035. * An Abstract Motion controller
  49036. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49037. * Each component has an observable to check for changes in value and state
  49038. */
  49039. export abstract class WebXRAbstractMotionController implements IDisposable {
  49040. protected scene: Scene;
  49041. protected layout: IMotionControllerLayout;
  49042. /**
  49043. * The gamepad object correlating to this controller
  49044. */
  49045. gamepadObject: IMinimalMotionControllerObject;
  49046. /**
  49047. * handedness (left/right/none) of this controller
  49048. */
  49049. handedness: MotionControllerHandedness;
  49050. private _initComponent;
  49051. private _modelReady;
  49052. /**
  49053. * A map of components (WebXRControllerComponent) in this motion controller
  49054. * Components have a ComponentType and can also have both button and axis definitions
  49055. */
  49056. readonly components: {
  49057. [id: string]: WebXRControllerComponent;
  49058. };
  49059. /**
  49060. * Disable the model's animation. Can be set at any time.
  49061. */
  49062. disableAnimation: boolean;
  49063. /**
  49064. * Observers registered here will be triggered when the model of this controller is done loading
  49065. */
  49066. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49067. /**
  49068. * The profile id of this motion controller
  49069. */
  49070. abstract profileId: string;
  49071. /**
  49072. * The root mesh of the model. It is null if the model was not yet initialized
  49073. */
  49074. rootMesh: Nullable<AbstractMesh>;
  49075. /**
  49076. * constructs a new abstract motion controller
  49077. * @param scene the scene to which the model of the controller will be added
  49078. * @param layout The profile layout to load
  49079. * @param gamepadObject The gamepad object correlating to this controller
  49080. * @param handedness handedness (left/right/none) of this controller
  49081. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49082. */
  49083. constructor(scene: Scene, layout: IMotionControllerLayout,
  49084. /**
  49085. * The gamepad object correlating to this controller
  49086. */
  49087. gamepadObject: IMinimalMotionControllerObject,
  49088. /**
  49089. * handedness (left/right/none) of this controller
  49090. */
  49091. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49092. /**
  49093. * Dispose this controller, the model mesh and all its components
  49094. */
  49095. dispose(): void;
  49096. /**
  49097. * Returns all components of specific type
  49098. * @param type the type to search for
  49099. * @return an array of components with this type
  49100. */
  49101. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49102. /**
  49103. * get a component based an its component id as defined in layout.components
  49104. * @param id the id of the component
  49105. * @returns the component correlates to the id or undefined if not found
  49106. */
  49107. getComponent(id: string): WebXRControllerComponent;
  49108. /**
  49109. * Get the list of components available in this motion controller
  49110. * @returns an array of strings correlating to available components
  49111. */
  49112. getComponentIds(): string[];
  49113. /**
  49114. * Get the first component of specific type
  49115. * @param type type of component to find
  49116. * @return a controller component or null if not found
  49117. */
  49118. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49119. /**
  49120. * Get the main (Select) component of this controller as defined in the layout
  49121. * @returns the main component of this controller
  49122. */
  49123. getMainComponent(): WebXRControllerComponent;
  49124. /**
  49125. * Loads the model correlating to this controller
  49126. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49127. * @returns A promise fulfilled with the result of the model loading
  49128. */
  49129. loadModel(): Promise<boolean>;
  49130. /**
  49131. * Update this model using the current XRFrame
  49132. * @param xrFrame the current xr frame to use and update the model
  49133. */
  49134. updateFromXRFrame(xrFrame: XRFrame): void;
  49135. /**
  49136. * Backwards compatibility due to a deeply-integrated typo
  49137. */
  49138. get handness(): XREye;
  49139. /**
  49140. * Pulse (vibrate) this controller
  49141. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49142. * Consecutive calls to this function will cancel the last pulse call
  49143. *
  49144. * @param value the strength of the pulse in 0.0...1.0 range
  49145. * @param duration Duration of the pulse in milliseconds
  49146. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49147. * @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
  49148. */
  49149. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49150. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49151. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49152. /**
  49153. * Moves the axis on the controller mesh based on its current state
  49154. * @param axis the index of the axis
  49155. * @param axisValue the value of the axis which determines the meshes new position
  49156. * @hidden
  49157. */
  49158. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49159. /**
  49160. * Update the model itself with the current frame data
  49161. * @param xrFrame the frame to use for updating the model mesh
  49162. */
  49163. protected updateModel(xrFrame: XRFrame): void;
  49164. /**
  49165. * Get the filename and path for this controller's model
  49166. * @returns a map of filename and path
  49167. */
  49168. protected abstract _getFilenameAndPath(): {
  49169. filename: string;
  49170. path: string;
  49171. };
  49172. /**
  49173. * This function is called before the mesh is loaded. It checks for loading constraints.
  49174. * For example, this function can check if the GLB loader is available
  49175. * If this function returns false, the generic controller will be loaded instead
  49176. * @returns Is the client ready to load the mesh
  49177. */
  49178. protected abstract _getModelLoadingConstraints(): boolean;
  49179. /**
  49180. * This function will be called after the model was successfully loaded and can be used
  49181. * for mesh transformations before it is available for the user
  49182. * @param meshes the loaded meshes
  49183. */
  49184. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49185. /**
  49186. * Set the root mesh for this controller. Important for the WebXR controller class
  49187. * @param meshes the loaded meshes
  49188. */
  49189. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49190. /**
  49191. * A function executed each frame that updates the mesh (if needed)
  49192. * @param xrFrame the current xrFrame
  49193. */
  49194. protected abstract _updateModel(xrFrame: XRFrame): void;
  49195. private _getGenericFilenameAndPath;
  49196. private _getGenericParentMesh;
  49197. }
  49198. }
  49199. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49200. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49202. import { Scene } from "babylonjs/scene";
  49203. /**
  49204. * A generic trigger-only motion controller for WebXR
  49205. */
  49206. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49207. /**
  49208. * Static version of the profile id of this controller
  49209. */
  49210. static ProfileId: string;
  49211. profileId: string;
  49212. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49213. protected _getFilenameAndPath(): {
  49214. filename: string;
  49215. path: string;
  49216. };
  49217. protected _getModelLoadingConstraints(): boolean;
  49218. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49219. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49220. protected _updateModel(): void;
  49221. }
  49222. }
  49223. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49224. import { Vector4 } from "babylonjs/Maths/math.vector";
  49225. import { Mesh } from "babylonjs/Meshes/mesh";
  49226. import { Scene } from "babylonjs/scene";
  49227. import { Nullable } from "babylonjs/types";
  49228. /**
  49229. * Class containing static functions to help procedurally build meshes
  49230. */
  49231. export class SphereBuilder {
  49232. /**
  49233. * Creates a sphere mesh
  49234. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49235. * * 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`)
  49236. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49237. * * 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
  49238. * * 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)
  49239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49240. * * 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
  49241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49242. * @param name defines the name of the mesh
  49243. * @param options defines the options used to create the mesh
  49244. * @param scene defines the hosting scene
  49245. * @returns the sphere mesh
  49246. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49247. */
  49248. static CreateSphere(name: string, options: {
  49249. segments?: number;
  49250. diameter?: number;
  49251. diameterX?: number;
  49252. diameterY?: number;
  49253. diameterZ?: number;
  49254. arc?: number;
  49255. slice?: number;
  49256. sideOrientation?: number;
  49257. frontUVs?: Vector4;
  49258. backUVs?: Vector4;
  49259. updatable?: boolean;
  49260. }, scene?: Nullable<Scene>): Mesh;
  49261. }
  49262. }
  49263. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49265. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49266. import { Scene } from "babylonjs/scene";
  49267. /**
  49268. * A profiled motion controller has its profile loaded from an online repository.
  49269. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49270. */
  49271. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49272. private _repositoryUrl;
  49273. private _buttonMeshMapping;
  49274. private _touchDots;
  49275. /**
  49276. * The profile ID of this controller. Will be populated when the controller initializes.
  49277. */
  49278. profileId: string;
  49279. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49280. dispose(): void;
  49281. protected _getFilenameAndPath(): {
  49282. filename: string;
  49283. path: string;
  49284. };
  49285. protected _getModelLoadingConstraints(): boolean;
  49286. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49287. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49288. protected _updateModel(_xrFrame: XRFrame): void;
  49289. }
  49290. }
  49291. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49292. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49293. import { Scene } from "babylonjs/scene";
  49294. /**
  49295. * A construction function type to create a new controller based on an xrInput object
  49296. */
  49297. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49298. /**
  49299. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49300. *
  49301. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49302. * it should be replaced with auto-loaded controllers.
  49303. *
  49304. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49305. */
  49306. export class WebXRMotionControllerManager {
  49307. private static _AvailableControllers;
  49308. private static _Fallbacks;
  49309. private static _ProfileLoadingPromises;
  49310. private static _ProfilesList;
  49311. /**
  49312. * The base URL of the online controller repository. Can be changed at any time.
  49313. */
  49314. static BaseRepositoryUrl: string;
  49315. /**
  49316. * Which repository gets priority - local or online
  49317. */
  49318. static PrioritizeOnlineRepository: boolean;
  49319. /**
  49320. * Use the online repository, or use only locally-defined controllers
  49321. */
  49322. static UseOnlineRepository: boolean;
  49323. /**
  49324. * Clear the cache used for profile loading and reload when requested again
  49325. */
  49326. static ClearProfilesCache(): void;
  49327. /**
  49328. * Register the default fallbacks.
  49329. * This function is called automatically when this file is imported.
  49330. */
  49331. static DefaultFallbacks(): void;
  49332. /**
  49333. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49334. * @param profileId the profile to which a fallback needs to be found
  49335. * @return an array with corresponding fallback profiles
  49336. */
  49337. static FindFallbackWithProfileId(profileId: string): string[];
  49338. /**
  49339. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49340. * The order of search:
  49341. *
  49342. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49343. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49344. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49345. * 4) return the generic trigger controller if none were found
  49346. *
  49347. * @param xrInput the xrInput to which a new controller is initialized
  49348. * @param scene the scene to which the model will be added
  49349. * @param forceProfile force a certain profile for this controller
  49350. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49351. */
  49352. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49353. /**
  49354. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49355. *
  49356. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49357. *
  49358. * @param type the profile type to register
  49359. * @param constructFunction the function to be called when loading this profile
  49360. */
  49361. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49362. /**
  49363. * Register a fallback to a specific profile.
  49364. * @param profileId the profileId that will receive the fallbacks
  49365. * @param fallbacks A list of fallback profiles
  49366. */
  49367. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49368. /**
  49369. * Will update the list of profiles available in the repository
  49370. * @return a promise that resolves to a map of profiles available online
  49371. */
  49372. static UpdateProfilesList(): Promise<{
  49373. [profile: string]: string;
  49374. }>;
  49375. private static _LoadProfileFromRepository;
  49376. private static _LoadProfilesFromAvailableControllers;
  49377. }
  49378. }
  49379. declare module "babylonjs/XR/webXRInputSource" {
  49380. import { Observable } from "babylonjs/Misc/observable";
  49381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49382. import { Ray } from "babylonjs/Culling/ray";
  49383. import { Scene } from "babylonjs/scene";
  49384. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49385. /**
  49386. * Configuration options for the WebXR controller creation
  49387. */
  49388. export interface IWebXRControllerOptions {
  49389. /**
  49390. * Should the controller mesh be animated when a user interacts with it
  49391. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49392. */
  49393. disableMotionControllerAnimation?: boolean;
  49394. /**
  49395. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49396. */
  49397. doNotLoadControllerMesh?: boolean;
  49398. /**
  49399. * Force a specific controller type for this controller.
  49400. * This can be used when creating your own profile or when testing different controllers
  49401. */
  49402. forceControllerProfile?: string;
  49403. /**
  49404. * Defines a rendering group ID for meshes that will be loaded.
  49405. * This is for the default controllers only.
  49406. */
  49407. renderingGroupId?: number;
  49408. }
  49409. /**
  49410. * Represents an XR controller
  49411. */
  49412. export class WebXRInputSource {
  49413. private _scene;
  49414. /** The underlying input source for the controller */
  49415. inputSource: XRInputSource;
  49416. private _options;
  49417. private _tmpVector;
  49418. private _uniqueId;
  49419. /**
  49420. * 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
  49421. */
  49422. grip?: AbstractMesh;
  49423. /**
  49424. * If available, this is the gamepad object related to this controller.
  49425. * Using this object it is possible to get click events and trackpad changes of the
  49426. * webxr controller that is currently being used.
  49427. */
  49428. motionController?: WebXRAbstractMotionController;
  49429. /**
  49430. * Event that fires when the controller is removed/disposed.
  49431. * The object provided as event data is this controller, after associated assets were disposed.
  49432. * uniqueId is still available.
  49433. */
  49434. onDisposeObservable: Observable<WebXRInputSource>;
  49435. /**
  49436. * Will be triggered when the mesh associated with the motion controller is done loading.
  49437. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49438. * A shortened version of controller -> motion controller -> on mesh loaded.
  49439. */
  49440. onMeshLoadedObservable: Observable<AbstractMesh>;
  49441. /**
  49442. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49443. */
  49444. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49445. /**
  49446. * Pointer which can be used to select objects or attach a visible laser to
  49447. */
  49448. pointer: AbstractMesh;
  49449. /**
  49450. * Creates the input source object
  49451. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49452. * @param _scene the scene which the controller should be associated to
  49453. * @param inputSource the underlying input source for the controller
  49454. * @param _options options for this controller creation
  49455. */
  49456. constructor(_scene: Scene,
  49457. /** The underlying input source for the controller */
  49458. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49459. /**
  49460. * Get this controllers unique id
  49461. */
  49462. get uniqueId(): string;
  49463. /**
  49464. * Disposes of the object
  49465. */
  49466. dispose(): void;
  49467. /**
  49468. * Gets a world space ray coming from the pointer or grip
  49469. * @param result the resulting ray
  49470. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49471. */
  49472. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49473. /**
  49474. * Updates the controller pose based on the given XRFrame
  49475. * @param xrFrame xr frame to update the pose with
  49476. * @param referenceSpace reference space to use
  49477. */
  49478. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49479. }
  49480. }
  49481. declare module "babylonjs/XR/webXRInput" {
  49482. import { Observable } from "babylonjs/Misc/observable";
  49483. import { IDisposable } from "babylonjs/scene";
  49484. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49485. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49486. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49487. /**
  49488. * The schema for initialization options of the XR Input class
  49489. */
  49490. export interface IWebXRInputOptions {
  49491. /**
  49492. * If set to true no model will be automatically loaded
  49493. */
  49494. doNotLoadControllerMeshes?: boolean;
  49495. /**
  49496. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49497. * If not found, the xr input profile data will be used.
  49498. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49499. */
  49500. forceInputProfile?: string;
  49501. /**
  49502. * Do not send a request to the controller repository to load the profile.
  49503. *
  49504. * Instead, use the controllers available in babylon itself.
  49505. */
  49506. disableOnlineControllerRepository?: boolean;
  49507. /**
  49508. * A custom URL for the controllers repository
  49509. */
  49510. customControllersRepositoryURL?: string;
  49511. /**
  49512. * Should the controller model's components not move according to the user input
  49513. */
  49514. disableControllerAnimation?: boolean;
  49515. /**
  49516. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49517. */
  49518. controllerOptions?: IWebXRControllerOptions;
  49519. }
  49520. /**
  49521. * XR input used to track XR inputs such as controllers/rays
  49522. */
  49523. export class WebXRInput implements IDisposable {
  49524. /**
  49525. * the xr session manager for this session
  49526. */
  49527. xrSessionManager: WebXRSessionManager;
  49528. /**
  49529. * the WebXR camera for this session. Mainly used for teleportation
  49530. */
  49531. xrCamera: WebXRCamera;
  49532. private readonly options;
  49533. /**
  49534. * XR controllers being tracked
  49535. */
  49536. controllers: Array<WebXRInputSource>;
  49537. private _frameObserver;
  49538. private _sessionEndedObserver;
  49539. private _sessionInitObserver;
  49540. /**
  49541. * Event when a controller has been connected/added
  49542. */
  49543. onControllerAddedObservable: Observable<WebXRInputSource>;
  49544. /**
  49545. * Event when a controller has been removed/disconnected
  49546. */
  49547. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49548. /**
  49549. * Initializes the WebXRInput
  49550. * @param xrSessionManager the xr session manager for this session
  49551. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49552. * @param options = initialization options for this xr input
  49553. */
  49554. constructor(
  49555. /**
  49556. * the xr session manager for this session
  49557. */
  49558. xrSessionManager: WebXRSessionManager,
  49559. /**
  49560. * the WebXR camera for this session. Mainly used for teleportation
  49561. */
  49562. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49563. private _onInputSourcesChange;
  49564. private _addAndRemoveControllers;
  49565. /**
  49566. * Disposes of the object
  49567. */
  49568. dispose(): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49572. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49573. import { Observable, EventState } from "babylonjs/Misc/observable";
  49574. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49575. /**
  49576. * This is the base class for all WebXR features.
  49577. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49578. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49579. */
  49580. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49581. protected _xrSessionManager: WebXRSessionManager;
  49582. private _attached;
  49583. private _removeOnDetach;
  49584. /**
  49585. * Should auto-attach be disabled?
  49586. */
  49587. disableAutoAttach: boolean;
  49588. /**
  49589. * Construct a new (abstract) WebXR feature
  49590. * @param _xrSessionManager the xr session manager for this feature
  49591. */
  49592. constructor(_xrSessionManager: WebXRSessionManager);
  49593. /**
  49594. * Is this feature attached
  49595. */
  49596. get attached(): boolean;
  49597. /**
  49598. * attach this feature
  49599. *
  49600. * @param force should attachment be forced (even when already attached)
  49601. * @returns true if successful, false is failed or already attached
  49602. */
  49603. attach(force?: boolean): boolean;
  49604. /**
  49605. * detach this feature.
  49606. *
  49607. * @returns true if successful, false if failed or already detached
  49608. */
  49609. detach(): boolean;
  49610. /**
  49611. * Dispose this feature and all of the resources attached
  49612. */
  49613. dispose(): void;
  49614. /**
  49615. * This is used to register callbacks that will automatically be removed when detach is called.
  49616. * @param observable the observable to which the observer will be attached
  49617. * @param callback the callback to register
  49618. */
  49619. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49620. /**
  49621. * Code in this function will be executed on each xrFrame received from the browser.
  49622. * This function will not execute after the feature is detached.
  49623. * @param _xrFrame the current frame
  49624. */
  49625. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49626. }
  49627. }
  49628. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49629. import { IDisposable, Scene } from "babylonjs/scene";
  49630. import { Nullable } from "babylonjs/types";
  49631. import { Observable } from "babylonjs/Misc/observable";
  49632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49633. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49634. import { Camera } from "babylonjs/Cameras/camera";
  49635. /**
  49636. * Renders a layer on top of an existing scene
  49637. */
  49638. export class UtilityLayerRenderer implements IDisposable {
  49639. /** the original scene that will be rendered on top of */
  49640. originalScene: Scene;
  49641. private _pointerCaptures;
  49642. private _lastPointerEvents;
  49643. private static _DefaultUtilityLayer;
  49644. private static _DefaultKeepDepthUtilityLayer;
  49645. private _sharedGizmoLight;
  49646. private _renderCamera;
  49647. /**
  49648. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49649. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49650. * @returns the camera that is used when rendering the utility layer
  49651. */
  49652. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49653. /**
  49654. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49655. * @param cam the camera that should be used when rendering the utility layer
  49656. */
  49657. setRenderCamera(cam: Nullable<Camera>): void;
  49658. /**
  49659. * @hidden
  49660. * Light which used by gizmos to get light shading
  49661. */
  49662. _getSharedGizmoLight(): HemisphericLight;
  49663. /**
  49664. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49665. */
  49666. pickUtilitySceneFirst: boolean;
  49667. /**
  49668. * 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)
  49669. */
  49670. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49671. /**
  49672. * 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)
  49673. */
  49674. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49675. /**
  49676. * The scene that is rendered on top of the original scene
  49677. */
  49678. utilityLayerScene: Scene;
  49679. /**
  49680. * If the utility layer should automatically be rendered on top of existing scene
  49681. */
  49682. shouldRender: boolean;
  49683. /**
  49684. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49685. */
  49686. onlyCheckPointerDownEvents: boolean;
  49687. /**
  49688. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49689. */
  49690. processAllEvents: boolean;
  49691. /**
  49692. * Observable raised when the pointer move from the utility layer scene to the main scene
  49693. */
  49694. onPointerOutObservable: Observable<number>;
  49695. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49696. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49697. private _afterRenderObserver;
  49698. private _sceneDisposeObserver;
  49699. private _originalPointerObserver;
  49700. /**
  49701. * Instantiates a UtilityLayerRenderer
  49702. * @param originalScene the original scene that will be rendered on top of
  49703. * @param handleEvents boolean indicating if the utility layer should handle events
  49704. */
  49705. constructor(
  49706. /** the original scene that will be rendered on top of */
  49707. originalScene: Scene, handleEvents?: boolean);
  49708. private _notifyObservers;
  49709. /**
  49710. * Renders the utility layers scene on top of the original scene
  49711. */
  49712. render(): void;
  49713. /**
  49714. * Disposes of the renderer
  49715. */
  49716. dispose(): void;
  49717. private _updateCamera;
  49718. }
  49719. }
  49720. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49721. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49723. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49724. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49725. import { Scene } from "babylonjs/scene";
  49726. import { Nullable } from "babylonjs/types";
  49727. import { Color3 } from "babylonjs/Maths/math.color";
  49728. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49729. /**
  49730. * Options interface for the pointer selection module
  49731. */
  49732. export interface IWebXRControllerPointerSelectionOptions {
  49733. /**
  49734. * if provided, this scene will be used to render meshes.
  49735. */
  49736. customUtilityLayerScene?: Scene;
  49737. /**
  49738. * 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)
  49739. * If not disabled, the last picked point will be used to execute a pointer up event
  49740. * If disabled, pointer up event will be triggered right after the pointer down event.
  49741. * Used in screen and gaze target ray mode only
  49742. */
  49743. disablePointerUpOnTouchOut: boolean;
  49744. /**
  49745. * For gaze mode (time to select instead of press)
  49746. */
  49747. forceGazeMode: boolean;
  49748. /**
  49749. * 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
  49750. * to start a new countdown to the pointer down event.
  49751. * Defaults to 1.
  49752. */
  49753. gazeModePointerMovedFactor?: number;
  49754. /**
  49755. * Different button type to use instead of the main component
  49756. */
  49757. overrideButtonId?: string;
  49758. /**
  49759. * use this rendering group id for the meshes (optional)
  49760. */
  49761. renderingGroupId?: number;
  49762. /**
  49763. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49764. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49765. * 3000 means 3 seconds between pointing at something and selecting it
  49766. */
  49767. timeToSelect?: number;
  49768. /**
  49769. * Should meshes created here be added to a utility layer or the main scene
  49770. */
  49771. useUtilityLayer?: boolean;
  49772. /**
  49773. * the xr input to use with this pointer selection
  49774. */
  49775. xrInput: WebXRInput;
  49776. }
  49777. /**
  49778. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49779. */
  49780. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49781. private readonly _options;
  49782. private static _idCounter;
  49783. private _attachController;
  49784. private _controllers;
  49785. private _scene;
  49786. private _tmpVectorForPickCompare;
  49787. /**
  49788. * The module's name
  49789. */
  49790. static readonly Name: string;
  49791. /**
  49792. * The (Babylon) version of this module.
  49793. * This is an integer representing the implementation version.
  49794. * This number does not correspond to the WebXR specs version
  49795. */
  49796. static readonly Version: number;
  49797. /**
  49798. * Disable lighting on the laser pointer (so it will always be visible)
  49799. */
  49800. disablePointerLighting: boolean;
  49801. /**
  49802. * Disable lighting on the selection mesh (so it will always be visible)
  49803. */
  49804. disableSelectionMeshLighting: boolean;
  49805. /**
  49806. * Should the laser pointer be displayed
  49807. */
  49808. displayLaserPointer: boolean;
  49809. /**
  49810. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49811. */
  49812. displaySelectionMesh: boolean;
  49813. /**
  49814. * This color will be set to the laser pointer when selection is triggered
  49815. */
  49816. laserPointerPickedColor: Color3;
  49817. /**
  49818. * Default color of the laser pointer
  49819. */
  49820. laserPointerDefaultColor: Color3;
  49821. /**
  49822. * default color of the selection ring
  49823. */
  49824. selectionMeshDefaultColor: Color3;
  49825. /**
  49826. * This color will be applied to the selection ring when selection is triggered
  49827. */
  49828. selectionMeshPickedColor: Color3;
  49829. /**
  49830. * Optional filter to be used for ray selection. This predicate shares behavior with
  49831. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49832. */
  49833. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49834. /**
  49835. * constructs a new background remover module
  49836. * @param _xrSessionManager the session manager for this module
  49837. * @param _options read-only options to be used in this module
  49838. */
  49839. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49840. /**
  49841. * attach this feature
  49842. * Will usually be called by the features manager
  49843. *
  49844. * @returns true if successful.
  49845. */
  49846. attach(): boolean;
  49847. /**
  49848. * detach this feature.
  49849. * Will usually be called by the features manager
  49850. *
  49851. * @returns true if successful.
  49852. */
  49853. detach(): boolean;
  49854. /**
  49855. * Will get the mesh under a specific pointer.
  49856. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49857. * @param controllerId the controllerId to check
  49858. * @returns The mesh under pointer or null if no mesh is under the pointer
  49859. */
  49860. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49861. /**
  49862. * Get the xr controller that correlates to the pointer id in the pointer event
  49863. *
  49864. * @param id the pointer id to search for
  49865. * @returns the controller that correlates to this id or null if not found
  49866. */
  49867. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49868. protected _onXRFrame(_xrFrame: XRFrame): void;
  49869. private _attachGazeMode;
  49870. private _attachScreenRayMode;
  49871. private _attachTrackedPointerRayMode;
  49872. private _convertNormalToDirectionOfRay;
  49873. private _detachController;
  49874. private _generateNewMeshPair;
  49875. private _pickingMoved;
  49876. private _updatePointerDistance;
  49877. /** @hidden */
  49878. get lasterPointerDefaultColor(): Color3;
  49879. }
  49880. }
  49881. declare module "babylonjs/XR/webXREnterExitUI" {
  49882. import { Nullable } from "babylonjs/types";
  49883. import { Observable } from "babylonjs/Misc/observable";
  49884. import { IDisposable, Scene } from "babylonjs/scene";
  49885. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49886. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49887. /**
  49888. * Button which can be used to enter a different mode of XR
  49889. */
  49890. export class WebXREnterExitUIButton {
  49891. /** button element */
  49892. element: HTMLElement;
  49893. /** XR initialization options for the button */
  49894. sessionMode: XRSessionMode;
  49895. /** Reference space type */
  49896. referenceSpaceType: XRReferenceSpaceType;
  49897. /**
  49898. * Creates a WebXREnterExitUIButton
  49899. * @param element button element
  49900. * @param sessionMode XR initialization session mode
  49901. * @param referenceSpaceType the type of reference space to be used
  49902. */
  49903. constructor(
  49904. /** button element */
  49905. element: HTMLElement,
  49906. /** XR initialization options for the button */
  49907. sessionMode: XRSessionMode,
  49908. /** Reference space type */
  49909. referenceSpaceType: XRReferenceSpaceType);
  49910. /**
  49911. * Extendable function which can be used to update the button's visuals when the state changes
  49912. * @param activeButton the current active button in the UI
  49913. */
  49914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49915. }
  49916. /**
  49917. * Options to create the webXR UI
  49918. */
  49919. export class WebXREnterExitUIOptions {
  49920. /**
  49921. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49922. */
  49923. customButtons?: Array<WebXREnterExitUIButton>;
  49924. /**
  49925. * A reference space type to use when creating the default button.
  49926. * Default is local-floor
  49927. */
  49928. referenceSpaceType?: XRReferenceSpaceType;
  49929. /**
  49930. * Context to enter xr with
  49931. */
  49932. renderTarget?: Nullable<WebXRRenderTarget>;
  49933. /**
  49934. * A session mode to use when creating the default button.
  49935. * Default is immersive-vr
  49936. */
  49937. sessionMode?: XRSessionMode;
  49938. /**
  49939. * A list of optional features to init the session with
  49940. */
  49941. optionalFeatures?: string[];
  49942. /**
  49943. * A list of optional features to init the session with
  49944. */
  49945. requiredFeatures?: string[];
  49946. }
  49947. /**
  49948. * UI to allow the user to enter/exit XR mode
  49949. */
  49950. export class WebXREnterExitUI implements IDisposable {
  49951. private scene;
  49952. /** version of the options passed to this UI */
  49953. options: WebXREnterExitUIOptions;
  49954. private _activeButton;
  49955. private _buttons;
  49956. private _overlay;
  49957. /**
  49958. * Fired every time the active button is changed.
  49959. *
  49960. * When xr is entered via a button that launches xr that button will be the callback parameter
  49961. *
  49962. * When exiting xr the callback parameter will be null)
  49963. */
  49964. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49965. /**
  49966. *
  49967. * @param scene babylon scene object to use
  49968. * @param options (read-only) version of the options passed to this UI
  49969. */
  49970. private constructor();
  49971. /**
  49972. * Creates UI to allow the user to enter/exit XR mode
  49973. * @param scene the scene to add the ui to
  49974. * @param helper the xr experience helper to enter/exit xr with
  49975. * @param options options to configure the UI
  49976. * @returns the created ui
  49977. */
  49978. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49979. /**
  49980. * Disposes of the XR UI component
  49981. */
  49982. dispose(): void;
  49983. private _updateButtons;
  49984. }
  49985. }
  49986. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49987. import { Vector3 } from "babylonjs/Maths/math.vector";
  49988. import { Color4 } from "babylonjs/Maths/math.color";
  49989. import { Nullable } from "babylonjs/types";
  49990. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49991. import { Scene } from "babylonjs/scene";
  49992. /**
  49993. * Class containing static functions to help procedurally build meshes
  49994. */
  49995. export class LinesBuilder {
  49996. /**
  49997. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49998. * * 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
  49999. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50000. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50001. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50002. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50003. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50004. * * 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
  50005. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50008. * @param name defines the name of the new line system
  50009. * @param options defines the options used to create the line system
  50010. * @param scene defines the hosting scene
  50011. * @returns a new line system mesh
  50012. */
  50013. static CreateLineSystem(name: string, options: {
  50014. lines: Vector3[][];
  50015. updatable?: boolean;
  50016. instance?: Nullable<LinesMesh>;
  50017. colors?: Nullable<Color4[][]>;
  50018. useVertexAlpha?: boolean;
  50019. }, scene: Nullable<Scene>): LinesMesh;
  50020. /**
  50021. * Creates a line mesh
  50022. * 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
  50023. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50024. * * The parameter `points` is an array successive Vector3
  50025. * * 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
  50026. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50027. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50028. * * When updating an instance, remember that only point positions can change, not the number of points
  50029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50031. * @param name defines the name of the new line system
  50032. * @param options defines the options used to create the line system
  50033. * @param scene defines the hosting scene
  50034. * @returns a new line mesh
  50035. */
  50036. static CreateLines(name: string, options: {
  50037. points: Vector3[];
  50038. updatable?: boolean;
  50039. instance?: Nullable<LinesMesh>;
  50040. colors?: Color4[];
  50041. useVertexAlpha?: boolean;
  50042. }, scene?: Nullable<Scene>): LinesMesh;
  50043. /**
  50044. * Creates a dashed line mesh
  50045. * * 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
  50046. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50047. * * The parameter `points` is an array successive Vector3
  50048. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50049. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50050. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50051. * * 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
  50052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50053. * * When updating an instance, remember that only point positions can change, not the number of points
  50054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50055. * @param name defines the name of the mesh
  50056. * @param options defines the options used to create the mesh
  50057. * @param scene defines the hosting scene
  50058. * @returns the dashed line mesh
  50059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50060. */
  50061. static CreateDashedLines(name: string, options: {
  50062. points: Vector3[];
  50063. dashSize?: number;
  50064. gapSize?: number;
  50065. dashNb?: number;
  50066. updatable?: boolean;
  50067. instance?: LinesMesh;
  50068. useVertexAlpha?: boolean;
  50069. }, scene?: Nullable<Scene>): LinesMesh;
  50070. }
  50071. }
  50072. declare module "babylonjs/Misc/timer" {
  50073. import { Observable, Observer } from "babylonjs/Misc/observable";
  50074. import { Nullable } from "babylonjs/types";
  50075. import { IDisposable } from "babylonjs/scene";
  50076. /**
  50077. * Construction options for a timer
  50078. */
  50079. export interface ITimerOptions<T> {
  50080. /**
  50081. * Time-to-end
  50082. */
  50083. timeout: number;
  50084. /**
  50085. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50086. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50087. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50088. */
  50089. contextObservable: Observable<T>;
  50090. /**
  50091. * Optional parameters when adding an observer to the observable
  50092. */
  50093. observableParameters?: {
  50094. mask?: number;
  50095. insertFirst?: boolean;
  50096. scope?: any;
  50097. };
  50098. /**
  50099. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50100. */
  50101. breakCondition?: (data?: ITimerData<T>) => boolean;
  50102. /**
  50103. * Will be triggered when the time condition has met
  50104. */
  50105. onEnded?: (data: ITimerData<any>) => void;
  50106. /**
  50107. * Will be triggered when the break condition has met (prematurely ended)
  50108. */
  50109. onAborted?: (data: ITimerData<any>) => void;
  50110. /**
  50111. * Optional function to execute on each tick (or count)
  50112. */
  50113. onTick?: (data: ITimerData<any>) => void;
  50114. }
  50115. /**
  50116. * An interface defining the data sent by the timer
  50117. */
  50118. export interface ITimerData<T> {
  50119. /**
  50120. * When did it start
  50121. */
  50122. startTime: number;
  50123. /**
  50124. * Time now
  50125. */
  50126. currentTime: number;
  50127. /**
  50128. * Time passed since started
  50129. */
  50130. deltaTime: number;
  50131. /**
  50132. * How much is completed, in [0.0...1.0].
  50133. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50134. */
  50135. completeRate: number;
  50136. /**
  50137. * What the registered observable sent in the last count
  50138. */
  50139. payload: T;
  50140. }
  50141. /**
  50142. * The current state of the timer
  50143. */
  50144. export enum TimerState {
  50145. /**
  50146. * Timer initialized, not yet started
  50147. */
  50148. INIT = 0,
  50149. /**
  50150. * Timer started and counting
  50151. */
  50152. STARTED = 1,
  50153. /**
  50154. * Timer ended (whether aborted or time reached)
  50155. */
  50156. ENDED = 2
  50157. }
  50158. /**
  50159. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50160. *
  50161. * @param options options with which to initialize this timer
  50162. */
  50163. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50164. /**
  50165. * An advanced implementation of a timer class
  50166. */
  50167. export class AdvancedTimer<T = any> implements IDisposable {
  50168. /**
  50169. * Will notify each time the timer calculates the remaining time
  50170. */
  50171. onEachCountObservable: Observable<ITimerData<T>>;
  50172. /**
  50173. * Will trigger when the timer was aborted due to the break condition
  50174. */
  50175. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50176. /**
  50177. * Will trigger when the timer ended successfully
  50178. */
  50179. onTimerEndedObservable: Observable<ITimerData<T>>;
  50180. /**
  50181. * Will trigger when the timer state has changed
  50182. */
  50183. onStateChangedObservable: Observable<TimerState>;
  50184. private _observer;
  50185. private _contextObservable;
  50186. private _observableParameters;
  50187. private _startTime;
  50188. private _timer;
  50189. private _state;
  50190. private _breakCondition;
  50191. private _timeToEnd;
  50192. private _breakOnNextTick;
  50193. /**
  50194. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50195. * @param options construction options for this advanced timer
  50196. */
  50197. constructor(options: ITimerOptions<T>);
  50198. /**
  50199. * set a breaking condition for this timer. Default is to never break during count
  50200. * @param predicate the new break condition. Returns true to break, false otherwise
  50201. */
  50202. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50203. /**
  50204. * Reset ALL associated observables in this advanced timer
  50205. */
  50206. clearObservables(): void;
  50207. /**
  50208. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50209. *
  50210. * @param timeToEnd how much time to measure until timer ended
  50211. */
  50212. start(timeToEnd?: number): void;
  50213. /**
  50214. * Will force a stop on the next tick.
  50215. */
  50216. stop(): void;
  50217. /**
  50218. * Dispose this timer, clearing all resources
  50219. */
  50220. dispose(): void;
  50221. private _setState;
  50222. private _tick;
  50223. private _stop;
  50224. }
  50225. }
  50226. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50227. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50228. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50229. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50231. import { Vector3 } from "babylonjs/Maths/math.vector";
  50232. import { Material } from "babylonjs/Materials/material";
  50233. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50234. import { Scene } from "babylonjs/scene";
  50235. /**
  50236. * The options container for the teleportation module
  50237. */
  50238. export interface IWebXRTeleportationOptions {
  50239. /**
  50240. * if provided, this scene will be used to render meshes.
  50241. */
  50242. customUtilityLayerScene?: Scene;
  50243. /**
  50244. * Values to configure the default target mesh
  50245. */
  50246. defaultTargetMeshOptions?: {
  50247. /**
  50248. * Fill color of the teleportation area
  50249. */
  50250. teleportationFillColor?: string;
  50251. /**
  50252. * Border color for the teleportation area
  50253. */
  50254. teleportationBorderColor?: string;
  50255. /**
  50256. * Disable the mesh's animation sequence
  50257. */
  50258. disableAnimation?: boolean;
  50259. /**
  50260. * Disable lighting on the material or the ring and arrow
  50261. */
  50262. disableLighting?: boolean;
  50263. /**
  50264. * Override the default material of the torus and arrow
  50265. */
  50266. torusArrowMaterial?: Material;
  50267. };
  50268. /**
  50269. * A list of meshes to use as floor meshes.
  50270. * Meshes can be added and removed after initializing the feature using the
  50271. * addFloorMesh and removeFloorMesh functions
  50272. * If empty, rotation will still work
  50273. */
  50274. floorMeshes?: AbstractMesh[];
  50275. /**
  50276. * use this rendering group id for the meshes (optional)
  50277. */
  50278. renderingGroupId?: number;
  50279. /**
  50280. * Should teleportation move only to snap points
  50281. */
  50282. snapPointsOnly?: boolean;
  50283. /**
  50284. * An array of points to which the teleportation will snap to.
  50285. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50286. */
  50287. snapPositions?: Vector3[];
  50288. /**
  50289. * How close should the teleportation ray be in order to snap to position.
  50290. * Default to 0.8 units (meters)
  50291. */
  50292. snapToPositionRadius?: number;
  50293. /**
  50294. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50295. * If you want to support rotation, make sure your mesh has a direction indicator.
  50296. *
  50297. * When left untouched, the default mesh will be initialized.
  50298. */
  50299. teleportationTargetMesh?: AbstractMesh;
  50300. /**
  50301. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50302. */
  50303. timeToTeleport?: number;
  50304. /**
  50305. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50306. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50307. */
  50308. useMainComponentOnly?: boolean;
  50309. /**
  50310. * Should meshes created here be added to a utility layer or the main scene
  50311. */
  50312. useUtilityLayer?: boolean;
  50313. /**
  50314. * Babylon XR Input class for controller
  50315. */
  50316. xrInput: WebXRInput;
  50317. }
  50318. /**
  50319. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50320. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50321. * the input of the attached controllers.
  50322. */
  50323. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50324. private _options;
  50325. private _controllers;
  50326. private _currentTeleportationControllerId;
  50327. private _floorMeshes;
  50328. private _quadraticBezierCurve;
  50329. private _selectionFeature;
  50330. private _snapToPositions;
  50331. private _snappedToPoint;
  50332. private _teleportationRingMaterial?;
  50333. private _tmpRay;
  50334. private _tmpVector;
  50335. /**
  50336. * The module's name
  50337. */
  50338. static readonly Name: string;
  50339. /**
  50340. * The (Babylon) version of this module.
  50341. * This is an integer representing the implementation version.
  50342. * This number does not correspond to the webxr specs version
  50343. */
  50344. static readonly Version: number;
  50345. /**
  50346. * Is movement backwards enabled
  50347. */
  50348. backwardsMovementEnabled: boolean;
  50349. /**
  50350. * Distance to travel when moving backwards
  50351. */
  50352. backwardsTeleportationDistance: number;
  50353. /**
  50354. * The distance from the user to the inspection point in the direction of the controller
  50355. * A higher number will allow the user to move further
  50356. * defaults to 5 (meters, in xr units)
  50357. */
  50358. parabolicCheckRadius: number;
  50359. /**
  50360. * Should the module support parabolic ray on top of direct ray
  50361. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50362. * Very helpful when moving between floors / different heights
  50363. */
  50364. parabolicRayEnabled: boolean;
  50365. /**
  50366. * How much rotation should be applied when rotating right and left
  50367. */
  50368. rotationAngle: number;
  50369. /**
  50370. * Is rotation enabled when moving forward?
  50371. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50372. */
  50373. rotationEnabled: boolean;
  50374. /**
  50375. * constructs a new anchor system
  50376. * @param _xrSessionManager an instance of WebXRSessionManager
  50377. * @param _options configuration object for this feature
  50378. */
  50379. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50380. /**
  50381. * Get the snapPointsOnly flag
  50382. */
  50383. get snapPointsOnly(): boolean;
  50384. /**
  50385. * Sets the snapPointsOnly flag
  50386. * @param snapToPoints should teleportation be exclusively to snap points
  50387. */
  50388. set snapPointsOnly(snapToPoints: boolean);
  50389. /**
  50390. * Add a new mesh to the floor meshes array
  50391. * @param mesh the mesh to use as floor mesh
  50392. */
  50393. addFloorMesh(mesh: AbstractMesh): void;
  50394. /**
  50395. * Add a new snap-to point to fix teleportation to this position
  50396. * @param newSnapPoint The new Snap-To point
  50397. */
  50398. addSnapPoint(newSnapPoint: Vector3): void;
  50399. attach(): boolean;
  50400. detach(): boolean;
  50401. dispose(): void;
  50402. /**
  50403. * Remove a mesh from the floor meshes array
  50404. * @param mesh the mesh to remove
  50405. */
  50406. removeFloorMesh(mesh: AbstractMesh): void;
  50407. /**
  50408. * Remove a mesh from the floor meshes array using its name
  50409. * @param name the mesh name to remove
  50410. */
  50411. removeFloorMeshByName(name: string): void;
  50412. /**
  50413. * 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
  50414. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50415. * @returns was the point found and removed or not
  50416. */
  50417. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50418. /**
  50419. * This function sets a selection feature that will be disabled when
  50420. * the forward ray is shown and will be reattached when hidden.
  50421. * This is used to remove the selection rays when moving.
  50422. * @param selectionFeature the feature to disable when forward movement is enabled
  50423. */
  50424. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50425. protected _onXRFrame(_xrFrame: XRFrame): void;
  50426. private _attachController;
  50427. private _createDefaultTargetMesh;
  50428. private _detachController;
  50429. private _findClosestSnapPointWithRadius;
  50430. private _setTargetMeshPosition;
  50431. private _setTargetMeshVisibility;
  50432. private _showParabolicPath;
  50433. private _teleportForward;
  50434. }
  50435. }
  50436. declare module "babylonjs/XR/webXRDefaultExperience" {
  50437. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50438. import { Scene } from "babylonjs/scene";
  50439. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50440. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50441. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50442. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50444. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50445. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50446. /**
  50447. * Options for the default xr helper
  50448. */
  50449. export class WebXRDefaultExperienceOptions {
  50450. /**
  50451. * Enable or disable default UI to enter XR
  50452. */
  50453. disableDefaultUI?: boolean;
  50454. /**
  50455. * Should teleportation not initialize. defaults to false.
  50456. */
  50457. disableTeleportation?: boolean;
  50458. /**
  50459. * Floor meshes that will be used for teleport
  50460. */
  50461. floorMeshes?: Array<AbstractMesh>;
  50462. /**
  50463. * If set to true, the first frame will not be used to reset position
  50464. * The first frame is mainly used when copying transformation from the old camera
  50465. * Mainly used in AR
  50466. */
  50467. ignoreNativeCameraTransformation?: boolean;
  50468. /**
  50469. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50470. */
  50471. inputOptions?: IWebXRInputOptions;
  50472. /**
  50473. * optional configuration for the output canvas
  50474. */
  50475. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50476. /**
  50477. * optional UI options. This can be used among other to change session mode and reference space type
  50478. */
  50479. uiOptions?: WebXREnterExitUIOptions;
  50480. /**
  50481. * When loading teleportation and pointer select, use stable versions instead of latest.
  50482. */
  50483. useStablePlugins?: boolean;
  50484. /**
  50485. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50486. */
  50487. renderingGroupId?: number;
  50488. /**
  50489. * A list of optional features to init the session with
  50490. * If set to true, all features we support will be added
  50491. */
  50492. optionalFeatures?: boolean | string[];
  50493. }
  50494. /**
  50495. * Default experience which provides a similar setup to the previous webVRExperience
  50496. */
  50497. export class WebXRDefaultExperience {
  50498. /**
  50499. * Base experience
  50500. */
  50501. baseExperience: WebXRExperienceHelper;
  50502. /**
  50503. * Enables ui for entering/exiting xr
  50504. */
  50505. enterExitUI: WebXREnterExitUI;
  50506. /**
  50507. * Input experience extension
  50508. */
  50509. input: WebXRInput;
  50510. /**
  50511. * Enables laser pointer and selection
  50512. */
  50513. pointerSelection: WebXRControllerPointerSelection;
  50514. /**
  50515. * Default target xr should render to
  50516. */
  50517. renderTarget: WebXRRenderTarget;
  50518. /**
  50519. * Enables teleportation
  50520. */
  50521. teleportation: WebXRMotionControllerTeleportation;
  50522. private constructor();
  50523. /**
  50524. * Creates the default xr experience
  50525. * @param scene scene
  50526. * @param options options for basic configuration
  50527. * @returns resulting WebXRDefaultExperience
  50528. */
  50529. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50530. /**
  50531. * DIsposes of the experience helper
  50532. */
  50533. dispose(): void;
  50534. }
  50535. }
  50536. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50537. import { Observable } from "babylonjs/Misc/observable";
  50538. import { Nullable } from "babylonjs/types";
  50539. import { Camera } from "babylonjs/Cameras/camera";
  50540. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50541. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50542. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50543. import { Scene } from "babylonjs/scene";
  50544. import { Vector3 } from "babylonjs/Maths/math.vector";
  50545. import { Color3 } from "babylonjs/Maths/math.color";
  50546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50548. import { Mesh } from "babylonjs/Meshes/mesh";
  50549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50550. import { EasingFunction } from "babylonjs/Animations/easing";
  50551. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50552. import "babylonjs/Meshes/Builders/groundBuilder";
  50553. import "babylonjs/Meshes/Builders/torusBuilder";
  50554. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50555. import "babylonjs/Gamepads/gamepadSceneComponent";
  50556. import "babylonjs/Animations/animatable";
  50557. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50558. /**
  50559. * Options to modify the vr teleportation behavior.
  50560. */
  50561. export interface VRTeleportationOptions {
  50562. /**
  50563. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50564. */
  50565. floorMeshName?: string;
  50566. /**
  50567. * A list of meshes to be used as the teleportation floor. (default: empty)
  50568. */
  50569. floorMeshes?: Mesh[];
  50570. /**
  50571. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50572. */
  50573. teleportationMode?: number;
  50574. /**
  50575. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50576. */
  50577. teleportationTime?: number;
  50578. /**
  50579. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50580. */
  50581. teleportationSpeed?: number;
  50582. /**
  50583. * The easing function used in the animation or null for Linear. (default CircleEase)
  50584. */
  50585. easingFunction?: EasingFunction;
  50586. }
  50587. /**
  50588. * Options to modify the vr experience helper's behavior.
  50589. */
  50590. export interface VRExperienceHelperOptions extends WebVROptions {
  50591. /**
  50592. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50593. */
  50594. createDeviceOrientationCamera?: boolean;
  50595. /**
  50596. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50597. */
  50598. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50599. /**
  50600. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50601. */
  50602. laserToggle?: boolean;
  50603. /**
  50604. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50605. */
  50606. floorMeshes?: Mesh[];
  50607. /**
  50608. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50609. */
  50610. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50611. /**
  50612. * Defines if WebXR should be used instead of WebVR (if available)
  50613. */
  50614. useXR?: boolean;
  50615. }
  50616. /**
  50617. * Event containing information after VR has been entered
  50618. */
  50619. export class OnAfterEnteringVRObservableEvent {
  50620. /**
  50621. * If entering vr was successful
  50622. */
  50623. success: boolean;
  50624. }
  50625. /**
  50626. * Helps to quickly add VR support to an existing scene.
  50627. * See https://doc.babylonjs.com/how_to/webvr_helper
  50628. */
  50629. export class VRExperienceHelper {
  50630. /** Options to modify the vr experience helper's behavior. */
  50631. webVROptions: VRExperienceHelperOptions;
  50632. private _scene;
  50633. private _position;
  50634. private _btnVR;
  50635. private _btnVRDisplayed;
  50636. private _webVRsupported;
  50637. private _webVRready;
  50638. private _webVRrequesting;
  50639. private _webVRpresenting;
  50640. private _hasEnteredVR;
  50641. private _fullscreenVRpresenting;
  50642. private _inputElement;
  50643. private _webVRCamera;
  50644. private _vrDeviceOrientationCamera;
  50645. private _deviceOrientationCamera;
  50646. private _existingCamera;
  50647. private _onKeyDown;
  50648. private _onVrDisplayPresentChange;
  50649. private _onVRDisplayChanged;
  50650. private _onVRRequestPresentStart;
  50651. private _onVRRequestPresentComplete;
  50652. /**
  50653. * 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)
  50654. */
  50655. enableGazeEvenWhenNoPointerLock: boolean;
  50656. /**
  50657. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50658. */
  50659. exitVROnDoubleTap: boolean;
  50660. /**
  50661. * Observable raised right before entering VR.
  50662. */
  50663. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50664. /**
  50665. * Observable raised when entering VR has completed.
  50666. */
  50667. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50668. /**
  50669. * Observable raised when exiting VR.
  50670. */
  50671. onExitingVRObservable: Observable<VRExperienceHelper>;
  50672. /**
  50673. * Observable raised when controller mesh is loaded.
  50674. */
  50675. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50676. /** Return this.onEnteringVRObservable
  50677. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50678. */
  50679. get onEnteringVR(): Observable<VRExperienceHelper>;
  50680. /** Return this.onExitingVRObservable
  50681. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50682. */
  50683. get onExitingVR(): Observable<VRExperienceHelper>;
  50684. /** Return this.onControllerMeshLoadedObservable
  50685. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50686. */
  50687. get onControllerMeshLoaded(): Observable<WebVRController>;
  50688. private _rayLength;
  50689. private _useCustomVRButton;
  50690. private _teleportationRequested;
  50691. private _teleportActive;
  50692. private _floorMeshName;
  50693. private _floorMeshesCollection;
  50694. private _teleportationMode;
  50695. private _teleportationTime;
  50696. private _teleportationSpeed;
  50697. private _teleportationEasing;
  50698. private _rotationAllowed;
  50699. private _teleportBackwardsVector;
  50700. private _teleportationTarget;
  50701. private _isDefaultTeleportationTarget;
  50702. private _postProcessMove;
  50703. private _teleportationFillColor;
  50704. private _teleportationBorderColor;
  50705. private _rotationAngle;
  50706. private _haloCenter;
  50707. private _cameraGazer;
  50708. private _padSensibilityUp;
  50709. private _padSensibilityDown;
  50710. private _leftController;
  50711. private _rightController;
  50712. private _gazeColor;
  50713. private _laserColor;
  50714. private _pickedLaserColor;
  50715. private _pickedGazeColor;
  50716. /**
  50717. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50718. */
  50719. onNewMeshSelected: Observable<AbstractMesh>;
  50720. /**
  50721. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50722. * This observable will provide the mesh and the controller used to select the mesh
  50723. */
  50724. onMeshSelectedWithController: Observable<{
  50725. mesh: AbstractMesh;
  50726. controller: WebVRController;
  50727. }>;
  50728. /**
  50729. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50730. */
  50731. onNewMeshPicked: Observable<PickingInfo>;
  50732. private _circleEase;
  50733. /**
  50734. * Observable raised before camera teleportation
  50735. */
  50736. onBeforeCameraTeleport: Observable<Vector3>;
  50737. /**
  50738. * Observable raised after camera teleportation
  50739. */
  50740. onAfterCameraTeleport: Observable<Vector3>;
  50741. /**
  50742. * Observable raised when current selected mesh gets unselected
  50743. */
  50744. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50745. private _raySelectionPredicate;
  50746. /**
  50747. * To be optionaly changed by user to define custom ray selection
  50748. */
  50749. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50750. /**
  50751. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50752. */
  50753. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50754. /**
  50755. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50756. */
  50757. teleportationEnabled: boolean;
  50758. private _defaultHeight;
  50759. private _teleportationInitialized;
  50760. private _interactionsEnabled;
  50761. private _interactionsRequested;
  50762. private _displayGaze;
  50763. private _displayLaserPointer;
  50764. /**
  50765. * The mesh used to display where the user is going to teleport.
  50766. */
  50767. get teleportationTarget(): Mesh;
  50768. /**
  50769. * Sets the mesh to be used to display where the user is going to teleport.
  50770. */
  50771. set teleportationTarget(value: Mesh);
  50772. /**
  50773. * 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
  50774. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50775. * See https://doc.babylonjs.com/resources/baking_transformations
  50776. */
  50777. get gazeTrackerMesh(): Mesh;
  50778. set gazeTrackerMesh(value: Mesh);
  50779. /**
  50780. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50781. */
  50782. updateGazeTrackerScale: boolean;
  50783. /**
  50784. * If the gaze trackers color should be updated when selecting meshes
  50785. */
  50786. updateGazeTrackerColor: boolean;
  50787. /**
  50788. * If the controller laser color should be updated when selecting meshes
  50789. */
  50790. updateControllerLaserColor: boolean;
  50791. /**
  50792. * The gaze tracking mesh corresponding to the left controller
  50793. */
  50794. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50795. /**
  50796. * The gaze tracking mesh corresponding to the right controller
  50797. */
  50798. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50799. /**
  50800. * If the ray of the gaze should be displayed.
  50801. */
  50802. get displayGaze(): boolean;
  50803. /**
  50804. * Sets if the ray of the gaze should be displayed.
  50805. */
  50806. set displayGaze(value: boolean);
  50807. /**
  50808. * If the ray of the LaserPointer should be displayed.
  50809. */
  50810. get displayLaserPointer(): boolean;
  50811. /**
  50812. * Sets if the ray of the LaserPointer should be displayed.
  50813. */
  50814. set displayLaserPointer(value: boolean);
  50815. /**
  50816. * The deviceOrientationCamera used as the camera when not in VR.
  50817. */
  50818. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50819. /**
  50820. * Based on the current WebVR support, returns the current VR camera used.
  50821. */
  50822. get currentVRCamera(): Nullable<Camera>;
  50823. /**
  50824. * The webVRCamera which is used when in VR.
  50825. */
  50826. get webVRCamera(): WebVRFreeCamera;
  50827. /**
  50828. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50829. */
  50830. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50831. /**
  50832. * The html button that is used to trigger entering into VR.
  50833. */
  50834. get vrButton(): Nullable<HTMLButtonElement>;
  50835. private get _teleportationRequestInitiated();
  50836. /**
  50837. * Defines whether or not Pointer lock should be requested when switching to
  50838. * full screen.
  50839. */
  50840. requestPointerLockOnFullScreen: boolean;
  50841. /**
  50842. * If asking to force XR, this will be populated with the default xr experience
  50843. */
  50844. xr: WebXRDefaultExperience;
  50845. /**
  50846. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50847. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50848. */
  50849. xrTestDone: boolean;
  50850. /**
  50851. * Instantiates a VRExperienceHelper.
  50852. * Helps to quickly add VR support to an existing scene.
  50853. * @param scene The scene the VRExperienceHelper belongs to.
  50854. * @param webVROptions Options to modify the vr experience helper's behavior.
  50855. */
  50856. constructor(scene: Scene,
  50857. /** Options to modify the vr experience helper's behavior. */
  50858. webVROptions?: VRExperienceHelperOptions);
  50859. private completeVRInit;
  50860. private _onDefaultMeshLoaded;
  50861. private _onResize;
  50862. private _onFullscreenChange;
  50863. /**
  50864. * Gets a value indicating if we are currently in VR mode.
  50865. */
  50866. get isInVRMode(): boolean;
  50867. private onVrDisplayPresentChange;
  50868. private onVRDisplayChanged;
  50869. private moveButtonToBottomRight;
  50870. private displayVRButton;
  50871. private updateButtonVisibility;
  50872. private _cachedAngularSensibility;
  50873. /**
  50874. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50875. * Otherwise, will use the fullscreen API.
  50876. */
  50877. enterVR(): void;
  50878. /**
  50879. * Attempt to exit VR, or fullscreen.
  50880. */
  50881. exitVR(): void;
  50882. /**
  50883. * The position of the vr experience helper.
  50884. */
  50885. get position(): Vector3;
  50886. /**
  50887. * Sets the position of the vr experience helper.
  50888. */
  50889. set position(value: Vector3);
  50890. /**
  50891. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50892. */
  50893. enableInteractions(): void;
  50894. private get _noControllerIsActive();
  50895. private beforeRender;
  50896. private _isTeleportationFloor;
  50897. /**
  50898. * Adds a floor mesh to be used for teleportation.
  50899. * @param floorMesh the mesh to be used for teleportation.
  50900. */
  50901. addFloorMesh(floorMesh: Mesh): void;
  50902. /**
  50903. * Removes a floor mesh from being used for teleportation.
  50904. * @param floorMesh the mesh to be removed.
  50905. */
  50906. removeFloorMesh(floorMesh: Mesh): void;
  50907. /**
  50908. * Enables interactions and teleportation using the VR controllers and gaze.
  50909. * @param vrTeleportationOptions options to modify teleportation behavior.
  50910. */
  50911. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50912. private _onNewGamepadConnected;
  50913. private _tryEnableInteractionOnController;
  50914. private _onNewGamepadDisconnected;
  50915. private _enableInteractionOnController;
  50916. private _checkTeleportWithRay;
  50917. private _checkRotate;
  50918. private _checkTeleportBackwards;
  50919. private _enableTeleportationOnController;
  50920. private _createTeleportationCircles;
  50921. private _displayTeleportationTarget;
  50922. private _hideTeleportationTarget;
  50923. private _rotateCamera;
  50924. private _moveTeleportationSelectorTo;
  50925. private _workingVector;
  50926. private _workingQuaternion;
  50927. private _workingMatrix;
  50928. /**
  50929. * Time Constant Teleportation Mode
  50930. */
  50931. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50932. /**
  50933. * Speed Constant Teleportation Mode
  50934. */
  50935. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50936. /**
  50937. * Teleports the users feet to the desired location
  50938. * @param location The location where the user's feet should be placed
  50939. */
  50940. teleportCamera(location: Vector3): void;
  50941. private _convertNormalToDirectionOfRay;
  50942. private _castRayAndSelectObject;
  50943. private _notifySelectedMeshUnselected;
  50944. /**
  50945. * Permanently set new colors for the laser pointer
  50946. * @param color the new laser color
  50947. * @param pickedColor the new laser color when picked mesh detected
  50948. */
  50949. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50950. /**
  50951. * Set lighting enabled / disabled on the laser pointer of both controllers
  50952. * @param enabled should the lighting be enabled on the laser pointer
  50953. */
  50954. setLaserLightingState(enabled?: boolean): void;
  50955. /**
  50956. * Permanently set new colors for the gaze pointer
  50957. * @param color the new gaze color
  50958. * @param pickedColor the new gaze color when picked mesh detected
  50959. */
  50960. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50961. /**
  50962. * Sets the color of the laser ray from the vr controllers.
  50963. * @param color new color for the ray.
  50964. */
  50965. changeLaserColor(color: Color3): void;
  50966. /**
  50967. * Sets the color of the ray from the vr headsets gaze.
  50968. * @param color new color for the ray.
  50969. */
  50970. changeGazeColor(color: Color3): void;
  50971. /**
  50972. * Exits VR and disposes of the vr experience helper
  50973. */
  50974. dispose(): void;
  50975. /**
  50976. * Gets the name of the VRExperienceHelper class
  50977. * @returns "VRExperienceHelper"
  50978. */
  50979. getClassName(): string;
  50980. }
  50981. }
  50982. declare module "babylonjs/Cameras/VR/index" {
  50983. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50984. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50985. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50986. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50987. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50988. export * from "babylonjs/Cameras/VR/webVRCamera";
  50989. }
  50990. declare module "babylonjs/Cameras/RigModes/index" {
  50991. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50992. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50993. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50994. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50995. }
  50996. declare module "babylonjs/Cameras/index" {
  50997. export * from "babylonjs/Cameras/Inputs/index";
  50998. export * from "babylonjs/Cameras/cameraInputsManager";
  50999. export * from "babylonjs/Cameras/camera";
  51000. export * from "babylonjs/Cameras/targetCamera";
  51001. export * from "babylonjs/Cameras/freeCamera";
  51002. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51003. export * from "babylonjs/Cameras/touchCamera";
  51004. export * from "babylonjs/Cameras/arcRotateCamera";
  51005. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51006. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51007. export * from "babylonjs/Cameras/flyCamera";
  51008. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51009. export * from "babylonjs/Cameras/followCamera";
  51010. export * from "babylonjs/Cameras/followCameraInputsManager";
  51011. export * from "babylonjs/Cameras/gamepadCamera";
  51012. export * from "babylonjs/Cameras/Stereoscopic/index";
  51013. export * from "babylonjs/Cameras/universalCamera";
  51014. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51015. export * from "babylonjs/Cameras/VR/index";
  51016. export * from "babylonjs/Cameras/RigModes/index";
  51017. }
  51018. declare module "babylonjs/Collisions/index" {
  51019. export * from "babylonjs/Collisions/collider";
  51020. export * from "babylonjs/Collisions/collisionCoordinator";
  51021. export * from "babylonjs/Collisions/pickingInfo";
  51022. export * from "babylonjs/Collisions/intersectionInfo";
  51023. export * from "babylonjs/Collisions/meshCollisionData";
  51024. }
  51025. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51026. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51027. import { Vector3 } from "babylonjs/Maths/math.vector";
  51028. import { Ray } from "babylonjs/Culling/ray";
  51029. import { Plane } from "babylonjs/Maths/math.plane";
  51030. /**
  51031. * Contains an array of blocks representing the octree
  51032. */
  51033. export interface IOctreeContainer<T> {
  51034. /**
  51035. * Blocks within the octree
  51036. */
  51037. blocks: Array<OctreeBlock<T>>;
  51038. }
  51039. /**
  51040. * Class used to store a cell in an octree
  51041. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51042. */
  51043. export class OctreeBlock<T> {
  51044. /**
  51045. * Gets the content of the current block
  51046. */
  51047. entries: T[];
  51048. /**
  51049. * Gets the list of block children
  51050. */
  51051. blocks: Array<OctreeBlock<T>>;
  51052. private _depth;
  51053. private _maxDepth;
  51054. private _capacity;
  51055. private _minPoint;
  51056. private _maxPoint;
  51057. private _boundingVectors;
  51058. private _creationFunc;
  51059. /**
  51060. * Creates a new block
  51061. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51062. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51063. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51064. * @param depth defines the current depth of this block in the octree
  51065. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51066. * @param creationFunc defines a callback to call when an element is added to the block
  51067. */
  51068. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51069. /**
  51070. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51071. */
  51072. get capacity(): number;
  51073. /**
  51074. * Gets the minimum vector (in world space) of the block's bounding box
  51075. */
  51076. get minPoint(): Vector3;
  51077. /**
  51078. * Gets the maximum vector (in world space) of the block's bounding box
  51079. */
  51080. get maxPoint(): Vector3;
  51081. /**
  51082. * Add a new element to this block
  51083. * @param entry defines the element to add
  51084. */
  51085. addEntry(entry: T): void;
  51086. /**
  51087. * Remove an element from this block
  51088. * @param entry defines the element to remove
  51089. */
  51090. removeEntry(entry: T): void;
  51091. /**
  51092. * Add an array of elements to this block
  51093. * @param entries defines the array of elements to add
  51094. */
  51095. addEntries(entries: T[]): void;
  51096. /**
  51097. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51098. * @param frustumPlanes defines the frustum planes to test
  51099. * @param selection defines the array to store current content if selection is positive
  51100. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51101. */
  51102. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51103. /**
  51104. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51105. * @param sphereCenter defines the bounding sphere center
  51106. * @param sphereRadius defines the bounding sphere radius
  51107. * @param selection defines the array to store current content if selection is positive
  51108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51109. */
  51110. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51111. /**
  51112. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51113. * @param ray defines the ray to test with
  51114. * @param selection defines the array to store current content if selection is positive
  51115. */
  51116. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51117. /**
  51118. * Subdivide the content into child blocks (this block will then be empty)
  51119. */
  51120. createInnerBlocks(): void;
  51121. /**
  51122. * @hidden
  51123. */
  51124. 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;
  51125. }
  51126. }
  51127. declare module "babylonjs/Culling/Octrees/octree" {
  51128. import { SmartArray } from "babylonjs/Misc/smartArray";
  51129. import { Vector3 } from "babylonjs/Maths/math.vector";
  51130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51132. import { Ray } from "babylonjs/Culling/ray";
  51133. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51134. import { Plane } from "babylonjs/Maths/math.plane";
  51135. /**
  51136. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51138. */
  51139. export class Octree<T> {
  51140. /** 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.) */
  51141. maxDepth: number;
  51142. /**
  51143. * Blocks within the octree containing objects
  51144. */
  51145. blocks: Array<OctreeBlock<T>>;
  51146. /**
  51147. * Content stored in the octree
  51148. */
  51149. dynamicContent: T[];
  51150. private _maxBlockCapacity;
  51151. private _selectionContent;
  51152. private _creationFunc;
  51153. /**
  51154. * Creates a octree
  51155. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51156. * @param creationFunc function to be used to instatiate the octree
  51157. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51158. * @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.)
  51159. */
  51160. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51161. /** 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.) */
  51162. maxDepth?: number);
  51163. /**
  51164. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51165. * @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);
  51166. * @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);
  51167. * @param entries meshes to be added to the octree blocks
  51168. */
  51169. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51170. /**
  51171. * Adds a mesh to the octree
  51172. * @param entry Mesh to add to the octree
  51173. */
  51174. addMesh(entry: T): void;
  51175. /**
  51176. * Remove an element from the octree
  51177. * @param entry defines the element to remove
  51178. */
  51179. removeMesh(entry: T): void;
  51180. /**
  51181. * Selects an array of meshes within the frustum
  51182. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51183. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51184. * @returns array of meshes within the frustum
  51185. */
  51186. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51187. /**
  51188. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51189. * @param sphereCenter defines the bounding sphere center
  51190. * @param sphereRadius defines the bounding sphere radius
  51191. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51192. * @returns an array of objects that intersect the sphere
  51193. */
  51194. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51195. /**
  51196. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51197. * @param ray defines the ray to test with
  51198. * @returns array of intersected objects
  51199. */
  51200. intersectsRay(ray: Ray): SmartArray<T>;
  51201. /**
  51202. * Adds a mesh into the octree block if it intersects the block
  51203. */
  51204. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51205. /**
  51206. * Adds a submesh into the octree block if it intersects the block
  51207. */
  51208. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51209. }
  51210. }
  51211. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51212. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51213. import { Scene } from "babylonjs/scene";
  51214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51216. import { Ray } from "babylonjs/Culling/ray";
  51217. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51218. import { Collider } from "babylonjs/Collisions/collider";
  51219. module "babylonjs/scene" {
  51220. interface Scene {
  51221. /**
  51222. * @hidden
  51223. * Backing Filed
  51224. */
  51225. _selectionOctree: Octree<AbstractMesh>;
  51226. /**
  51227. * Gets the octree used to boost mesh selection (picking)
  51228. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51229. */
  51230. selectionOctree: Octree<AbstractMesh>;
  51231. /**
  51232. * Creates or updates the octree used to boost selection (picking)
  51233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51234. * @param maxCapacity defines the maximum capacity per leaf
  51235. * @param maxDepth defines the maximum depth of the octree
  51236. * @returns an octree of AbstractMesh
  51237. */
  51238. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51239. }
  51240. }
  51241. module "babylonjs/Meshes/abstractMesh" {
  51242. interface AbstractMesh {
  51243. /**
  51244. * @hidden
  51245. * Backing Field
  51246. */
  51247. _submeshesOctree: Octree<SubMesh>;
  51248. /**
  51249. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51250. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51251. * @param maxCapacity defines the maximum size of each block (64 by default)
  51252. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51253. * @returns the new octree
  51254. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51255. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51256. */
  51257. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51258. }
  51259. }
  51260. /**
  51261. * Defines the octree scene component responsible to manage any octrees
  51262. * in a given scene.
  51263. */
  51264. export class OctreeSceneComponent {
  51265. /**
  51266. * The component name help to identify the component in the list of scene components.
  51267. */
  51268. readonly name: string;
  51269. /**
  51270. * The scene the component belongs to.
  51271. */
  51272. scene: Scene;
  51273. /**
  51274. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51275. */
  51276. readonly checksIsEnabled: boolean;
  51277. /**
  51278. * Creates a new instance of the component for the given scene
  51279. * @param scene Defines the scene to register the component in
  51280. */
  51281. constructor(scene: Scene);
  51282. /**
  51283. * Registers the component in a given scene
  51284. */
  51285. register(): void;
  51286. /**
  51287. * Return the list of active meshes
  51288. * @returns the list of active meshes
  51289. */
  51290. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51291. /**
  51292. * Return the list of active sub meshes
  51293. * @param mesh The mesh to get the candidates sub meshes from
  51294. * @returns the list of active sub meshes
  51295. */
  51296. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51297. private _tempRay;
  51298. /**
  51299. * Return the list of sub meshes intersecting with a given local ray
  51300. * @param mesh defines the mesh to find the submesh for
  51301. * @param localRay defines the ray in local space
  51302. * @returns the list of intersecting sub meshes
  51303. */
  51304. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51305. /**
  51306. * Return the list of sub meshes colliding with a collider
  51307. * @param mesh defines the mesh to find the submesh for
  51308. * @param collider defines the collider to evaluate the collision against
  51309. * @returns the list of colliding sub meshes
  51310. */
  51311. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51312. /**
  51313. * Rebuilds the elements related to this component in case of
  51314. * context lost for instance.
  51315. */
  51316. rebuild(): void;
  51317. /**
  51318. * Disposes the component and the associated ressources.
  51319. */
  51320. dispose(): void;
  51321. }
  51322. }
  51323. declare module "babylonjs/Culling/Octrees/index" {
  51324. export * from "babylonjs/Culling/Octrees/octree";
  51325. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51326. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51327. }
  51328. declare module "babylonjs/Culling/index" {
  51329. export * from "babylonjs/Culling/boundingBox";
  51330. export * from "babylonjs/Culling/boundingInfo";
  51331. export * from "babylonjs/Culling/boundingSphere";
  51332. export * from "babylonjs/Culling/Octrees/index";
  51333. export * from "babylonjs/Culling/ray";
  51334. }
  51335. declare module "babylonjs/Gizmos/gizmo" {
  51336. import { Nullable } from "babylonjs/types";
  51337. import { IDisposable } from "babylonjs/scene";
  51338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51339. import { Mesh } from "babylonjs/Meshes/mesh";
  51340. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51341. /**
  51342. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51343. */
  51344. export class Gizmo implements IDisposable {
  51345. /** The utility layer the gizmo will be added to */
  51346. gizmoLayer: UtilityLayerRenderer;
  51347. /**
  51348. * The root mesh of the gizmo
  51349. */
  51350. _rootMesh: Mesh;
  51351. private _attachedMesh;
  51352. /**
  51353. * Ratio for the scale of the gizmo (Default: 1)
  51354. */
  51355. scaleRatio: number;
  51356. /**
  51357. * If a custom mesh has been set (Default: false)
  51358. */
  51359. protected _customMeshSet: boolean;
  51360. /**
  51361. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51362. * * When set, interactions will be enabled
  51363. */
  51364. get attachedMesh(): Nullable<AbstractMesh>;
  51365. set attachedMesh(value: Nullable<AbstractMesh>);
  51366. /**
  51367. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51368. * @param mesh The mesh to replace the default mesh of the gizmo
  51369. */
  51370. setCustomMesh(mesh: Mesh): void;
  51371. /**
  51372. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51373. */
  51374. updateGizmoRotationToMatchAttachedMesh: boolean;
  51375. /**
  51376. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51377. */
  51378. updateGizmoPositionToMatchAttachedMesh: boolean;
  51379. /**
  51380. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51381. */
  51382. updateScale: boolean;
  51383. protected _interactionsEnabled: boolean;
  51384. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51385. private _beforeRenderObserver;
  51386. private _tempVector;
  51387. /**
  51388. * Creates a gizmo
  51389. * @param gizmoLayer The utility layer the gizmo will be added to
  51390. */
  51391. constructor(
  51392. /** The utility layer the gizmo will be added to */
  51393. gizmoLayer?: UtilityLayerRenderer);
  51394. /**
  51395. * Updates the gizmo to match the attached mesh's position/rotation
  51396. */
  51397. protected _update(): void;
  51398. /**
  51399. * Disposes of the gizmo
  51400. */
  51401. dispose(): void;
  51402. }
  51403. }
  51404. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51405. import { Observable } from "babylonjs/Misc/observable";
  51406. import { Nullable } from "babylonjs/types";
  51407. import { Vector3 } from "babylonjs/Maths/math.vector";
  51408. import { Color3 } from "babylonjs/Maths/math.color";
  51409. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51411. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51412. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51413. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51414. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51415. import { Scene } from "babylonjs/scene";
  51416. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51417. /**
  51418. * Single plane drag gizmo
  51419. */
  51420. export class PlaneDragGizmo extends Gizmo {
  51421. /**
  51422. * Drag behavior responsible for the gizmos dragging interactions
  51423. */
  51424. dragBehavior: PointerDragBehavior;
  51425. private _pointerObserver;
  51426. /**
  51427. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51428. */
  51429. snapDistance: number;
  51430. /**
  51431. * Event that fires each time the gizmo snaps to a new location.
  51432. * * snapDistance is the the change in distance
  51433. */
  51434. onSnapObservable: Observable<{
  51435. snapDistance: number;
  51436. }>;
  51437. private _plane;
  51438. private _coloredMaterial;
  51439. private _hoverMaterial;
  51440. private _isEnabled;
  51441. private _parent;
  51442. /** @hidden */
  51443. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51444. /** @hidden */
  51445. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51446. /**
  51447. * Creates a PlaneDragGizmo
  51448. * @param gizmoLayer The utility layer the gizmo will be added to
  51449. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51450. * @param color The color of the gizmo
  51451. */
  51452. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51453. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51454. /**
  51455. * If the gizmo is enabled
  51456. */
  51457. set isEnabled(value: boolean);
  51458. get isEnabled(): boolean;
  51459. /**
  51460. * Disposes of the gizmo
  51461. */
  51462. dispose(): void;
  51463. }
  51464. }
  51465. declare module "babylonjs/Gizmos/positionGizmo" {
  51466. import { Observable } from "babylonjs/Misc/observable";
  51467. import { Nullable } from "babylonjs/types";
  51468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51469. import { Mesh } from "babylonjs/Meshes/mesh";
  51470. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51471. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51472. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51473. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51474. /**
  51475. * Gizmo that enables dragging a mesh along 3 axis
  51476. */
  51477. export class PositionGizmo extends Gizmo {
  51478. /**
  51479. * Internal gizmo used for interactions on the x axis
  51480. */
  51481. xGizmo: AxisDragGizmo;
  51482. /**
  51483. * Internal gizmo used for interactions on the y axis
  51484. */
  51485. yGizmo: AxisDragGizmo;
  51486. /**
  51487. * Internal gizmo used for interactions on the z axis
  51488. */
  51489. zGizmo: AxisDragGizmo;
  51490. /**
  51491. * Internal gizmo used for interactions on the yz plane
  51492. */
  51493. xPlaneGizmo: PlaneDragGizmo;
  51494. /**
  51495. * Internal gizmo used for interactions on the xz plane
  51496. */
  51497. yPlaneGizmo: PlaneDragGizmo;
  51498. /**
  51499. * Internal gizmo used for interactions on the xy plane
  51500. */
  51501. zPlaneGizmo: PlaneDragGizmo;
  51502. /**
  51503. * private variables
  51504. */
  51505. private _meshAttached;
  51506. private _updateGizmoRotationToMatchAttachedMesh;
  51507. private _snapDistance;
  51508. private _scaleRatio;
  51509. /** Fires an event when any of it's sub gizmos are dragged */
  51510. onDragStartObservable: Observable<unknown>;
  51511. /** Fires an event when any of it's sub gizmos are released from dragging */
  51512. onDragEndObservable: Observable<unknown>;
  51513. /**
  51514. * If set to true, planar drag is enabled
  51515. */
  51516. private _planarGizmoEnabled;
  51517. get attachedMesh(): Nullable<AbstractMesh>;
  51518. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51519. /**
  51520. * Creates a PositionGizmo
  51521. * @param gizmoLayer The utility layer the gizmo will be added to
  51522. */
  51523. constructor(gizmoLayer?: UtilityLayerRenderer);
  51524. /**
  51525. * If the planar drag gizmo is enabled
  51526. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51527. */
  51528. set planarGizmoEnabled(value: boolean);
  51529. get planarGizmoEnabled(): boolean;
  51530. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51531. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51532. /**
  51533. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51534. */
  51535. set snapDistance(value: number);
  51536. get snapDistance(): number;
  51537. /**
  51538. * Ratio for the scale of the gizmo (Default: 1)
  51539. */
  51540. set scaleRatio(value: number);
  51541. get scaleRatio(): number;
  51542. /**
  51543. * Disposes of the gizmo
  51544. */
  51545. dispose(): void;
  51546. /**
  51547. * CustomMeshes are not supported by this gizmo
  51548. * @param mesh The mesh to replace the default mesh of the gizmo
  51549. */
  51550. setCustomMesh(mesh: Mesh): void;
  51551. }
  51552. }
  51553. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51554. import { Observable } from "babylonjs/Misc/observable";
  51555. import { Nullable } from "babylonjs/types";
  51556. import { Vector3 } from "babylonjs/Maths/math.vector";
  51557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51559. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51560. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51561. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51562. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51563. import { Scene } from "babylonjs/scene";
  51564. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51565. import { Color3 } from "babylonjs/Maths/math.color";
  51566. /**
  51567. * Single axis drag gizmo
  51568. */
  51569. export class AxisDragGizmo extends Gizmo {
  51570. /**
  51571. * Drag behavior responsible for the gizmos dragging interactions
  51572. */
  51573. dragBehavior: PointerDragBehavior;
  51574. private _pointerObserver;
  51575. /**
  51576. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51577. */
  51578. snapDistance: number;
  51579. /**
  51580. * Event that fires each time the gizmo snaps to a new location.
  51581. * * snapDistance is the the change in distance
  51582. */
  51583. onSnapObservable: Observable<{
  51584. snapDistance: number;
  51585. }>;
  51586. private _isEnabled;
  51587. private _parent;
  51588. private _arrow;
  51589. private _coloredMaterial;
  51590. private _hoverMaterial;
  51591. /** @hidden */
  51592. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51593. /** @hidden */
  51594. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51595. /**
  51596. * Creates an AxisDragGizmo
  51597. * @param gizmoLayer The utility layer the gizmo will be added to
  51598. * @param dragAxis The axis which the gizmo will be able to drag on
  51599. * @param color The color of the gizmo
  51600. */
  51601. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51602. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51603. /**
  51604. * If the gizmo is enabled
  51605. */
  51606. set isEnabled(value: boolean);
  51607. get isEnabled(): boolean;
  51608. /**
  51609. * Disposes of the gizmo
  51610. */
  51611. dispose(): void;
  51612. }
  51613. }
  51614. declare module "babylonjs/Debug/axesViewer" {
  51615. import { Vector3 } from "babylonjs/Maths/math.vector";
  51616. import { Nullable } from "babylonjs/types";
  51617. import { Scene } from "babylonjs/scene";
  51618. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51619. /**
  51620. * The Axes viewer will show 3 axes in a specific point in space
  51621. */
  51622. export class AxesViewer {
  51623. private _xAxis;
  51624. private _yAxis;
  51625. private _zAxis;
  51626. private _scaleLinesFactor;
  51627. private _instanced;
  51628. /**
  51629. * Gets the hosting scene
  51630. */
  51631. scene: Scene;
  51632. /**
  51633. * Gets or sets a number used to scale line length
  51634. */
  51635. scaleLines: number;
  51636. /** Gets the node hierarchy used to render x-axis */
  51637. get xAxis(): TransformNode;
  51638. /** Gets the node hierarchy used to render y-axis */
  51639. get yAxis(): TransformNode;
  51640. /** Gets the node hierarchy used to render z-axis */
  51641. get zAxis(): TransformNode;
  51642. /**
  51643. * Creates a new AxesViewer
  51644. * @param scene defines the hosting scene
  51645. * @param scaleLines defines a number used to scale line length (1 by default)
  51646. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51647. * @param xAxis defines the node hierarchy used to render the x-axis
  51648. * @param yAxis defines the node hierarchy used to render the y-axis
  51649. * @param zAxis defines the node hierarchy used to render the z-axis
  51650. */
  51651. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51652. /**
  51653. * Force the viewer to update
  51654. * @param position defines the position of the viewer
  51655. * @param xaxis defines the x axis of the viewer
  51656. * @param yaxis defines the y axis of the viewer
  51657. * @param zaxis defines the z axis of the viewer
  51658. */
  51659. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51660. /**
  51661. * Creates an instance of this axes viewer.
  51662. * @returns a new axes viewer with instanced meshes
  51663. */
  51664. createInstance(): AxesViewer;
  51665. /** Releases resources */
  51666. dispose(): void;
  51667. private static _SetRenderingGroupId;
  51668. }
  51669. }
  51670. declare module "babylonjs/Debug/boneAxesViewer" {
  51671. import { Nullable } from "babylonjs/types";
  51672. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51673. import { Vector3 } from "babylonjs/Maths/math.vector";
  51674. import { Mesh } from "babylonjs/Meshes/mesh";
  51675. import { Bone } from "babylonjs/Bones/bone";
  51676. import { Scene } from "babylonjs/scene";
  51677. /**
  51678. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51679. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51680. */
  51681. export class BoneAxesViewer extends AxesViewer {
  51682. /**
  51683. * Gets or sets the target mesh where to display the axes viewer
  51684. */
  51685. mesh: Nullable<Mesh>;
  51686. /**
  51687. * Gets or sets the target bone where to display the axes viewer
  51688. */
  51689. bone: Nullable<Bone>;
  51690. /** Gets current position */
  51691. pos: Vector3;
  51692. /** Gets direction of X axis */
  51693. xaxis: Vector3;
  51694. /** Gets direction of Y axis */
  51695. yaxis: Vector3;
  51696. /** Gets direction of Z axis */
  51697. zaxis: Vector3;
  51698. /**
  51699. * Creates a new BoneAxesViewer
  51700. * @param scene defines the hosting scene
  51701. * @param bone defines the target bone
  51702. * @param mesh defines the target mesh
  51703. * @param scaleLines defines a scaling factor for line length (1 by default)
  51704. */
  51705. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51706. /**
  51707. * Force the viewer to update
  51708. */
  51709. update(): void;
  51710. /** Releases resources */
  51711. dispose(): void;
  51712. }
  51713. }
  51714. declare module "babylonjs/Debug/debugLayer" {
  51715. import { Scene } from "babylonjs/scene";
  51716. /**
  51717. * Interface used to define scene explorer extensibility option
  51718. */
  51719. export interface IExplorerExtensibilityOption {
  51720. /**
  51721. * Define the option label
  51722. */
  51723. label: string;
  51724. /**
  51725. * Defines the action to execute on click
  51726. */
  51727. action: (entity: any) => void;
  51728. }
  51729. /**
  51730. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51731. */
  51732. export interface IExplorerExtensibilityGroup {
  51733. /**
  51734. * Defines a predicate to test if a given type mut be extended
  51735. */
  51736. predicate: (entity: any) => boolean;
  51737. /**
  51738. * Gets the list of options added to a type
  51739. */
  51740. entries: IExplorerExtensibilityOption[];
  51741. }
  51742. /**
  51743. * Interface used to define the options to use to create the Inspector
  51744. */
  51745. export interface IInspectorOptions {
  51746. /**
  51747. * Display in overlay mode (default: false)
  51748. */
  51749. overlay?: boolean;
  51750. /**
  51751. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51752. */
  51753. globalRoot?: HTMLElement;
  51754. /**
  51755. * Display the Scene explorer
  51756. */
  51757. showExplorer?: boolean;
  51758. /**
  51759. * Display the property inspector
  51760. */
  51761. showInspector?: boolean;
  51762. /**
  51763. * Display in embed mode (both panes on the right)
  51764. */
  51765. embedMode?: boolean;
  51766. /**
  51767. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51768. */
  51769. handleResize?: boolean;
  51770. /**
  51771. * Allow the panes to popup (default: true)
  51772. */
  51773. enablePopup?: boolean;
  51774. /**
  51775. * Allow the panes to be closed by users (default: true)
  51776. */
  51777. enableClose?: boolean;
  51778. /**
  51779. * Optional list of extensibility entries
  51780. */
  51781. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51782. /**
  51783. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51784. */
  51785. inspectorURL?: string;
  51786. /**
  51787. * Optional initial tab (default to DebugLayerTab.Properties)
  51788. */
  51789. initialTab?: DebugLayerTab;
  51790. }
  51791. module "babylonjs/scene" {
  51792. interface Scene {
  51793. /**
  51794. * @hidden
  51795. * Backing field
  51796. */
  51797. _debugLayer: DebugLayer;
  51798. /**
  51799. * Gets the debug layer (aka Inspector) associated with the scene
  51800. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51801. */
  51802. debugLayer: DebugLayer;
  51803. }
  51804. }
  51805. /**
  51806. * Enum of inspector action tab
  51807. */
  51808. export enum DebugLayerTab {
  51809. /**
  51810. * Properties tag (default)
  51811. */
  51812. Properties = 0,
  51813. /**
  51814. * Debug tab
  51815. */
  51816. Debug = 1,
  51817. /**
  51818. * Statistics tab
  51819. */
  51820. Statistics = 2,
  51821. /**
  51822. * Tools tab
  51823. */
  51824. Tools = 3,
  51825. /**
  51826. * Settings tab
  51827. */
  51828. Settings = 4
  51829. }
  51830. /**
  51831. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51832. * what is happening in your scene
  51833. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51834. */
  51835. export class DebugLayer {
  51836. /**
  51837. * Define the url to get the inspector script from.
  51838. * By default it uses the babylonjs CDN.
  51839. * @ignoreNaming
  51840. */
  51841. static InspectorURL: string;
  51842. private _scene;
  51843. private BJSINSPECTOR;
  51844. private _onPropertyChangedObservable?;
  51845. /**
  51846. * Observable triggered when a property is changed through the inspector.
  51847. */
  51848. get onPropertyChangedObservable(): any;
  51849. /**
  51850. * Instantiates a new debug layer.
  51851. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51852. * what is happening in your scene
  51853. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51854. * @param scene Defines the scene to inspect
  51855. */
  51856. constructor(scene: Scene);
  51857. /** Creates the inspector window. */
  51858. private _createInspector;
  51859. /**
  51860. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51861. * @param entity defines the entity to select
  51862. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51863. */
  51864. select(entity: any, lineContainerTitles?: string | string[]): void;
  51865. /** Get the inspector from bundle or global */
  51866. private _getGlobalInspector;
  51867. /**
  51868. * Get if the inspector is visible or not.
  51869. * @returns true if visible otherwise, false
  51870. */
  51871. isVisible(): boolean;
  51872. /**
  51873. * Hide the inspector and close its window.
  51874. */
  51875. hide(): void;
  51876. /**
  51877. * Update the scene in the inspector
  51878. */
  51879. setAsActiveScene(): void;
  51880. /**
  51881. * Launch the debugLayer.
  51882. * @param config Define the configuration of the inspector
  51883. * @return a promise fulfilled when the debug layer is visible
  51884. */
  51885. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51886. }
  51887. }
  51888. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51889. import { Nullable } from "babylonjs/types";
  51890. import { Scene } from "babylonjs/scene";
  51891. import { Vector4 } from "babylonjs/Maths/math.vector";
  51892. import { Color4 } from "babylonjs/Maths/math.color";
  51893. import { Mesh } from "babylonjs/Meshes/mesh";
  51894. /**
  51895. * Class containing static functions to help procedurally build meshes
  51896. */
  51897. export class BoxBuilder {
  51898. /**
  51899. * Creates a box mesh
  51900. * * The parameter `size` sets the size (float) of each box side (default 1)
  51901. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51902. * * 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)
  51903. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51905. * * 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
  51906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51907. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51908. * @param name defines the name of the mesh
  51909. * @param options defines the options used to create the mesh
  51910. * @param scene defines the hosting scene
  51911. * @returns the box mesh
  51912. */
  51913. static CreateBox(name: string, options: {
  51914. size?: number;
  51915. width?: number;
  51916. height?: number;
  51917. depth?: number;
  51918. faceUV?: Vector4[];
  51919. faceColors?: Color4[];
  51920. sideOrientation?: number;
  51921. frontUVs?: Vector4;
  51922. backUVs?: Vector4;
  51923. wrap?: boolean;
  51924. topBaseAt?: number;
  51925. bottomBaseAt?: number;
  51926. updatable?: boolean;
  51927. }, scene?: Nullable<Scene>): Mesh;
  51928. }
  51929. }
  51930. declare module "babylonjs/Debug/physicsViewer" {
  51931. import { Nullable } from "babylonjs/types";
  51932. import { Scene } from "babylonjs/scene";
  51933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51934. import { Mesh } from "babylonjs/Meshes/mesh";
  51935. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51936. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51937. /**
  51938. * Used to show the physics impostor around the specific mesh
  51939. */
  51940. export class PhysicsViewer {
  51941. /** @hidden */
  51942. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51943. /** @hidden */
  51944. protected _meshes: Array<Nullable<AbstractMesh>>;
  51945. /** @hidden */
  51946. protected _scene: Nullable<Scene>;
  51947. /** @hidden */
  51948. protected _numMeshes: number;
  51949. /** @hidden */
  51950. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51951. private _renderFunction;
  51952. private _utilityLayer;
  51953. private _debugBoxMesh;
  51954. private _debugSphereMesh;
  51955. private _debugCylinderMesh;
  51956. private _debugMaterial;
  51957. private _debugMeshMeshes;
  51958. /**
  51959. * Creates a new PhysicsViewer
  51960. * @param scene defines the hosting scene
  51961. */
  51962. constructor(scene: Scene);
  51963. /** @hidden */
  51964. protected _updateDebugMeshes(): void;
  51965. /**
  51966. * Renders a specified physic impostor
  51967. * @param impostor defines the impostor to render
  51968. * @param targetMesh defines the mesh represented by the impostor
  51969. * @returns the new debug mesh used to render the impostor
  51970. */
  51971. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51972. /**
  51973. * Hides a specified physic impostor
  51974. * @param impostor defines the impostor to hide
  51975. */
  51976. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51977. private _getDebugMaterial;
  51978. private _getDebugBoxMesh;
  51979. private _getDebugSphereMesh;
  51980. private _getDebugCylinderMesh;
  51981. private _getDebugMeshMesh;
  51982. private _getDebugMesh;
  51983. /** Releases all resources */
  51984. dispose(): void;
  51985. }
  51986. }
  51987. declare module "babylonjs/Debug/rayHelper" {
  51988. import { Nullable } from "babylonjs/types";
  51989. import { Ray } from "babylonjs/Culling/ray";
  51990. import { Vector3 } from "babylonjs/Maths/math.vector";
  51991. import { Color3 } from "babylonjs/Maths/math.color";
  51992. import { Scene } from "babylonjs/scene";
  51993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51994. import "babylonjs/Meshes/Builders/linesBuilder";
  51995. /**
  51996. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51997. * in order to better appreciate the issue one might have.
  51998. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51999. */
  52000. export class RayHelper {
  52001. /**
  52002. * Defines the ray we are currently tryin to visualize.
  52003. */
  52004. ray: Nullable<Ray>;
  52005. private _renderPoints;
  52006. private _renderLine;
  52007. private _renderFunction;
  52008. private _scene;
  52009. private _updateToMeshFunction;
  52010. private _attachedToMesh;
  52011. private _meshSpaceDirection;
  52012. private _meshSpaceOrigin;
  52013. /**
  52014. * Helper function to create a colored helper in a scene in one line.
  52015. * @param ray Defines the ray we are currently tryin to visualize
  52016. * @param scene Defines the scene the ray is used in
  52017. * @param color Defines the color we want to see the ray in
  52018. * @returns The newly created ray helper.
  52019. */
  52020. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52021. /**
  52022. * Instantiate a new ray helper.
  52023. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52024. * in order to better appreciate the issue one might have.
  52025. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52026. * @param ray Defines the ray we are currently tryin to visualize
  52027. */
  52028. constructor(ray: Ray);
  52029. /**
  52030. * Shows the ray we are willing to debug.
  52031. * @param scene Defines the scene the ray needs to be rendered in
  52032. * @param color Defines the color the ray needs to be rendered in
  52033. */
  52034. show(scene: Scene, color?: Color3): void;
  52035. /**
  52036. * Hides the ray we are debugging.
  52037. */
  52038. hide(): void;
  52039. private _render;
  52040. /**
  52041. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52042. * @param mesh Defines the mesh we want the helper attached to
  52043. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52044. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52045. * @param length Defines the length of the ray
  52046. */
  52047. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52048. /**
  52049. * Detach the ray helper from the mesh it has previously been attached to.
  52050. */
  52051. detachFromMesh(): void;
  52052. private _updateToMesh;
  52053. /**
  52054. * Dispose the helper and release its associated resources.
  52055. */
  52056. dispose(): void;
  52057. }
  52058. }
  52059. declare module "babylonjs/Debug/skeletonViewer" {
  52060. import { Color3 } from "babylonjs/Maths/math.color";
  52061. import { Scene } from "babylonjs/scene";
  52062. import { Nullable } from "babylonjs/types";
  52063. import { Skeleton } from "babylonjs/Bones/skeleton";
  52064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52065. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52066. /**
  52067. * Class used to render a debug view of a given skeleton
  52068. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52069. */
  52070. export class SkeletonViewer {
  52071. /** defines the skeleton to render */
  52072. skeleton: Skeleton;
  52073. /** defines the mesh attached to the skeleton */
  52074. mesh: AbstractMesh;
  52075. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52076. autoUpdateBonesMatrices: boolean;
  52077. /** defines the rendering group id to use with the viewer */
  52078. renderingGroupId: number;
  52079. /** Gets or sets the color used to render the skeleton */
  52080. color: Color3;
  52081. private _scene;
  52082. private _debugLines;
  52083. private _debugMesh;
  52084. private _isEnabled;
  52085. private _renderFunction;
  52086. private _utilityLayer;
  52087. /**
  52088. * Returns the mesh used to render the bones
  52089. */
  52090. get debugMesh(): Nullable<LinesMesh>;
  52091. /**
  52092. * Creates a new SkeletonViewer
  52093. * @param skeleton defines the skeleton to render
  52094. * @param mesh defines the mesh attached to the skeleton
  52095. * @param scene defines the hosting scene
  52096. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52097. * @param renderingGroupId defines the rendering group id to use with the viewer
  52098. */
  52099. constructor(
  52100. /** defines the skeleton to render */
  52101. skeleton: Skeleton,
  52102. /** defines the mesh attached to the skeleton */
  52103. mesh: AbstractMesh, scene: Scene,
  52104. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52105. autoUpdateBonesMatrices?: boolean,
  52106. /** defines the rendering group id to use with the viewer */
  52107. renderingGroupId?: number);
  52108. /** Gets or sets a boolean indicating if the viewer is enabled */
  52109. set isEnabled(value: boolean);
  52110. get isEnabled(): boolean;
  52111. private _getBonePosition;
  52112. private _getLinesForBonesWithLength;
  52113. private _getLinesForBonesNoLength;
  52114. /** Update the viewer to sync with current skeleton state */
  52115. update(): void;
  52116. /** Release associated resources */
  52117. dispose(): void;
  52118. }
  52119. }
  52120. declare module "babylonjs/Debug/index" {
  52121. export * from "babylonjs/Debug/axesViewer";
  52122. export * from "babylonjs/Debug/boneAxesViewer";
  52123. export * from "babylonjs/Debug/debugLayer";
  52124. export * from "babylonjs/Debug/physicsViewer";
  52125. export * from "babylonjs/Debug/rayHelper";
  52126. export * from "babylonjs/Debug/skeletonViewer";
  52127. }
  52128. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52129. /**
  52130. * Enum for Device Types
  52131. */
  52132. export enum DeviceType {
  52133. /** Generic */
  52134. Generic = 0,
  52135. /** Keyboard */
  52136. Keyboard = 1,
  52137. /** Mouse */
  52138. Mouse = 2,
  52139. /** Touch Pointers */
  52140. Touch = 3,
  52141. /** PS4 Dual Shock */
  52142. DualShock = 4,
  52143. /** Xbox */
  52144. Xbox = 5,
  52145. /** Switch Controller */
  52146. Switch = 6
  52147. }
  52148. /**
  52149. * Enum for All Pointers (Touch/Mouse)
  52150. */
  52151. export enum PointerInput {
  52152. /** Horizontal Axis */
  52153. Horizontal = 0,
  52154. /** Vertical Axis */
  52155. Vertical = 1,
  52156. /** Left Click or Touch */
  52157. LeftClick = 2,
  52158. /** Middle Click */
  52159. MiddleClick = 3,
  52160. /** Right Click */
  52161. RightClick = 4,
  52162. /** Browser Back */
  52163. BrowserBack = 5,
  52164. /** Browser Forward */
  52165. BrowserForward = 6
  52166. }
  52167. /**
  52168. * Enum for Dual Shock Gamepad
  52169. */
  52170. export enum DualShockInput {
  52171. /** Cross */
  52172. Cross = 0,
  52173. /** Circle */
  52174. Circle = 1,
  52175. /** Square */
  52176. Square = 2,
  52177. /** Triangle */
  52178. Triangle = 3,
  52179. /** L1 */
  52180. L1 = 4,
  52181. /** R1 */
  52182. R1 = 5,
  52183. /** L2 */
  52184. L2 = 6,
  52185. /** R2 */
  52186. R2 = 7,
  52187. /** Share */
  52188. Share = 8,
  52189. /** Options */
  52190. Options = 9,
  52191. /** L3 */
  52192. L3 = 10,
  52193. /** R3 */
  52194. R3 = 11,
  52195. /** DPadUp */
  52196. DPadUp = 12,
  52197. /** DPadDown */
  52198. DPadDown = 13,
  52199. /** DPadLeft */
  52200. DPadLeft = 14,
  52201. /** DRight */
  52202. DPadRight = 15,
  52203. /** Home */
  52204. Home = 16,
  52205. /** TouchPad */
  52206. TouchPad = 17,
  52207. /** LStickXAxis */
  52208. LStickXAxis = 18,
  52209. /** LStickYAxis */
  52210. LStickYAxis = 19,
  52211. /** RStickXAxis */
  52212. RStickXAxis = 20,
  52213. /** RStickYAxis */
  52214. RStickYAxis = 21
  52215. }
  52216. /**
  52217. * Enum for Xbox Gamepad
  52218. */
  52219. export enum XboxInput {
  52220. /** A */
  52221. A = 0,
  52222. /** B */
  52223. B = 1,
  52224. /** X */
  52225. X = 2,
  52226. /** Y */
  52227. Y = 3,
  52228. /** LB */
  52229. LB = 4,
  52230. /** RB */
  52231. RB = 5,
  52232. /** LT */
  52233. LT = 6,
  52234. /** RT */
  52235. RT = 7,
  52236. /** Back */
  52237. Back = 8,
  52238. /** Start */
  52239. Start = 9,
  52240. /** LS */
  52241. LS = 10,
  52242. /** RS */
  52243. RS = 11,
  52244. /** DPadUp */
  52245. DPadUp = 12,
  52246. /** DPadDown */
  52247. DPadDown = 13,
  52248. /** DPadLeft */
  52249. DPadLeft = 14,
  52250. /** DRight */
  52251. DPadRight = 15,
  52252. /** Home */
  52253. Home = 16,
  52254. /** LStickXAxis */
  52255. LStickXAxis = 17,
  52256. /** LStickYAxis */
  52257. LStickYAxis = 18,
  52258. /** RStickXAxis */
  52259. RStickXAxis = 19,
  52260. /** RStickYAxis */
  52261. RStickYAxis = 20
  52262. }
  52263. /**
  52264. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52265. */
  52266. export enum SwitchInput {
  52267. /** B */
  52268. B = 0,
  52269. /** A */
  52270. A = 1,
  52271. /** Y */
  52272. Y = 2,
  52273. /** X */
  52274. X = 3,
  52275. /** L */
  52276. L = 4,
  52277. /** R */
  52278. R = 5,
  52279. /** ZL */
  52280. ZL = 6,
  52281. /** ZR */
  52282. ZR = 7,
  52283. /** Minus */
  52284. Minus = 8,
  52285. /** Plus */
  52286. Plus = 9,
  52287. /** LS */
  52288. LS = 10,
  52289. /** RS */
  52290. RS = 11,
  52291. /** DPadUp */
  52292. DPadUp = 12,
  52293. /** DPadDown */
  52294. DPadDown = 13,
  52295. /** DPadLeft */
  52296. DPadLeft = 14,
  52297. /** DRight */
  52298. DPadRight = 15,
  52299. /** Home */
  52300. Home = 16,
  52301. /** Capture */
  52302. Capture = 17,
  52303. /** LStickXAxis */
  52304. LStickXAxis = 18,
  52305. /** LStickYAxis */
  52306. LStickYAxis = 19,
  52307. /** RStickXAxis */
  52308. RStickXAxis = 20,
  52309. /** RStickYAxis */
  52310. RStickYAxis = 21
  52311. }
  52312. }
  52313. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52314. import { Engine } from "babylonjs/Engines/engine";
  52315. import { IDisposable } from "babylonjs/scene";
  52316. import { Nullable } from "babylonjs/types";
  52317. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52318. /**
  52319. * This class will take all inputs from Keyboard, Pointer, and
  52320. * any Gamepads and provide a polling system that all devices
  52321. * will use. This class assumes that there will only be one
  52322. * pointer device and one keyboard.
  52323. */
  52324. export class DeviceInputSystem implements IDisposable {
  52325. /**
  52326. * Callback to be triggered when a device is connected
  52327. */
  52328. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52329. /**
  52330. * Callback to be triggered when a device is disconnected
  52331. */
  52332. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52333. /**
  52334. * Callback to be triggered when event driven input is updated
  52335. */
  52336. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52337. private _inputs;
  52338. private _gamepads;
  52339. private _keyboardActive;
  52340. private _pointerActive;
  52341. private _elementToAttachTo;
  52342. private _keyboardDownEvent;
  52343. private _keyboardUpEvent;
  52344. private _pointerMoveEvent;
  52345. private _pointerDownEvent;
  52346. private _pointerUpEvent;
  52347. private _gamepadConnectedEvent;
  52348. private _gamepadDisconnectedEvent;
  52349. private static _MAX_KEYCODES;
  52350. private static _MAX_POINTER_INPUTS;
  52351. private constructor();
  52352. /**
  52353. * Creates a new DeviceInputSystem instance
  52354. * @param engine Engine to pull input element from
  52355. * @returns The new instance
  52356. */
  52357. static Create(engine: Engine): DeviceInputSystem;
  52358. /**
  52359. * Checks for current device input value, given an id and input index
  52360. * @param deviceName Id of connected device
  52361. * @param inputIndex Index of device input
  52362. * @returns Current value of input
  52363. */
  52364. /**
  52365. * Checks for current device input value, given an id and input index
  52366. * @param deviceType Enum specifiying device type
  52367. * @param deviceSlot "Slot" or index that device is referenced in
  52368. * @param inputIndex Id of input to be checked
  52369. * @returns Current value of input
  52370. */
  52371. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52372. /**
  52373. * Dispose of all the eventlisteners
  52374. */
  52375. dispose(): void;
  52376. /**
  52377. * Add device and inputs to device array
  52378. * @param deviceType Enum specifiying device type
  52379. * @param deviceSlot "Slot" or index that device is referenced in
  52380. * @param numberOfInputs Number of input entries to create for given device
  52381. */
  52382. private _registerDevice;
  52383. /**
  52384. * Given a specific device name, remove that device from the device map
  52385. * @param deviceType Enum specifiying device type
  52386. * @param deviceSlot "Slot" or index that device is referenced in
  52387. */
  52388. private _unregisterDevice;
  52389. /**
  52390. * Handle all actions that come from keyboard interaction
  52391. */
  52392. private _handleKeyActions;
  52393. /**
  52394. * Handle all actions that come from pointer interaction
  52395. */
  52396. private _handlePointerActions;
  52397. /**
  52398. * Handle all actions that come from gamepad interaction
  52399. */
  52400. private _handleGamepadActions;
  52401. /**
  52402. * Update all non-event based devices with each frame
  52403. * @param deviceType Enum specifiying device type
  52404. * @param deviceSlot "Slot" or index that device is referenced in
  52405. * @param inputIndex Id of input to be checked
  52406. */
  52407. private _updateDevice;
  52408. /**
  52409. * Gets DeviceType from the device name
  52410. * @param deviceName Name of Device from DeviceInputSystem
  52411. * @returns DeviceType enum value
  52412. */
  52413. private _getGamepadDeviceType;
  52414. }
  52415. }
  52416. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52417. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52418. /**
  52419. * Type to handle enforcement of inputs
  52420. */
  52421. 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;
  52422. }
  52423. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52424. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52425. import { Engine } from "babylonjs/Engines/engine";
  52426. import { IDisposable } from "babylonjs/scene";
  52427. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52428. import { Nullable } from "babylonjs/types";
  52429. import { Observable } from "babylonjs/Misc/observable";
  52430. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52431. /**
  52432. * Class that handles all input for a specific device
  52433. */
  52434. export class DeviceSource<T extends DeviceType> {
  52435. /** Type of device */
  52436. readonly deviceType: DeviceType;
  52437. /** "Slot" or index that device is referenced in */
  52438. readonly deviceSlot: number;
  52439. /**
  52440. * Observable to handle device input changes per device
  52441. */
  52442. readonly onInputChangedObservable: Observable<{
  52443. inputIndex: DeviceInput<T>;
  52444. previousState: Nullable<number>;
  52445. currentState: Nullable<number>;
  52446. }>;
  52447. private readonly _deviceInputSystem;
  52448. /**
  52449. * Default Constructor
  52450. * @param deviceInputSystem Reference to DeviceInputSystem
  52451. * @param deviceType Type of device
  52452. * @param deviceSlot "Slot" or index that device is referenced in
  52453. */
  52454. constructor(deviceInputSystem: DeviceInputSystem,
  52455. /** Type of device */
  52456. deviceType: DeviceType,
  52457. /** "Slot" or index that device is referenced in */
  52458. deviceSlot?: number);
  52459. /**
  52460. * Get input for specific input
  52461. * @param inputIndex index of specific input on device
  52462. * @returns Input value from DeviceInputSystem
  52463. */
  52464. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52465. }
  52466. /**
  52467. * Class to keep track of devices
  52468. */
  52469. export class DeviceSourceManager implements IDisposable {
  52470. /**
  52471. * Observable to be triggered when before a device is connected
  52472. */
  52473. readonly onBeforeDeviceConnectedObservable: Observable<{
  52474. deviceType: DeviceType;
  52475. deviceSlot: number;
  52476. }>;
  52477. /**
  52478. * Observable to be triggered when before a device is disconnected
  52479. */
  52480. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52481. deviceType: DeviceType;
  52482. deviceSlot: number;
  52483. }>;
  52484. /**
  52485. * Observable to be triggered when after a device is connected
  52486. */
  52487. readonly onAfterDeviceConnectedObservable: Observable<{
  52488. deviceType: DeviceType;
  52489. deviceSlot: number;
  52490. }>;
  52491. /**
  52492. * Observable to be triggered when after a device is disconnected
  52493. */
  52494. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52495. deviceType: DeviceType;
  52496. deviceSlot: number;
  52497. }>;
  52498. private readonly _devices;
  52499. private readonly _firstDevice;
  52500. private readonly _deviceInputSystem;
  52501. /**
  52502. * Default Constructor
  52503. * @param engine engine to pull input element from
  52504. */
  52505. constructor(engine: Engine);
  52506. /**
  52507. * Gets a DeviceSource, given a type and slot
  52508. * @param deviceType Enum specifying device type
  52509. * @param deviceSlot "Slot" or index that device is referenced in
  52510. * @returns DeviceSource object
  52511. */
  52512. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52513. /**
  52514. * Gets an array of DeviceSource objects for a given device type
  52515. * @param deviceType Enum specifying device type
  52516. * @returns Array of DeviceSource objects
  52517. */
  52518. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52519. /**
  52520. * Dispose of DeviceInputSystem and other parts
  52521. */
  52522. dispose(): void;
  52523. /**
  52524. * Function to add device name to device list
  52525. * @param deviceType Enum specifying device type
  52526. * @param deviceSlot "Slot" or index that device is referenced in
  52527. */
  52528. private _addDevice;
  52529. /**
  52530. * Function to remove device name to device list
  52531. * @param deviceType Enum specifying device type
  52532. * @param deviceSlot "Slot" or index that device is referenced in
  52533. */
  52534. private _removeDevice;
  52535. /**
  52536. * Updates array storing first connected device of each type
  52537. * @param type Type of Device
  52538. */
  52539. private _updateFirstDevices;
  52540. }
  52541. }
  52542. declare module "babylonjs/DeviceInput/index" {
  52543. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52544. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52545. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52546. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52547. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52548. }
  52549. declare module "babylonjs/Engines/nullEngine" {
  52550. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52551. import { Engine } from "babylonjs/Engines/engine";
  52552. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52553. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52555. import { Effect } from "babylonjs/Materials/effect";
  52556. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52558. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52559. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52560. /**
  52561. * Options to create the null engine
  52562. */
  52563. export class NullEngineOptions {
  52564. /**
  52565. * Render width (Default: 512)
  52566. */
  52567. renderWidth: number;
  52568. /**
  52569. * Render height (Default: 256)
  52570. */
  52571. renderHeight: number;
  52572. /**
  52573. * Texture size (Default: 512)
  52574. */
  52575. textureSize: number;
  52576. /**
  52577. * If delta time between frames should be constant
  52578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52579. */
  52580. deterministicLockstep: boolean;
  52581. /**
  52582. * Maximum about of steps between frames (Default: 4)
  52583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52584. */
  52585. lockstepMaxSteps: number;
  52586. }
  52587. /**
  52588. * The null engine class provides support for headless version of babylon.js.
  52589. * This can be used in server side scenario or for testing purposes
  52590. */
  52591. export class NullEngine extends Engine {
  52592. private _options;
  52593. /**
  52594. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52595. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52596. * @returns true if engine is in deterministic lock step mode
  52597. */
  52598. isDeterministicLockStep(): boolean;
  52599. /**
  52600. * Gets the max steps when engine is running in deterministic lock step
  52601. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52602. * @returns the max steps
  52603. */
  52604. getLockstepMaxSteps(): number;
  52605. /**
  52606. * Gets the current hardware scaling level.
  52607. * By default the hardware scaling level is computed from the window device ratio.
  52608. * 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.
  52609. * @returns a number indicating the current hardware scaling level
  52610. */
  52611. getHardwareScalingLevel(): number;
  52612. constructor(options?: NullEngineOptions);
  52613. /**
  52614. * Creates a vertex buffer
  52615. * @param vertices the data for the vertex buffer
  52616. * @returns the new WebGL static buffer
  52617. */
  52618. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52619. /**
  52620. * Creates a new index buffer
  52621. * @param indices defines the content of the index buffer
  52622. * @param updatable defines if the index buffer must be updatable
  52623. * @returns a new webGL buffer
  52624. */
  52625. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52626. /**
  52627. * Clear the current render buffer or the current render target (if any is set up)
  52628. * @param color defines the color to use
  52629. * @param backBuffer defines if the back buffer must be cleared
  52630. * @param depth defines if the depth buffer must be cleared
  52631. * @param stencil defines if the stencil buffer must be cleared
  52632. */
  52633. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52634. /**
  52635. * Gets the current render width
  52636. * @param useScreen defines if screen size must be used (or the current render target if any)
  52637. * @returns a number defining the current render width
  52638. */
  52639. getRenderWidth(useScreen?: boolean): number;
  52640. /**
  52641. * Gets the current render height
  52642. * @param useScreen defines if screen size must be used (or the current render target if any)
  52643. * @returns a number defining the current render height
  52644. */
  52645. getRenderHeight(useScreen?: boolean): number;
  52646. /**
  52647. * Set the WebGL's viewport
  52648. * @param viewport defines the viewport element to be used
  52649. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52650. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52651. */
  52652. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52653. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52654. /**
  52655. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52656. * @param pipelineContext defines the pipeline context to use
  52657. * @param uniformsNames defines the list of uniform names
  52658. * @returns an array of webGL uniform locations
  52659. */
  52660. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52661. /**
  52662. * Gets the lsit of active attributes for a given webGL program
  52663. * @param pipelineContext defines the pipeline context to use
  52664. * @param attributesNames defines the list of attribute names to get
  52665. * @returns an array of indices indicating the offset of each attribute
  52666. */
  52667. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52668. /**
  52669. * Binds an effect to the webGL context
  52670. * @param effect defines the effect to bind
  52671. */
  52672. bindSamplers(effect: Effect): void;
  52673. /**
  52674. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52675. * @param effect defines the effect to activate
  52676. */
  52677. enableEffect(effect: Effect): void;
  52678. /**
  52679. * Set various states to the webGL context
  52680. * @param culling defines backface culling state
  52681. * @param zOffset defines the value to apply to zOffset (0 by default)
  52682. * @param force defines if states must be applied even if cache is up to date
  52683. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52684. */
  52685. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52686. /**
  52687. * Set the value of an uniform to an array of int32
  52688. * @param uniform defines the webGL uniform location where to store the value
  52689. * @param array defines the array of int32 to store
  52690. */
  52691. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52692. /**
  52693. * Set the value of an uniform to an array of int32 (stored as vec2)
  52694. * @param uniform defines the webGL uniform location where to store the value
  52695. * @param array defines the array of int32 to store
  52696. */
  52697. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52698. /**
  52699. * Set the value of an uniform to an array of int32 (stored as vec3)
  52700. * @param uniform defines the webGL uniform location where to store the value
  52701. * @param array defines the array of int32 to store
  52702. */
  52703. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52704. /**
  52705. * Set the value of an uniform to an array of int32 (stored as vec4)
  52706. * @param uniform defines the webGL uniform location where to store the value
  52707. * @param array defines the array of int32 to store
  52708. */
  52709. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52710. /**
  52711. * Set the value of an uniform to an array of float32
  52712. * @param uniform defines the webGL uniform location where to store the value
  52713. * @param array defines the array of float32 to store
  52714. */
  52715. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52716. /**
  52717. * Set the value of an uniform to an array of float32 (stored as vec2)
  52718. * @param uniform defines the webGL uniform location where to store the value
  52719. * @param array defines the array of float32 to store
  52720. */
  52721. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52722. /**
  52723. * Set the value of an uniform to an array of float32 (stored as vec3)
  52724. * @param uniform defines the webGL uniform location where to store the value
  52725. * @param array defines the array of float32 to store
  52726. */
  52727. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52728. /**
  52729. * Set the value of an uniform to an array of float32 (stored as vec4)
  52730. * @param uniform defines the webGL uniform location where to store the value
  52731. * @param array defines the array of float32 to store
  52732. */
  52733. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52734. /**
  52735. * Set the value of an uniform to an array of number
  52736. * @param uniform defines the webGL uniform location where to store the value
  52737. * @param array defines the array of number to store
  52738. */
  52739. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52740. /**
  52741. * Set the value of an uniform to an array of number (stored as vec2)
  52742. * @param uniform defines the webGL uniform location where to store the value
  52743. * @param array defines the array of number to store
  52744. */
  52745. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52746. /**
  52747. * Set the value of an uniform to an array of number (stored as vec3)
  52748. * @param uniform defines the webGL uniform location where to store the value
  52749. * @param array defines the array of number to store
  52750. */
  52751. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52752. /**
  52753. * Set the value of an uniform to an array of number (stored as vec4)
  52754. * @param uniform defines the webGL uniform location where to store the value
  52755. * @param array defines the array of number to store
  52756. */
  52757. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52758. /**
  52759. * Set the value of an uniform to an array of float32 (stored as matrices)
  52760. * @param uniform defines the webGL uniform location where to store the value
  52761. * @param matrices defines the array of float32 to store
  52762. */
  52763. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52764. /**
  52765. * Set the value of an uniform to a matrix (3x3)
  52766. * @param uniform defines the webGL uniform location where to store the value
  52767. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52768. */
  52769. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52770. /**
  52771. * Set the value of an uniform to a matrix (2x2)
  52772. * @param uniform defines the webGL uniform location where to store the value
  52773. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52774. */
  52775. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52776. /**
  52777. * Set the value of an uniform to a number (float)
  52778. * @param uniform defines the webGL uniform location where to store the value
  52779. * @param value defines the float number to store
  52780. */
  52781. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52782. /**
  52783. * Set the value of an uniform to a vec2
  52784. * @param uniform defines the webGL uniform location where to store the value
  52785. * @param x defines the 1st component of the value
  52786. * @param y defines the 2nd component of the value
  52787. */
  52788. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52789. /**
  52790. * Set the value of an uniform to a vec3
  52791. * @param uniform defines the webGL uniform location where to store the value
  52792. * @param x defines the 1st component of the value
  52793. * @param y defines the 2nd component of the value
  52794. * @param z defines the 3rd component of the value
  52795. */
  52796. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52797. /**
  52798. * Set the value of an uniform to a boolean
  52799. * @param uniform defines the webGL uniform location where to store the value
  52800. * @param bool defines the boolean to store
  52801. */
  52802. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52803. /**
  52804. * Set the value of an uniform to a vec4
  52805. * @param uniform defines the webGL uniform location where to store the value
  52806. * @param x defines the 1st component of the value
  52807. * @param y defines the 2nd component of the value
  52808. * @param z defines the 3rd component of the value
  52809. * @param w defines the 4th component of the value
  52810. */
  52811. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52812. /**
  52813. * Sets the current alpha mode
  52814. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52815. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52816. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52817. */
  52818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52819. /**
  52820. * Bind webGl buffers directly to the webGL context
  52821. * @param vertexBuffers defines the vertex buffer to bind
  52822. * @param indexBuffer defines the index buffer to bind
  52823. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52824. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52825. * @param effect defines the effect associated with the vertex buffer
  52826. */
  52827. bindBuffers(vertexBuffers: {
  52828. [key: string]: VertexBuffer;
  52829. }, indexBuffer: DataBuffer, effect: Effect): void;
  52830. /**
  52831. * Force the entire cache to be cleared
  52832. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52833. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52834. */
  52835. wipeCaches(bruteForce?: boolean): void;
  52836. /**
  52837. * Send a draw order
  52838. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52839. * @param indexStart defines the starting index
  52840. * @param indexCount defines the number of index to draw
  52841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52842. */
  52843. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52844. /**
  52845. * Draw a list of indexed primitives
  52846. * @param fillMode defines the primitive to use
  52847. * @param indexStart defines the starting index
  52848. * @param indexCount defines the number of index to draw
  52849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52850. */
  52851. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52852. /**
  52853. * Draw a list of unindexed primitives
  52854. * @param fillMode defines the primitive to use
  52855. * @param verticesStart defines the index of first vertex to draw
  52856. * @param verticesCount defines the count of vertices to draw
  52857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52858. */
  52859. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52860. /** @hidden */
  52861. _createTexture(): WebGLTexture;
  52862. /** @hidden */
  52863. _releaseTexture(texture: InternalTexture): void;
  52864. /**
  52865. * Usually called from Texture.ts.
  52866. * Passed information to create a WebGLTexture
  52867. * @param urlArg defines a value which contains one of the following:
  52868. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52869. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52870. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52872. * @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)
  52873. * @param scene needed for loading to the correct scene
  52874. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52875. * @param onLoad optional callback to be called upon successful completion
  52876. * @param onError optional callback to be called upon failure
  52877. * @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
  52878. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52879. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52880. * @param forcedExtension defines the extension to use to pick the right loader
  52881. * @param mimeType defines an optional mime type
  52882. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52883. */
  52884. 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;
  52885. /**
  52886. * Creates a new render target texture
  52887. * @param size defines the size of the texture
  52888. * @param options defines the options used to create the texture
  52889. * @returns a new render target texture stored in an InternalTexture
  52890. */
  52891. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52892. /**
  52893. * Update the sampling mode of a given texture
  52894. * @param samplingMode defines the required sampling mode
  52895. * @param texture defines the texture to update
  52896. */
  52897. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52898. /**
  52899. * Binds the frame buffer to the specified texture.
  52900. * @param texture The texture to render to or null for the default canvas
  52901. * @param faceIndex The face of the texture to render to in case of cube texture
  52902. * @param requiredWidth The width of the target to render to
  52903. * @param requiredHeight The height of the target to render to
  52904. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52905. * @param lodLevel defines le lod level to bind to the frame buffer
  52906. */
  52907. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52908. /**
  52909. * Unbind the current render target texture from the webGL context
  52910. * @param texture defines the render target texture to unbind
  52911. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52912. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52913. */
  52914. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52915. /**
  52916. * Creates a dynamic vertex buffer
  52917. * @param vertices the data for the dynamic vertex buffer
  52918. * @returns the new WebGL dynamic buffer
  52919. */
  52920. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52921. /**
  52922. * Update the content of a dynamic texture
  52923. * @param texture defines the texture to update
  52924. * @param canvas defines the canvas containing the source
  52925. * @param invertY defines if data must be stored with Y axis inverted
  52926. * @param premulAlpha defines if alpha is stored as premultiplied
  52927. * @param format defines the format of the data
  52928. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52929. */
  52930. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52931. /**
  52932. * Gets a boolean indicating if all created effects are ready
  52933. * @returns true if all effects are ready
  52934. */
  52935. areAllEffectsReady(): boolean;
  52936. /**
  52937. * @hidden
  52938. * Get the current error code of the webGL context
  52939. * @returns the error code
  52940. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52941. */
  52942. getError(): number;
  52943. /** @hidden */
  52944. _getUnpackAlignement(): number;
  52945. /** @hidden */
  52946. _unpackFlipY(value: boolean): void;
  52947. /**
  52948. * Update a dynamic index buffer
  52949. * @param indexBuffer defines the target index buffer
  52950. * @param indices defines the data to update
  52951. * @param offset defines the offset in the target index buffer where update should start
  52952. */
  52953. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52954. /**
  52955. * Updates a dynamic vertex buffer.
  52956. * @param vertexBuffer the vertex buffer to update
  52957. * @param vertices the data used to update the vertex buffer
  52958. * @param byteOffset the byte offset of the data (optional)
  52959. * @param byteLength the byte length of the data (optional)
  52960. */
  52961. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52962. /** @hidden */
  52963. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52964. /** @hidden */
  52965. _bindTexture(channel: number, texture: InternalTexture): void;
  52966. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52967. /**
  52968. * 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
  52969. */
  52970. releaseEffects(): void;
  52971. displayLoadingUI(): void;
  52972. hideLoadingUI(): void;
  52973. /** @hidden */
  52974. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52975. /** @hidden */
  52976. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52977. /** @hidden */
  52978. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52979. /** @hidden */
  52980. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52981. }
  52982. }
  52983. declare module "babylonjs/Instrumentation/timeToken" {
  52984. import { Nullable } from "babylonjs/types";
  52985. /**
  52986. * @hidden
  52987. **/
  52988. export class _TimeToken {
  52989. _startTimeQuery: Nullable<WebGLQuery>;
  52990. _endTimeQuery: Nullable<WebGLQuery>;
  52991. _timeElapsedQuery: Nullable<WebGLQuery>;
  52992. _timeElapsedQueryEnded: boolean;
  52993. }
  52994. }
  52995. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52996. import { Nullable, int } from "babylonjs/types";
  52997. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52998. /** @hidden */
  52999. export class _OcclusionDataStorage {
  53000. /** @hidden */
  53001. occlusionInternalRetryCounter: number;
  53002. /** @hidden */
  53003. isOcclusionQueryInProgress: boolean;
  53004. /** @hidden */
  53005. isOccluded: boolean;
  53006. /** @hidden */
  53007. occlusionRetryCount: number;
  53008. /** @hidden */
  53009. occlusionType: number;
  53010. /** @hidden */
  53011. occlusionQueryAlgorithmType: number;
  53012. }
  53013. module "babylonjs/Engines/engine" {
  53014. interface Engine {
  53015. /**
  53016. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53017. * @return the new query
  53018. */
  53019. createQuery(): WebGLQuery;
  53020. /**
  53021. * Delete and release a webGL query
  53022. * @param query defines the query to delete
  53023. * @return the current engine
  53024. */
  53025. deleteQuery(query: WebGLQuery): Engine;
  53026. /**
  53027. * Check if a given query has resolved and got its value
  53028. * @param query defines the query to check
  53029. * @returns true if the query got its value
  53030. */
  53031. isQueryResultAvailable(query: WebGLQuery): boolean;
  53032. /**
  53033. * Gets the value of a given query
  53034. * @param query defines the query to check
  53035. * @returns the value of the query
  53036. */
  53037. getQueryResult(query: WebGLQuery): number;
  53038. /**
  53039. * Initiates an occlusion query
  53040. * @param algorithmType defines the algorithm to use
  53041. * @param query defines the query to use
  53042. * @returns the current engine
  53043. * @see https://doc.babylonjs.com/features/occlusionquery
  53044. */
  53045. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53046. /**
  53047. * Ends an occlusion query
  53048. * @see https://doc.babylonjs.com/features/occlusionquery
  53049. * @param algorithmType defines the algorithm to use
  53050. * @returns the current engine
  53051. */
  53052. endOcclusionQuery(algorithmType: number): Engine;
  53053. /**
  53054. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53055. * Please note that only one query can be issued at a time
  53056. * @returns a time token used to track the time span
  53057. */
  53058. startTimeQuery(): Nullable<_TimeToken>;
  53059. /**
  53060. * Ends a time query
  53061. * @param token defines the token used to measure the time span
  53062. * @returns the time spent (in ns)
  53063. */
  53064. endTimeQuery(token: _TimeToken): int;
  53065. /** @hidden */
  53066. _currentNonTimestampToken: Nullable<_TimeToken>;
  53067. /** @hidden */
  53068. _createTimeQuery(): WebGLQuery;
  53069. /** @hidden */
  53070. _deleteTimeQuery(query: WebGLQuery): void;
  53071. /** @hidden */
  53072. _getGlAlgorithmType(algorithmType: number): number;
  53073. /** @hidden */
  53074. _getTimeQueryResult(query: WebGLQuery): any;
  53075. /** @hidden */
  53076. _getTimeQueryAvailability(query: WebGLQuery): any;
  53077. }
  53078. }
  53079. module "babylonjs/Meshes/abstractMesh" {
  53080. interface AbstractMesh {
  53081. /**
  53082. * Backing filed
  53083. * @hidden
  53084. */
  53085. __occlusionDataStorage: _OcclusionDataStorage;
  53086. /**
  53087. * Access property
  53088. * @hidden
  53089. */
  53090. _occlusionDataStorage: _OcclusionDataStorage;
  53091. /**
  53092. * 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.
  53093. * The default value is -1 which means don't break the query and wait till the result
  53094. * @see https://doc.babylonjs.com/features/occlusionquery
  53095. */
  53096. occlusionRetryCount: number;
  53097. /**
  53098. * 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:
  53099. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53100. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53101. * * 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.
  53102. * @see https://doc.babylonjs.com/features/occlusionquery
  53103. */
  53104. occlusionType: number;
  53105. /**
  53106. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53107. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53108. * * 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.
  53109. * @see https://doc.babylonjs.com/features/occlusionquery
  53110. */
  53111. occlusionQueryAlgorithmType: number;
  53112. /**
  53113. * 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
  53114. * @see https://doc.babylonjs.com/features/occlusionquery
  53115. */
  53116. isOccluded: boolean;
  53117. /**
  53118. * Flag to check the progress status of the query
  53119. * @see https://doc.babylonjs.com/features/occlusionquery
  53120. */
  53121. isOcclusionQueryInProgress: boolean;
  53122. }
  53123. }
  53124. }
  53125. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53126. import { Nullable } from "babylonjs/types";
  53127. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53128. /** @hidden */
  53129. export var _forceTransformFeedbackToBundle: boolean;
  53130. module "babylonjs/Engines/engine" {
  53131. interface Engine {
  53132. /**
  53133. * Creates a webGL transform feedback object
  53134. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53135. * @returns the webGL transform feedback object
  53136. */
  53137. createTransformFeedback(): WebGLTransformFeedback;
  53138. /**
  53139. * Delete a webGL transform feedback object
  53140. * @param value defines the webGL transform feedback object to delete
  53141. */
  53142. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53143. /**
  53144. * Bind a webGL transform feedback object to the webgl context
  53145. * @param value defines the webGL transform feedback object to bind
  53146. */
  53147. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53148. /**
  53149. * Begins a transform feedback operation
  53150. * @param usePoints defines if points or triangles must be used
  53151. */
  53152. beginTransformFeedback(usePoints: boolean): void;
  53153. /**
  53154. * Ends a transform feedback operation
  53155. */
  53156. endTransformFeedback(): void;
  53157. /**
  53158. * Specify the varyings to use with transform feedback
  53159. * @param program defines the associated webGL program
  53160. * @param value defines the list of strings representing the varying names
  53161. */
  53162. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53163. /**
  53164. * Bind a webGL buffer for a transform feedback operation
  53165. * @param value defines the webGL buffer to bind
  53166. */
  53167. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53168. }
  53169. }
  53170. }
  53171. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53172. import { Scene } from "babylonjs/scene";
  53173. import { Engine } from "babylonjs/Engines/engine";
  53174. import { Texture } from "babylonjs/Materials/Textures/texture";
  53175. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53176. import "babylonjs/Engines/Extensions/engine.multiRender";
  53177. /**
  53178. * Creation options of the multi render target texture.
  53179. */
  53180. export interface IMultiRenderTargetOptions {
  53181. /**
  53182. * Define if the texture needs to create mip maps after render.
  53183. */
  53184. generateMipMaps?: boolean;
  53185. /**
  53186. * Define the types of all the draw buffers we want to create
  53187. */
  53188. types?: number[];
  53189. /**
  53190. * Define the sampling modes of all the draw buffers we want to create
  53191. */
  53192. samplingModes?: number[];
  53193. /**
  53194. * Define if a depth buffer is required
  53195. */
  53196. generateDepthBuffer?: boolean;
  53197. /**
  53198. * Define if a stencil buffer is required
  53199. */
  53200. generateStencilBuffer?: boolean;
  53201. /**
  53202. * Define if a depth texture is required instead of a depth buffer
  53203. */
  53204. generateDepthTexture?: boolean;
  53205. /**
  53206. * Define the number of desired draw buffers
  53207. */
  53208. textureCount?: number;
  53209. /**
  53210. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53211. */
  53212. doNotChangeAspectRatio?: boolean;
  53213. /**
  53214. * Define the default type of the buffers we are creating
  53215. */
  53216. defaultType?: number;
  53217. }
  53218. /**
  53219. * A multi render target, like a render target provides the ability to render to a texture.
  53220. * Unlike the render target, it can render to several draw buffers in one draw.
  53221. * This is specially interesting in deferred rendering or for any effects requiring more than
  53222. * just one color from a single pass.
  53223. */
  53224. export class MultiRenderTarget extends RenderTargetTexture {
  53225. private _internalTextures;
  53226. private _textures;
  53227. private _multiRenderTargetOptions;
  53228. private _count;
  53229. /**
  53230. * Get if draw buffers are currently supported by the used hardware and browser.
  53231. */
  53232. get isSupported(): boolean;
  53233. /**
  53234. * Get the list of textures generated by the multi render target.
  53235. */
  53236. get textures(): Texture[];
  53237. /**
  53238. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53239. */
  53240. get count(): number;
  53241. /**
  53242. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53243. */
  53244. get depthTexture(): Texture;
  53245. /**
  53246. * Set the wrapping mode on U of all the textures we are rendering to.
  53247. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53248. */
  53249. set wrapU(wrap: number);
  53250. /**
  53251. * Set the wrapping mode on V of all the textures we are rendering to.
  53252. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53253. */
  53254. set wrapV(wrap: number);
  53255. /**
  53256. * Instantiate a new multi render target texture.
  53257. * A multi render target, like a render target provides the ability to render to a texture.
  53258. * Unlike the render target, it can render to several draw buffers in one draw.
  53259. * This is specially interesting in deferred rendering or for any effects requiring more than
  53260. * just one color from a single pass.
  53261. * @param name Define the name of the texture
  53262. * @param size Define the size of the buffers to render to
  53263. * @param count Define the number of target we are rendering into
  53264. * @param scene Define the scene the texture belongs to
  53265. * @param options Define the options used to create the multi render target
  53266. */
  53267. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53268. /** @hidden */
  53269. _rebuild(): void;
  53270. private _createInternalTextures;
  53271. private _createTextures;
  53272. /**
  53273. * Define the number of samples used if MSAA is enabled.
  53274. */
  53275. get samples(): number;
  53276. set samples(value: number);
  53277. /**
  53278. * Resize all the textures in the multi render target.
  53279. * Be carrefull as it will recreate all the data in the new texture.
  53280. * @param size Define the new size
  53281. */
  53282. resize(size: any): void;
  53283. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53284. /**
  53285. * Dispose the render targets and their associated resources
  53286. */
  53287. dispose(): void;
  53288. /**
  53289. * Release all the underlying texture used as draw buffers.
  53290. */
  53291. releaseInternalTextures(): void;
  53292. }
  53293. }
  53294. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53295. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53296. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53297. import { Nullable } from "babylonjs/types";
  53298. module "babylonjs/Engines/thinEngine" {
  53299. interface ThinEngine {
  53300. /**
  53301. * Unbind a list of render target textures from the webGL context
  53302. * This is used only when drawBuffer extension or webGL2 are active
  53303. * @param textures defines the render target textures to unbind
  53304. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53305. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53306. */
  53307. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53308. /**
  53309. * Create a multi render target texture
  53310. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53311. * @param size defines the size of the texture
  53312. * @param options defines the creation options
  53313. * @returns the cube texture as an InternalTexture
  53314. */
  53315. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53316. /**
  53317. * Update the sample count for a given multiple render target texture
  53318. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53319. * @param textures defines the textures to update
  53320. * @param samples defines the sample count to set
  53321. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53322. */
  53323. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53324. /**
  53325. * Select a subsets of attachments to draw to.
  53326. * @param attachments gl attachments
  53327. */
  53328. bindAttachments(attachments: number[]): void;
  53329. }
  53330. }
  53331. }
  53332. declare module "babylonjs/Engines/Extensions/engine.views" {
  53333. import { Camera } from "babylonjs/Cameras/camera";
  53334. import { Nullable } from "babylonjs/types";
  53335. /**
  53336. * Class used to define an additional view for the engine
  53337. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53338. */
  53339. export class EngineView {
  53340. /** Defines the canvas where to render the view */
  53341. target: HTMLCanvasElement;
  53342. /** Defines an optional camera used to render the view (will use active camera else) */
  53343. camera?: Camera;
  53344. }
  53345. module "babylonjs/Engines/engine" {
  53346. interface Engine {
  53347. /**
  53348. * Gets or sets the HTML element to use for attaching events
  53349. */
  53350. inputElement: Nullable<HTMLElement>;
  53351. /**
  53352. * Gets the current engine view
  53353. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53354. */
  53355. activeView: Nullable<EngineView>;
  53356. /** Gets or sets the list of views */
  53357. views: EngineView[];
  53358. /**
  53359. * Register a new child canvas
  53360. * @param canvas defines the canvas to register
  53361. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53362. * @returns the associated view
  53363. */
  53364. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53365. /**
  53366. * Remove a registered child canvas
  53367. * @param canvas defines the canvas to remove
  53368. * @returns the current engine
  53369. */
  53370. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53371. }
  53372. }
  53373. }
  53374. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53375. import { Nullable } from "babylonjs/types";
  53376. module "babylonjs/Engines/engine" {
  53377. interface Engine {
  53378. /** @hidden */
  53379. _excludedCompressedTextures: string[];
  53380. /** @hidden */
  53381. _textureFormatInUse: string;
  53382. /**
  53383. * Gets the list of texture formats supported
  53384. */
  53385. readonly texturesSupported: Array<string>;
  53386. /**
  53387. * Gets the texture format in use
  53388. */
  53389. readonly textureFormatInUse: Nullable<string>;
  53390. /**
  53391. * Set the compressed texture extensions or file names to skip.
  53392. *
  53393. * @param skippedFiles defines the list of those texture files you want to skip
  53394. * Example: [".dds", ".env", "myfile.png"]
  53395. */
  53396. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53397. /**
  53398. * Set the compressed texture format to use, based on the formats you have, and the formats
  53399. * supported by the hardware / browser.
  53400. *
  53401. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53402. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53403. * to API arguments needed to compressed textures. This puts the burden on the container
  53404. * generator to house the arcane code for determining these for current & future formats.
  53405. *
  53406. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53407. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53408. *
  53409. * Note: The result of this call is not taken into account when a texture is base64.
  53410. *
  53411. * @param formatsAvailable defines the list of those format families you have created
  53412. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53413. *
  53414. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53415. * @returns The extension selected.
  53416. */
  53417. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53418. }
  53419. }
  53420. }
  53421. declare module "babylonjs/Engines/Extensions/index" {
  53422. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53423. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53424. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53425. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53426. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53427. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53428. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53429. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53430. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53431. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53432. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53433. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53434. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53435. export * from "babylonjs/Engines/Extensions/engine.views";
  53436. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53437. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53438. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53439. }
  53440. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53441. import { Nullable } from "babylonjs/types";
  53442. /**
  53443. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53444. */
  53445. export interface CubeMapInfo {
  53446. /**
  53447. * The pixel array for the front face.
  53448. * This is stored in format, left to right, up to down format.
  53449. */
  53450. front: Nullable<ArrayBufferView>;
  53451. /**
  53452. * The pixel array for the back face.
  53453. * This is stored in format, left to right, up to down format.
  53454. */
  53455. back: Nullable<ArrayBufferView>;
  53456. /**
  53457. * The pixel array for the left face.
  53458. * This is stored in format, left to right, up to down format.
  53459. */
  53460. left: Nullable<ArrayBufferView>;
  53461. /**
  53462. * The pixel array for the right face.
  53463. * This is stored in format, left to right, up to down format.
  53464. */
  53465. right: Nullable<ArrayBufferView>;
  53466. /**
  53467. * The pixel array for the up face.
  53468. * This is stored in format, left to right, up to down format.
  53469. */
  53470. up: Nullable<ArrayBufferView>;
  53471. /**
  53472. * The pixel array for the down face.
  53473. * This is stored in format, left to right, up to down format.
  53474. */
  53475. down: Nullable<ArrayBufferView>;
  53476. /**
  53477. * The size of the cubemap stored.
  53478. *
  53479. * Each faces will be size * size pixels.
  53480. */
  53481. size: number;
  53482. /**
  53483. * The format of the texture.
  53484. *
  53485. * RGBA, RGB.
  53486. */
  53487. format: number;
  53488. /**
  53489. * The type of the texture data.
  53490. *
  53491. * UNSIGNED_INT, FLOAT.
  53492. */
  53493. type: number;
  53494. /**
  53495. * Specifies whether the texture is in gamma space.
  53496. */
  53497. gammaSpace: boolean;
  53498. }
  53499. /**
  53500. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53501. */
  53502. export class PanoramaToCubeMapTools {
  53503. private static FACE_LEFT;
  53504. private static FACE_RIGHT;
  53505. private static FACE_FRONT;
  53506. private static FACE_BACK;
  53507. private static FACE_DOWN;
  53508. private static FACE_UP;
  53509. /**
  53510. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53511. *
  53512. * @param float32Array The source data.
  53513. * @param inputWidth The width of the input panorama.
  53514. * @param inputHeight The height of the input panorama.
  53515. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53516. * @return The cubemap data
  53517. */
  53518. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53519. private static CreateCubemapTexture;
  53520. private static CalcProjectionSpherical;
  53521. }
  53522. }
  53523. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53524. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53526. import { Nullable } from "babylonjs/types";
  53527. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53528. /**
  53529. * Helper class dealing with the extraction of spherical polynomial dataArray
  53530. * from a cube map.
  53531. */
  53532. export class CubeMapToSphericalPolynomialTools {
  53533. private static FileFaces;
  53534. /**
  53535. * Converts a texture to the according Spherical Polynomial data.
  53536. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53537. *
  53538. * @param texture The texture to extract the information from.
  53539. * @return The Spherical Polynomial data.
  53540. */
  53541. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53542. /**
  53543. * Converts a cubemap to the according Spherical Polynomial data.
  53544. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53545. *
  53546. * @param cubeInfo The Cube map to extract the information from.
  53547. * @return The Spherical Polynomial data.
  53548. */
  53549. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53550. }
  53551. }
  53552. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53553. import { Nullable } from "babylonjs/types";
  53554. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53555. module "babylonjs/Materials/Textures/baseTexture" {
  53556. interface BaseTexture {
  53557. /**
  53558. * Get the polynomial representation of the texture data.
  53559. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53560. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53561. */
  53562. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53563. }
  53564. }
  53565. }
  53566. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53568. /** @hidden */
  53569. export var rgbdEncodePixelShader: {
  53570. name: string;
  53571. shader: string;
  53572. };
  53573. }
  53574. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53576. /** @hidden */
  53577. export var rgbdDecodePixelShader: {
  53578. name: string;
  53579. shader: string;
  53580. };
  53581. }
  53582. declare module "babylonjs/Misc/environmentTextureTools" {
  53583. import { Nullable } from "babylonjs/types";
  53584. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53587. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53588. import "babylonjs/Engines/Extensions/engine.readTexture";
  53589. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53590. import "babylonjs/Shaders/rgbdEncode.fragment";
  53591. import "babylonjs/Shaders/rgbdDecode.fragment";
  53592. /**
  53593. * Raw texture data and descriptor sufficient for WebGL texture upload
  53594. */
  53595. export interface EnvironmentTextureInfo {
  53596. /**
  53597. * Version of the environment map
  53598. */
  53599. version: number;
  53600. /**
  53601. * Width of image
  53602. */
  53603. width: number;
  53604. /**
  53605. * Irradiance information stored in the file.
  53606. */
  53607. irradiance: any;
  53608. /**
  53609. * Specular information stored in the file.
  53610. */
  53611. specular: any;
  53612. }
  53613. /**
  53614. * Defines One Image in the file. It requires only the position in the file
  53615. * as well as the length.
  53616. */
  53617. interface BufferImageData {
  53618. /**
  53619. * Length of the image data.
  53620. */
  53621. length: number;
  53622. /**
  53623. * Position of the data from the null terminator delimiting the end of the JSON.
  53624. */
  53625. position: number;
  53626. }
  53627. /**
  53628. * Defines the specular data enclosed in the file.
  53629. * This corresponds to the version 1 of the data.
  53630. */
  53631. export interface EnvironmentTextureSpecularInfoV1 {
  53632. /**
  53633. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53634. */
  53635. specularDataPosition?: number;
  53636. /**
  53637. * This contains all the images data needed to reconstruct the cubemap.
  53638. */
  53639. mipmaps: Array<BufferImageData>;
  53640. /**
  53641. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53642. */
  53643. lodGenerationScale: number;
  53644. }
  53645. /**
  53646. * Sets of helpers addressing the serialization and deserialization of environment texture
  53647. * stored in a BabylonJS env file.
  53648. * Those files are usually stored as .env files.
  53649. */
  53650. export class EnvironmentTextureTools {
  53651. /**
  53652. * Magic number identifying the env file.
  53653. */
  53654. private static _MagicBytes;
  53655. /**
  53656. * Gets the environment info from an env file.
  53657. * @param data The array buffer containing the .env bytes.
  53658. * @returns the environment file info (the json header) if successfully parsed.
  53659. */
  53660. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53661. /**
  53662. * Creates an environment texture from a loaded cube texture.
  53663. * @param texture defines the cube texture to convert in env file
  53664. * @return a promise containing the environment data if succesfull.
  53665. */
  53666. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53667. /**
  53668. * Creates a JSON representation of the spherical data.
  53669. * @param texture defines the texture containing the polynomials
  53670. * @return the JSON representation of the spherical info
  53671. */
  53672. private static _CreateEnvTextureIrradiance;
  53673. /**
  53674. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53675. * @param data the image data
  53676. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53677. * @return the views described by info providing access to the underlying buffer
  53678. */
  53679. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53680. /**
  53681. * Uploads the texture info contained in the env file to the GPU.
  53682. * @param texture defines the internal texture to upload to
  53683. * @param data defines the data to load
  53684. * @param info defines the texture info retrieved through the GetEnvInfo method
  53685. * @returns a promise
  53686. */
  53687. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53688. private static _OnImageReadyAsync;
  53689. /**
  53690. * Uploads the levels of image data to the GPU.
  53691. * @param texture defines the internal texture to upload to
  53692. * @param imageData defines the array buffer views of image data [mipmap][face]
  53693. * @returns a promise
  53694. */
  53695. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53696. /**
  53697. * Uploads spherical polynomials information to the texture.
  53698. * @param texture defines the texture we are trying to upload the information to
  53699. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53700. */
  53701. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53702. /** @hidden */
  53703. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53704. }
  53705. }
  53706. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53707. /**
  53708. * Class used to inline functions in shader code
  53709. */
  53710. export class ShaderCodeInliner {
  53711. private static readonly _RegexpFindFunctionNameAndType;
  53712. private _sourceCode;
  53713. private _functionDescr;
  53714. private _numMaxIterations;
  53715. /** Gets or sets the token used to mark the functions to inline */
  53716. inlineToken: string;
  53717. /** Gets or sets the debug mode */
  53718. debug: boolean;
  53719. /** Gets the code after the inlining process */
  53720. get code(): string;
  53721. /**
  53722. * Initializes the inliner
  53723. * @param sourceCode shader code source to inline
  53724. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53725. */
  53726. constructor(sourceCode: string, numMaxIterations?: number);
  53727. /**
  53728. * Start the processing of the shader code
  53729. */
  53730. processCode(): void;
  53731. private _collectFunctions;
  53732. private _processInlining;
  53733. private _extractBetweenMarkers;
  53734. private _skipWhitespaces;
  53735. private _removeComments;
  53736. private _replaceFunctionCallsByCode;
  53737. private _findBackward;
  53738. private _escapeRegExp;
  53739. private _replaceNames;
  53740. }
  53741. }
  53742. declare module "babylonjs/Engines/nativeEngine" {
  53743. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53744. import { Engine } from "babylonjs/Engines/engine";
  53745. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53748. import { Effect } from "babylonjs/Materials/effect";
  53749. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53750. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53751. import { IColor4Like } from "babylonjs/Maths/math.like";
  53752. import { Scene } from "babylonjs/scene";
  53753. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53754. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53755. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53756. /**
  53757. * Container for accessors for natively-stored mesh data buffers.
  53758. */
  53759. class NativeDataBuffer extends DataBuffer {
  53760. /**
  53761. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53762. */
  53763. nativeIndexBuffer?: any;
  53764. /**
  53765. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53766. */
  53767. nativeVertexBuffer?: any;
  53768. }
  53769. /** @hidden */
  53770. class NativeTexture extends InternalTexture {
  53771. getInternalTexture(): InternalTexture;
  53772. getViewCount(): number;
  53773. }
  53774. /** @hidden */
  53775. export class NativeEngine extends Engine {
  53776. private readonly _native;
  53777. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53778. private readonly INVALID_HANDLE;
  53779. getHardwareScalingLevel(): number;
  53780. constructor();
  53781. dispose(): void;
  53782. /**
  53783. * Can be used to override the current requestAnimationFrame requester.
  53784. * @hidden
  53785. */
  53786. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53787. /**
  53788. * Override default engine behavior.
  53789. * @param color
  53790. * @param backBuffer
  53791. * @param depth
  53792. * @param stencil
  53793. */
  53794. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53795. /**
  53796. * Gets host document
  53797. * @returns the host document object
  53798. */
  53799. getHostDocument(): Nullable<Document>;
  53800. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53801. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53802. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53803. recordVertexArrayObject(vertexBuffers: {
  53804. [key: string]: VertexBuffer;
  53805. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53806. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53807. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53808. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53809. /**
  53810. * Draw a list of indexed primitives
  53811. * @param fillMode defines the primitive to use
  53812. * @param indexStart defines the starting index
  53813. * @param indexCount defines the number of index to draw
  53814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53815. */
  53816. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53817. /**
  53818. * Draw a list of unindexed primitives
  53819. * @param fillMode defines the primitive to use
  53820. * @param verticesStart defines the index of first vertex to draw
  53821. * @param verticesCount defines the count of vertices to draw
  53822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53823. */
  53824. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53825. createPipelineContext(): IPipelineContext;
  53826. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53827. /** @hidden */
  53828. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53829. /** @hidden */
  53830. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53831. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53832. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53833. protected _setProgram(program: WebGLProgram): void;
  53834. _releaseEffect(effect: Effect): void;
  53835. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53836. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53837. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53838. bindSamplers(effect: Effect): void;
  53839. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53840. getRenderWidth(useScreen?: boolean): number;
  53841. getRenderHeight(useScreen?: boolean): number;
  53842. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53843. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53844. /**
  53845. * Set the z offset to apply to current rendering
  53846. * @param value defines the offset to apply
  53847. */
  53848. setZOffset(value: number): void;
  53849. /**
  53850. * Gets the current value of the zOffset
  53851. * @returns the current zOffset state
  53852. */
  53853. getZOffset(): number;
  53854. /**
  53855. * Enable or disable depth buffering
  53856. * @param enable defines the state to set
  53857. */
  53858. setDepthBuffer(enable: boolean): void;
  53859. /**
  53860. * Gets a boolean indicating if depth writing is enabled
  53861. * @returns the current depth writing state
  53862. */
  53863. getDepthWrite(): boolean;
  53864. /**
  53865. * Enable or disable depth writing
  53866. * @param enable defines the state to set
  53867. */
  53868. setDepthWrite(enable: boolean): void;
  53869. /**
  53870. * Enable or disable color writing
  53871. * @param enable defines the state to set
  53872. */
  53873. setColorWrite(enable: boolean): void;
  53874. /**
  53875. * Gets a boolean indicating if color writing is enabled
  53876. * @returns the current color writing state
  53877. */
  53878. getColorWrite(): boolean;
  53879. /**
  53880. * Sets alpha constants used by some alpha blending modes
  53881. * @param r defines the red component
  53882. * @param g defines the green component
  53883. * @param b defines the blue component
  53884. * @param a defines the alpha component
  53885. */
  53886. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53887. /**
  53888. * Sets the current alpha mode
  53889. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53890. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53891. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53892. */
  53893. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53894. /**
  53895. * Gets the current alpha mode
  53896. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53897. * @returns the current alpha mode
  53898. */
  53899. getAlphaMode(): number;
  53900. setInt(uniform: WebGLUniformLocation, int: number): void;
  53901. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53902. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53903. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53904. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53905. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53906. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53907. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53908. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53909. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53910. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53911. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53912. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53913. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53914. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53915. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53916. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53917. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53918. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53919. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53920. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53921. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53922. wipeCaches(bruteForce?: boolean): void;
  53923. _createTexture(): WebGLTexture;
  53924. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53925. /**
  53926. * Usually called from Texture.ts.
  53927. * Passed information to create a WebGLTexture
  53928. * @param url defines a value which contains one of the following:
  53929. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53930. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53931. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53933. * @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)
  53934. * @param scene needed for loading to the correct scene
  53935. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53936. * @param onLoad optional callback to be called upon successful completion
  53937. * @param onError optional callback to be called upon failure
  53938. * @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
  53939. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53940. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53941. * @param forcedExtension defines the extension to use to pick the right loader
  53942. * @param mimeType defines an optional mime type
  53943. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53944. */
  53945. 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;
  53946. /**
  53947. * Creates a cube texture
  53948. * @param rootUrl defines the url where the files to load is located
  53949. * @param scene defines the current scene
  53950. * @param files defines the list of files to load (1 per face)
  53951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53952. * @param onLoad defines an optional callback raised when the texture is loaded
  53953. * @param onError defines an optional callback raised if there is an issue to load the texture
  53954. * @param format defines the format of the data
  53955. * @param forcedExtension defines the extension to use to pick the right loader
  53956. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53957. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53958. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53959. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53960. * @returns the cube texture as an InternalTexture
  53961. */
  53962. 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;
  53963. private _getSamplingFilter;
  53964. private static _GetNativeTextureFormat;
  53965. createRenderTargetTexture(size: number | {
  53966. width: number;
  53967. height: number;
  53968. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53969. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53970. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53971. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53972. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53973. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53974. /**
  53975. * Updates a dynamic vertex buffer.
  53976. * @param vertexBuffer the vertex buffer to update
  53977. * @param data the data used to update the vertex buffer
  53978. * @param byteOffset the byte offset of the data (optional)
  53979. * @param byteLength the byte length of the data (optional)
  53980. */
  53981. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53982. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53983. private _updateAnisotropicLevel;
  53984. private _getAddressMode;
  53985. /** @hidden */
  53986. _bindTexture(channel: number, texture: InternalTexture): void;
  53987. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53988. releaseEffects(): void;
  53989. /** @hidden */
  53990. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53991. /** @hidden */
  53992. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53993. /** @hidden */
  53994. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53995. /** @hidden */
  53996. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53997. }
  53998. }
  53999. declare module "babylonjs/Engines/index" {
  54000. export * from "babylonjs/Engines/constants";
  54001. export * from "babylonjs/Engines/engineCapabilities";
  54002. export * from "babylonjs/Engines/instancingAttributeInfo";
  54003. export * from "babylonjs/Engines/thinEngine";
  54004. export * from "babylonjs/Engines/engine";
  54005. export * from "babylonjs/Engines/engineStore";
  54006. export * from "babylonjs/Engines/nullEngine";
  54007. export * from "babylonjs/Engines/Extensions/index";
  54008. export * from "babylonjs/Engines/IPipelineContext";
  54009. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54010. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54011. export * from "babylonjs/Engines/nativeEngine";
  54012. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54013. }
  54014. declare module "babylonjs/Events/clipboardEvents" {
  54015. /**
  54016. * Gather the list of clipboard event types as constants.
  54017. */
  54018. export class ClipboardEventTypes {
  54019. /**
  54020. * The clipboard event is fired when a copy command is active (pressed).
  54021. */
  54022. static readonly COPY: number;
  54023. /**
  54024. * The clipboard event is fired when a cut command is active (pressed).
  54025. */
  54026. static readonly CUT: number;
  54027. /**
  54028. * The clipboard event is fired when a paste command is active (pressed).
  54029. */
  54030. static readonly PASTE: number;
  54031. }
  54032. /**
  54033. * This class is used to store clipboard related info for the onClipboardObservable event.
  54034. */
  54035. export class ClipboardInfo {
  54036. /**
  54037. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54038. */
  54039. type: number;
  54040. /**
  54041. * Defines the related dom event
  54042. */
  54043. event: ClipboardEvent;
  54044. /**
  54045. *Creates an instance of ClipboardInfo.
  54046. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54047. * @param event Defines the related dom event
  54048. */
  54049. constructor(
  54050. /**
  54051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54052. */
  54053. type: number,
  54054. /**
  54055. * Defines the related dom event
  54056. */
  54057. event: ClipboardEvent);
  54058. /**
  54059. * Get the clipboard event's type from the keycode.
  54060. * @param keyCode Defines the keyCode for the current keyboard event.
  54061. * @return {number}
  54062. */
  54063. static GetTypeFromCharacter(keyCode: number): number;
  54064. }
  54065. }
  54066. declare module "babylonjs/Events/index" {
  54067. export * from "babylonjs/Events/keyboardEvents";
  54068. export * from "babylonjs/Events/pointerEvents";
  54069. export * from "babylonjs/Events/clipboardEvents";
  54070. }
  54071. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54072. import { Scene } from "babylonjs/scene";
  54073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54074. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54075. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54076. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54077. /**
  54078. * Google Daydream controller
  54079. */
  54080. export class DaydreamController extends WebVRController {
  54081. /**
  54082. * Base Url for the controller model.
  54083. */
  54084. static MODEL_BASE_URL: string;
  54085. /**
  54086. * File name for the controller model.
  54087. */
  54088. static MODEL_FILENAME: string;
  54089. /**
  54090. * Gamepad Id prefix used to identify Daydream Controller.
  54091. */
  54092. static readonly GAMEPAD_ID_PREFIX: string;
  54093. /**
  54094. * Creates a new DaydreamController from a gamepad
  54095. * @param vrGamepad the gamepad that the controller should be created from
  54096. */
  54097. constructor(vrGamepad: any);
  54098. /**
  54099. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54100. * @param scene scene in which to add meshes
  54101. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54102. */
  54103. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54104. /**
  54105. * Called once for each button that changed state since the last frame
  54106. * @param buttonIdx Which button index changed
  54107. * @param state New state of the button
  54108. * @param changes Which properties on the state changed since last frame
  54109. */
  54110. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54111. }
  54112. }
  54113. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54114. import { Scene } from "babylonjs/scene";
  54115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54116. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54117. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54118. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54119. /**
  54120. * Gear VR Controller
  54121. */
  54122. export class GearVRController extends WebVRController {
  54123. /**
  54124. * Base Url for the controller model.
  54125. */
  54126. static MODEL_BASE_URL: string;
  54127. /**
  54128. * File name for the controller model.
  54129. */
  54130. static MODEL_FILENAME: string;
  54131. /**
  54132. * Gamepad Id prefix used to identify this controller.
  54133. */
  54134. static readonly GAMEPAD_ID_PREFIX: string;
  54135. private readonly _buttonIndexToObservableNameMap;
  54136. /**
  54137. * Creates a new GearVRController from a gamepad
  54138. * @param vrGamepad the gamepad that the controller should be created from
  54139. */
  54140. constructor(vrGamepad: any);
  54141. /**
  54142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54143. * @param scene scene in which to add meshes
  54144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54145. */
  54146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54147. /**
  54148. * Called once for each button that changed state since the last frame
  54149. * @param buttonIdx Which button index changed
  54150. * @param state New state of the button
  54151. * @param changes Which properties on the state changed since last frame
  54152. */
  54153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54154. }
  54155. }
  54156. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54157. import { Scene } from "babylonjs/scene";
  54158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54159. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54160. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54161. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54162. /**
  54163. * Generic Controller
  54164. */
  54165. export class GenericController extends WebVRController {
  54166. /**
  54167. * Base Url for the controller model.
  54168. */
  54169. static readonly MODEL_BASE_URL: string;
  54170. /**
  54171. * File name for the controller model.
  54172. */
  54173. static readonly MODEL_FILENAME: string;
  54174. /**
  54175. * Creates a new GenericController from a gamepad
  54176. * @param vrGamepad the gamepad that the controller should be created from
  54177. */
  54178. constructor(vrGamepad: any);
  54179. /**
  54180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54181. * @param scene scene in which to add meshes
  54182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54183. */
  54184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54185. /**
  54186. * Called once for each button that changed state since the last frame
  54187. * @param buttonIdx Which button index changed
  54188. * @param state New state of the button
  54189. * @param changes Which properties on the state changed since last frame
  54190. */
  54191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54192. }
  54193. }
  54194. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54195. import { Observable } from "babylonjs/Misc/observable";
  54196. import { Scene } from "babylonjs/scene";
  54197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54198. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54199. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54200. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54201. /**
  54202. * Oculus Touch Controller
  54203. */
  54204. export class OculusTouchController extends WebVRController {
  54205. /**
  54206. * Base Url for the controller model.
  54207. */
  54208. static MODEL_BASE_URL: string;
  54209. /**
  54210. * File name for the left controller model.
  54211. */
  54212. static MODEL_LEFT_FILENAME: string;
  54213. /**
  54214. * File name for the right controller model.
  54215. */
  54216. static MODEL_RIGHT_FILENAME: string;
  54217. /**
  54218. * Base Url for the Quest controller model.
  54219. */
  54220. static QUEST_MODEL_BASE_URL: string;
  54221. /**
  54222. * @hidden
  54223. * If the controllers are running on a device that needs the updated Quest controller models
  54224. */
  54225. static _IsQuest: boolean;
  54226. /**
  54227. * Fired when the secondary trigger on this controller is modified
  54228. */
  54229. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54230. /**
  54231. * Fired when the thumb rest on this controller is modified
  54232. */
  54233. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54234. /**
  54235. * Creates a new OculusTouchController from a gamepad
  54236. * @param vrGamepad the gamepad that the controller should be created from
  54237. */
  54238. constructor(vrGamepad: any);
  54239. /**
  54240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54241. * @param scene scene in which to add meshes
  54242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54243. */
  54244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54245. /**
  54246. * Fired when the A button on this controller is modified
  54247. */
  54248. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54249. /**
  54250. * Fired when the B button on this controller is modified
  54251. */
  54252. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54253. /**
  54254. * Fired when the X button on this controller is modified
  54255. */
  54256. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54257. /**
  54258. * Fired when the Y button on this controller is modified
  54259. */
  54260. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54261. /**
  54262. * Called once for each button that changed state since the last frame
  54263. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54264. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54265. * 2) secondary trigger (same)
  54266. * 3) A (right) X (left), touch, pressed = value
  54267. * 4) B / Y
  54268. * 5) thumb rest
  54269. * @param buttonIdx Which button index changed
  54270. * @param state New state of the button
  54271. * @param changes Which properties on the state changed since last frame
  54272. */
  54273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54274. }
  54275. }
  54276. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54277. import { Scene } from "babylonjs/scene";
  54278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54279. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54280. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54281. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54282. import { Observable } from "babylonjs/Misc/observable";
  54283. /**
  54284. * Vive Controller
  54285. */
  54286. export class ViveController extends WebVRController {
  54287. /**
  54288. * Base Url for the controller model.
  54289. */
  54290. static MODEL_BASE_URL: string;
  54291. /**
  54292. * File name for the controller model.
  54293. */
  54294. static MODEL_FILENAME: string;
  54295. /**
  54296. * Creates a new ViveController from a gamepad
  54297. * @param vrGamepad the gamepad that the controller should be created from
  54298. */
  54299. constructor(vrGamepad: any);
  54300. /**
  54301. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54302. * @param scene scene in which to add meshes
  54303. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54304. */
  54305. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54306. /**
  54307. * Fired when the left button on this controller is modified
  54308. */
  54309. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54310. /**
  54311. * Fired when the right button on this controller is modified
  54312. */
  54313. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54314. /**
  54315. * Fired when the menu button on this controller is modified
  54316. */
  54317. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54318. /**
  54319. * Called once for each button that changed state since the last frame
  54320. * Vive mapping:
  54321. * 0: touchpad
  54322. * 1: trigger
  54323. * 2: left AND right buttons
  54324. * 3: menu button
  54325. * @param buttonIdx Which button index changed
  54326. * @param state New state of the button
  54327. * @param changes Which properties on the state changed since last frame
  54328. */
  54329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54330. }
  54331. }
  54332. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54333. import { Observable } from "babylonjs/Misc/observable";
  54334. import { Scene } from "babylonjs/scene";
  54335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54336. import { Ray } from "babylonjs/Culling/ray";
  54337. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54338. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54339. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54340. /**
  54341. * Defines the WindowsMotionController object that the state of the windows motion controller
  54342. */
  54343. export class WindowsMotionController extends WebVRController {
  54344. /**
  54345. * The base url used to load the left and right controller models
  54346. */
  54347. static MODEL_BASE_URL: string;
  54348. /**
  54349. * The name of the left controller model file
  54350. */
  54351. static MODEL_LEFT_FILENAME: string;
  54352. /**
  54353. * The name of the right controller model file
  54354. */
  54355. static MODEL_RIGHT_FILENAME: string;
  54356. /**
  54357. * The controller name prefix for this controller type
  54358. */
  54359. static readonly GAMEPAD_ID_PREFIX: string;
  54360. /**
  54361. * The controller id pattern for this controller type
  54362. */
  54363. private static readonly GAMEPAD_ID_PATTERN;
  54364. private _loadedMeshInfo;
  54365. protected readonly _mapping: {
  54366. buttons: string[];
  54367. buttonMeshNames: {
  54368. trigger: string;
  54369. menu: string;
  54370. grip: string;
  54371. thumbstick: string;
  54372. trackpad: string;
  54373. };
  54374. buttonObservableNames: {
  54375. trigger: string;
  54376. menu: string;
  54377. grip: string;
  54378. thumbstick: string;
  54379. trackpad: string;
  54380. };
  54381. axisMeshNames: string[];
  54382. pointingPoseMeshName: string;
  54383. };
  54384. /**
  54385. * Fired when the trackpad on this controller is clicked
  54386. */
  54387. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54388. /**
  54389. * Fired when the trackpad on this controller is modified
  54390. */
  54391. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54392. /**
  54393. * The current x and y values of this controller's trackpad
  54394. */
  54395. trackpad: StickValues;
  54396. /**
  54397. * Creates a new WindowsMotionController from a gamepad
  54398. * @param vrGamepad the gamepad that the controller should be created from
  54399. */
  54400. constructor(vrGamepad: any);
  54401. /**
  54402. * Fired when the trigger on this controller is modified
  54403. */
  54404. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54405. /**
  54406. * Fired when the menu button on this controller is modified
  54407. */
  54408. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54409. /**
  54410. * Fired when the grip button on this controller is modified
  54411. */
  54412. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54413. /**
  54414. * Fired when the thumbstick button on this controller is modified
  54415. */
  54416. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54417. /**
  54418. * Fired when the touchpad button on this controller is modified
  54419. */
  54420. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54421. /**
  54422. * Fired when the touchpad values on this controller are modified
  54423. */
  54424. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54425. protected _updateTrackpad(): void;
  54426. /**
  54427. * Called once per frame by the engine.
  54428. */
  54429. update(): void;
  54430. /**
  54431. * Called once for each button that changed state since the last frame
  54432. * @param buttonIdx Which button index changed
  54433. * @param state New state of the button
  54434. * @param changes Which properties on the state changed since last frame
  54435. */
  54436. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54437. /**
  54438. * Moves the buttons on the controller mesh based on their current state
  54439. * @param buttonName the name of the button to move
  54440. * @param buttonValue the value of the button which determines the buttons new position
  54441. */
  54442. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54443. /**
  54444. * Moves the axis on the controller mesh based on its current state
  54445. * @param axis the index of the axis
  54446. * @param axisValue the value of the axis which determines the meshes new position
  54447. * @hidden
  54448. */
  54449. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54450. /**
  54451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54452. * @param scene scene in which to add meshes
  54453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54454. */
  54455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54456. /**
  54457. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54458. * can be transformed by button presses and axes values, based on this._mapping.
  54459. *
  54460. * @param scene scene in which the meshes exist
  54461. * @param meshes list of meshes that make up the controller model to process
  54462. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54463. */
  54464. private processModel;
  54465. private createMeshInfo;
  54466. /**
  54467. * Gets the ray of the controller in the direction the controller is pointing
  54468. * @param length the length the resulting ray should be
  54469. * @returns a ray in the direction the controller is pointing
  54470. */
  54471. getForwardRay(length?: number): Ray;
  54472. /**
  54473. * Disposes of the controller
  54474. */
  54475. dispose(): void;
  54476. }
  54477. /**
  54478. * This class represents a new windows motion controller in XR.
  54479. */
  54480. export class XRWindowsMotionController extends WindowsMotionController {
  54481. /**
  54482. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54483. */
  54484. protected readonly _mapping: {
  54485. buttons: string[];
  54486. buttonMeshNames: {
  54487. trigger: string;
  54488. menu: string;
  54489. grip: string;
  54490. thumbstick: string;
  54491. trackpad: string;
  54492. };
  54493. buttonObservableNames: {
  54494. trigger: string;
  54495. menu: string;
  54496. grip: string;
  54497. thumbstick: string;
  54498. trackpad: string;
  54499. };
  54500. axisMeshNames: string[];
  54501. pointingPoseMeshName: string;
  54502. };
  54503. /**
  54504. * Construct a new XR-Based windows motion controller
  54505. *
  54506. * @param gamepadInfo the gamepad object from the browser
  54507. */
  54508. constructor(gamepadInfo: any);
  54509. /**
  54510. * holds the thumbstick values (X,Y)
  54511. */
  54512. thumbstickValues: StickValues;
  54513. /**
  54514. * Fired when the thumbstick on this controller is clicked
  54515. */
  54516. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54517. /**
  54518. * Fired when the thumbstick on this controller is modified
  54519. */
  54520. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54521. /**
  54522. * Fired when the touchpad button on this controller is modified
  54523. */
  54524. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54525. /**
  54526. * Fired when the touchpad values on this controller are modified
  54527. */
  54528. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54529. /**
  54530. * Fired when the thumbstick button on this controller is modified
  54531. * here to prevent breaking changes
  54532. */
  54533. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54534. /**
  54535. * updating the thumbstick(!) and not the trackpad.
  54536. * This is named this way due to the difference between WebVR and XR and to avoid
  54537. * changing the parent class.
  54538. */
  54539. protected _updateTrackpad(): void;
  54540. /**
  54541. * Disposes the class with joy
  54542. */
  54543. dispose(): void;
  54544. }
  54545. }
  54546. declare module "babylonjs/Gamepads/Controllers/index" {
  54547. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54548. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54549. export * from "babylonjs/Gamepads/Controllers/genericController";
  54550. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54551. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54552. export * from "babylonjs/Gamepads/Controllers/viveController";
  54553. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54554. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54555. }
  54556. declare module "babylonjs/Gamepads/index" {
  54557. export * from "babylonjs/Gamepads/Controllers/index";
  54558. export * from "babylonjs/Gamepads/gamepad";
  54559. export * from "babylonjs/Gamepads/gamepadManager";
  54560. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54561. export * from "babylonjs/Gamepads/xboxGamepad";
  54562. export * from "babylonjs/Gamepads/dualShockGamepad";
  54563. }
  54564. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54565. import { Scene } from "babylonjs/scene";
  54566. import { Vector4 } from "babylonjs/Maths/math.vector";
  54567. import { Color4 } from "babylonjs/Maths/math.color";
  54568. import { Mesh } from "babylonjs/Meshes/mesh";
  54569. import { Nullable } from "babylonjs/types";
  54570. /**
  54571. * Class containing static functions to help procedurally build meshes
  54572. */
  54573. export class PolyhedronBuilder {
  54574. /**
  54575. * Creates a polyhedron mesh
  54576. * * 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
  54577. * * The parameter `size` (positive float, default 1) sets the polygon size
  54578. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54579. * * 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`
  54580. * * 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
  54581. * * 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)`)
  54582. * * 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
  54583. * * 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
  54584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54585. * * 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
  54586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54587. * @param name defines the name of the mesh
  54588. * @param options defines the options used to create the mesh
  54589. * @param scene defines the hosting scene
  54590. * @returns the polyhedron mesh
  54591. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54592. */
  54593. static CreatePolyhedron(name: string, options: {
  54594. type?: number;
  54595. size?: number;
  54596. sizeX?: number;
  54597. sizeY?: number;
  54598. sizeZ?: number;
  54599. custom?: any;
  54600. faceUV?: Vector4[];
  54601. faceColors?: Color4[];
  54602. flat?: boolean;
  54603. updatable?: boolean;
  54604. sideOrientation?: number;
  54605. frontUVs?: Vector4;
  54606. backUVs?: Vector4;
  54607. }, scene?: Nullable<Scene>): Mesh;
  54608. }
  54609. }
  54610. declare module "babylonjs/Gizmos/scaleGizmo" {
  54611. import { Observable } from "babylonjs/Misc/observable";
  54612. import { Nullable } from "babylonjs/types";
  54613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54614. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54615. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54616. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54617. /**
  54618. * Gizmo that enables scaling a mesh along 3 axis
  54619. */
  54620. export class ScaleGizmo extends Gizmo {
  54621. /**
  54622. * Internal gizmo used for interactions on the x axis
  54623. */
  54624. xGizmo: AxisScaleGizmo;
  54625. /**
  54626. * Internal gizmo used for interactions on the y axis
  54627. */
  54628. yGizmo: AxisScaleGizmo;
  54629. /**
  54630. * Internal gizmo used for interactions on the z axis
  54631. */
  54632. zGizmo: AxisScaleGizmo;
  54633. /**
  54634. * Internal gizmo used to scale all axis equally
  54635. */
  54636. uniformScaleGizmo: AxisScaleGizmo;
  54637. private _meshAttached;
  54638. private _updateGizmoRotationToMatchAttachedMesh;
  54639. private _snapDistance;
  54640. private _scaleRatio;
  54641. private _uniformScalingMesh;
  54642. private _octahedron;
  54643. private _sensitivity;
  54644. /** Fires an event when any of it's sub gizmos are dragged */
  54645. onDragStartObservable: Observable<unknown>;
  54646. /** Fires an event when any of it's sub gizmos are released from dragging */
  54647. onDragEndObservable: Observable<unknown>;
  54648. get attachedMesh(): Nullable<AbstractMesh>;
  54649. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54650. /**
  54651. * Creates a ScaleGizmo
  54652. * @param gizmoLayer The utility layer the gizmo will be added to
  54653. */
  54654. constructor(gizmoLayer?: UtilityLayerRenderer);
  54655. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54656. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54657. /**
  54658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54659. */
  54660. set snapDistance(value: number);
  54661. get snapDistance(): number;
  54662. /**
  54663. * Ratio for the scale of the gizmo (Default: 1)
  54664. */
  54665. set scaleRatio(value: number);
  54666. get scaleRatio(): number;
  54667. /**
  54668. * Sensitivity factor for dragging (Default: 1)
  54669. */
  54670. set sensitivity(value: number);
  54671. get sensitivity(): number;
  54672. /**
  54673. * Disposes of the gizmo
  54674. */
  54675. dispose(): void;
  54676. }
  54677. }
  54678. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54679. import { Observable } from "babylonjs/Misc/observable";
  54680. import { Nullable } from "babylonjs/types";
  54681. import { Vector3 } from "babylonjs/Maths/math.vector";
  54682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54683. import { Mesh } from "babylonjs/Meshes/mesh";
  54684. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54685. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54686. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54687. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54688. import { Color3 } from "babylonjs/Maths/math.color";
  54689. /**
  54690. * Single axis scale gizmo
  54691. */
  54692. export class AxisScaleGizmo extends Gizmo {
  54693. /**
  54694. * Drag behavior responsible for the gizmos dragging interactions
  54695. */
  54696. dragBehavior: PointerDragBehavior;
  54697. private _pointerObserver;
  54698. /**
  54699. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54700. */
  54701. snapDistance: number;
  54702. /**
  54703. * Event that fires each time the gizmo snaps to a new location.
  54704. * * snapDistance is the the change in distance
  54705. */
  54706. onSnapObservable: Observable<{
  54707. snapDistance: number;
  54708. }>;
  54709. /**
  54710. * If the scaling operation should be done on all axis (default: false)
  54711. */
  54712. uniformScaling: boolean;
  54713. /**
  54714. * Custom sensitivity value for the drag strength
  54715. */
  54716. sensitivity: number;
  54717. private _isEnabled;
  54718. private _parent;
  54719. private _arrow;
  54720. private _coloredMaterial;
  54721. private _hoverMaterial;
  54722. /**
  54723. * Creates an AxisScaleGizmo
  54724. * @param gizmoLayer The utility layer the gizmo will be added to
  54725. * @param dragAxis The axis which the gizmo will be able to scale on
  54726. * @param color The color of the gizmo
  54727. */
  54728. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54730. /**
  54731. * If the gizmo is enabled
  54732. */
  54733. set isEnabled(value: boolean);
  54734. get isEnabled(): boolean;
  54735. /**
  54736. * Disposes of the gizmo
  54737. */
  54738. dispose(): void;
  54739. /**
  54740. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54741. * @param mesh The mesh to replace the default mesh of the gizmo
  54742. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54743. */
  54744. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54745. }
  54746. }
  54747. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54748. import { Observable } from "babylonjs/Misc/observable";
  54749. import { Nullable } from "babylonjs/types";
  54750. import { Vector3 } from "babylonjs/Maths/math.vector";
  54751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54752. import { Mesh } from "babylonjs/Meshes/mesh";
  54753. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54754. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54755. import { Color3 } from "babylonjs/Maths/math.color";
  54756. import "babylonjs/Meshes/Builders/boxBuilder";
  54757. /**
  54758. * Bounding box gizmo
  54759. */
  54760. export class BoundingBoxGizmo extends Gizmo {
  54761. private _lineBoundingBox;
  54762. private _rotateSpheresParent;
  54763. private _scaleBoxesParent;
  54764. private _boundingDimensions;
  54765. private _renderObserver;
  54766. private _pointerObserver;
  54767. private _scaleDragSpeed;
  54768. private _tmpQuaternion;
  54769. private _tmpVector;
  54770. private _tmpRotationMatrix;
  54771. /**
  54772. * 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)
  54773. */
  54774. ignoreChildren: boolean;
  54775. /**
  54776. * 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)
  54777. */
  54778. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54779. /**
  54780. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54781. */
  54782. rotationSphereSize: number;
  54783. /**
  54784. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54785. */
  54786. scaleBoxSize: number;
  54787. /**
  54788. * 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)
  54789. */
  54790. fixedDragMeshScreenSize: boolean;
  54791. /**
  54792. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54793. */
  54794. fixedDragMeshScreenSizeDistanceFactor: number;
  54795. /**
  54796. * Fired when a rotation sphere or scale box is dragged
  54797. */
  54798. onDragStartObservable: Observable<{}>;
  54799. /**
  54800. * Fired when a scale box is dragged
  54801. */
  54802. onScaleBoxDragObservable: Observable<{}>;
  54803. /**
  54804. * Fired when a scale box drag is ended
  54805. */
  54806. onScaleBoxDragEndObservable: Observable<{}>;
  54807. /**
  54808. * Fired when a rotation sphere is dragged
  54809. */
  54810. onRotationSphereDragObservable: Observable<{}>;
  54811. /**
  54812. * Fired when a rotation sphere drag is ended
  54813. */
  54814. onRotationSphereDragEndObservable: Observable<{}>;
  54815. /**
  54816. * 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)
  54817. */
  54818. scalePivot: Nullable<Vector3>;
  54819. /**
  54820. * Mesh used as a pivot to rotate the attached mesh
  54821. */
  54822. private _anchorMesh;
  54823. private _existingMeshScale;
  54824. private _dragMesh;
  54825. private pointerDragBehavior;
  54826. private coloredMaterial;
  54827. private hoverColoredMaterial;
  54828. /**
  54829. * Sets the color of the bounding box gizmo
  54830. * @param color the color to set
  54831. */
  54832. setColor(color: Color3): void;
  54833. /**
  54834. * Creates an BoundingBoxGizmo
  54835. * @param gizmoLayer The utility layer the gizmo will be added to
  54836. * @param color The color of the gizmo
  54837. */
  54838. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54839. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54840. private _selectNode;
  54841. /**
  54842. * Updates the bounding box information for the Gizmo
  54843. */
  54844. updateBoundingBox(): void;
  54845. private _updateRotationSpheres;
  54846. private _updateScaleBoxes;
  54847. /**
  54848. * Enables rotation on the specified axis and disables rotation on the others
  54849. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54850. */
  54851. setEnabledRotationAxis(axis: string): void;
  54852. /**
  54853. * Enables/disables scaling
  54854. * @param enable if scaling should be enabled
  54855. * @param homogeneousScaling defines if scaling should only be homogeneous
  54856. */
  54857. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54858. private _updateDummy;
  54859. /**
  54860. * Enables a pointer drag behavior on the bounding box of the gizmo
  54861. */
  54862. enableDragBehavior(): void;
  54863. /**
  54864. * Disposes of the gizmo
  54865. */
  54866. dispose(): void;
  54867. /**
  54868. * 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)
  54869. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54870. * @returns the bounding box mesh with the passed in mesh as a child
  54871. */
  54872. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54873. /**
  54874. * CustomMeshes are not supported by this gizmo
  54875. * @param mesh The mesh to replace the default mesh of the gizmo
  54876. */
  54877. setCustomMesh(mesh: Mesh): void;
  54878. }
  54879. }
  54880. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54881. import { Observable } from "babylonjs/Misc/observable";
  54882. import { Nullable } from "babylonjs/types";
  54883. import { Vector3 } from "babylonjs/Maths/math.vector";
  54884. import { Color3 } from "babylonjs/Maths/math.color";
  54885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54886. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54887. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54888. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54889. import "babylonjs/Meshes/Builders/linesBuilder";
  54890. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54891. /**
  54892. * Single plane rotation gizmo
  54893. */
  54894. export class PlaneRotationGizmo extends Gizmo {
  54895. /**
  54896. * Drag behavior responsible for the gizmos dragging interactions
  54897. */
  54898. dragBehavior: PointerDragBehavior;
  54899. private _pointerObserver;
  54900. /**
  54901. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54902. */
  54903. snapDistance: number;
  54904. /**
  54905. * Event that fires each time the gizmo snaps to a new location.
  54906. * * snapDistance is the the change in distance
  54907. */
  54908. onSnapObservable: Observable<{
  54909. snapDistance: number;
  54910. }>;
  54911. private _isEnabled;
  54912. private _parent;
  54913. /**
  54914. * Creates a PlaneRotationGizmo
  54915. * @param gizmoLayer The utility layer the gizmo will be added to
  54916. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54917. * @param color The color of the gizmo
  54918. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54919. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54920. */
  54921. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54923. /**
  54924. * If the gizmo is enabled
  54925. */
  54926. set isEnabled(value: boolean);
  54927. get isEnabled(): boolean;
  54928. /**
  54929. * Disposes of the gizmo
  54930. */
  54931. dispose(): void;
  54932. }
  54933. }
  54934. declare module "babylonjs/Gizmos/rotationGizmo" {
  54935. import { Observable } from "babylonjs/Misc/observable";
  54936. import { Nullable } from "babylonjs/types";
  54937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54938. import { Mesh } from "babylonjs/Meshes/mesh";
  54939. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54940. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54942. /**
  54943. * Gizmo that enables rotating a mesh along 3 axis
  54944. */
  54945. export class RotationGizmo extends Gizmo {
  54946. /**
  54947. * Internal gizmo used for interactions on the x axis
  54948. */
  54949. xGizmo: PlaneRotationGizmo;
  54950. /**
  54951. * Internal gizmo used for interactions on the y axis
  54952. */
  54953. yGizmo: PlaneRotationGizmo;
  54954. /**
  54955. * Internal gizmo used for interactions on the z axis
  54956. */
  54957. zGizmo: PlaneRotationGizmo;
  54958. /** Fires an event when any of it's sub gizmos are dragged */
  54959. onDragStartObservable: Observable<unknown>;
  54960. /** Fires an event when any of it's sub gizmos are released from dragging */
  54961. onDragEndObservable: Observable<unknown>;
  54962. private _meshAttached;
  54963. get attachedMesh(): Nullable<AbstractMesh>;
  54964. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54965. /**
  54966. * Creates a RotationGizmo
  54967. * @param gizmoLayer The utility layer the gizmo will be added to
  54968. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54969. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54970. */
  54971. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54972. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54973. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54974. /**
  54975. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54976. */
  54977. set snapDistance(value: number);
  54978. get snapDistance(): number;
  54979. /**
  54980. * Ratio for the scale of the gizmo (Default: 1)
  54981. */
  54982. set scaleRatio(value: number);
  54983. get scaleRatio(): number;
  54984. /**
  54985. * Disposes of the gizmo
  54986. */
  54987. dispose(): void;
  54988. /**
  54989. * CustomMeshes are not supported by this gizmo
  54990. * @param mesh The mesh to replace the default mesh of the gizmo
  54991. */
  54992. setCustomMesh(mesh: Mesh): void;
  54993. }
  54994. }
  54995. declare module "babylonjs/Gizmos/gizmoManager" {
  54996. import { Observable } from "babylonjs/Misc/observable";
  54997. import { Nullable } from "babylonjs/types";
  54998. import { Scene, IDisposable } from "babylonjs/scene";
  54999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55000. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55001. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55002. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55003. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55004. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55005. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55006. /**
  55007. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55008. */
  55009. export class GizmoManager implements IDisposable {
  55010. private scene;
  55011. /**
  55012. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55013. */
  55014. gizmos: {
  55015. positionGizmo: Nullable<PositionGizmo>;
  55016. rotationGizmo: Nullable<RotationGizmo>;
  55017. scaleGizmo: Nullable<ScaleGizmo>;
  55018. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55019. };
  55020. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55021. clearGizmoOnEmptyPointerEvent: boolean;
  55022. /** Fires an event when the manager is attached to a mesh */
  55023. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55024. private _gizmosEnabled;
  55025. private _pointerObserver;
  55026. private _attachedMesh;
  55027. private _boundingBoxColor;
  55028. private _defaultUtilityLayer;
  55029. private _defaultKeepDepthUtilityLayer;
  55030. /**
  55031. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55032. */
  55033. boundingBoxDragBehavior: SixDofDragBehavior;
  55034. /**
  55035. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55036. */
  55037. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55038. /**
  55039. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55040. */
  55041. usePointerToAttachGizmos: boolean;
  55042. /**
  55043. * Utility layer that the bounding box gizmo belongs to
  55044. */
  55045. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55046. /**
  55047. * Utility layer that all gizmos besides bounding box belong to
  55048. */
  55049. get utilityLayer(): UtilityLayerRenderer;
  55050. /**
  55051. * Instatiates a gizmo manager
  55052. * @param scene the scene to overlay the gizmos on top of
  55053. */
  55054. constructor(scene: Scene);
  55055. /**
  55056. * Attaches a set of gizmos to the specified mesh
  55057. * @param mesh The mesh the gizmo's should be attached to
  55058. */
  55059. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55060. /**
  55061. * If the position gizmo is enabled
  55062. */
  55063. set positionGizmoEnabled(value: boolean);
  55064. get positionGizmoEnabled(): boolean;
  55065. /**
  55066. * If the rotation gizmo is enabled
  55067. */
  55068. set rotationGizmoEnabled(value: boolean);
  55069. get rotationGizmoEnabled(): boolean;
  55070. /**
  55071. * If the scale gizmo is enabled
  55072. */
  55073. set scaleGizmoEnabled(value: boolean);
  55074. get scaleGizmoEnabled(): boolean;
  55075. /**
  55076. * If the boundingBox gizmo is enabled
  55077. */
  55078. set boundingBoxGizmoEnabled(value: boolean);
  55079. get boundingBoxGizmoEnabled(): boolean;
  55080. /**
  55081. * Disposes of the gizmo manager
  55082. */
  55083. dispose(): void;
  55084. }
  55085. }
  55086. declare module "babylonjs/Lights/directionalLight" {
  55087. import { Camera } from "babylonjs/Cameras/camera";
  55088. import { Scene } from "babylonjs/scene";
  55089. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55091. import { Light } from "babylonjs/Lights/light";
  55092. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55093. import { Effect } from "babylonjs/Materials/effect";
  55094. /**
  55095. * A directional light is defined by a direction (what a surprise!).
  55096. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55097. * 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.
  55098. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55099. */
  55100. export class DirectionalLight extends ShadowLight {
  55101. private _shadowFrustumSize;
  55102. /**
  55103. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55104. */
  55105. get shadowFrustumSize(): number;
  55106. /**
  55107. * Specifies a fix frustum size for the shadow generation.
  55108. */
  55109. set shadowFrustumSize(value: number);
  55110. private _shadowOrthoScale;
  55111. /**
  55112. * Gets the shadow projection scale against the optimal computed one.
  55113. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55114. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55115. */
  55116. get shadowOrthoScale(): number;
  55117. /**
  55118. * Sets the shadow projection scale against the optimal computed one.
  55119. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55120. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55121. */
  55122. set shadowOrthoScale(value: number);
  55123. /**
  55124. * Automatically compute the projection matrix to best fit (including all the casters)
  55125. * on each frame.
  55126. */
  55127. autoUpdateExtends: boolean;
  55128. /**
  55129. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55130. * on each frame. autoUpdateExtends must be set to true for this to work
  55131. */
  55132. autoCalcShadowZBounds: boolean;
  55133. private _orthoLeft;
  55134. private _orthoRight;
  55135. private _orthoTop;
  55136. private _orthoBottom;
  55137. /**
  55138. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55139. * The directional light is emitted from everywhere in the given direction.
  55140. * It can cast shadows.
  55141. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55142. * @param name The friendly name of the light
  55143. * @param direction The direction of the light
  55144. * @param scene The scene the light belongs to
  55145. */
  55146. constructor(name: string, direction: Vector3, scene: Scene);
  55147. /**
  55148. * Returns the string "DirectionalLight".
  55149. * @return The class name
  55150. */
  55151. getClassName(): string;
  55152. /**
  55153. * Returns the integer 1.
  55154. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55155. */
  55156. getTypeID(): number;
  55157. /**
  55158. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55159. * Returns the DirectionalLight Shadow projection matrix.
  55160. */
  55161. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55162. /**
  55163. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55164. * Returns the DirectionalLight Shadow projection matrix.
  55165. */
  55166. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55167. /**
  55168. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55169. * Returns the DirectionalLight Shadow projection matrix.
  55170. */
  55171. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55172. protected _buildUniformLayout(): void;
  55173. /**
  55174. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55175. * @param effect The effect to update
  55176. * @param lightIndex The index of the light in the effect to update
  55177. * @returns The directional light
  55178. */
  55179. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55180. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55181. /**
  55182. * Gets the minZ used for shadow according to both the scene and the light.
  55183. *
  55184. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55185. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55186. * @param activeCamera The camera we are returning the min for
  55187. * @returns the depth min z
  55188. */
  55189. getDepthMinZ(activeCamera: Camera): number;
  55190. /**
  55191. * Gets the maxZ used for shadow according to both the scene and the light.
  55192. *
  55193. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55194. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55195. * @param activeCamera The camera we are returning the max for
  55196. * @returns the depth max z
  55197. */
  55198. getDepthMaxZ(activeCamera: Camera): number;
  55199. /**
  55200. * Prepares the list of defines specific to the light type.
  55201. * @param defines the list of defines
  55202. * @param lightIndex defines the index of the light for the effect
  55203. */
  55204. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55205. }
  55206. }
  55207. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55208. import { Mesh } from "babylonjs/Meshes/mesh";
  55209. /**
  55210. * Class containing static functions to help procedurally build meshes
  55211. */
  55212. export class HemisphereBuilder {
  55213. /**
  55214. * Creates a hemisphere mesh
  55215. * @param name defines the name of the mesh
  55216. * @param options defines the options used to create the mesh
  55217. * @param scene defines the hosting scene
  55218. * @returns the hemisphere mesh
  55219. */
  55220. static CreateHemisphere(name: string, options: {
  55221. segments?: number;
  55222. diameter?: number;
  55223. sideOrientation?: number;
  55224. }, scene: any): Mesh;
  55225. }
  55226. }
  55227. declare module "babylonjs/Lights/spotLight" {
  55228. import { Nullable } from "babylonjs/types";
  55229. import { Scene } from "babylonjs/scene";
  55230. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55232. import { Effect } from "babylonjs/Materials/effect";
  55233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55234. import { Light } from "babylonjs/Lights/light";
  55235. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55236. /**
  55237. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55238. * These values define a cone of light starting from the position, emitting toward the direction.
  55239. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55240. * and the exponent defines the speed of the decay of the light with distance (reach).
  55241. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55242. */
  55243. export class SpotLight extends ShadowLight {
  55244. private _angle;
  55245. private _innerAngle;
  55246. private _cosHalfAngle;
  55247. private _lightAngleScale;
  55248. private _lightAngleOffset;
  55249. /**
  55250. * Gets the cone angle of the spot light in Radians.
  55251. */
  55252. get angle(): number;
  55253. /**
  55254. * Sets the cone angle of the spot light in Radians.
  55255. */
  55256. set angle(value: number);
  55257. /**
  55258. * Only used in gltf falloff mode, this defines the angle where
  55259. * the directional falloff will start before cutting at angle which could be seen
  55260. * as outer angle.
  55261. */
  55262. get innerAngle(): number;
  55263. /**
  55264. * Only used in gltf falloff mode, this defines the angle where
  55265. * the directional falloff will start before cutting at angle which could be seen
  55266. * as outer angle.
  55267. */
  55268. set innerAngle(value: number);
  55269. private _shadowAngleScale;
  55270. /**
  55271. * Allows scaling the angle of the light for shadow generation only.
  55272. */
  55273. get shadowAngleScale(): number;
  55274. /**
  55275. * Allows scaling the angle of the light for shadow generation only.
  55276. */
  55277. set shadowAngleScale(value: number);
  55278. /**
  55279. * The light decay speed with the distance from the emission spot.
  55280. */
  55281. exponent: number;
  55282. private _projectionTextureMatrix;
  55283. /**
  55284. * Allows reading the projecton texture
  55285. */
  55286. get projectionTextureMatrix(): Matrix;
  55287. protected _projectionTextureLightNear: number;
  55288. /**
  55289. * Gets the near clip of the Spotlight for texture projection.
  55290. */
  55291. get projectionTextureLightNear(): number;
  55292. /**
  55293. * Sets the near clip of the Spotlight for texture projection.
  55294. */
  55295. set projectionTextureLightNear(value: number);
  55296. protected _projectionTextureLightFar: number;
  55297. /**
  55298. * Gets the far clip of the Spotlight for texture projection.
  55299. */
  55300. get projectionTextureLightFar(): number;
  55301. /**
  55302. * Sets the far clip of the Spotlight for texture projection.
  55303. */
  55304. set projectionTextureLightFar(value: number);
  55305. protected _projectionTextureUpDirection: Vector3;
  55306. /**
  55307. * Gets the Up vector of the Spotlight for texture projection.
  55308. */
  55309. get projectionTextureUpDirection(): Vector3;
  55310. /**
  55311. * Sets the Up vector of the Spotlight for texture projection.
  55312. */
  55313. set projectionTextureUpDirection(value: Vector3);
  55314. private _projectionTexture;
  55315. /**
  55316. * Gets the projection texture of the light.
  55317. */
  55318. get projectionTexture(): Nullable<BaseTexture>;
  55319. /**
  55320. * Sets the projection texture of the light.
  55321. */
  55322. set projectionTexture(value: Nullable<BaseTexture>);
  55323. private _projectionTextureViewLightDirty;
  55324. private _projectionTextureProjectionLightDirty;
  55325. private _projectionTextureDirty;
  55326. private _projectionTextureViewTargetVector;
  55327. private _projectionTextureViewLightMatrix;
  55328. private _projectionTextureProjectionLightMatrix;
  55329. private _projectionTextureScalingMatrix;
  55330. /**
  55331. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55332. * It can cast shadows.
  55333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55334. * @param name The light friendly name
  55335. * @param position The position of the spot light in the scene
  55336. * @param direction The direction of the light in the scene
  55337. * @param angle The cone angle of the light in Radians
  55338. * @param exponent The light decay speed with the distance from the emission spot
  55339. * @param scene The scene the lights belongs to
  55340. */
  55341. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55342. /**
  55343. * Returns the string "SpotLight".
  55344. * @returns the class name
  55345. */
  55346. getClassName(): string;
  55347. /**
  55348. * Returns the integer 2.
  55349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55350. */
  55351. getTypeID(): number;
  55352. /**
  55353. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55354. */
  55355. protected _setDirection(value: Vector3): void;
  55356. /**
  55357. * Overrides the position setter to recompute the projection texture view light Matrix.
  55358. */
  55359. protected _setPosition(value: Vector3): void;
  55360. /**
  55361. * 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.
  55362. * Returns the SpotLight.
  55363. */
  55364. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55365. protected _computeProjectionTextureViewLightMatrix(): void;
  55366. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55367. /**
  55368. * Main function for light texture projection matrix computing.
  55369. */
  55370. protected _computeProjectionTextureMatrix(): void;
  55371. protected _buildUniformLayout(): void;
  55372. private _computeAngleValues;
  55373. /**
  55374. * Sets the passed Effect "effect" with the Light textures.
  55375. * @param effect The effect to update
  55376. * @param lightIndex The index of the light in the effect to update
  55377. * @returns The light
  55378. */
  55379. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55380. /**
  55381. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55382. * @param effect The effect to update
  55383. * @param lightIndex The index of the light in the effect to update
  55384. * @returns The spot light
  55385. */
  55386. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55387. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55388. /**
  55389. * Disposes the light and the associated resources.
  55390. */
  55391. dispose(): void;
  55392. /**
  55393. * Prepares the list of defines specific to the light type.
  55394. * @param defines the list of defines
  55395. * @param lightIndex defines the index of the light for the effect
  55396. */
  55397. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55398. }
  55399. }
  55400. declare module "babylonjs/Gizmos/lightGizmo" {
  55401. import { Nullable } from "babylonjs/types";
  55402. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55403. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55404. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55405. import { Light } from "babylonjs/Lights/light";
  55406. /**
  55407. * Gizmo that enables viewing a light
  55408. */
  55409. export class LightGizmo extends Gizmo {
  55410. private _lightMesh;
  55411. private _material;
  55412. private _cachedPosition;
  55413. private _cachedForward;
  55414. private _attachedMeshParent;
  55415. /**
  55416. * Creates a LightGizmo
  55417. * @param gizmoLayer The utility layer the gizmo will be added to
  55418. */
  55419. constructor(gizmoLayer?: UtilityLayerRenderer);
  55420. private _light;
  55421. /**
  55422. * The light that the gizmo is attached to
  55423. */
  55424. set light(light: Nullable<Light>);
  55425. get light(): Nullable<Light>;
  55426. /**
  55427. * Gets the material used to render the light gizmo
  55428. */
  55429. get material(): StandardMaterial;
  55430. /**
  55431. * @hidden
  55432. * Updates the gizmo to match the attached mesh's position/rotation
  55433. */
  55434. protected _update(): void;
  55435. private static _Scale;
  55436. /**
  55437. * Creates the lines for a light mesh
  55438. */
  55439. private static _CreateLightLines;
  55440. /**
  55441. * Disposes of the light gizmo
  55442. */
  55443. dispose(): void;
  55444. private static _CreateHemisphericLightMesh;
  55445. private static _CreatePointLightMesh;
  55446. private static _CreateSpotLightMesh;
  55447. private static _CreateDirectionalLightMesh;
  55448. }
  55449. }
  55450. declare module "babylonjs/Gizmos/index" {
  55451. export * from "babylonjs/Gizmos/axisDragGizmo";
  55452. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55453. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55454. export * from "babylonjs/Gizmos/gizmo";
  55455. export * from "babylonjs/Gizmos/gizmoManager";
  55456. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55457. export * from "babylonjs/Gizmos/positionGizmo";
  55458. export * from "babylonjs/Gizmos/rotationGizmo";
  55459. export * from "babylonjs/Gizmos/scaleGizmo";
  55460. export * from "babylonjs/Gizmos/lightGizmo";
  55461. export * from "babylonjs/Gizmos/planeDragGizmo";
  55462. }
  55463. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55464. /** @hidden */
  55465. export var backgroundFragmentDeclaration: {
  55466. name: string;
  55467. shader: string;
  55468. };
  55469. }
  55470. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55471. /** @hidden */
  55472. export var backgroundUboDeclaration: {
  55473. name: string;
  55474. shader: string;
  55475. };
  55476. }
  55477. declare module "babylonjs/Shaders/background.fragment" {
  55478. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55479. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55480. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55481. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55482. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55483. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55484. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55485. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55486. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55487. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55488. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55489. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55490. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55491. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55492. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55493. /** @hidden */
  55494. export var backgroundPixelShader: {
  55495. name: string;
  55496. shader: string;
  55497. };
  55498. }
  55499. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55500. /** @hidden */
  55501. export var backgroundVertexDeclaration: {
  55502. name: string;
  55503. shader: string;
  55504. };
  55505. }
  55506. declare module "babylonjs/Shaders/background.vertex" {
  55507. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55508. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55514. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55515. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55516. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55517. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55518. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55519. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55520. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55521. /** @hidden */
  55522. export var backgroundVertexShader: {
  55523. name: string;
  55524. shader: string;
  55525. };
  55526. }
  55527. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55528. import { Nullable, int, float } from "babylonjs/types";
  55529. import { Scene } from "babylonjs/scene";
  55530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55533. import { Mesh } from "babylonjs/Meshes/mesh";
  55534. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55535. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55536. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55538. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55539. import { Color3 } from "babylonjs/Maths/math.color";
  55540. import "babylonjs/Shaders/background.fragment";
  55541. import "babylonjs/Shaders/background.vertex";
  55542. /**
  55543. * Background material used to create an efficient environement around your scene.
  55544. */
  55545. export class BackgroundMaterial extends PushMaterial {
  55546. /**
  55547. * Standard reflectance value at parallel view angle.
  55548. */
  55549. static StandardReflectance0: number;
  55550. /**
  55551. * Standard reflectance value at grazing angle.
  55552. */
  55553. static StandardReflectance90: number;
  55554. protected _primaryColor: Color3;
  55555. /**
  55556. * Key light Color (multiply against the environement texture)
  55557. */
  55558. primaryColor: Color3;
  55559. protected __perceptualColor: Nullable<Color3>;
  55560. /**
  55561. * Experimental Internal Use Only.
  55562. *
  55563. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55564. * This acts as a helper to set the primary color to a more "human friendly" value.
  55565. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55566. * output color as close as possible from the chosen value.
  55567. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55568. * part of lighting setup.)
  55569. */
  55570. get _perceptualColor(): Nullable<Color3>;
  55571. set _perceptualColor(value: Nullable<Color3>);
  55572. protected _primaryColorShadowLevel: float;
  55573. /**
  55574. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55575. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55576. */
  55577. get primaryColorShadowLevel(): float;
  55578. set primaryColorShadowLevel(value: float);
  55579. protected _primaryColorHighlightLevel: float;
  55580. /**
  55581. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55582. * The primary color is used at the level chosen to define what the white area would look.
  55583. */
  55584. get primaryColorHighlightLevel(): float;
  55585. set primaryColorHighlightLevel(value: float);
  55586. protected _reflectionTexture: Nullable<BaseTexture>;
  55587. /**
  55588. * Reflection Texture used in the material.
  55589. * Should be author in a specific way for the best result (refer to the documentation).
  55590. */
  55591. reflectionTexture: Nullable<BaseTexture>;
  55592. protected _reflectionBlur: float;
  55593. /**
  55594. * Reflection Texture level of blur.
  55595. *
  55596. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55597. * texture twice.
  55598. */
  55599. reflectionBlur: float;
  55600. protected _diffuseTexture: Nullable<BaseTexture>;
  55601. /**
  55602. * Diffuse Texture used in the material.
  55603. * Should be author in a specific way for the best result (refer to the documentation).
  55604. */
  55605. diffuseTexture: Nullable<BaseTexture>;
  55606. protected _shadowLights: Nullable<IShadowLight[]>;
  55607. /**
  55608. * Specify the list of lights casting shadow on the material.
  55609. * All scene shadow lights will be included if null.
  55610. */
  55611. shadowLights: Nullable<IShadowLight[]>;
  55612. protected _shadowLevel: float;
  55613. /**
  55614. * Helps adjusting the shadow to a softer level if required.
  55615. * 0 means black shadows and 1 means no shadows.
  55616. */
  55617. shadowLevel: float;
  55618. protected _sceneCenter: Vector3;
  55619. /**
  55620. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55621. * It is usually zero but might be interesting to modify according to your setup.
  55622. */
  55623. sceneCenter: Vector3;
  55624. protected _opacityFresnel: boolean;
  55625. /**
  55626. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55627. * This helps ensuring a nice transition when the camera goes under the ground.
  55628. */
  55629. opacityFresnel: boolean;
  55630. protected _reflectionFresnel: boolean;
  55631. /**
  55632. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55633. * This helps adding a mirror texture on the ground.
  55634. */
  55635. reflectionFresnel: boolean;
  55636. protected _reflectionFalloffDistance: number;
  55637. /**
  55638. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55639. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55640. */
  55641. reflectionFalloffDistance: number;
  55642. protected _reflectionAmount: number;
  55643. /**
  55644. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55645. */
  55646. reflectionAmount: number;
  55647. protected _reflectionReflectance0: number;
  55648. /**
  55649. * This specifies the weight of the reflection at grazing angle.
  55650. */
  55651. reflectionReflectance0: number;
  55652. protected _reflectionReflectance90: number;
  55653. /**
  55654. * This specifies the weight of the reflection at a perpendicular point of view.
  55655. */
  55656. reflectionReflectance90: number;
  55657. /**
  55658. * Sets the reflection reflectance fresnel values according to the default standard
  55659. * empirically know to work well :-)
  55660. */
  55661. set reflectionStandardFresnelWeight(value: number);
  55662. protected _useRGBColor: boolean;
  55663. /**
  55664. * Helps to directly use the maps channels instead of their level.
  55665. */
  55666. useRGBColor: boolean;
  55667. protected _enableNoise: boolean;
  55668. /**
  55669. * This helps reducing the banding effect that could occur on the background.
  55670. */
  55671. enableNoise: boolean;
  55672. /**
  55673. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55674. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55675. * Recommended to be keep at 1.0 except for special cases.
  55676. */
  55677. get fovMultiplier(): number;
  55678. set fovMultiplier(value: number);
  55679. private _fovMultiplier;
  55680. /**
  55681. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55682. */
  55683. useEquirectangularFOV: boolean;
  55684. private _maxSimultaneousLights;
  55685. /**
  55686. * Number of Simultaneous lights allowed on the material.
  55687. */
  55688. maxSimultaneousLights: int;
  55689. private _shadowOnly;
  55690. /**
  55691. * Make the material only render shadows
  55692. */
  55693. shadowOnly: boolean;
  55694. /**
  55695. * Default configuration related to image processing available in the Background Material.
  55696. */
  55697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55698. /**
  55699. * Keep track of the image processing observer to allow dispose and replace.
  55700. */
  55701. private _imageProcessingObserver;
  55702. /**
  55703. * Attaches a new image processing configuration to the PBR Material.
  55704. * @param configuration (if null the scene configuration will be use)
  55705. */
  55706. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55707. /**
  55708. * Gets the image processing configuration used either in this material.
  55709. */
  55710. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55711. /**
  55712. * Sets the Default image processing configuration used either in the this material.
  55713. *
  55714. * If sets to null, the scene one is in use.
  55715. */
  55716. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55717. /**
  55718. * Gets wether the color curves effect is enabled.
  55719. */
  55720. get cameraColorCurvesEnabled(): boolean;
  55721. /**
  55722. * Sets wether the color curves effect is enabled.
  55723. */
  55724. set cameraColorCurvesEnabled(value: boolean);
  55725. /**
  55726. * Gets wether the color grading effect is enabled.
  55727. */
  55728. get cameraColorGradingEnabled(): boolean;
  55729. /**
  55730. * Gets wether the color grading effect is enabled.
  55731. */
  55732. set cameraColorGradingEnabled(value: boolean);
  55733. /**
  55734. * Gets wether tonemapping is enabled or not.
  55735. */
  55736. get cameraToneMappingEnabled(): boolean;
  55737. /**
  55738. * Sets wether tonemapping is enabled or not
  55739. */
  55740. set cameraToneMappingEnabled(value: boolean);
  55741. /**
  55742. * The camera exposure used on this material.
  55743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55744. * This corresponds to a photographic exposure.
  55745. */
  55746. get cameraExposure(): float;
  55747. /**
  55748. * The camera exposure used on this material.
  55749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55750. * This corresponds to a photographic exposure.
  55751. */
  55752. set cameraExposure(value: float);
  55753. /**
  55754. * Gets The camera contrast used on this material.
  55755. */
  55756. get cameraContrast(): float;
  55757. /**
  55758. * Sets The camera contrast used on this material.
  55759. */
  55760. set cameraContrast(value: float);
  55761. /**
  55762. * Gets the Color Grading 2D Lookup Texture.
  55763. */
  55764. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55765. /**
  55766. * Sets the Color Grading 2D Lookup Texture.
  55767. */
  55768. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55769. /**
  55770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55772. * 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;
  55773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55774. */
  55775. get cameraColorCurves(): Nullable<ColorCurves>;
  55776. /**
  55777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55779. * 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;
  55780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55781. */
  55782. set cameraColorCurves(value: Nullable<ColorCurves>);
  55783. /**
  55784. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55785. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55786. */
  55787. switchToBGR: boolean;
  55788. private _renderTargets;
  55789. private _reflectionControls;
  55790. private _white;
  55791. private _primaryShadowColor;
  55792. private _primaryHighlightColor;
  55793. /**
  55794. * Instantiates a Background Material in the given scene
  55795. * @param name The friendly name of the material
  55796. * @param scene The scene to add the material to
  55797. */
  55798. constructor(name: string, scene: Scene);
  55799. /**
  55800. * Gets a boolean indicating that current material needs to register RTT
  55801. */
  55802. get hasRenderTargetTextures(): boolean;
  55803. /**
  55804. * The entire material has been created in order to prevent overdraw.
  55805. * @returns false
  55806. */
  55807. needAlphaTesting(): boolean;
  55808. /**
  55809. * The entire material has been created in order to prevent overdraw.
  55810. * @returns true if blending is enable
  55811. */
  55812. needAlphaBlending(): boolean;
  55813. /**
  55814. * Checks wether the material is ready to be rendered for a given mesh.
  55815. * @param mesh The mesh to render
  55816. * @param subMesh The submesh to check against
  55817. * @param useInstances Specify wether or not the material is used with instances
  55818. * @returns true if all the dependencies are ready (Textures, Effects...)
  55819. */
  55820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55821. /**
  55822. * Compute the primary color according to the chosen perceptual color.
  55823. */
  55824. private _computePrimaryColorFromPerceptualColor;
  55825. /**
  55826. * Compute the highlights and shadow colors according to their chosen levels.
  55827. */
  55828. private _computePrimaryColors;
  55829. /**
  55830. * Build the uniform buffer used in the material.
  55831. */
  55832. buildUniformLayout(): void;
  55833. /**
  55834. * Unbind the material.
  55835. */
  55836. unbind(): void;
  55837. /**
  55838. * Bind only the world matrix to the material.
  55839. * @param world The world matrix to bind.
  55840. */
  55841. bindOnlyWorldMatrix(world: Matrix): void;
  55842. /**
  55843. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55844. * @param world The world matrix to bind.
  55845. * @param subMesh The submesh to bind for.
  55846. */
  55847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55848. /**
  55849. * Checks to see if a texture is used in the material.
  55850. * @param texture - Base texture to use.
  55851. * @returns - Boolean specifying if a texture is used in the material.
  55852. */
  55853. hasTexture(texture: BaseTexture): boolean;
  55854. /**
  55855. * Dispose the material.
  55856. * @param forceDisposeEffect Force disposal of the associated effect.
  55857. * @param forceDisposeTextures Force disposal of the associated textures.
  55858. */
  55859. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55860. /**
  55861. * Clones the material.
  55862. * @param name The cloned name.
  55863. * @returns The cloned material.
  55864. */
  55865. clone(name: string): BackgroundMaterial;
  55866. /**
  55867. * Serializes the current material to its JSON representation.
  55868. * @returns The JSON representation.
  55869. */
  55870. serialize(): any;
  55871. /**
  55872. * Gets the class name of the material
  55873. * @returns "BackgroundMaterial"
  55874. */
  55875. getClassName(): string;
  55876. /**
  55877. * Parse a JSON input to create back a background material.
  55878. * @param source The JSON data to parse
  55879. * @param scene The scene to create the parsed material in
  55880. * @param rootUrl The root url of the assets the material depends upon
  55881. * @returns the instantiated BackgroundMaterial.
  55882. */
  55883. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55884. }
  55885. }
  55886. declare module "babylonjs/Helpers/environmentHelper" {
  55887. import { Observable } from "babylonjs/Misc/observable";
  55888. import { Nullable } from "babylonjs/types";
  55889. import { Scene } from "babylonjs/scene";
  55890. import { Vector3 } from "babylonjs/Maths/math.vector";
  55891. import { Color3 } from "babylonjs/Maths/math.color";
  55892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55893. import { Mesh } from "babylonjs/Meshes/mesh";
  55894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55895. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55896. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55897. import "babylonjs/Meshes/Builders/planeBuilder";
  55898. import "babylonjs/Meshes/Builders/boxBuilder";
  55899. /**
  55900. * Represents the different options available during the creation of
  55901. * a Environment helper.
  55902. *
  55903. * This can control the default ground, skybox and image processing setup of your scene.
  55904. */
  55905. export interface IEnvironmentHelperOptions {
  55906. /**
  55907. * Specifies whether or not to create a ground.
  55908. * True by default.
  55909. */
  55910. createGround: boolean;
  55911. /**
  55912. * Specifies the ground size.
  55913. * 15 by default.
  55914. */
  55915. groundSize: number;
  55916. /**
  55917. * The texture used on the ground for the main color.
  55918. * Comes from the BabylonJS CDN by default.
  55919. *
  55920. * Remarks: Can be either a texture or a url.
  55921. */
  55922. groundTexture: string | BaseTexture;
  55923. /**
  55924. * The color mixed in the ground texture by default.
  55925. * BabylonJS clearColor by default.
  55926. */
  55927. groundColor: Color3;
  55928. /**
  55929. * Specifies the ground opacity.
  55930. * 1 by default.
  55931. */
  55932. groundOpacity: number;
  55933. /**
  55934. * Enables the ground to receive shadows.
  55935. * True by default.
  55936. */
  55937. enableGroundShadow: boolean;
  55938. /**
  55939. * Helps preventing the shadow to be fully black on the ground.
  55940. * 0.5 by default.
  55941. */
  55942. groundShadowLevel: number;
  55943. /**
  55944. * Creates a mirror texture attach to the ground.
  55945. * false by default.
  55946. */
  55947. enableGroundMirror: boolean;
  55948. /**
  55949. * Specifies the ground mirror size ratio.
  55950. * 0.3 by default as the default kernel is 64.
  55951. */
  55952. groundMirrorSizeRatio: number;
  55953. /**
  55954. * Specifies the ground mirror blur kernel size.
  55955. * 64 by default.
  55956. */
  55957. groundMirrorBlurKernel: number;
  55958. /**
  55959. * Specifies the ground mirror visibility amount.
  55960. * 1 by default
  55961. */
  55962. groundMirrorAmount: number;
  55963. /**
  55964. * Specifies the ground mirror reflectance weight.
  55965. * This uses the standard weight of the background material to setup the fresnel effect
  55966. * of the mirror.
  55967. * 1 by default.
  55968. */
  55969. groundMirrorFresnelWeight: number;
  55970. /**
  55971. * Specifies the ground mirror Falloff distance.
  55972. * This can helps reducing the size of the reflection.
  55973. * 0 by Default.
  55974. */
  55975. groundMirrorFallOffDistance: number;
  55976. /**
  55977. * Specifies the ground mirror texture type.
  55978. * Unsigned Int by Default.
  55979. */
  55980. groundMirrorTextureType: number;
  55981. /**
  55982. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55983. * the shown objects.
  55984. */
  55985. groundYBias: number;
  55986. /**
  55987. * Specifies whether or not to create a skybox.
  55988. * True by default.
  55989. */
  55990. createSkybox: boolean;
  55991. /**
  55992. * Specifies the skybox size.
  55993. * 20 by default.
  55994. */
  55995. skyboxSize: number;
  55996. /**
  55997. * The texture used on the skybox for the main color.
  55998. * Comes from the BabylonJS CDN by default.
  55999. *
  56000. * Remarks: Can be either a texture or a url.
  56001. */
  56002. skyboxTexture: string | BaseTexture;
  56003. /**
  56004. * The color mixed in the skybox texture by default.
  56005. * BabylonJS clearColor by default.
  56006. */
  56007. skyboxColor: Color3;
  56008. /**
  56009. * The background rotation around the Y axis of the scene.
  56010. * This helps aligning the key lights of your scene with the background.
  56011. * 0 by default.
  56012. */
  56013. backgroundYRotation: number;
  56014. /**
  56015. * Compute automatically the size of the elements to best fit with the scene.
  56016. */
  56017. sizeAuto: boolean;
  56018. /**
  56019. * Default position of the rootMesh if autoSize is not true.
  56020. */
  56021. rootPosition: Vector3;
  56022. /**
  56023. * Sets up the image processing in the scene.
  56024. * true by default.
  56025. */
  56026. setupImageProcessing: boolean;
  56027. /**
  56028. * The texture used as your environment texture in the scene.
  56029. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56030. *
  56031. * Remarks: Can be either a texture or a url.
  56032. */
  56033. environmentTexture: string | BaseTexture;
  56034. /**
  56035. * The value of the exposure to apply to the scene.
  56036. * 0.6 by default if setupImageProcessing is true.
  56037. */
  56038. cameraExposure: number;
  56039. /**
  56040. * The value of the contrast to apply to the scene.
  56041. * 1.6 by default if setupImageProcessing is true.
  56042. */
  56043. cameraContrast: number;
  56044. /**
  56045. * Specifies whether or not tonemapping should be enabled in the scene.
  56046. * true by default if setupImageProcessing is true.
  56047. */
  56048. toneMappingEnabled: boolean;
  56049. }
  56050. /**
  56051. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56052. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56053. * It also helps with the default setup of your imageProcessing configuration.
  56054. */
  56055. export class EnvironmentHelper {
  56056. /**
  56057. * Default ground texture URL.
  56058. */
  56059. private static _groundTextureCDNUrl;
  56060. /**
  56061. * Default skybox texture URL.
  56062. */
  56063. private static _skyboxTextureCDNUrl;
  56064. /**
  56065. * Default environment texture URL.
  56066. */
  56067. private static _environmentTextureCDNUrl;
  56068. /**
  56069. * Creates the default options for the helper.
  56070. */
  56071. private static _getDefaultOptions;
  56072. private _rootMesh;
  56073. /**
  56074. * Gets the root mesh created by the helper.
  56075. */
  56076. get rootMesh(): Mesh;
  56077. private _skybox;
  56078. /**
  56079. * Gets the skybox created by the helper.
  56080. */
  56081. get skybox(): Nullable<Mesh>;
  56082. private _skyboxTexture;
  56083. /**
  56084. * Gets the skybox texture created by the helper.
  56085. */
  56086. get skyboxTexture(): Nullable<BaseTexture>;
  56087. private _skyboxMaterial;
  56088. /**
  56089. * Gets the skybox material created by the helper.
  56090. */
  56091. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56092. private _ground;
  56093. /**
  56094. * Gets the ground mesh created by the helper.
  56095. */
  56096. get ground(): Nullable<Mesh>;
  56097. private _groundTexture;
  56098. /**
  56099. * Gets the ground texture created by the helper.
  56100. */
  56101. get groundTexture(): Nullable<BaseTexture>;
  56102. private _groundMirror;
  56103. /**
  56104. * Gets the ground mirror created by the helper.
  56105. */
  56106. get groundMirror(): Nullable<MirrorTexture>;
  56107. /**
  56108. * Gets the ground mirror render list to helps pushing the meshes
  56109. * you wish in the ground reflection.
  56110. */
  56111. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56112. private _groundMaterial;
  56113. /**
  56114. * Gets the ground material created by the helper.
  56115. */
  56116. get groundMaterial(): Nullable<BackgroundMaterial>;
  56117. /**
  56118. * Stores the creation options.
  56119. */
  56120. private readonly _scene;
  56121. private _options;
  56122. /**
  56123. * This observable will be notified with any error during the creation of the environment,
  56124. * mainly texture creation errors.
  56125. */
  56126. onErrorObservable: Observable<{
  56127. message?: string;
  56128. exception?: any;
  56129. }>;
  56130. /**
  56131. * constructor
  56132. * @param options Defines the options we want to customize the helper
  56133. * @param scene The scene to add the material to
  56134. */
  56135. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56136. /**
  56137. * Updates the background according to the new options
  56138. * @param options
  56139. */
  56140. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56141. /**
  56142. * Sets the primary color of all the available elements.
  56143. * @param color the main color to affect to the ground and the background
  56144. */
  56145. setMainColor(color: Color3): void;
  56146. /**
  56147. * Setup the image processing according to the specified options.
  56148. */
  56149. private _setupImageProcessing;
  56150. /**
  56151. * Setup the environment texture according to the specified options.
  56152. */
  56153. private _setupEnvironmentTexture;
  56154. /**
  56155. * Setup the background according to the specified options.
  56156. */
  56157. private _setupBackground;
  56158. /**
  56159. * Get the scene sizes according to the setup.
  56160. */
  56161. private _getSceneSize;
  56162. /**
  56163. * Setup the ground according to the specified options.
  56164. */
  56165. private _setupGround;
  56166. /**
  56167. * Setup the ground material according to the specified options.
  56168. */
  56169. private _setupGroundMaterial;
  56170. /**
  56171. * Setup the ground diffuse texture according to the specified options.
  56172. */
  56173. private _setupGroundDiffuseTexture;
  56174. /**
  56175. * Setup the ground mirror texture according to the specified options.
  56176. */
  56177. private _setupGroundMirrorTexture;
  56178. /**
  56179. * Setup the ground to receive the mirror texture.
  56180. */
  56181. private _setupMirrorInGroundMaterial;
  56182. /**
  56183. * Setup the skybox according to the specified options.
  56184. */
  56185. private _setupSkybox;
  56186. /**
  56187. * Setup the skybox material according to the specified options.
  56188. */
  56189. private _setupSkyboxMaterial;
  56190. /**
  56191. * Setup the skybox reflection texture according to the specified options.
  56192. */
  56193. private _setupSkyboxReflectionTexture;
  56194. private _errorHandler;
  56195. /**
  56196. * Dispose all the elements created by the Helper.
  56197. */
  56198. dispose(): void;
  56199. }
  56200. }
  56201. declare module "babylonjs/Helpers/photoDome" {
  56202. import { Observable } from "babylonjs/Misc/observable";
  56203. import { Nullable } from "babylonjs/types";
  56204. import { Scene } from "babylonjs/scene";
  56205. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56206. import { Mesh } from "babylonjs/Meshes/mesh";
  56207. import { Texture } from "babylonjs/Materials/Textures/texture";
  56208. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56209. import "babylonjs/Meshes/Builders/sphereBuilder";
  56210. /**
  56211. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56212. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56213. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56214. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56215. */
  56216. export class PhotoDome extends TransformNode {
  56217. /**
  56218. * Define the image as a Monoscopic panoramic 360 image.
  56219. */
  56220. static readonly MODE_MONOSCOPIC: number;
  56221. /**
  56222. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56223. */
  56224. static readonly MODE_TOPBOTTOM: number;
  56225. /**
  56226. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56227. */
  56228. static readonly MODE_SIDEBYSIDE: number;
  56229. private _useDirectMapping;
  56230. /**
  56231. * The texture being displayed on the sphere
  56232. */
  56233. protected _photoTexture: Texture;
  56234. /**
  56235. * Gets or sets the texture being displayed on the sphere
  56236. */
  56237. get photoTexture(): Texture;
  56238. set photoTexture(value: Texture);
  56239. /**
  56240. * Observable raised when an error occured while loading the 360 image
  56241. */
  56242. onLoadErrorObservable: Observable<string>;
  56243. /**
  56244. * The skybox material
  56245. */
  56246. protected _material: BackgroundMaterial;
  56247. /**
  56248. * The surface used for the skybox
  56249. */
  56250. protected _mesh: Mesh;
  56251. /**
  56252. * Gets the mesh used for the skybox.
  56253. */
  56254. get mesh(): Mesh;
  56255. /**
  56256. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56257. * Also see the options.resolution property.
  56258. */
  56259. get fovMultiplier(): number;
  56260. set fovMultiplier(value: number);
  56261. private _imageMode;
  56262. /**
  56263. * Gets or set the current video mode for the video. It can be:
  56264. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56265. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56266. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56267. */
  56268. get imageMode(): number;
  56269. set imageMode(value: number);
  56270. /**
  56271. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56272. * @param name Element's name, child elements will append suffixes for their own names.
  56273. * @param urlsOfPhoto defines the url of the photo to display
  56274. * @param options defines an object containing optional or exposed sub element properties
  56275. * @param onError defines a callback called when an error occured while loading the texture
  56276. */
  56277. constructor(name: string, urlOfPhoto: string, options: {
  56278. resolution?: number;
  56279. size?: number;
  56280. useDirectMapping?: boolean;
  56281. faceForward?: boolean;
  56282. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56283. private _onBeforeCameraRenderObserver;
  56284. private _changeImageMode;
  56285. /**
  56286. * Releases resources associated with this node.
  56287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56289. */
  56290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56291. }
  56292. }
  56293. declare module "babylonjs/Misc/rgbdTextureTools" {
  56294. import "babylonjs/Shaders/rgbdDecode.fragment";
  56295. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56296. import { Texture } from "babylonjs/Materials/Textures/texture";
  56297. /**
  56298. * Class used to host RGBD texture specific utilities
  56299. */
  56300. export class RGBDTextureTools {
  56301. /**
  56302. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56303. * @param texture the texture to expand.
  56304. */
  56305. static ExpandRGBDTexture(texture: Texture): void;
  56306. }
  56307. }
  56308. declare module "babylonjs/Misc/brdfTextureTools" {
  56309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56310. import { Scene } from "babylonjs/scene";
  56311. /**
  56312. * Class used to host texture specific utilities
  56313. */
  56314. export class BRDFTextureTools {
  56315. /**
  56316. * Prevents texture cache collision
  56317. */
  56318. private static _instanceNumber;
  56319. /**
  56320. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56321. * @param scene defines the hosting scene
  56322. * @returns the environment BRDF texture
  56323. */
  56324. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56325. private static _environmentBRDFBase64Texture;
  56326. }
  56327. }
  56328. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56329. import { Nullable } from "babylonjs/types";
  56330. import { Color3 } from "babylonjs/Maths/math.color";
  56331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56332. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56334. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56335. import { Engine } from "babylonjs/Engines/engine";
  56336. import { Scene } from "babylonjs/scene";
  56337. /**
  56338. * @hidden
  56339. */
  56340. export interface IMaterialClearCoatDefines {
  56341. CLEARCOAT: boolean;
  56342. CLEARCOAT_DEFAULTIOR: boolean;
  56343. CLEARCOAT_TEXTURE: boolean;
  56344. CLEARCOAT_TEXTUREDIRECTUV: number;
  56345. CLEARCOAT_BUMP: boolean;
  56346. CLEARCOAT_BUMPDIRECTUV: number;
  56347. CLEARCOAT_TINT: boolean;
  56348. CLEARCOAT_TINT_TEXTURE: boolean;
  56349. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56350. /** @hidden */
  56351. _areTexturesDirty: boolean;
  56352. }
  56353. /**
  56354. * Define the code related to the clear coat parameters of the pbr material.
  56355. */
  56356. export class PBRClearCoatConfiguration {
  56357. /**
  56358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56359. * The default fits with a polyurethane material.
  56360. */
  56361. private static readonly _DefaultIndexOfRefraction;
  56362. private _isEnabled;
  56363. /**
  56364. * Defines if the clear coat is enabled in the material.
  56365. */
  56366. isEnabled: boolean;
  56367. /**
  56368. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56369. */
  56370. intensity: number;
  56371. /**
  56372. * Defines the clear coat layer roughness.
  56373. */
  56374. roughness: number;
  56375. private _indexOfRefraction;
  56376. /**
  56377. * Defines the index of refraction of the clear coat.
  56378. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56379. * The default fits with a polyurethane material.
  56380. * Changing the default value is more performance intensive.
  56381. */
  56382. indexOfRefraction: number;
  56383. private _texture;
  56384. /**
  56385. * Stores the clear coat values in a texture.
  56386. */
  56387. texture: Nullable<BaseTexture>;
  56388. private _bumpTexture;
  56389. /**
  56390. * Define the clear coat specific bump texture.
  56391. */
  56392. bumpTexture: Nullable<BaseTexture>;
  56393. private _isTintEnabled;
  56394. /**
  56395. * Defines if the clear coat tint is enabled in the material.
  56396. */
  56397. isTintEnabled: boolean;
  56398. /**
  56399. * Defines the clear coat tint of the material.
  56400. * This is only use if tint is enabled
  56401. */
  56402. tintColor: Color3;
  56403. /**
  56404. * Defines the distance at which the tint color should be found in the
  56405. * clear coat media.
  56406. * This is only use if tint is enabled
  56407. */
  56408. tintColorAtDistance: number;
  56409. /**
  56410. * Defines the clear coat layer thickness.
  56411. * This is only use if tint is enabled
  56412. */
  56413. tintThickness: number;
  56414. private _tintTexture;
  56415. /**
  56416. * Stores the clear tint values in a texture.
  56417. * rgb is tint
  56418. * a is a thickness factor
  56419. */
  56420. tintTexture: Nullable<BaseTexture>;
  56421. /** @hidden */
  56422. private _internalMarkAllSubMeshesAsTexturesDirty;
  56423. /** @hidden */
  56424. _markAllSubMeshesAsTexturesDirty(): void;
  56425. /**
  56426. * Instantiate a new istance of clear coat configuration.
  56427. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56428. */
  56429. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56430. /**
  56431. * Gets wehter the submesh is ready to be used or not.
  56432. * @param defines the list of "defines" to update.
  56433. * @param scene defines the scene the material belongs to.
  56434. * @param engine defines the engine the material belongs to.
  56435. * @param disableBumpMap defines wether the material disables bump or not.
  56436. * @returns - boolean indicating that the submesh is ready or not.
  56437. */
  56438. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56439. /**
  56440. * Checks to see if a texture is used in the material.
  56441. * @param defines the list of "defines" to update.
  56442. * @param scene defines the scene to the material belongs to.
  56443. */
  56444. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56445. /**
  56446. * Binds the material data.
  56447. * @param uniformBuffer defines the Uniform buffer to fill in.
  56448. * @param scene defines the scene the material belongs to.
  56449. * @param engine defines the engine the material belongs to.
  56450. * @param disableBumpMap defines wether the material disables bump or not.
  56451. * @param isFrozen defines wether the material is frozen or not.
  56452. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56453. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56454. */
  56455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56456. /**
  56457. * Checks to see if a texture is used in the material.
  56458. * @param texture - Base texture to use.
  56459. * @returns - Boolean specifying if a texture is used in the material.
  56460. */
  56461. hasTexture(texture: BaseTexture): boolean;
  56462. /**
  56463. * Returns an array of the actively used textures.
  56464. * @param activeTextures Array of BaseTextures
  56465. */
  56466. getActiveTextures(activeTextures: BaseTexture[]): void;
  56467. /**
  56468. * Returns the animatable textures.
  56469. * @param animatables Array of animatable textures.
  56470. */
  56471. getAnimatables(animatables: IAnimatable[]): void;
  56472. /**
  56473. * Disposes the resources of the material.
  56474. * @param forceDisposeTextures - Forces the disposal of all textures.
  56475. */
  56476. dispose(forceDisposeTextures?: boolean): void;
  56477. /**
  56478. * Get the current class name of the texture useful for serialization or dynamic coding.
  56479. * @returns "PBRClearCoatConfiguration"
  56480. */
  56481. getClassName(): string;
  56482. /**
  56483. * Add fallbacks to the effect fallbacks list.
  56484. * @param defines defines the Base texture to use.
  56485. * @param fallbacks defines the current fallback list.
  56486. * @param currentRank defines the current fallback rank.
  56487. * @returns the new fallback rank.
  56488. */
  56489. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56490. /**
  56491. * Add the required uniforms to the current list.
  56492. * @param uniforms defines the current uniform list.
  56493. */
  56494. static AddUniforms(uniforms: string[]): void;
  56495. /**
  56496. * Add the required samplers to the current list.
  56497. * @param samplers defines the current sampler list.
  56498. */
  56499. static AddSamplers(samplers: string[]): void;
  56500. /**
  56501. * Add the required uniforms to the current buffer.
  56502. * @param uniformBuffer defines the current uniform buffer.
  56503. */
  56504. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56505. /**
  56506. * Makes a duplicate of the current configuration into another one.
  56507. * @param clearCoatConfiguration define the config where to copy the info
  56508. */
  56509. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56510. /**
  56511. * Serializes this clear coat configuration.
  56512. * @returns - An object with the serialized config.
  56513. */
  56514. serialize(): any;
  56515. /**
  56516. * Parses a anisotropy Configuration from a serialized object.
  56517. * @param source - Serialized object.
  56518. * @param scene Defines the scene we are parsing for
  56519. * @param rootUrl Defines the rootUrl to load from
  56520. */
  56521. parse(source: any, scene: Scene, rootUrl: string): void;
  56522. }
  56523. }
  56524. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56525. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56527. import { Vector2 } from "babylonjs/Maths/math.vector";
  56528. import { Scene } from "babylonjs/scene";
  56529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56530. import { Nullable } from "babylonjs/types";
  56531. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56532. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56533. /**
  56534. * @hidden
  56535. */
  56536. export interface IMaterialAnisotropicDefines {
  56537. ANISOTROPIC: boolean;
  56538. ANISOTROPIC_TEXTURE: boolean;
  56539. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56540. MAINUV1: boolean;
  56541. _areTexturesDirty: boolean;
  56542. _needUVs: boolean;
  56543. }
  56544. /**
  56545. * Define the code related to the anisotropic parameters of the pbr material.
  56546. */
  56547. export class PBRAnisotropicConfiguration {
  56548. private _isEnabled;
  56549. /**
  56550. * Defines if the anisotropy is enabled in the material.
  56551. */
  56552. isEnabled: boolean;
  56553. /**
  56554. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56555. */
  56556. intensity: number;
  56557. /**
  56558. * Defines if the effect is along the tangents, bitangents or in between.
  56559. * By default, the effect is "strectching" the highlights along the tangents.
  56560. */
  56561. direction: Vector2;
  56562. private _texture;
  56563. /**
  56564. * Stores the anisotropy values in a texture.
  56565. * rg is direction (like normal from -1 to 1)
  56566. * b is a intensity
  56567. */
  56568. texture: Nullable<BaseTexture>;
  56569. /** @hidden */
  56570. private _internalMarkAllSubMeshesAsTexturesDirty;
  56571. /** @hidden */
  56572. _markAllSubMeshesAsTexturesDirty(): void;
  56573. /**
  56574. * Instantiate a new istance of anisotropy configuration.
  56575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56576. */
  56577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56578. /**
  56579. * Specifies that the submesh is ready to be used.
  56580. * @param defines the list of "defines" to update.
  56581. * @param scene defines the scene the material belongs to.
  56582. * @returns - boolean indicating that the submesh is ready or not.
  56583. */
  56584. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56585. /**
  56586. * Checks to see if a texture is used in the material.
  56587. * @param defines the list of "defines" to update.
  56588. * @param mesh the mesh we are preparing the defines for.
  56589. * @param scene defines the scene the material belongs to.
  56590. */
  56591. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56592. /**
  56593. * Binds the material data.
  56594. * @param uniformBuffer defines the Uniform buffer to fill in.
  56595. * @param scene defines the scene the material belongs to.
  56596. * @param isFrozen defines wether the material is frozen or not.
  56597. */
  56598. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56599. /**
  56600. * Checks to see if a texture is used in the material.
  56601. * @param texture - Base texture to use.
  56602. * @returns - Boolean specifying if a texture is used in the material.
  56603. */
  56604. hasTexture(texture: BaseTexture): boolean;
  56605. /**
  56606. * Returns an array of the actively used textures.
  56607. * @param activeTextures Array of BaseTextures
  56608. */
  56609. getActiveTextures(activeTextures: BaseTexture[]): void;
  56610. /**
  56611. * Returns the animatable textures.
  56612. * @param animatables Array of animatable textures.
  56613. */
  56614. getAnimatables(animatables: IAnimatable[]): void;
  56615. /**
  56616. * Disposes the resources of the material.
  56617. * @param forceDisposeTextures - Forces the disposal of all textures.
  56618. */
  56619. dispose(forceDisposeTextures?: boolean): void;
  56620. /**
  56621. * Get the current class name of the texture useful for serialization or dynamic coding.
  56622. * @returns "PBRAnisotropicConfiguration"
  56623. */
  56624. getClassName(): string;
  56625. /**
  56626. * Add fallbacks to the effect fallbacks list.
  56627. * @param defines defines the Base texture to use.
  56628. * @param fallbacks defines the current fallback list.
  56629. * @param currentRank defines the current fallback rank.
  56630. * @returns the new fallback rank.
  56631. */
  56632. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56633. /**
  56634. * Add the required uniforms to the current list.
  56635. * @param uniforms defines the current uniform list.
  56636. */
  56637. static AddUniforms(uniforms: string[]): void;
  56638. /**
  56639. * Add the required uniforms to the current buffer.
  56640. * @param uniformBuffer defines the current uniform buffer.
  56641. */
  56642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56643. /**
  56644. * Add the required samplers to the current list.
  56645. * @param samplers defines the current sampler list.
  56646. */
  56647. static AddSamplers(samplers: string[]): void;
  56648. /**
  56649. * Makes a duplicate of the current configuration into another one.
  56650. * @param anisotropicConfiguration define the config where to copy the info
  56651. */
  56652. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56653. /**
  56654. * Serializes this anisotropy configuration.
  56655. * @returns - An object with the serialized config.
  56656. */
  56657. serialize(): any;
  56658. /**
  56659. * Parses a anisotropy Configuration from a serialized object.
  56660. * @param source - Serialized object.
  56661. * @param scene Defines the scene we are parsing for
  56662. * @param rootUrl Defines the rootUrl to load from
  56663. */
  56664. parse(source: any, scene: Scene, rootUrl: string): void;
  56665. }
  56666. }
  56667. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56668. import { Scene } from "babylonjs/scene";
  56669. /**
  56670. * @hidden
  56671. */
  56672. export interface IMaterialBRDFDefines {
  56673. BRDF_V_HEIGHT_CORRELATED: boolean;
  56674. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56675. SPHERICAL_HARMONICS: boolean;
  56676. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56677. /** @hidden */
  56678. _areMiscDirty: boolean;
  56679. }
  56680. /**
  56681. * Define the code related to the BRDF parameters of the pbr material.
  56682. */
  56683. export class PBRBRDFConfiguration {
  56684. /**
  56685. * Default value used for the energy conservation.
  56686. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56687. */
  56688. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56689. /**
  56690. * Default value used for the Smith Visibility Height Correlated mode.
  56691. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56692. */
  56693. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56694. /**
  56695. * Default value used for the IBL diffuse part.
  56696. * This can help switching back to the polynomials mode globally which is a tiny bit
  56697. * less GPU intensive at the drawback of a lower quality.
  56698. */
  56699. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56700. /**
  56701. * Default value used for activating energy conservation for the specular workflow.
  56702. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56703. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56704. */
  56705. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56706. private _useEnergyConservation;
  56707. /**
  56708. * Defines if the material uses energy conservation.
  56709. */
  56710. useEnergyConservation: boolean;
  56711. private _useSmithVisibilityHeightCorrelated;
  56712. /**
  56713. * LEGACY Mode set to false
  56714. * Defines if the material uses height smith correlated visibility term.
  56715. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56716. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56717. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56718. * Not relying on height correlated will also disable energy conservation.
  56719. */
  56720. useSmithVisibilityHeightCorrelated: boolean;
  56721. private _useSphericalHarmonics;
  56722. /**
  56723. * LEGACY Mode set to false
  56724. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56725. * diffuse part of the IBL.
  56726. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56727. * to the ground truth.
  56728. */
  56729. useSphericalHarmonics: boolean;
  56730. private _useSpecularGlossinessInputEnergyConservation;
  56731. /**
  56732. * Defines if the material uses energy conservation, when the specular workflow is active.
  56733. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56734. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56735. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56736. */
  56737. useSpecularGlossinessInputEnergyConservation: boolean;
  56738. /** @hidden */
  56739. private _internalMarkAllSubMeshesAsMiscDirty;
  56740. /** @hidden */
  56741. _markAllSubMeshesAsMiscDirty(): void;
  56742. /**
  56743. * Instantiate a new istance of clear coat configuration.
  56744. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56745. */
  56746. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56747. /**
  56748. * Checks to see if a texture is used in the material.
  56749. * @param defines the list of "defines" to update.
  56750. */
  56751. prepareDefines(defines: IMaterialBRDFDefines): void;
  56752. /**
  56753. * Get the current class name of the texture useful for serialization or dynamic coding.
  56754. * @returns "PBRClearCoatConfiguration"
  56755. */
  56756. getClassName(): string;
  56757. /**
  56758. * Makes a duplicate of the current configuration into another one.
  56759. * @param brdfConfiguration define the config where to copy the info
  56760. */
  56761. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56762. /**
  56763. * Serializes this BRDF configuration.
  56764. * @returns - An object with the serialized config.
  56765. */
  56766. serialize(): any;
  56767. /**
  56768. * Parses a anisotropy Configuration from a serialized object.
  56769. * @param source - Serialized object.
  56770. * @param scene Defines the scene we are parsing for
  56771. * @param rootUrl Defines the rootUrl to load from
  56772. */
  56773. parse(source: any, scene: Scene, rootUrl: string): void;
  56774. }
  56775. }
  56776. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56777. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56778. import { Color3 } from "babylonjs/Maths/math.color";
  56779. import { Scene } from "babylonjs/scene";
  56780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56781. import { Nullable } from "babylonjs/types";
  56782. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56783. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56784. /**
  56785. * @hidden
  56786. */
  56787. export interface IMaterialSheenDefines {
  56788. SHEEN: boolean;
  56789. SHEEN_TEXTURE: boolean;
  56790. SHEEN_TEXTUREDIRECTUV: number;
  56791. SHEEN_LINKWITHALBEDO: boolean;
  56792. SHEEN_ROUGHNESS: boolean;
  56793. SHEEN_ALBEDOSCALING: boolean;
  56794. /** @hidden */
  56795. _areTexturesDirty: boolean;
  56796. }
  56797. /**
  56798. * Define the code related to the Sheen parameters of the pbr material.
  56799. */
  56800. export class PBRSheenConfiguration {
  56801. private _isEnabled;
  56802. /**
  56803. * Defines if the material uses sheen.
  56804. */
  56805. isEnabled: boolean;
  56806. private _linkSheenWithAlbedo;
  56807. /**
  56808. * Defines if the sheen is linked to the sheen color.
  56809. */
  56810. linkSheenWithAlbedo: boolean;
  56811. /**
  56812. * Defines the sheen intensity.
  56813. */
  56814. intensity: number;
  56815. /**
  56816. * Defines the sheen color.
  56817. */
  56818. color: Color3;
  56819. private _texture;
  56820. /**
  56821. * Stores the sheen tint values in a texture.
  56822. * rgb is tint
  56823. * a is a intensity or roughness if roughness has been defined
  56824. */
  56825. texture: Nullable<BaseTexture>;
  56826. private _roughness;
  56827. /**
  56828. * Defines the sheen roughness.
  56829. * It is not taken into account if linkSheenWithAlbedo is true.
  56830. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56831. */
  56832. roughness: Nullable<number>;
  56833. private _albedoScaling;
  56834. /**
  56835. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56836. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56837. * making it easier to setup and tweak the effect
  56838. */
  56839. albedoScaling: boolean;
  56840. /** @hidden */
  56841. private _internalMarkAllSubMeshesAsTexturesDirty;
  56842. /** @hidden */
  56843. _markAllSubMeshesAsTexturesDirty(): void;
  56844. /**
  56845. * Instantiate a new istance of clear coat configuration.
  56846. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56847. */
  56848. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56849. /**
  56850. * Specifies that the submesh is ready to be used.
  56851. * @param defines the list of "defines" to update.
  56852. * @param scene defines the scene the material belongs to.
  56853. * @returns - boolean indicating that the submesh is ready or not.
  56854. */
  56855. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56856. /**
  56857. * Checks to see if a texture is used in the material.
  56858. * @param defines the list of "defines" to update.
  56859. * @param scene defines the scene the material belongs to.
  56860. */
  56861. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56862. /**
  56863. * Binds the material data.
  56864. * @param uniformBuffer defines the Uniform buffer to fill in.
  56865. * @param scene defines the scene the material belongs to.
  56866. * @param isFrozen defines wether the material is frozen or not.
  56867. */
  56868. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56869. /**
  56870. * Checks to see if a texture is used in the material.
  56871. * @param texture - Base texture to use.
  56872. * @returns - Boolean specifying if a texture is used in the material.
  56873. */
  56874. hasTexture(texture: BaseTexture): boolean;
  56875. /**
  56876. * Returns an array of the actively used textures.
  56877. * @param activeTextures Array of BaseTextures
  56878. */
  56879. getActiveTextures(activeTextures: BaseTexture[]): void;
  56880. /**
  56881. * Returns the animatable textures.
  56882. * @param animatables Array of animatable textures.
  56883. */
  56884. getAnimatables(animatables: IAnimatable[]): void;
  56885. /**
  56886. * Disposes the resources of the material.
  56887. * @param forceDisposeTextures - Forces the disposal of all textures.
  56888. */
  56889. dispose(forceDisposeTextures?: boolean): void;
  56890. /**
  56891. * Get the current class name of the texture useful for serialization or dynamic coding.
  56892. * @returns "PBRSheenConfiguration"
  56893. */
  56894. getClassName(): string;
  56895. /**
  56896. * Add fallbacks to the effect fallbacks list.
  56897. * @param defines defines the Base texture to use.
  56898. * @param fallbacks defines the current fallback list.
  56899. * @param currentRank defines the current fallback rank.
  56900. * @returns the new fallback rank.
  56901. */
  56902. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56903. /**
  56904. * Add the required uniforms to the current list.
  56905. * @param uniforms defines the current uniform list.
  56906. */
  56907. static AddUniforms(uniforms: string[]): void;
  56908. /**
  56909. * Add the required uniforms to the current buffer.
  56910. * @param uniformBuffer defines the current uniform buffer.
  56911. */
  56912. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56913. /**
  56914. * Add the required samplers to the current list.
  56915. * @param samplers defines the current sampler list.
  56916. */
  56917. static AddSamplers(samplers: string[]): void;
  56918. /**
  56919. * Makes a duplicate of the current configuration into another one.
  56920. * @param sheenConfiguration define the config where to copy the info
  56921. */
  56922. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56923. /**
  56924. * Serializes this BRDF configuration.
  56925. * @returns - An object with the serialized config.
  56926. */
  56927. serialize(): any;
  56928. /**
  56929. * Parses a anisotropy Configuration from a serialized object.
  56930. * @param source - Serialized object.
  56931. * @param scene Defines the scene we are parsing for
  56932. * @param rootUrl Defines the rootUrl to load from
  56933. */
  56934. parse(source: any, scene: Scene, rootUrl: string): void;
  56935. }
  56936. }
  56937. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56938. import { Nullable } from "babylonjs/types";
  56939. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56940. import { Color3 } from "babylonjs/Maths/math.color";
  56941. import { SmartArray } from "babylonjs/Misc/smartArray";
  56942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56944. import { Effect } from "babylonjs/Materials/effect";
  56945. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56946. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56947. import { Engine } from "babylonjs/Engines/engine";
  56948. import { Scene } from "babylonjs/scene";
  56949. /**
  56950. * @hidden
  56951. */
  56952. export interface IMaterialSubSurfaceDefines {
  56953. SUBSURFACE: boolean;
  56954. SS_REFRACTION: boolean;
  56955. SS_TRANSLUCENCY: boolean;
  56956. SS_SCATTERING: boolean;
  56957. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56958. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56959. SS_REFRACTIONMAP_3D: boolean;
  56960. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56961. SS_LODINREFRACTIONALPHA: boolean;
  56962. SS_GAMMAREFRACTION: boolean;
  56963. SS_RGBDREFRACTION: boolean;
  56964. SS_LINEARSPECULARREFRACTION: boolean;
  56965. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56966. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56967. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56968. /** @hidden */
  56969. _areTexturesDirty: boolean;
  56970. }
  56971. /**
  56972. * Define the code related to the sub surface parameters of the pbr material.
  56973. */
  56974. export class PBRSubSurfaceConfiguration {
  56975. private _isRefractionEnabled;
  56976. /**
  56977. * Defines if the refraction is enabled in the material.
  56978. */
  56979. isRefractionEnabled: boolean;
  56980. private _isTranslucencyEnabled;
  56981. /**
  56982. * Defines if the translucency is enabled in the material.
  56983. */
  56984. isTranslucencyEnabled: boolean;
  56985. private _isScatteringEnabled;
  56986. /**
  56987. * Defines if the sub surface scattering is enabled in the material.
  56988. */
  56989. isScatteringEnabled: boolean;
  56990. private _scatteringDiffusionProfileIndex;
  56991. /**
  56992. * Diffusion profile for subsurface scattering.
  56993. * Useful for better scattering in the skins or foliages.
  56994. */
  56995. get scatteringDiffusionProfile(): Nullable<Color3>;
  56996. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56997. /**
  56998. * Defines the refraction intensity of the material.
  56999. * The refraction when enabled replaces the Diffuse part of the material.
  57000. * The intensity helps transitionning between diffuse and refraction.
  57001. */
  57002. refractionIntensity: number;
  57003. /**
  57004. * Defines the translucency intensity of the material.
  57005. * When translucency has been enabled, this defines how much of the "translucency"
  57006. * is addded to the diffuse part of the material.
  57007. */
  57008. translucencyIntensity: number;
  57009. /**
  57010. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57011. */
  57012. useAlbedoToTintRefraction: boolean;
  57013. private _thicknessTexture;
  57014. /**
  57015. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57016. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57017. * 0 would mean minimumThickness
  57018. * 1 would mean maximumThickness
  57019. * The other channels might be use as a mask to vary the different effects intensity.
  57020. */
  57021. thicknessTexture: Nullable<BaseTexture>;
  57022. private _refractionTexture;
  57023. /**
  57024. * Defines the texture to use for refraction.
  57025. */
  57026. refractionTexture: Nullable<BaseTexture>;
  57027. private _indexOfRefraction;
  57028. /**
  57029. * Index of refraction of the material base layer.
  57030. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57031. *
  57032. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57033. *
  57034. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57035. */
  57036. indexOfRefraction: number;
  57037. private _volumeIndexOfRefraction;
  57038. /**
  57039. * Index of refraction of the material's volume.
  57040. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57041. *
  57042. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57043. * the volume will use the same IOR as the surface.
  57044. */
  57045. get volumeIndexOfRefraction(): number;
  57046. set volumeIndexOfRefraction(value: number);
  57047. private _invertRefractionY;
  57048. /**
  57049. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57050. */
  57051. invertRefractionY: boolean;
  57052. private _linkRefractionWithTransparency;
  57053. /**
  57054. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57055. * Materials half opaque for instance using refraction could benefit from this control.
  57056. */
  57057. linkRefractionWithTransparency: boolean;
  57058. /**
  57059. * Defines the minimum thickness stored in the thickness map.
  57060. * If no thickness map is defined, this value will be used to simulate thickness.
  57061. */
  57062. minimumThickness: number;
  57063. /**
  57064. * Defines the maximum thickness stored in the thickness map.
  57065. */
  57066. maximumThickness: number;
  57067. /**
  57068. * Defines the volume tint of the material.
  57069. * This is used for both translucency and scattering.
  57070. */
  57071. tintColor: Color3;
  57072. /**
  57073. * Defines the distance at which the tint color should be found in the media.
  57074. * This is used for refraction only.
  57075. */
  57076. tintColorAtDistance: number;
  57077. /**
  57078. * Defines how far each channel transmit through the media.
  57079. * It is defined as a color to simplify it selection.
  57080. */
  57081. diffusionDistance: Color3;
  57082. private _useMaskFromThicknessTexture;
  57083. /**
  57084. * Stores the intensity of the different subsurface effects in the thickness texture.
  57085. * * the green channel is the translucency intensity.
  57086. * * the blue channel is the scattering intensity.
  57087. * * the alpha channel is the refraction intensity.
  57088. */
  57089. useMaskFromThicknessTexture: boolean;
  57090. private _scene;
  57091. /** @hidden */
  57092. private _internalMarkAllSubMeshesAsTexturesDirty;
  57093. private _internalMarkScenePrePassDirty;
  57094. /** @hidden */
  57095. _markAllSubMeshesAsTexturesDirty(): void;
  57096. /** @hidden */
  57097. _markScenePrePassDirty(): void;
  57098. /**
  57099. * Instantiate a new istance of sub surface configuration.
  57100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57101. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57102. * @param scene The scene
  57103. */
  57104. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57105. /**
  57106. * Gets wehter the submesh is ready to be used or not.
  57107. * @param defines the list of "defines" to update.
  57108. * @param scene defines the scene the material belongs to.
  57109. * @returns - boolean indicating that the submesh is ready or not.
  57110. */
  57111. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57112. /**
  57113. * Checks to see if a texture is used in the material.
  57114. * @param defines the list of "defines" to update.
  57115. * @param scene defines the scene to the material belongs to.
  57116. */
  57117. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57118. /**
  57119. * Binds the material data.
  57120. * @param uniformBuffer defines the Uniform buffer to fill in.
  57121. * @param scene defines the scene the material belongs to.
  57122. * @param engine defines the engine the material belongs to.
  57123. * @param isFrozen defines whether the material is frozen or not.
  57124. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57125. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57126. */
  57127. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57128. /**
  57129. * Unbinds the material from the mesh.
  57130. * @param activeEffect defines the effect that should be unbound from.
  57131. * @returns true if unbound, otherwise false
  57132. */
  57133. unbind(activeEffect: Effect): boolean;
  57134. /**
  57135. * Returns the texture used for refraction or null if none is used.
  57136. * @param scene defines the scene the material belongs to.
  57137. * @returns - Refraction texture if present. If no refraction texture and refraction
  57138. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57139. */
  57140. private _getRefractionTexture;
  57141. /**
  57142. * Returns true if alpha blending should be disabled.
  57143. */
  57144. get disableAlphaBlending(): boolean;
  57145. /**
  57146. * Fills the list of render target textures.
  57147. * @param renderTargets the list of render targets to update
  57148. */
  57149. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57150. /**
  57151. * Checks to see if a texture is used in the material.
  57152. * @param texture - Base texture to use.
  57153. * @returns - Boolean specifying if a texture is used in the material.
  57154. */
  57155. hasTexture(texture: BaseTexture): boolean;
  57156. /**
  57157. * Gets a boolean indicating that current material needs to register RTT
  57158. * @returns true if this uses a render target otherwise false.
  57159. */
  57160. hasRenderTargetTextures(): boolean;
  57161. /**
  57162. * Returns an array of the actively used textures.
  57163. * @param activeTextures Array of BaseTextures
  57164. */
  57165. getActiveTextures(activeTextures: BaseTexture[]): void;
  57166. /**
  57167. * Returns the animatable textures.
  57168. * @param animatables Array of animatable textures.
  57169. */
  57170. getAnimatables(animatables: IAnimatable[]): void;
  57171. /**
  57172. * Disposes the resources of the material.
  57173. * @param forceDisposeTextures - Forces the disposal of all textures.
  57174. */
  57175. dispose(forceDisposeTextures?: boolean): void;
  57176. /**
  57177. * Get the current class name of the texture useful for serialization or dynamic coding.
  57178. * @returns "PBRSubSurfaceConfiguration"
  57179. */
  57180. getClassName(): string;
  57181. /**
  57182. * Add fallbacks to the effect fallbacks list.
  57183. * @param defines defines the Base texture to use.
  57184. * @param fallbacks defines the current fallback list.
  57185. * @param currentRank defines the current fallback rank.
  57186. * @returns the new fallback rank.
  57187. */
  57188. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57189. /**
  57190. * Add the required uniforms to the current list.
  57191. * @param uniforms defines the current uniform list.
  57192. */
  57193. static AddUniforms(uniforms: string[]): void;
  57194. /**
  57195. * Add the required samplers to the current list.
  57196. * @param samplers defines the current sampler list.
  57197. */
  57198. static AddSamplers(samplers: string[]): void;
  57199. /**
  57200. * Add the required uniforms to the current buffer.
  57201. * @param uniformBuffer defines the current uniform buffer.
  57202. */
  57203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57204. /**
  57205. * Makes a duplicate of the current configuration into another one.
  57206. * @param configuration define the config where to copy the info
  57207. */
  57208. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57209. /**
  57210. * Serializes this Sub Surface configuration.
  57211. * @returns - An object with the serialized config.
  57212. */
  57213. serialize(): any;
  57214. /**
  57215. * Parses a anisotropy Configuration from a serialized object.
  57216. * @param source - Serialized object.
  57217. * @param scene Defines the scene we are parsing for
  57218. * @param rootUrl Defines the rootUrl to load from
  57219. */
  57220. parse(source: any, scene: Scene, rootUrl: string): void;
  57221. }
  57222. }
  57223. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  57224. /** @hidden */
  57225. export var prePassDeclaration: {
  57226. name: string;
  57227. shader: string;
  57228. };
  57229. }
  57230. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57231. /** @hidden */
  57232. export var pbrFragmentDeclaration: {
  57233. name: string;
  57234. shader: string;
  57235. };
  57236. }
  57237. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57238. /** @hidden */
  57239. export var pbrUboDeclaration: {
  57240. name: string;
  57241. shader: string;
  57242. };
  57243. }
  57244. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57245. /** @hidden */
  57246. export var pbrFragmentExtraDeclaration: {
  57247. name: string;
  57248. shader: string;
  57249. };
  57250. }
  57251. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57252. /** @hidden */
  57253. export var pbrFragmentSamplersDeclaration: {
  57254. name: string;
  57255. shader: string;
  57256. };
  57257. }
  57258. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57259. /** @hidden */
  57260. export var subSurfaceScatteringFunctions: {
  57261. name: string;
  57262. shader: string;
  57263. };
  57264. }
  57265. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57266. /** @hidden */
  57267. export var importanceSampling: {
  57268. name: string;
  57269. shader: string;
  57270. };
  57271. }
  57272. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57273. /** @hidden */
  57274. export var pbrHelperFunctions: {
  57275. name: string;
  57276. shader: string;
  57277. };
  57278. }
  57279. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57280. /** @hidden */
  57281. export var harmonicsFunctions: {
  57282. name: string;
  57283. shader: string;
  57284. };
  57285. }
  57286. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57287. /** @hidden */
  57288. export var pbrDirectLightingSetupFunctions: {
  57289. name: string;
  57290. shader: string;
  57291. };
  57292. }
  57293. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57294. /** @hidden */
  57295. export var pbrDirectLightingFalloffFunctions: {
  57296. name: string;
  57297. shader: string;
  57298. };
  57299. }
  57300. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57301. /** @hidden */
  57302. export var pbrBRDFFunctions: {
  57303. name: string;
  57304. shader: string;
  57305. };
  57306. }
  57307. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57308. /** @hidden */
  57309. export var hdrFilteringFunctions: {
  57310. name: string;
  57311. shader: string;
  57312. };
  57313. }
  57314. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57315. /** @hidden */
  57316. export var pbrDirectLightingFunctions: {
  57317. name: string;
  57318. shader: string;
  57319. };
  57320. }
  57321. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57322. /** @hidden */
  57323. export var pbrIBLFunctions: {
  57324. name: string;
  57325. shader: string;
  57326. };
  57327. }
  57328. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57329. /** @hidden */
  57330. export var pbrBlockAlbedoOpacity: {
  57331. name: string;
  57332. shader: string;
  57333. };
  57334. }
  57335. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57336. /** @hidden */
  57337. export var pbrBlockReflectivity: {
  57338. name: string;
  57339. shader: string;
  57340. };
  57341. }
  57342. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57343. /** @hidden */
  57344. export var pbrBlockAmbientOcclusion: {
  57345. name: string;
  57346. shader: string;
  57347. };
  57348. }
  57349. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57350. /** @hidden */
  57351. export var pbrBlockAlphaFresnel: {
  57352. name: string;
  57353. shader: string;
  57354. };
  57355. }
  57356. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57357. /** @hidden */
  57358. export var pbrBlockAnisotropic: {
  57359. name: string;
  57360. shader: string;
  57361. };
  57362. }
  57363. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57364. /** @hidden */
  57365. export var pbrBlockReflection: {
  57366. name: string;
  57367. shader: string;
  57368. };
  57369. }
  57370. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57371. /** @hidden */
  57372. export var pbrBlockSheen: {
  57373. name: string;
  57374. shader: string;
  57375. };
  57376. }
  57377. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57378. /** @hidden */
  57379. export var pbrBlockClearcoat: {
  57380. name: string;
  57381. shader: string;
  57382. };
  57383. }
  57384. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57385. /** @hidden */
  57386. export var pbrBlockSubSurface: {
  57387. name: string;
  57388. shader: string;
  57389. };
  57390. }
  57391. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57392. /** @hidden */
  57393. export var pbrBlockNormalGeometric: {
  57394. name: string;
  57395. shader: string;
  57396. };
  57397. }
  57398. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57399. /** @hidden */
  57400. export var pbrBlockNormalFinal: {
  57401. name: string;
  57402. shader: string;
  57403. };
  57404. }
  57405. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57406. /** @hidden */
  57407. export var pbrBlockGeometryInfo: {
  57408. name: string;
  57409. shader: string;
  57410. };
  57411. }
  57412. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57413. /** @hidden */
  57414. export var pbrBlockReflectance0: {
  57415. name: string;
  57416. shader: string;
  57417. };
  57418. }
  57419. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57420. /** @hidden */
  57421. export var pbrBlockReflectance: {
  57422. name: string;
  57423. shader: string;
  57424. };
  57425. }
  57426. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57427. /** @hidden */
  57428. export var pbrBlockDirectLighting: {
  57429. name: string;
  57430. shader: string;
  57431. };
  57432. }
  57433. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57434. /** @hidden */
  57435. export var pbrBlockFinalLitComponents: {
  57436. name: string;
  57437. shader: string;
  57438. };
  57439. }
  57440. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57441. /** @hidden */
  57442. export var pbrBlockFinalUnlitComponents: {
  57443. name: string;
  57444. shader: string;
  57445. };
  57446. }
  57447. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57448. /** @hidden */
  57449. export var pbrBlockFinalColorComposition: {
  57450. name: string;
  57451. shader: string;
  57452. };
  57453. }
  57454. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57455. /** @hidden */
  57456. export var pbrBlockImageProcessing: {
  57457. name: string;
  57458. shader: string;
  57459. };
  57460. }
  57461. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57462. /** @hidden */
  57463. export var pbrDebug: {
  57464. name: string;
  57465. shader: string;
  57466. };
  57467. }
  57468. declare module "babylonjs/Shaders/pbr.fragment" {
  57469. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57470. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57471. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57472. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57473. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57474. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57475. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57476. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57478. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57479. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57481. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57482. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57483. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57484. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57485. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57486. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57487. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57488. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57489. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57490. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57491. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57492. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57493. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57494. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57495. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57496. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57497. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57498. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57499. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57500. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57501. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57502. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57503. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57504. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57505. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57506. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57507. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57508. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57509. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57510. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57511. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57512. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57513. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57514. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57515. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57516. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57517. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57518. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57519. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57520. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57521. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57522. /** @hidden */
  57523. export var pbrPixelShader: {
  57524. name: string;
  57525. shader: string;
  57526. };
  57527. }
  57528. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57529. /** @hidden */
  57530. export var pbrVertexDeclaration: {
  57531. name: string;
  57532. shader: string;
  57533. };
  57534. }
  57535. declare module "babylonjs/Shaders/pbr.vertex" {
  57536. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57537. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57538. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57539. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57540. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57542. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57543. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57544. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57545. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57546. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57549. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57551. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57552. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57553. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57555. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57556. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57557. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57558. /** @hidden */
  57559. export var pbrVertexShader: {
  57560. name: string;
  57561. shader: string;
  57562. };
  57563. }
  57564. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57565. import { Nullable } from "babylonjs/types";
  57566. import { Scene } from "babylonjs/scene";
  57567. import { Matrix } from "babylonjs/Maths/math.vector";
  57568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57570. import { Mesh } from "babylonjs/Meshes/mesh";
  57571. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57572. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57573. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57574. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57575. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57576. import { Color3 } from "babylonjs/Maths/math.color";
  57577. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57578. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57579. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57580. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57582. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57583. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57584. import "babylonjs/Shaders/pbr.fragment";
  57585. import "babylonjs/Shaders/pbr.vertex";
  57586. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57587. /**
  57588. * Manages the defines for the PBR Material.
  57589. * @hidden
  57590. */
  57591. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57592. PBR: boolean;
  57593. NUM_SAMPLES: string;
  57594. REALTIME_FILTERING: boolean;
  57595. MAINUV1: boolean;
  57596. MAINUV2: boolean;
  57597. UV1: boolean;
  57598. UV2: boolean;
  57599. ALBEDO: boolean;
  57600. GAMMAALBEDO: boolean;
  57601. ALBEDODIRECTUV: number;
  57602. VERTEXCOLOR: boolean;
  57603. DETAIL: boolean;
  57604. DETAILDIRECTUV: number;
  57605. DETAIL_NORMALBLENDMETHOD: number;
  57606. AMBIENT: boolean;
  57607. AMBIENTDIRECTUV: number;
  57608. AMBIENTINGRAYSCALE: boolean;
  57609. OPACITY: boolean;
  57610. VERTEXALPHA: boolean;
  57611. OPACITYDIRECTUV: number;
  57612. OPACITYRGB: boolean;
  57613. ALPHATEST: boolean;
  57614. DEPTHPREPASS: boolean;
  57615. ALPHABLEND: boolean;
  57616. ALPHAFROMALBEDO: boolean;
  57617. ALPHATESTVALUE: string;
  57618. SPECULAROVERALPHA: boolean;
  57619. RADIANCEOVERALPHA: boolean;
  57620. ALPHAFRESNEL: boolean;
  57621. LINEARALPHAFRESNEL: boolean;
  57622. PREMULTIPLYALPHA: boolean;
  57623. EMISSIVE: boolean;
  57624. EMISSIVEDIRECTUV: number;
  57625. REFLECTIVITY: boolean;
  57626. REFLECTIVITYDIRECTUV: number;
  57627. SPECULARTERM: boolean;
  57628. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57629. MICROSURFACEAUTOMATIC: boolean;
  57630. LODBASEDMICROSFURACE: boolean;
  57631. MICROSURFACEMAP: boolean;
  57632. MICROSURFACEMAPDIRECTUV: number;
  57633. METALLICWORKFLOW: boolean;
  57634. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57635. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57636. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57637. AOSTOREINMETALMAPRED: boolean;
  57638. METALLIC_REFLECTANCE: boolean;
  57639. METALLIC_REFLECTANCEDIRECTUV: number;
  57640. ENVIRONMENTBRDF: boolean;
  57641. ENVIRONMENTBRDF_RGBD: boolean;
  57642. NORMAL: boolean;
  57643. TANGENT: boolean;
  57644. BUMP: boolean;
  57645. BUMPDIRECTUV: number;
  57646. OBJECTSPACE_NORMALMAP: boolean;
  57647. PARALLAX: boolean;
  57648. PARALLAXOCCLUSION: boolean;
  57649. NORMALXYSCALE: boolean;
  57650. LIGHTMAP: boolean;
  57651. LIGHTMAPDIRECTUV: number;
  57652. USELIGHTMAPASSHADOWMAP: boolean;
  57653. GAMMALIGHTMAP: boolean;
  57654. RGBDLIGHTMAP: boolean;
  57655. REFLECTION: boolean;
  57656. REFLECTIONMAP_3D: boolean;
  57657. REFLECTIONMAP_SPHERICAL: boolean;
  57658. REFLECTIONMAP_PLANAR: boolean;
  57659. REFLECTIONMAP_CUBIC: boolean;
  57660. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57661. REFLECTIONMAP_PROJECTION: boolean;
  57662. REFLECTIONMAP_SKYBOX: boolean;
  57663. REFLECTIONMAP_EXPLICIT: boolean;
  57664. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57665. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57666. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57667. INVERTCUBICMAP: boolean;
  57668. USESPHERICALFROMREFLECTIONMAP: boolean;
  57669. USEIRRADIANCEMAP: boolean;
  57670. SPHERICAL_HARMONICS: boolean;
  57671. USESPHERICALINVERTEX: boolean;
  57672. REFLECTIONMAP_OPPOSITEZ: boolean;
  57673. LODINREFLECTIONALPHA: boolean;
  57674. GAMMAREFLECTION: boolean;
  57675. RGBDREFLECTION: boolean;
  57676. LINEARSPECULARREFLECTION: boolean;
  57677. RADIANCEOCCLUSION: boolean;
  57678. HORIZONOCCLUSION: boolean;
  57679. INSTANCES: boolean;
  57680. THIN_INSTANCES: boolean;
  57681. PREPASS: boolean;
  57682. SCENE_MRT_COUNT: number;
  57683. NUM_BONE_INFLUENCERS: number;
  57684. BonesPerMesh: number;
  57685. BONETEXTURE: boolean;
  57686. NONUNIFORMSCALING: boolean;
  57687. MORPHTARGETS: boolean;
  57688. MORPHTARGETS_NORMAL: boolean;
  57689. MORPHTARGETS_TANGENT: boolean;
  57690. MORPHTARGETS_UV: boolean;
  57691. NUM_MORPH_INFLUENCERS: number;
  57692. IMAGEPROCESSING: boolean;
  57693. VIGNETTE: boolean;
  57694. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57695. VIGNETTEBLENDMODEOPAQUE: boolean;
  57696. TONEMAPPING: boolean;
  57697. TONEMAPPING_ACES: boolean;
  57698. CONTRAST: boolean;
  57699. COLORCURVES: boolean;
  57700. COLORGRADING: boolean;
  57701. COLORGRADING3D: boolean;
  57702. SAMPLER3DGREENDEPTH: boolean;
  57703. SAMPLER3DBGRMAP: boolean;
  57704. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57705. EXPOSURE: boolean;
  57706. MULTIVIEW: boolean;
  57707. USEPHYSICALLIGHTFALLOFF: boolean;
  57708. USEGLTFLIGHTFALLOFF: boolean;
  57709. TWOSIDEDLIGHTING: boolean;
  57710. SHADOWFLOAT: boolean;
  57711. CLIPPLANE: boolean;
  57712. CLIPPLANE2: boolean;
  57713. CLIPPLANE3: boolean;
  57714. CLIPPLANE4: boolean;
  57715. CLIPPLANE5: boolean;
  57716. CLIPPLANE6: boolean;
  57717. POINTSIZE: boolean;
  57718. FOG: boolean;
  57719. LOGARITHMICDEPTH: boolean;
  57720. FORCENORMALFORWARD: boolean;
  57721. SPECULARAA: boolean;
  57722. CLEARCOAT: boolean;
  57723. CLEARCOAT_DEFAULTIOR: boolean;
  57724. CLEARCOAT_TEXTURE: boolean;
  57725. CLEARCOAT_TEXTUREDIRECTUV: number;
  57726. CLEARCOAT_BUMP: boolean;
  57727. CLEARCOAT_BUMPDIRECTUV: number;
  57728. CLEARCOAT_TINT: boolean;
  57729. CLEARCOAT_TINT_TEXTURE: boolean;
  57730. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57731. ANISOTROPIC: boolean;
  57732. ANISOTROPIC_TEXTURE: boolean;
  57733. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57734. BRDF_V_HEIGHT_CORRELATED: boolean;
  57735. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57736. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57737. SHEEN: boolean;
  57738. SHEEN_TEXTURE: boolean;
  57739. SHEEN_TEXTUREDIRECTUV: number;
  57740. SHEEN_LINKWITHALBEDO: boolean;
  57741. SHEEN_ROUGHNESS: boolean;
  57742. SHEEN_ALBEDOSCALING: boolean;
  57743. SUBSURFACE: boolean;
  57744. SS_REFRACTION: boolean;
  57745. SS_TRANSLUCENCY: boolean;
  57746. SS_SCATTERING: boolean;
  57747. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57748. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57749. SS_REFRACTIONMAP_3D: boolean;
  57750. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57751. SS_LODINREFRACTIONALPHA: boolean;
  57752. SS_GAMMAREFRACTION: boolean;
  57753. SS_RGBDREFRACTION: boolean;
  57754. SS_LINEARSPECULARREFRACTION: boolean;
  57755. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57756. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57757. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57758. UNLIT: boolean;
  57759. DEBUGMODE: number;
  57760. /**
  57761. * Initializes the PBR Material defines.
  57762. */
  57763. constructor();
  57764. /**
  57765. * Resets the PBR Material defines.
  57766. */
  57767. reset(): void;
  57768. }
  57769. /**
  57770. * The Physically based material base class of BJS.
  57771. *
  57772. * This offers the main features of a standard PBR material.
  57773. * For more information, please refer to the documentation :
  57774. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57775. */
  57776. export abstract class PBRBaseMaterial extends PushMaterial {
  57777. /**
  57778. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57779. */
  57780. static readonly PBRMATERIAL_OPAQUE: number;
  57781. /**
  57782. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57783. */
  57784. static readonly PBRMATERIAL_ALPHATEST: number;
  57785. /**
  57786. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57787. */
  57788. static readonly PBRMATERIAL_ALPHABLEND: number;
  57789. /**
  57790. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57791. * They are also discarded below the alpha cutoff threshold to improve performances.
  57792. */
  57793. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57794. /**
  57795. * Defines the default value of how much AO map is occluding the analytical lights
  57796. * (point spot...).
  57797. */
  57798. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57799. /**
  57800. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57801. */
  57802. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57803. /**
  57804. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57805. * to enhance interoperability with other engines.
  57806. */
  57807. static readonly LIGHTFALLOFF_GLTF: number;
  57808. /**
  57809. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57810. * to enhance interoperability with other materials.
  57811. */
  57812. static readonly LIGHTFALLOFF_STANDARD: number;
  57813. /**
  57814. * Intensity of the direct lights e.g. the four lights available in your scene.
  57815. * This impacts both the direct diffuse and specular highlights.
  57816. */
  57817. protected _directIntensity: number;
  57818. /**
  57819. * Intensity of the emissive part of the material.
  57820. * This helps controlling the emissive effect without modifying the emissive color.
  57821. */
  57822. protected _emissiveIntensity: number;
  57823. /**
  57824. * Intensity of the environment e.g. how much the environment will light the object
  57825. * either through harmonics for rough material or through the refelction for shiny ones.
  57826. */
  57827. protected _environmentIntensity: number;
  57828. /**
  57829. * This is a special control allowing the reduction of the specular highlights coming from the
  57830. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57831. */
  57832. protected _specularIntensity: number;
  57833. /**
  57834. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57835. */
  57836. private _lightingInfos;
  57837. /**
  57838. * Debug Control allowing disabling the bump map on this material.
  57839. */
  57840. protected _disableBumpMap: boolean;
  57841. /**
  57842. * AKA Diffuse Texture in standard nomenclature.
  57843. */
  57844. protected _albedoTexture: Nullable<BaseTexture>;
  57845. /**
  57846. * AKA Occlusion Texture in other nomenclature.
  57847. */
  57848. protected _ambientTexture: Nullable<BaseTexture>;
  57849. /**
  57850. * AKA Occlusion Texture Intensity in other nomenclature.
  57851. */
  57852. protected _ambientTextureStrength: number;
  57853. /**
  57854. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57855. * 1 means it completely occludes it
  57856. * 0 mean it has no impact
  57857. */
  57858. protected _ambientTextureImpactOnAnalyticalLights: number;
  57859. /**
  57860. * Stores the alpha values in a texture.
  57861. */
  57862. protected _opacityTexture: Nullable<BaseTexture>;
  57863. /**
  57864. * Stores the reflection values in a texture.
  57865. */
  57866. protected _reflectionTexture: Nullable<BaseTexture>;
  57867. /**
  57868. * Stores the emissive values in a texture.
  57869. */
  57870. protected _emissiveTexture: Nullable<BaseTexture>;
  57871. /**
  57872. * AKA Specular texture in other nomenclature.
  57873. */
  57874. protected _reflectivityTexture: Nullable<BaseTexture>;
  57875. /**
  57876. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57877. */
  57878. protected _metallicTexture: Nullable<BaseTexture>;
  57879. /**
  57880. * Specifies the metallic scalar of the metallic/roughness workflow.
  57881. * Can also be used to scale the metalness values of the metallic texture.
  57882. */
  57883. protected _metallic: Nullable<number>;
  57884. /**
  57885. * Specifies the roughness scalar of the metallic/roughness workflow.
  57886. * Can also be used to scale the roughness values of the metallic texture.
  57887. */
  57888. protected _roughness: Nullable<number>;
  57889. /**
  57890. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57891. * By default the indexOfrefraction is used to compute F0;
  57892. *
  57893. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57894. *
  57895. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57896. * F90 = metallicReflectanceColor;
  57897. */
  57898. protected _metallicF0Factor: number;
  57899. /**
  57900. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57901. * By default the F90 is always 1;
  57902. *
  57903. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57904. *
  57905. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57906. * F90 = metallicReflectanceColor;
  57907. */
  57908. protected _metallicReflectanceColor: Color3;
  57909. /**
  57910. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57911. * This is multiply against the scalar values defined in the material.
  57912. */
  57913. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57914. /**
  57915. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57916. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57917. */
  57918. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57919. /**
  57920. * Stores surface normal data used to displace a mesh in a texture.
  57921. */
  57922. protected _bumpTexture: Nullable<BaseTexture>;
  57923. /**
  57924. * Stores the pre-calculated light information of a mesh in a texture.
  57925. */
  57926. protected _lightmapTexture: Nullable<BaseTexture>;
  57927. /**
  57928. * The color of a material in ambient lighting.
  57929. */
  57930. protected _ambientColor: Color3;
  57931. /**
  57932. * AKA Diffuse Color in other nomenclature.
  57933. */
  57934. protected _albedoColor: Color3;
  57935. /**
  57936. * AKA Specular Color in other nomenclature.
  57937. */
  57938. protected _reflectivityColor: Color3;
  57939. /**
  57940. * The color applied when light is reflected from a material.
  57941. */
  57942. protected _reflectionColor: Color3;
  57943. /**
  57944. * The color applied when light is emitted from a material.
  57945. */
  57946. protected _emissiveColor: Color3;
  57947. /**
  57948. * AKA Glossiness in other nomenclature.
  57949. */
  57950. protected _microSurface: number;
  57951. /**
  57952. * Specifies that the material will use the light map as a show map.
  57953. */
  57954. protected _useLightmapAsShadowmap: boolean;
  57955. /**
  57956. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57957. * makes the reflect vector face the model (under horizon).
  57958. */
  57959. protected _useHorizonOcclusion: boolean;
  57960. /**
  57961. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57962. * too much the area relying on ambient texture to define their ambient occlusion.
  57963. */
  57964. protected _useRadianceOcclusion: boolean;
  57965. /**
  57966. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57967. */
  57968. protected _useAlphaFromAlbedoTexture: boolean;
  57969. /**
  57970. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57971. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57972. */
  57973. protected _useSpecularOverAlpha: boolean;
  57974. /**
  57975. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57976. */
  57977. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57978. /**
  57979. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57980. */
  57981. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57982. /**
  57983. * Specifies if the metallic texture contains the roughness information in its green channel.
  57984. */
  57985. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57986. /**
  57987. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57988. */
  57989. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57990. /**
  57991. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57992. */
  57993. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57994. /**
  57995. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57996. */
  57997. protected _useAmbientInGrayScale: boolean;
  57998. /**
  57999. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58000. * The material will try to infer what glossiness each pixel should be.
  58001. */
  58002. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58003. /**
  58004. * Defines the falloff type used in this material.
  58005. * It by default is Physical.
  58006. */
  58007. protected _lightFalloff: number;
  58008. /**
  58009. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58010. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58011. */
  58012. protected _useRadianceOverAlpha: boolean;
  58013. /**
  58014. * Allows using an object space normal map (instead of tangent space).
  58015. */
  58016. protected _useObjectSpaceNormalMap: boolean;
  58017. /**
  58018. * Allows using the bump map in parallax mode.
  58019. */
  58020. protected _useParallax: boolean;
  58021. /**
  58022. * Allows using the bump map in parallax occlusion mode.
  58023. */
  58024. protected _useParallaxOcclusion: boolean;
  58025. /**
  58026. * Controls the scale bias of the parallax mode.
  58027. */
  58028. protected _parallaxScaleBias: number;
  58029. /**
  58030. * If sets to true, disables all the lights affecting the material.
  58031. */
  58032. protected _disableLighting: boolean;
  58033. /**
  58034. * Number of Simultaneous lights allowed on the material.
  58035. */
  58036. protected _maxSimultaneousLights: number;
  58037. /**
  58038. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58039. */
  58040. protected _invertNormalMapX: boolean;
  58041. /**
  58042. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58043. */
  58044. protected _invertNormalMapY: boolean;
  58045. /**
  58046. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58047. */
  58048. protected _twoSidedLighting: boolean;
  58049. /**
  58050. * Defines the alpha limits in alpha test mode.
  58051. */
  58052. protected _alphaCutOff: number;
  58053. /**
  58054. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58055. */
  58056. protected _forceAlphaTest: boolean;
  58057. /**
  58058. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58059. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58060. */
  58061. protected _useAlphaFresnel: boolean;
  58062. /**
  58063. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58064. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58065. */
  58066. protected _useLinearAlphaFresnel: boolean;
  58067. /**
  58068. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58069. * from cos thetav and roughness:
  58070. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58071. */
  58072. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58073. /**
  58074. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58075. */
  58076. protected _forceIrradianceInFragment: boolean;
  58077. private _realTimeFiltering;
  58078. /**
  58079. * Enables realtime filtering on the texture.
  58080. */
  58081. get realTimeFiltering(): boolean;
  58082. set realTimeFiltering(b: boolean);
  58083. private _realTimeFilteringQuality;
  58084. /**
  58085. * Quality switch for realtime filtering
  58086. */
  58087. get realTimeFilteringQuality(): number;
  58088. set realTimeFilteringQuality(n: number);
  58089. /**
  58090. * Should this material render to several textures at once
  58091. */
  58092. get shouldRenderToMRT(): boolean;
  58093. /**
  58094. * Force normal to face away from face.
  58095. */
  58096. protected _forceNormalForward: boolean;
  58097. /**
  58098. * Enables specular anti aliasing in the PBR shader.
  58099. * It will both interacts on the Geometry for analytical and IBL lighting.
  58100. * It also prefilter the roughness map based on the bump values.
  58101. */
  58102. protected _enableSpecularAntiAliasing: boolean;
  58103. /**
  58104. * Default configuration related to image processing available in the PBR Material.
  58105. */
  58106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58107. /**
  58108. * Keep track of the image processing observer to allow dispose and replace.
  58109. */
  58110. private _imageProcessingObserver;
  58111. /**
  58112. * Attaches a new image processing configuration to the PBR Material.
  58113. * @param configuration
  58114. */
  58115. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58116. /**
  58117. * Stores the available render targets.
  58118. */
  58119. private _renderTargets;
  58120. /**
  58121. * Sets the global ambient color for the material used in lighting calculations.
  58122. */
  58123. private _globalAmbientColor;
  58124. /**
  58125. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58126. */
  58127. private _useLogarithmicDepth;
  58128. /**
  58129. * If set to true, no lighting calculations will be applied.
  58130. */
  58131. private _unlit;
  58132. private _debugMode;
  58133. /**
  58134. * @hidden
  58135. * This is reserved for the inspector.
  58136. * Defines the material debug mode.
  58137. * It helps seeing only some components of the material while troubleshooting.
  58138. */
  58139. debugMode: number;
  58140. /**
  58141. * @hidden
  58142. * This is reserved for the inspector.
  58143. * Specify from where on screen the debug mode should start.
  58144. * The value goes from -1 (full screen) to 1 (not visible)
  58145. * It helps with side by side comparison against the final render
  58146. * This defaults to -1
  58147. */
  58148. private debugLimit;
  58149. /**
  58150. * @hidden
  58151. * This is reserved for the inspector.
  58152. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58153. * You can use the factor to better multiply the final value.
  58154. */
  58155. private debugFactor;
  58156. /**
  58157. * Defines the clear coat layer parameters for the material.
  58158. */
  58159. readonly clearCoat: PBRClearCoatConfiguration;
  58160. /**
  58161. * Defines the anisotropic parameters for the material.
  58162. */
  58163. readonly anisotropy: PBRAnisotropicConfiguration;
  58164. /**
  58165. * Defines the BRDF parameters for the material.
  58166. */
  58167. readonly brdf: PBRBRDFConfiguration;
  58168. /**
  58169. * Defines the Sheen parameters for the material.
  58170. */
  58171. readonly sheen: PBRSheenConfiguration;
  58172. /**
  58173. * Defines the SubSurface parameters for the material.
  58174. */
  58175. readonly subSurface: PBRSubSurfaceConfiguration;
  58176. /**
  58177. * Defines the detail map parameters for the material.
  58178. */
  58179. readonly detailMap: DetailMapConfiguration;
  58180. protected _rebuildInParallel: boolean;
  58181. /**
  58182. * Instantiates a new PBRMaterial instance.
  58183. *
  58184. * @param name The material name
  58185. * @param scene The scene the material will be use in.
  58186. */
  58187. constructor(name: string, scene: Scene);
  58188. /**
  58189. * Gets a boolean indicating that current material needs to register RTT
  58190. */
  58191. get hasRenderTargetTextures(): boolean;
  58192. /**
  58193. * Gets the name of the material class.
  58194. */
  58195. getClassName(): string;
  58196. /**
  58197. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58198. */
  58199. get useLogarithmicDepth(): boolean;
  58200. /**
  58201. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58202. */
  58203. set useLogarithmicDepth(value: boolean);
  58204. /**
  58205. * Returns true if alpha blending should be disabled.
  58206. */
  58207. protected get _disableAlphaBlending(): boolean;
  58208. /**
  58209. * Specifies whether or not this material should be rendered in alpha blend mode.
  58210. */
  58211. needAlphaBlending(): boolean;
  58212. /**
  58213. * Specifies whether or not this material should be rendered in alpha test mode.
  58214. */
  58215. needAlphaTesting(): boolean;
  58216. /**
  58217. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58218. */
  58219. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58220. /**
  58221. * Gets the texture used for the alpha test.
  58222. */
  58223. getAlphaTestTexture(): Nullable<BaseTexture>;
  58224. /**
  58225. * Specifies that the submesh is ready to be used.
  58226. * @param mesh - BJS mesh.
  58227. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58228. * @param useInstances - Specifies that instances should be used.
  58229. * @returns - boolean indicating that the submesh is ready or not.
  58230. */
  58231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58232. /**
  58233. * Specifies if the material uses metallic roughness workflow.
  58234. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58235. */
  58236. isMetallicWorkflow(): boolean;
  58237. private _prepareEffect;
  58238. private _prepareDefines;
  58239. /**
  58240. * Force shader compilation
  58241. */
  58242. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58243. /**
  58244. * Initializes the uniform buffer layout for the shader.
  58245. */
  58246. buildUniformLayout(): void;
  58247. /**
  58248. * Unbinds the material from the mesh
  58249. */
  58250. unbind(): void;
  58251. /**
  58252. * Binds the submesh data.
  58253. * @param world - The world matrix.
  58254. * @param mesh - The BJS mesh.
  58255. * @param subMesh - A submesh of the BJS mesh.
  58256. */
  58257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58258. /**
  58259. * Returns the animatable textures.
  58260. * @returns - Array of animatable textures.
  58261. */
  58262. getAnimatables(): IAnimatable[];
  58263. /**
  58264. * Returns the texture used for reflections.
  58265. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58266. */
  58267. private _getReflectionTexture;
  58268. /**
  58269. * Returns an array of the actively used textures.
  58270. * @returns - Array of BaseTextures
  58271. */
  58272. getActiveTextures(): BaseTexture[];
  58273. /**
  58274. * Checks to see if a texture is used in the material.
  58275. * @param texture - Base texture to use.
  58276. * @returns - Boolean specifying if a texture is used in the material.
  58277. */
  58278. hasTexture(texture: BaseTexture): boolean;
  58279. /**
  58280. * Disposes the resources of the material.
  58281. * @param forceDisposeEffect - Forces the disposal of effects.
  58282. * @param forceDisposeTextures - Forces the disposal of all textures.
  58283. */
  58284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58285. }
  58286. }
  58287. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58288. import { Nullable } from "babylonjs/types";
  58289. import { Scene } from "babylonjs/scene";
  58290. import { Color3 } from "babylonjs/Maths/math.color";
  58291. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58292. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58294. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58295. /**
  58296. * The Physically based material of BJS.
  58297. *
  58298. * This offers the main features of a standard PBR material.
  58299. * For more information, please refer to the documentation :
  58300. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58301. */
  58302. export class PBRMaterial extends PBRBaseMaterial {
  58303. /**
  58304. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58305. */
  58306. static readonly PBRMATERIAL_OPAQUE: number;
  58307. /**
  58308. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58309. */
  58310. static readonly PBRMATERIAL_ALPHATEST: number;
  58311. /**
  58312. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58313. */
  58314. static readonly PBRMATERIAL_ALPHABLEND: number;
  58315. /**
  58316. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58317. * They are also discarded below the alpha cutoff threshold to improve performances.
  58318. */
  58319. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58320. /**
  58321. * Defines the default value of how much AO map is occluding the analytical lights
  58322. * (point spot...).
  58323. */
  58324. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58325. /**
  58326. * Intensity of the direct lights e.g. the four lights available in your scene.
  58327. * This impacts both the direct diffuse and specular highlights.
  58328. */
  58329. directIntensity: number;
  58330. /**
  58331. * Intensity of the emissive part of the material.
  58332. * This helps controlling the emissive effect without modifying the emissive color.
  58333. */
  58334. emissiveIntensity: number;
  58335. /**
  58336. * Intensity of the environment e.g. how much the environment will light the object
  58337. * either through harmonics for rough material or through the refelction for shiny ones.
  58338. */
  58339. environmentIntensity: number;
  58340. /**
  58341. * This is a special control allowing the reduction of the specular highlights coming from the
  58342. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58343. */
  58344. specularIntensity: number;
  58345. /**
  58346. * Debug Control allowing disabling the bump map on this material.
  58347. */
  58348. disableBumpMap: boolean;
  58349. /**
  58350. * AKA Diffuse Texture in standard nomenclature.
  58351. */
  58352. albedoTexture: BaseTexture;
  58353. /**
  58354. * AKA Occlusion Texture in other nomenclature.
  58355. */
  58356. ambientTexture: BaseTexture;
  58357. /**
  58358. * AKA Occlusion Texture Intensity in other nomenclature.
  58359. */
  58360. ambientTextureStrength: number;
  58361. /**
  58362. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58363. * 1 means it completely occludes it
  58364. * 0 mean it has no impact
  58365. */
  58366. ambientTextureImpactOnAnalyticalLights: number;
  58367. /**
  58368. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58369. */
  58370. opacityTexture: BaseTexture;
  58371. /**
  58372. * Stores the reflection values in a texture.
  58373. */
  58374. reflectionTexture: Nullable<BaseTexture>;
  58375. /**
  58376. * Stores the emissive values in a texture.
  58377. */
  58378. emissiveTexture: BaseTexture;
  58379. /**
  58380. * AKA Specular texture in other nomenclature.
  58381. */
  58382. reflectivityTexture: BaseTexture;
  58383. /**
  58384. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58385. */
  58386. metallicTexture: BaseTexture;
  58387. /**
  58388. * Specifies the metallic scalar of the metallic/roughness workflow.
  58389. * Can also be used to scale the metalness values of the metallic texture.
  58390. */
  58391. metallic: Nullable<number>;
  58392. /**
  58393. * Specifies the roughness scalar of the metallic/roughness workflow.
  58394. * Can also be used to scale the roughness values of the metallic texture.
  58395. */
  58396. roughness: Nullable<number>;
  58397. /**
  58398. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58399. * By default the indexOfrefraction is used to compute F0;
  58400. *
  58401. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58402. *
  58403. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58404. * F90 = metallicReflectanceColor;
  58405. */
  58406. metallicF0Factor: number;
  58407. /**
  58408. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58409. * By default the F90 is always 1;
  58410. *
  58411. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58412. *
  58413. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58414. * F90 = metallicReflectanceColor;
  58415. */
  58416. metallicReflectanceColor: Color3;
  58417. /**
  58418. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58419. * This is multiply against the scalar values defined in the material.
  58420. */
  58421. metallicReflectanceTexture: Nullable<BaseTexture>;
  58422. /**
  58423. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58424. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58425. */
  58426. microSurfaceTexture: BaseTexture;
  58427. /**
  58428. * Stores surface normal data used to displace a mesh in a texture.
  58429. */
  58430. bumpTexture: BaseTexture;
  58431. /**
  58432. * Stores the pre-calculated light information of a mesh in a texture.
  58433. */
  58434. lightmapTexture: BaseTexture;
  58435. /**
  58436. * Stores the refracted light information in a texture.
  58437. */
  58438. get refractionTexture(): Nullable<BaseTexture>;
  58439. set refractionTexture(value: Nullable<BaseTexture>);
  58440. /**
  58441. * The color of a material in ambient lighting.
  58442. */
  58443. ambientColor: Color3;
  58444. /**
  58445. * AKA Diffuse Color in other nomenclature.
  58446. */
  58447. albedoColor: Color3;
  58448. /**
  58449. * AKA Specular Color in other nomenclature.
  58450. */
  58451. reflectivityColor: Color3;
  58452. /**
  58453. * The color reflected from the material.
  58454. */
  58455. reflectionColor: Color3;
  58456. /**
  58457. * The color emitted from the material.
  58458. */
  58459. emissiveColor: Color3;
  58460. /**
  58461. * AKA Glossiness in other nomenclature.
  58462. */
  58463. microSurface: number;
  58464. /**
  58465. * Index of refraction of the material base layer.
  58466. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58467. *
  58468. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58469. *
  58470. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58471. */
  58472. get indexOfRefraction(): number;
  58473. set indexOfRefraction(value: number);
  58474. /**
  58475. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58476. */
  58477. get invertRefractionY(): boolean;
  58478. set invertRefractionY(value: boolean);
  58479. /**
  58480. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58481. * Materials half opaque for instance using refraction could benefit from this control.
  58482. */
  58483. get linkRefractionWithTransparency(): boolean;
  58484. set linkRefractionWithTransparency(value: boolean);
  58485. /**
  58486. * If true, the light map contains occlusion information instead of lighting info.
  58487. */
  58488. useLightmapAsShadowmap: boolean;
  58489. /**
  58490. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58491. */
  58492. useAlphaFromAlbedoTexture: boolean;
  58493. /**
  58494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58495. */
  58496. forceAlphaTest: boolean;
  58497. /**
  58498. * Defines the alpha limits in alpha test mode.
  58499. */
  58500. alphaCutOff: number;
  58501. /**
  58502. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58503. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58504. */
  58505. useSpecularOverAlpha: boolean;
  58506. /**
  58507. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58508. */
  58509. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58510. /**
  58511. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58512. */
  58513. useRoughnessFromMetallicTextureAlpha: boolean;
  58514. /**
  58515. * Specifies if the metallic texture contains the roughness information in its green channel.
  58516. */
  58517. useRoughnessFromMetallicTextureGreen: boolean;
  58518. /**
  58519. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58520. */
  58521. useMetallnessFromMetallicTextureBlue: boolean;
  58522. /**
  58523. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58524. */
  58525. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58526. /**
  58527. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58528. */
  58529. useAmbientInGrayScale: boolean;
  58530. /**
  58531. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58532. * The material will try to infer what glossiness each pixel should be.
  58533. */
  58534. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58535. /**
  58536. * BJS is using an harcoded light falloff based on a manually sets up range.
  58537. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58538. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58539. */
  58540. get usePhysicalLightFalloff(): boolean;
  58541. /**
  58542. * BJS is using an harcoded light falloff based on a manually sets up range.
  58543. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58544. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58545. */
  58546. set usePhysicalLightFalloff(value: boolean);
  58547. /**
  58548. * In order to support the falloff compatibility with gltf, a special mode has been added
  58549. * to reproduce the gltf light falloff.
  58550. */
  58551. get useGLTFLightFalloff(): boolean;
  58552. /**
  58553. * In order to support the falloff compatibility with gltf, a special mode has been added
  58554. * to reproduce the gltf light falloff.
  58555. */
  58556. set useGLTFLightFalloff(value: boolean);
  58557. /**
  58558. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58559. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58560. */
  58561. useRadianceOverAlpha: boolean;
  58562. /**
  58563. * Allows using an object space normal map (instead of tangent space).
  58564. */
  58565. useObjectSpaceNormalMap: boolean;
  58566. /**
  58567. * Allows using the bump map in parallax mode.
  58568. */
  58569. useParallax: boolean;
  58570. /**
  58571. * Allows using the bump map in parallax occlusion mode.
  58572. */
  58573. useParallaxOcclusion: boolean;
  58574. /**
  58575. * Controls the scale bias of the parallax mode.
  58576. */
  58577. parallaxScaleBias: number;
  58578. /**
  58579. * If sets to true, disables all the lights affecting the material.
  58580. */
  58581. disableLighting: boolean;
  58582. /**
  58583. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58584. */
  58585. forceIrradianceInFragment: boolean;
  58586. /**
  58587. * Number of Simultaneous lights allowed on the material.
  58588. */
  58589. maxSimultaneousLights: number;
  58590. /**
  58591. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58592. */
  58593. invertNormalMapX: boolean;
  58594. /**
  58595. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58596. */
  58597. invertNormalMapY: boolean;
  58598. /**
  58599. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58600. */
  58601. twoSidedLighting: boolean;
  58602. /**
  58603. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58604. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58605. */
  58606. useAlphaFresnel: boolean;
  58607. /**
  58608. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58609. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58610. */
  58611. useLinearAlphaFresnel: boolean;
  58612. /**
  58613. * Let user defines the brdf lookup texture used for IBL.
  58614. * A default 8bit version is embedded but you could point at :
  58615. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58616. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58617. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58618. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58619. */
  58620. environmentBRDFTexture: Nullable<BaseTexture>;
  58621. /**
  58622. * Force normal to face away from face.
  58623. */
  58624. forceNormalForward: boolean;
  58625. /**
  58626. * Enables specular anti aliasing in the PBR shader.
  58627. * It will both interacts on the Geometry for analytical and IBL lighting.
  58628. * It also prefilter the roughness map based on the bump values.
  58629. */
  58630. enableSpecularAntiAliasing: boolean;
  58631. /**
  58632. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58633. * makes the reflect vector face the model (under horizon).
  58634. */
  58635. useHorizonOcclusion: boolean;
  58636. /**
  58637. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58638. * too much the area relying on ambient texture to define their ambient occlusion.
  58639. */
  58640. useRadianceOcclusion: boolean;
  58641. /**
  58642. * If set to true, no lighting calculations will be applied.
  58643. */
  58644. unlit: boolean;
  58645. /**
  58646. * Gets the image processing configuration used either in this material.
  58647. */
  58648. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58649. /**
  58650. * Sets the Default image processing configuration used either in the this material.
  58651. *
  58652. * If sets to null, the scene one is in use.
  58653. */
  58654. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58655. /**
  58656. * Gets wether the color curves effect is enabled.
  58657. */
  58658. get cameraColorCurvesEnabled(): boolean;
  58659. /**
  58660. * Sets wether the color curves effect is enabled.
  58661. */
  58662. set cameraColorCurvesEnabled(value: boolean);
  58663. /**
  58664. * Gets wether the color grading effect is enabled.
  58665. */
  58666. get cameraColorGradingEnabled(): boolean;
  58667. /**
  58668. * Gets wether the color grading effect is enabled.
  58669. */
  58670. set cameraColorGradingEnabled(value: boolean);
  58671. /**
  58672. * Gets wether tonemapping is enabled or not.
  58673. */
  58674. get cameraToneMappingEnabled(): boolean;
  58675. /**
  58676. * Sets wether tonemapping is enabled or not
  58677. */
  58678. set cameraToneMappingEnabled(value: boolean);
  58679. /**
  58680. * The camera exposure used on this material.
  58681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58682. * This corresponds to a photographic exposure.
  58683. */
  58684. get cameraExposure(): number;
  58685. /**
  58686. * The camera exposure used on this material.
  58687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58688. * This corresponds to a photographic exposure.
  58689. */
  58690. set cameraExposure(value: number);
  58691. /**
  58692. * Gets The camera contrast used on this material.
  58693. */
  58694. get cameraContrast(): number;
  58695. /**
  58696. * Sets The camera contrast used on this material.
  58697. */
  58698. set cameraContrast(value: number);
  58699. /**
  58700. * Gets the Color Grading 2D Lookup Texture.
  58701. */
  58702. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58703. /**
  58704. * Sets the Color Grading 2D Lookup Texture.
  58705. */
  58706. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58707. /**
  58708. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58709. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58710. * 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;
  58711. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58712. */
  58713. get cameraColorCurves(): Nullable<ColorCurves>;
  58714. /**
  58715. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58716. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58717. * 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;
  58718. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58719. */
  58720. set cameraColorCurves(value: Nullable<ColorCurves>);
  58721. /**
  58722. * Instantiates a new PBRMaterial instance.
  58723. *
  58724. * @param name The material name
  58725. * @param scene The scene the material will be use in.
  58726. */
  58727. constructor(name: string, scene: Scene);
  58728. /**
  58729. * Returns the name of this material class.
  58730. */
  58731. getClassName(): string;
  58732. /**
  58733. * Makes a duplicate of the current material.
  58734. * @param name - name to use for the new material.
  58735. */
  58736. clone(name: string): PBRMaterial;
  58737. /**
  58738. * Serializes this PBR Material.
  58739. * @returns - An object with the serialized material.
  58740. */
  58741. serialize(): any;
  58742. /**
  58743. * Parses a PBR Material from a serialized object.
  58744. * @param source - Serialized object.
  58745. * @param scene - BJS scene instance.
  58746. * @param rootUrl - url for the scene object
  58747. * @returns - PBRMaterial
  58748. */
  58749. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58750. }
  58751. }
  58752. declare module "babylonjs/Misc/dds" {
  58753. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58755. import { Nullable } from "babylonjs/types";
  58756. import { Scene } from "babylonjs/scene";
  58757. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58758. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58759. /**
  58760. * Direct draw surface info
  58761. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58762. */
  58763. export interface DDSInfo {
  58764. /**
  58765. * Width of the texture
  58766. */
  58767. width: number;
  58768. /**
  58769. * Width of the texture
  58770. */
  58771. height: number;
  58772. /**
  58773. * Number of Mipmaps for the texture
  58774. * @see https://en.wikipedia.org/wiki/Mipmap
  58775. */
  58776. mipmapCount: number;
  58777. /**
  58778. * If the textures format is a known fourCC format
  58779. * @see https://www.fourcc.org/
  58780. */
  58781. isFourCC: boolean;
  58782. /**
  58783. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58784. */
  58785. isRGB: boolean;
  58786. /**
  58787. * If the texture is a lumincance format
  58788. */
  58789. isLuminance: boolean;
  58790. /**
  58791. * If this is a cube texture
  58792. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58793. */
  58794. isCube: boolean;
  58795. /**
  58796. * If the texture is a compressed format eg. FOURCC_DXT1
  58797. */
  58798. isCompressed: boolean;
  58799. /**
  58800. * The dxgiFormat of the texture
  58801. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58802. */
  58803. dxgiFormat: number;
  58804. /**
  58805. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58806. */
  58807. textureType: number;
  58808. /**
  58809. * Sphericle polynomial created for the dds texture
  58810. */
  58811. sphericalPolynomial?: SphericalPolynomial;
  58812. }
  58813. /**
  58814. * Class used to provide DDS decompression tools
  58815. */
  58816. export class DDSTools {
  58817. /**
  58818. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58819. */
  58820. static StoreLODInAlphaChannel: boolean;
  58821. /**
  58822. * Gets DDS information from an array buffer
  58823. * @param data defines the array buffer view to read data from
  58824. * @returns the DDS information
  58825. */
  58826. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58827. private static _FloatView;
  58828. private static _Int32View;
  58829. private static _ToHalfFloat;
  58830. private static _FromHalfFloat;
  58831. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58832. private static _GetHalfFloatRGBAArrayBuffer;
  58833. private static _GetFloatRGBAArrayBuffer;
  58834. private static _GetFloatAsUIntRGBAArrayBuffer;
  58835. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58836. private static _GetRGBAArrayBuffer;
  58837. private static _ExtractLongWordOrder;
  58838. private static _GetRGBArrayBuffer;
  58839. private static _GetLuminanceArrayBuffer;
  58840. /**
  58841. * Uploads DDS Levels to a Babylon Texture
  58842. * @hidden
  58843. */
  58844. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58845. }
  58846. module "babylonjs/Engines/thinEngine" {
  58847. interface ThinEngine {
  58848. /**
  58849. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58850. * @param rootUrl defines the url where the file to load is located
  58851. * @param scene defines the current scene
  58852. * @param lodScale defines scale to apply to the mip map selection
  58853. * @param lodOffset defines offset to apply to the mip map selection
  58854. * @param onLoad defines an optional callback raised when the texture is loaded
  58855. * @param onError defines an optional callback raised if there is an issue to load the texture
  58856. * @param format defines the format of the data
  58857. * @param forcedExtension defines the extension to use to pick the right loader
  58858. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58859. * @returns the cube texture as an InternalTexture
  58860. */
  58861. 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;
  58862. }
  58863. }
  58864. }
  58865. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58866. import { Nullable } from "babylonjs/types";
  58867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58868. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58869. /**
  58870. * Implementation of the DDS Texture Loader.
  58871. * @hidden
  58872. */
  58873. export class _DDSTextureLoader implements IInternalTextureLoader {
  58874. /**
  58875. * Defines wether the loader supports cascade loading the different faces.
  58876. */
  58877. readonly supportCascades: boolean;
  58878. /**
  58879. * This returns if the loader support the current file information.
  58880. * @param extension defines the file extension of the file being loaded
  58881. * @returns true if the loader can load the specified file
  58882. */
  58883. canLoad(extension: string): boolean;
  58884. /**
  58885. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58886. * @param data contains the texture data
  58887. * @param texture defines the BabylonJS internal texture
  58888. * @param createPolynomials will be true if polynomials have been requested
  58889. * @param onLoad defines the callback to trigger once the texture is ready
  58890. * @param onError defines the callback to trigger in case of error
  58891. */
  58892. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58893. /**
  58894. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58895. * @param data contains the texture data
  58896. * @param texture defines the BabylonJS internal texture
  58897. * @param callback defines the method to call once ready to upload
  58898. */
  58899. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58900. }
  58901. }
  58902. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58903. import { Nullable } from "babylonjs/types";
  58904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58905. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58906. /**
  58907. * Implementation of the ENV Texture Loader.
  58908. * @hidden
  58909. */
  58910. export class _ENVTextureLoader implements IInternalTextureLoader {
  58911. /**
  58912. * Defines wether the loader supports cascade loading the different faces.
  58913. */
  58914. readonly supportCascades: boolean;
  58915. /**
  58916. * This returns if the loader support the current file information.
  58917. * @param extension defines the file extension of the file being loaded
  58918. * @returns true if the loader can load the specified file
  58919. */
  58920. canLoad(extension: string): boolean;
  58921. /**
  58922. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58923. * @param data contains the texture data
  58924. * @param texture defines the BabylonJS internal texture
  58925. * @param createPolynomials will be true if polynomials have been requested
  58926. * @param onLoad defines the callback to trigger once the texture is ready
  58927. * @param onError defines the callback to trigger in case of error
  58928. */
  58929. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58930. /**
  58931. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58932. * @param data contains the texture data
  58933. * @param texture defines the BabylonJS internal texture
  58934. * @param callback defines the method to call once ready to upload
  58935. */
  58936. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58937. }
  58938. }
  58939. declare module "babylonjs/Misc/khronosTextureContainer" {
  58940. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58941. /**
  58942. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58943. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58944. */
  58945. export class KhronosTextureContainer {
  58946. /** contents of the KTX container file */
  58947. data: ArrayBufferView;
  58948. private static HEADER_LEN;
  58949. private static COMPRESSED_2D;
  58950. private static COMPRESSED_3D;
  58951. private static TEX_2D;
  58952. private static TEX_3D;
  58953. /**
  58954. * Gets the openGL type
  58955. */
  58956. glType: number;
  58957. /**
  58958. * Gets the openGL type size
  58959. */
  58960. glTypeSize: number;
  58961. /**
  58962. * Gets the openGL format
  58963. */
  58964. glFormat: number;
  58965. /**
  58966. * Gets the openGL internal format
  58967. */
  58968. glInternalFormat: number;
  58969. /**
  58970. * Gets the base internal format
  58971. */
  58972. glBaseInternalFormat: number;
  58973. /**
  58974. * Gets image width in pixel
  58975. */
  58976. pixelWidth: number;
  58977. /**
  58978. * Gets image height in pixel
  58979. */
  58980. pixelHeight: number;
  58981. /**
  58982. * Gets image depth in pixels
  58983. */
  58984. pixelDepth: number;
  58985. /**
  58986. * Gets the number of array elements
  58987. */
  58988. numberOfArrayElements: number;
  58989. /**
  58990. * Gets the number of faces
  58991. */
  58992. numberOfFaces: number;
  58993. /**
  58994. * Gets the number of mipmap levels
  58995. */
  58996. numberOfMipmapLevels: number;
  58997. /**
  58998. * Gets the bytes of key value data
  58999. */
  59000. bytesOfKeyValueData: number;
  59001. /**
  59002. * Gets the load type
  59003. */
  59004. loadType: number;
  59005. /**
  59006. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59007. */
  59008. isInvalid: boolean;
  59009. /**
  59010. * Creates a new KhronosTextureContainer
  59011. * @param data contents of the KTX container file
  59012. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59013. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59014. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59015. */
  59016. constructor(
  59017. /** contents of the KTX container file */
  59018. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59019. /**
  59020. * Uploads KTX content to a Babylon Texture.
  59021. * It is assumed that the texture has already been created & is currently bound
  59022. * @hidden
  59023. */
  59024. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59025. private _upload2DCompressedLevels;
  59026. /**
  59027. * Checks if the given data starts with a KTX file identifier.
  59028. * @param data the data to check
  59029. * @returns true if the data is a KTX file or false otherwise
  59030. */
  59031. static IsValid(data: ArrayBufferView): boolean;
  59032. }
  59033. }
  59034. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59036. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59037. /**
  59038. * Class for loading KTX2 files
  59039. * !!! Experimental Extension Subject to Changes !!!
  59040. * @hidden
  59041. */
  59042. export class KhronosTextureContainer2 {
  59043. private static _ModulePromise;
  59044. private static _TranscodeFormat;
  59045. constructor(engine: ThinEngine);
  59046. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59047. private _determineTranscodeFormat;
  59048. /**
  59049. * Checks if the given data starts with a KTX2 file identifier.
  59050. * @param data the data to check
  59051. * @returns true if the data is a KTX2 file or false otherwise
  59052. */
  59053. static IsValid(data: ArrayBufferView): boolean;
  59054. }
  59055. }
  59056. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59057. import { Nullable } from "babylonjs/types";
  59058. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59059. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59060. /**
  59061. * Implementation of the KTX Texture Loader.
  59062. * @hidden
  59063. */
  59064. export class _KTXTextureLoader implements IInternalTextureLoader {
  59065. /**
  59066. * Defines wether the loader supports cascade loading the different faces.
  59067. */
  59068. readonly supportCascades: boolean;
  59069. /**
  59070. * This returns if the loader support the current file information.
  59071. * @param extension defines the file extension of the file being loaded
  59072. * @param mimeType defines the optional mime type of the file being loaded
  59073. * @returns true if the loader can load the specified file
  59074. */
  59075. canLoad(extension: string, mimeType?: string): boolean;
  59076. /**
  59077. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59078. * @param data contains the texture data
  59079. * @param texture defines the BabylonJS internal texture
  59080. * @param createPolynomials will be true if polynomials have been requested
  59081. * @param onLoad defines the callback to trigger once the texture is ready
  59082. * @param onError defines the callback to trigger in case of error
  59083. */
  59084. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59085. /**
  59086. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59087. * @param data contains the texture data
  59088. * @param texture defines the BabylonJS internal texture
  59089. * @param callback defines the method to call once ready to upload
  59090. */
  59091. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59092. }
  59093. }
  59094. declare module "babylonjs/Helpers/sceneHelpers" {
  59095. import { Nullable } from "babylonjs/types";
  59096. import { Mesh } from "babylonjs/Meshes/mesh";
  59097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59098. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59099. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59100. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59101. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59102. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59103. import "babylonjs/Meshes/Builders/boxBuilder";
  59104. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59105. /** @hidden */
  59106. export var _forceSceneHelpersToBundle: boolean;
  59107. module "babylonjs/scene" {
  59108. interface Scene {
  59109. /**
  59110. * Creates a default light for the scene.
  59111. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59112. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59113. */
  59114. createDefaultLight(replace?: boolean): void;
  59115. /**
  59116. * Creates a default camera for the scene.
  59117. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59118. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59119. * @param replace has default false, when true replaces the active camera in the scene
  59120. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59121. */
  59122. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59123. /**
  59124. * Creates a default camera and a default light.
  59125. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59126. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59127. * @param replace has the default false, when true replaces the active camera/light in the scene
  59128. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59129. */
  59130. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59131. /**
  59132. * Creates a new sky box
  59133. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59134. * @param environmentTexture defines the texture to use as environment texture
  59135. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59136. * @param scale defines the overall scale of the skybox
  59137. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59138. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59139. * @returns a new mesh holding the sky box
  59140. */
  59141. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59142. /**
  59143. * Creates a new environment
  59144. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59145. * @param options defines the options you can use to configure the environment
  59146. * @returns the new EnvironmentHelper
  59147. */
  59148. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59149. /**
  59150. * Creates a new VREXperienceHelper
  59151. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59152. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59153. * @returns a new VREXperienceHelper
  59154. */
  59155. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59156. /**
  59157. * Creates a new WebXRDefaultExperience
  59158. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59159. * @param options experience options
  59160. * @returns a promise for a new WebXRDefaultExperience
  59161. */
  59162. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59163. }
  59164. }
  59165. }
  59166. declare module "babylonjs/Helpers/videoDome" {
  59167. import { Scene } from "babylonjs/scene";
  59168. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59169. import { Mesh } from "babylonjs/Meshes/mesh";
  59170. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59171. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59172. import "babylonjs/Meshes/Builders/sphereBuilder";
  59173. /**
  59174. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59175. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59176. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59177. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59178. */
  59179. export class VideoDome extends TransformNode {
  59180. /**
  59181. * Define the video source as a Monoscopic panoramic 360 video.
  59182. */
  59183. static readonly MODE_MONOSCOPIC: number;
  59184. /**
  59185. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59186. */
  59187. static readonly MODE_TOPBOTTOM: number;
  59188. /**
  59189. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59190. */
  59191. static readonly MODE_SIDEBYSIDE: number;
  59192. private _halfDome;
  59193. private _useDirectMapping;
  59194. /**
  59195. * The video texture being displayed on the sphere
  59196. */
  59197. protected _videoTexture: VideoTexture;
  59198. /**
  59199. * Gets the video texture being displayed on the sphere
  59200. */
  59201. get videoTexture(): VideoTexture;
  59202. /**
  59203. * The skybox material
  59204. */
  59205. protected _material: BackgroundMaterial;
  59206. /**
  59207. * The surface used for the skybox
  59208. */
  59209. protected _mesh: Mesh;
  59210. /**
  59211. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59212. */
  59213. private _halfDomeMask;
  59214. /**
  59215. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59216. * Also see the options.resolution property.
  59217. */
  59218. get fovMultiplier(): number;
  59219. set fovMultiplier(value: number);
  59220. private _videoMode;
  59221. /**
  59222. * Gets or set the current video mode for the video. It can be:
  59223. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59224. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59225. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59226. */
  59227. get videoMode(): number;
  59228. set videoMode(value: number);
  59229. /**
  59230. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59231. *
  59232. */
  59233. get halfDome(): boolean;
  59234. /**
  59235. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59236. */
  59237. set halfDome(enabled: boolean);
  59238. /**
  59239. * Oberserver used in Stereoscopic VR Mode.
  59240. */
  59241. private _onBeforeCameraRenderObserver;
  59242. /**
  59243. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59244. * @param name Element's name, child elements will append suffixes for their own names.
  59245. * @param urlsOrVideo defines the url(s) or the video element to use
  59246. * @param options An object containing optional or exposed sub element properties
  59247. */
  59248. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59249. resolution?: number;
  59250. clickToPlay?: boolean;
  59251. autoPlay?: boolean;
  59252. loop?: boolean;
  59253. size?: number;
  59254. poster?: string;
  59255. faceForward?: boolean;
  59256. useDirectMapping?: boolean;
  59257. halfDomeMode?: boolean;
  59258. }, scene: Scene);
  59259. private _changeVideoMode;
  59260. /**
  59261. * Releases resources associated with this node.
  59262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59264. */
  59265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59266. }
  59267. }
  59268. declare module "babylonjs/Helpers/index" {
  59269. export * from "babylonjs/Helpers/environmentHelper";
  59270. export * from "babylonjs/Helpers/photoDome";
  59271. export * from "babylonjs/Helpers/sceneHelpers";
  59272. export * from "babylonjs/Helpers/videoDome";
  59273. }
  59274. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59275. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59276. import { IDisposable } from "babylonjs/scene";
  59277. import { Engine } from "babylonjs/Engines/engine";
  59278. /**
  59279. * This class can be used to get instrumentation data from a Babylon engine
  59280. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59281. */
  59282. export class EngineInstrumentation implements IDisposable {
  59283. /**
  59284. * Define the instrumented engine.
  59285. */
  59286. engine: Engine;
  59287. private _captureGPUFrameTime;
  59288. private _gpuFrameTimeToken;
  59289. private _gpuFrameTime;
  59290. private _captureShaderCompilationTime;
  59291. private _shaderCompilationTime;
  59292. private _onBeginFrameObserver;
  59293. private _onEndFrameObserver;
  59294. private _onBeforeShaderCompilationObserver;
  59295. private _onAfterShaderCompilationObserver;
  59296. /**
  59297. * Gets the perf counter used for GPU frame time
  59298. */
  59299. get gpuFrameTimeCounter(): PerfCounter;
  59300. /**
  59301. * Gets the GPU frame time capture status
  59302. */
  59303. get captureGPUFrameTime(): boolean;
  59304. /**
  59305. * Enable or disable the GPU frame time capture
  59306. */
  59307. set captureGPUFrameTime(value: boolean);
  59308. /**
  59309. * Gets the perf counter used for shader compilation time
  59310. */
  59311. get shaderCompilationTimeCounter(): PerfCounter;
  59312. /**
  59313. * Gets the shader compilation time capture status
  59314. */
  59315. get captureShaderCompilationTime(): boolean;
  59316. /**
  59317. * Enable or disable the shader compilation time capture
  59318. */
  59319. set captureShaderCompilationTime(value: boolean);
  59320. /**
  59321. * Instantiates a new engine instrumentation.
  59322. * This class can be used to get instrumentation data from a Babylon engine
  59323. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59324. * @param engine Defines the engine to instrument
  59325. */
  59326. constructor(
  59327. /**
  59328. * Define the instrumented engine.
  59329. */
  59330. engine: Engine);
  59331. /**
  59332. * Dispose and release associated resources.
  59333. */
  59334. dispose(): void;
  59335. }
  59336. }
  59337. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59338. import { Scene, IDisposable } from "babylonjs/scene";
  59339. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59340. /**
  59341. * This class can be used to get instrumentation data from a Babylon engine
  59342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59343. */
  59344. export class SceneInstrumentation implements IDisposable {
  59345. /**
  59346. * Defines the scene to instrument
  59347. */
  59348. scene: Scene;
  59349. private _captureActiveMeshesEvaluationTime;
  59350. private _activeMeshesEvaluationTime;
  59351. private _captureRenderTargetsRenderTime;
  59352. private _renderTargetsRenderTime;
  59353. private _captureFrameTime;
  59354. private _frameTime;
  59355. private _captureRenderTime;
  59356. private _renderTime;
  59357. private _captureInterFrameTime;
  59358. private _interFrameTime;
  59359. private _captureParticlesRenderTime;
  59360. private _particlesRenderTime;
  59361. private _captureSpritesRenderTime;
  59362. private _spritesRenderTime;
  59363. private _capturePhysicsTime;
  59364. private _physicsTime;
  59365. private _captureAnimationsTime;
  59366. private _animationsTime;
  59367. private _captureCameraRenderTime;
  59368. private _cameraRenderTime;
  59369. private _onBeforeActiveMeshesEvaluationObserver;
  59370. private _onAfterActiveMeshesEvaluationObserver;
  59371. private _onBeforeRenderTargetsRenderObserver;
  59372. private _onAfterRenderTargetsRenderObserver;
  59373. private _onAfterRenderObserver;
  59374. private _onBeforeDrawPhaseObserver;
  59375. private _onAfterDrawPhaseObserver;
  59376. private _onBeforeAnimationsObserver;
  59377. private _onBeforeParticlesRenderingObserver;
  59378. private _onAfterParticlesRenderingObserver;
  59379. private _onBeforeSpritesRenderingObserver;
  59380. private _onAfterSpritesRenderingObserver;
  59381. private _onBeforePhysicsObserver;
  59382. private _onAfterPhysicsObserver;
  59383. private _onAfterAnimationsObserver;
  59384. private _onBeforeCameraRenderObserver;
  59385. private _onAfterCameraRenderObserver;
  59386. /**
  59387. * Gets the perf counter used for active meshes evaluation time
  59388. */
  59389. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59390. /**
  59391. * Gets the active meshes evaluation time capture status
  59392. */
  59393. get captureActiveMeshesEvaluationTime(): boolean;
  59394. /**
  59395. * Enable or disable the active meshes evaluation time capture
  59396. */
  59397. set captureActiveMeshesEvaluationTime(value: boolean);
  59398. /**
  59399. * Gets the perf counter used for render targets render time
  59400. */
  59401. get renderTargetsRenderTimeCounter(): PerfCounter;
  59402. /**
  59403. * Gets the render targets render time capture status
  59404. */
  59405. get captureRenderTargetsRenderTime(): boolean;
  59406. /**
  59407. * Enable or disable the render targets render time capture
  59408. */
  59409. set captureRenderTargetsRenderTime(value: boolean);
  59410. /**
  59411. * Gets the perf counter used for particles render time
  59412. */
  59413. get particlesRenderTimeCounter(): PerfCounter;
  59414. /**
  59415. * Gets the particles render time capture status
  59416. */
  59417. get captureParticlesRenderTime(): boolean;
  59418. /**
  59419. * Enable or disable the particles render time capture
  59420. */
  59421. set captureParticlesRenderTime(value: boolean);
  59422. /**
  59423. * Gets the perf counter used for sprites render time
  59424. */
  59425. get spritesRenderTimeCounter(): PerfCounter;
  59426. /**
  59427. * Gets the sprites render time capture status
  59428. */
  59429. get captureSpritesRenderTime(): boolean;
  59430. /**
  59431. * Enable or disable the sprites render time capture
  59432. */
  59433. set captureSpritesRenderTime(value: boolean);
  59434. /**
  59435. * Gets the perf counter used for physics time
  59436. */
  59437. get physicsTimeCounter(): PerfCounter;
  59438. /**
  59439. * Gets the physics time capture status
  59440. */
  59441. get capturePhysicsTime(): boolean;
  59442. /**
  59443. * Enable or disable the physics time capture
  59444. */
  59445. set capturePhysicsTime(value: boolean);
  59446. /**
  59447. * Gets the perf counter used for animations time
  59448. */
  59449. get animationsTimeCounter(): PerfCounter;
  59450. /**
  59451. * Gets the animations time capture status
  59452. */
  59453. get captureAnimationsTime(): boolean;
  59454. /**
  59455. * Enable or disable the animations time capture
  59456. */
  59457. set captureAnimationsTime(value: boolean);
  59458. /**
  59459. * Gets the perf counter used for frame time capture
  59460. */
  59461. get frameTimeCounter(): PerfCounter;
  59462. /**
  59463. * Gets the frame time capture status
  59464. */
  59465. get captureFrameTime(): boolean;
  59466. /**
  59467. * Enable or disable the frame time capture
  59468. */
  59469. set captureFrameTime(value: boolean);
  59470. /**
  59471. * Gets the perf counter used for inter-frames time capture
  59472. */
  59473. get interFrameTimeCounter(): PerfCounter;
  59474. /**
  59475. * Gets the inter-frames time capture status
  59476. */
  59477. get captureInterFrameTime(): boolean;
  59478. /**
  59479. * Enable or disable the inter-frames time capture
  59480. */
  59481. set captureInterFrameTime(value: boolean);
  59482. /**
  59483. * Gets the perf counter used for render time capture
  59484. */
  59485. get renderTimeCounter(): PerfCounter;
  59486. /**
  59487. * Gets the render time capture status
  59488. */
  59489. get captureRenderTime(): boolean;
  59490. /**
  59491. * Enable or disable the render time capture
  59492. */
  59493. set captureRenderTime(value: boolean);
  59494. /**
  59495. * Gets the perf counter used for camera render time capture
  59496. */
  59497. get cameraRenderTimeCounter(): PerfCounter;
  59498. /**
  59499. * Gets the camera render time capture status
  59500. */
  59501. get captureCameraRenderTime(): boolean;
  59502. /**
  59503. * Enable or disable the camera render time capture
  59504. */
  59505. set captureCameraRenderTime(value: boolean);
  59506. /**
  59507. * Gets the perf counter used for draw calls
  59508. */
  59509. get drawCallsCounter(): PerfCounter;
  59510. /**
  59511. * Instantiates a new scene instrumentation.
  59512. * This class can be used to get instrumentation data from a Babylon engine
  59513. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59514. * @param scene Defines the scene to instrument
  59515. */
  59516. constructor(
  59517. /**
  59518. * Defines the scene to instrument
  59519. */
  59520. scene: Scene);
  59521. /**
  59522. * Dispose and release associated resources.
  59523. */
  59524. dispose(): void;
  59525. }
  59526. }
  59527. declare module "babylonjs/Instrumentation/index" {
  59528. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59529. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59530. export * from "babylonjs/Instrumentation/timeToken";
  59531. }
  59532. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59533. /** @hidden */
  59534. export var glowMapGenerationPixelShader: {
  59535. name: string;
  59536. shader: string;
  59537. };
  59538. }
  59539. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59540. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59543. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59545. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59546. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59547. /** @hidden */
  59548. export var glowMapGenerationVertexShader: {
  59549. name: string;
  59550. shader: string;
  59551. };
  59552. }
  59553. declare module "babylonjs/Layers/effectLayer" {
  59554. import { Observable } from "babylonjs/Misc/observable";
  59555. import { Nullable } from "babylonjs/types";
  59556. import { Camera } from "babylonjs/Cameras/camera";
  59557. import { Scene } from "babylonjs/scene";
  59558. import { ISize } from "babylonjs/Maths/math.size";
  59559. import { Color4 } from "babylonjs/Maths/math.color";
  59560. import { Engine } from "babylonjs/Engines/engine";
  59561. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59563. import { Mesh } from "babylonjs/Meshes/mesh";
  59564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59567. import { Effect } from "babylonjs/Materials/effect";
  59568. import { Material } from "babylonjs/Materials/material";
  59569. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59570. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59571. /**
  59572. * Effect layer options. This helps customizing the behaviour
  59573. * of the effect layer.
  59574. */
  59575. export interface IEffectLayerOptions {
  59576. /**
  59577. * Multiplication factor apply to the canvas size to compute the render target size
  59578. * used to generated the objects (the smaller the faster).
  59579. */
  59580. mainTextureRatio: number;
  59581. /**
  59582. * Enforces a fixed size texture to ensure effect stability across devices.
  59583. */
  59584. mainTextureFixedSize?: number;
  59585. /**
  59586. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59587. */
  59588. alphaBlendingMode: number;
  59589. /**
  59590. * The camera attached to the layer.
  59591. */
  59592. camera: Nullable<Camera>;
  59593. /**
  59594. * The rendering group to draw the layer in.
  59595. */
  59596. renderingGroupId: number;
  59597. }
  59598. /**
  59599. * The effect layer Helps adding post process effect blended with the main pass.
  59600. *
  59601. * This can be for instance use to generate glow or higlight effects on the scene.
  59602. *
  59603. * The effect layer class can not be used directly and is intented to inherited from to be
  59604. * customized per effects.
  59605. */
  59606. export abstract class EffectLayer {
  59607. private _vertexBuffers;
  59608. private _indexBuffer;
  59609. private _cachedDefines;
  59610. private _effectLayerMapGenerationEffect;
  59611. private _effectLayerOptions;
  59612. private _mergeEffect;
  59613. protected _scene: Scene;
  59614. protected _engine: Engine;
  59615. protected _maxSize: number;
  59616. protected _mainTextureDesiredSize: ISize;
  59617. protected _mainTexture: RenderTargetTexture;
  59618. protected _shouldRender: boolean;
  59619. protected _postProcesses: PostProcess[];
  59620. protected _textures: BaseTexture[];
  59621. protected _emissiveTextureAndColor: {
  59622. texture: Nullable<BaseTexture>;
  59623. color: Color4;
  59624. };
  59625. /**
  59626. * The name of the layer
  59627. */
  59628. name: string;
  59629. /**
  59630. * The clear color of the texture used to generate the glow map.
  59631. */
  59632. neutralColor: Color4;
  59633. /**
  59634. * Specifies whether the highlight layer is enabled or not.
  59635. */
  59636. isEnabled: boolean;
  59637. /**
  59638. * Gets the camera attached to the layer.
  59639. */
  59640. get camera(): Nullable<Camera>;
  59641. /**
  59642. * Gets the rendering group id the layer should render in.
  59643. */
  59644. get renderingGroupId(): number;
  59645. set renderingGroupId(renderingGroupId: number);
  59646. /**
  59647. * An event triggered when the effect layer has been disposed.
  59648. */
  59649. onDisposeObservable: Observable<EffectLayer>;
  59650. /**
  59651. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59652. */
  59653. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59654. /**
  59655. * An event triggered when the generated texture is being merged in the scene.
  59656. */
  59657. onBeforeComposeObservable: Observable<EffectLayer>;
  59658. /**
  59659. * An event triggered when the mesh is rendered into the effect render target.
  59660. */
  59661. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59662. /**
  59663. * An event triggered after the mesh has been rendered into the effect render target.
  59664. */
  59665. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59666. /**
  59667. * An event triggered when the generated texture has been merged in the scene.
  59668. */
  59669. onAfterComposeObservable: Observable<EffectLayer>;
  59670. /**
  59671. * An event triggered when the efffect layer changes its size.
  59672. */
  59673. onSizeChangedObservable: Observable<EffectLayer>;
  59674. /** @hidden */
  59675. static _SceneComponentInitialization: (scene: Scene) => void;
  59676. /**
  59677. * Instantiates a new effect Layer and references it in the scene.
  59678. * @param name The name of the layer
  59679. * @param scene The scene to use the layer in
  59680. */
  59681. constructor(
  59682. /** The Friendly of the effect in the scene */
  59683. name: string, scene: Scene);
  59684. /**
  59685. * Get the effect name of the layer.
  59686. * @return The effect name
  59687. */
  59688. abstract getEffectName(): string;
  59689. /**
  59690. * Checks for the readiness of the element composing the layer.
  59691. * @param subMesh the mesh to check for
  59692. * @param useInstances specify whether or not to use instances to render the mesh
  59693. * @return true if ready otherwise, false
  59694. */
  59695. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59696. /**
  59697. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59698. * @returns true if the effect requires stencil during the main canvas render pass.
  59699. */
  59700. abstract needStencil(): boolean;
  59701. /**
  59702. * Create the merge effect. This is the shader use to blit the information back
  59703. * to the main canvas at the end of the scene rendering.
  59704. * @returns The effect containing the shader used to merge the effect on the main canvas
  59705. */
  59706. protected abstract _createMergeEffect(): Effect;
  59707. /**
  59708. * Creates the render target textures and post processes used in the effect layer.
  59709. */
  59710. protected abstract _createTextureAndPostProcesses(): void;
  59711. /**
  59712. * Implementation specific of rendering the generating effect on the main canvas.
  59713. * @param effect The effect used to render through
  59714. */
  59715. protected abstract _internalRender(effect: Effect): void;
  59716. /**
  59717. * Sets the required values for both the emissive texture and and the main color.
  59718. */
  59719. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59720. /**
  59721. * Free any resources and references associated to a mesh.
  59722. * Internal use
  59723. * @param mesh The mesh to free.
  59724. */
  59725. abstract _disposeMesh(mesh: Mesh): void;
  59726. /**
  59727. * Serializes this layer (Glow or Highlight for example)
  59728. * @returns a serialized layer object
  59729. */
  59730. abstract serialize?(): any;
  59731. /**
  59732. * Initializes the effect layer with the required options.
  59733. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59734. */
  59735. protected _init(options: Partial<IEffectLayerOptions>): void;
  59736. /**
  59737. * Generates the index buffer of the full screen quad blending to the main canvas.
  59738. */
  59739. private _generateIndexBuffer;
  59740. /**
  59741. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59742. */
  59743. private _generateVertexBuffer;
  59744. /**
  59745. * Sets the main texture desired size which is the closest power of two
  59746. * of the engine canvas size.
  59747. */
  59748. private _setMainTextureSize;
  59749. /**
  59750. * Creates the main texture for the effect layer.
  59751. */
  59752. protected _createMainTexture(): void;
  59753. /**
  59754. * Adds specific effects defines.
  59755. * @param defines The defines to add specifics to.
  59756. */
  59757. protected _addCustomEffectDefines(defines: string[]): void;
  59758. /**
  59759. * Checks for the readiness of the element composing the layer.
  59760. * @param subMesh the mesh to check for
  59761. * @param useInstances specify whether or not to use instances to render the mesh
  59762. * @param emissiveTexture the associated emissive texture used to generate the glow
  59763. * @return true if ready otherwise, false
  59764. */
  59765. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59766. /**
  59767. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59768. */
  59769. render(): void;
  59770. /**
  59771. * Determine if a given mesh will be used in the current effect.
  59772. * @param mesh mesh to test
  59773. * @returns true if the mesh will be used
  59774. */
  59775. hasMesh(mesh: AbstractMesh): boolean;
  59776. /**
  59777. * Returns true if the layer contains information to display, otherwise false.
  59778. * @returns true if the glow layer should be rendered
  59779. */
  59780. shouldRender(): boolean;
  59781. /**
  59782. * Returns true if the mesh should render, otherwise false.
  59783. * @param mesh The mesh to render
  59784. * @returns true if it should render otherwise false
  59785. */
  59786. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59787. /**
  59788. * Returns true if the mesh can be rendered, otherwise false.
  59789. * @param mesh The mesh to render
  59790. * @param material The material used on the mesh
  59791. * @returns true if it can be rendered otherwise false
  59792. */
  59793. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59794. /**
  59795. * Returns true if the mesh should render, otherwise false.
  59796. * @param mesh The mesh to render
  59797. * @returns true if it should render otherwise false
  59798. */
  59799. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59800. /**
  59801. * Renders the submesh passed in parameter to the generation map.
  59802. */
  59803. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59804. /**
  59805. * Defines whether the current material of the mesh should be use to render the effect.
  59806. * @param mesh defines the current mesh to render
  59807. */
  59808. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59809. /**
  59810. * Rebuild the required buffers.
  59811. * @hidden Internal use only.
  59812. */
  59813. _rebuild(): void;
  59814. /**
  59815. * Dispose only the render target textures and post process.
  59816. */
  59817. private _disposeTextureAndPostProcesses;
  59818. /**
  59819. * Dispose the highlight layer and free resources.
  59820. */
  59821. dispose(): void;
  59822. /**
  59823. * Gets the class name of the effect layer
  59824. * @returns the string with the class name of the effect layer
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Creates an effect layer from parsed effect layer data
  59829. * @param parsedEffectLayer defines effect layer data
  59830. * @param scene defines the current scene
  59831. * @param rootUrl defines the root URL containing the effect layer information
  59832. * @returns a parsed effect Layer
  59833. */
  59834. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59835. }
  59836. }
  59837. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59838. import { Scene } from "babylonjs/scene";
  59839. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59840. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59841. import { AbstractScene } from "babylonjs/abstractScene";
  59842. module "babylonjs/abstractScene" {
  59843. interface AbstractScene {
  59844. /**
  59845. * The list of effect layers (highlights/glow) added to the scene
  59846. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59847. * @see https://doc.babylonjs.com/how_to/glow_layer
  59848. */
  59849. effectLayers: Array<EffectLayer>;
  59850. /**
  59851. * Removes the given effect layer from this scene.
  59852. * @param toRemove defines the effect layer to remove
  59853. * @returns the index of the removed effect layer
  59854. */
  59855. removeEffectLayer(toRemove: EffectLayer): number;
  59856. /**
  59857. * Adds the given effect layer to this scene
  59858. * @param newEffectLayer defines the effect layer to add
  59859. */
  59860. addEffectLayer(newEffectLayer: EffectLayer): void;
  59861. }
  59862. }
  59863. /**
  59864. * Defines the layer scene component responsible to manage any effect layers
  59865. * in a given scene.
  59866. */
  59867. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59868. /**
  59869. * The component name helpfull to identify the component in the list of scene components.
  59870. */
  59871. readonly name: string;
  59872. /**
  59873. * The scene the component belongs to.
  59874. */
  59875. scene: Scene;
  59876. private _engine;
  59877. private _renderEffects;
  59878. private _needStencil;
  59879. private _previousStencilState;
  59880. /**
  59881. * Creates a new instance of the component for the given scene
  59882. * @param scene Defines the scene to register the component in
  59883. */
  59884. constructor(scene: Scene);
  59885. /**
  59886. * Registers the component in a given scene
  59887. */
  59888. register(): void;
  59889. /**
  59890. * Rebuilds the elements related to this component in case of
  59891. * context lost for instance.
  59892. */
  59893. rebuild(): void;
  59894. /**
  59895. * Serializes the component data to the specified json object
  59896. * @param serializationObject The object to serialize to
  59897. */
  59898. serialize(serializationObject: any): void;
  59899. /**
  59900. * Adds all the elements from the container to the scene
  59901. * @param container the container holding the elements
  59902. */
  59903. addFromContainer(container: AbstractScene): void;
  59904. /**
  59905. * Removes all the elements in the container from the scene
  59906. * @param container contains the elements to remove
  59907. * @param dispose if the removed element should be disposed (default: false)
  59908. */
  59909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59910. /**
  59911. * Disposes the component and the associated ressources.
  59912. */
  59913. dispose(): void;
  59914. private _isReadyForMesh;
  59915. private _renderMainTexture;
  59916. private _setStencil;
  59917. private _setStencilBack;
  59918. private _draw;
  59919. private _drawCamera;
  59920. private _drawRenderingGroup;
  59921. }
  59922. }
  59923. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59924. /** @hidden */
  59925. export var glowMapMergePixelShader: {
  59926. name: string;
  59927. shader: string;
  59928. };
  59929. }
  59930. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59931. /** @hidden */
  59932. export var glowMapMergeVertexShader: {
  59933. name: string;
  59934. shader: string;
  59935. };
  59936. }
  59937. declare module "babylonjs/Layers/glowLayer" {
  59938. import { Nullable } from "babylonjs/types";
  59939. import { Camera } from "babylonjs/Cameras/camera";
  59940. import { Scene } from "babylonjs/scene";
  59941. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59943. import { Mesh } from "babylonjs/Meshes/mesh";
  59944. import { Texture } from "babylonjs/Materials/Textures/texture";
  59945. import { Effect } from "babylonjs/Materials/effect";
  59946. import { Material } from "babylonjs/Materials/material";
  59947. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59948. import { Color4 } from "babylonjs/Maths/math.color";
  59949. import "babylonjs/Shaders/glowMapMerge.fragment";
  59950. import "babylonjs/Shaders/glowMapMerge.vertex";
  59951. import "babylonjs/Layers/effectLayerSceneComponent";
  59952. module "babylonjs/abstractScene" {
  59953. interface AbstractScene {
  59954. /**
  59955. * Return a the first highlight layer of the scene with a given name.
  59956. * @param name The name of the highlight layer to look for.
  59957. * @return The highlight layer if found otherwise null.
  59958. */
  59959. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59960. }
  59961. }
  59962. /**
  59963. * Glow layer options. This helps customizing the behaviour
  59964. * of the glow layer.
  59965. */
  59966. export interface IGlowLayerOptions {
  59967. /**
  59968. * Multiplication factor apply to the canvas size to compute the render target size
  59969. * used to generated the glowing objects (the smaller the faster).
  59970. */
  59971. mainTextureRatio: number;
  59972. /**
  59973. * Enforces a fixed size texture to ensure resize independant blur.
  59974. */
  59975. mainTextureFixedSize?: number;
  59976. /**
  59977. * How big is the kernel of the blur texture.
  59978. */
  59979. blurKernelSize: number;
  59980. /**
  59981. * The camera attached to the layer.
  59982. */
  59983. camera: Nullable<Camera>;
  59984. /**
  59985. * Enable MSAA by chosing the number of samples.
  59986. */
  59987. mainTextureSamples?: number;
  59988. /**
  59989. * The rendering group to draw the layer in.
  59990. */
  59991. renderingGroupId: number;
  59992. }
  59993. /**
  59994. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59995. *
  59996. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59997. *
  59998. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59999. */
  60000. export class GlowLayer extends EffectLayer {
  60001. /**
  60002. * Effect Name of the layer.
  60003. */
  60004. static readonly EffectName: string;
  60005. /**
  60006. * The default blur kernel size used for the glow.
  60007. */
  60008. static DefaultBlurKernelSize: number;
  60009. /**
  60010. * The default texture size ratio used for the glow.
  60011. */
  60012. static DefaultTextureRatio: number;
  60013. /**
  60014. * Sets the kernel size of the blur.
  60015. */
  60016. set blurKernelSize(value: number);
  60017. /**
  60018. * Gets the kernel size of the blur.
  60019. */
  60020. get blurKernelSize(): number;
  60021. /**
  60022. * Sets the glow intensity.
  60023. */
  60024. set intensity(value: number);
  60025. /**
  60026. * Gets the glow intensity.
  60027. */
  60028. get intensity(): number;
  60029. private _options;
  60030. private _intensity;
  60031. private _horizontalBlurPostprocess1;
  60032. private _verticalBlurPostprocess1;
  60033. private _horizontalBlurPostprocess2;
  60034. private _verticalBlurPostprocess2;
  60035. private _blurTexture1;
  60036. private _blurTexture2;
  60037. private _postProcesses1;
  60038. private _postProcesses2;
  60039. private _includedOnlyMeshes;
  60040. private _excludedMeshes;
  60041. private _meshesUsingTheirOwnMaterials;
  60042. /**
  60043. * Callback used to let the user override the color selection on a per mesh basis
  60044. */
  60045. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60046. /**
  60047. * Callback used to let the user override the texture selection on a per mesh basis
  60048. */
  60049. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60050. /**
  60051. * Instantiates a new glow Layer and references it to the scene.
  60052. * @param name The name of the layer
  60053. * @param scene The scene to use the layer in
  60054. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60055. */
  60056. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60057. /**
  60058. * Get the effect name of the layer.
  60059. * @return The effect name
  60060. */
  60061. getEffectName(): string;
  60062. /**
  60063. * Create the merge effect. This is the shader use to blit the information back
  60064. * to the main canvas at the end of the scene rendering.
  60065. */
  60066. protected _createMergeEffect(): Effect;
  60067. /**
  60068. * Creates the render target textures and post processes used in the glow layer.
  60069. */
  60070. protected _createTextureAndPostProcesses(): void;
  60071. /**
  60072. * Checks for the readiness of the element composing the layer.
  60073. * @param subMesh the mesh to check for
  60074. * @param useInstances specify wether or not to use instances to render the mesh
  60075. * @param emissiveTexture the associated emissive texture used to generate the glow
  60076. * @return true if ready otherwise, false
  60077. */
  60078. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60079. /**
  60080. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60081. */
  60082. needStencil(): boolean;
  60083. /**
  60084. * Returns true if the mesh can be rendered, otherwise false.
  60085. * @param mesh The mesh to render
  60086. * @param material The material used on the mesh
  60087. * @returns true if it can be rendered otherwise false
  60088. */
  60089. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60090. /**
  60091. * Implementation specific of rendering the generating effect on the main canvas.
  60092. * @param effect The effect used to render through
  60093. */
  60094. protected _internalRender(effect: Effect): void;
  60095. /**
  60096. * Sets the required values for both the emissive texture and and the main color.
  60097. */
  60098. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60099. /**
  60100. * Returns true if the mesh should render, otherwise false.
  60101. * @param mesh The mesh to render
  60102. * @returns true if it should render otherwise false
  60103. */
  60104. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60105. /**
  60106. * Adds specific effects defines.
  60107. * @param defines The defines to add specifics to.
  60108. */
  60109. protected _addCustomEffectDefines(defines: string[]): void;
  60110. /**
  60111. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60112. * @param mesh The mesh to exclude from the glow layer
  60113. */
  60114. addExcludedMesh(mesh: Mesh): void;
  60115. /**
  60116. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60117. * @param mesh The mesh to remove
  60118. */
  60119. removeExcludedMesh(mesh: Mesh): void;
  60120. /**
  60121. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60122. * @param mesh The mesh to include in the glow layer
  60123. */
  60124. addIncludedOnlyMesh(mesh: Mesh): void;
  60125. /**
  60126. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60127. * @param mesh The mesh to remove
  60128. */
  60129. removeIncludedOnlyMesh(mesh: Mesh): void;
  60130. /**
  60131. * Determine if a given mesh will be used in the glow layer
  60132. * @param mesh The mesh to test
  60133. * @returns true if the mesh will be highlighted by the current glow layer
  60134. */
  60135. hasMesh(mesh: AbstractMesh): boolean;
  60136. /**
  60137. * Defines whether the current material of the mesh should be use to render the effect.
  60138. * @param mesh defines the current mesh to render
  60139. */
  60140. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60141. /**
  60142. * Add a mesh to be rendered through its own material and not with emissive only.
  60143. * @param mesh The mesh for which we need to use its material
  60144. */
  60145. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60146. /**
  60147. * Remove a mesh from being rendered through its own material and not with emissive only.
  60148. * @param mesh The mesh for which we need to not use its material
  60149. */
  60150. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60151. /**
  60152. * Free any resources and references associated to a mesh.
  60153. * Internal use
  60154. * @param mesh The mesh to free.
  60155. * @hidden
  60156. */
  60157. _disposeMesh(mesh: Mesh): void;
  60158. /**
  60159. * Gets the class name of the effect layer
  60160. * @returns the string with the class name of the effect layer
  60161. */
  60162. getClassName(): string;
  60163. /**
  60164. * Serializes this glow layer
  60165. * @returns a serialized glow layer object
  60166. */
  60167. serialize(): any;
  60168. /**
  60169. * Creates a Glow Layer from parsed glow layer data
  60170. * @param parsedGlowLayer defines glow layer data
  60171. * @param scene defines the current scene
  60172. * @param rootUrl defines the root URL containing the glow layer information
  60173. * @returns a parsed Glow Layer
  60174. */
  60175. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60176. }
  60177. }
  60178. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60179. /** @hidden */
  60180. export var glowBlurPostProcessPixelShader: {
  60181. name: string;
  60182. shader: string;
  60183. };
  60184. }
  60185. declare module "babylonjs/Layers/highlightLayer" {
  60186. import { Observable } from "babylonjs/Misc/observable";
  60187. import { Nullable } from "babylonjs/types";
  60188. import { Camera } from "babylonjs/Cameras/camera";
  60189. import { Scene } from "babylonjs/scene";
  60190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60192. import { Mesh } from "babylonjs/Meshes/mesh";
  60193. import { Effect } from "babylonjs/Materials/effect";
  60194. import { Material } from "babylonjs/Materials/material";
  60195. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60196. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60197. import "babylonjs/Shaders/glowMapMerge.fragment";
  60198. import "babylonjs/Shaders/glowMapMerge.vertex";
  60199. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60200. module "babylonjs/abstractScene" {
  60201. interface AbstractScene {
  60202. /**
  60203. * Return a the first highlight layer of the scene with a given name.
  60204. * @param name The name of the highlight layer to look for.
  60205. * @return The highlight layer if found otherwise null.
  60206. */
  60207. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60208. }
  60209. }
  60210. /**
  60211. * Highlight layer options. This helps customizing the behaviour
  60212. * of the highlight layer.
  60213. */
  60214. export interface IHighlightLayerOptions {
  60215. /**
  60216. * Multiplication factor apply to the canvas size to compute the render target size
  60217. * used to generated the glowing objects (the smaller the faster).
  60218. */
  60219. mainTextureRatio: number;
  60220. /**
  60221. * Enforces a fixed size texture to ensure resize independant blur.
  60222. */
  60223. mainTextureFixedSize?: number;
  60224. /**
  60225. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60226. * of the picture to blur (the smaller the faster).
  60227. */
  60228. blurTextureSizeRatio: number;
  60229. /**
  60230. * How big in texel of the blur texture is the vertical blur.
  60231. */
  60232. blurVerticalSize: number;
  60233. /**
  60234. * How big in texel of the blur texture is the horizontal blur.
  60235. */
  60236. blurHorizontalSize: number;
  60237. /**
  60238. * Alpha blending mode used to apply the blur. Default is combine.
  60239. */
  60240. alphaBlendingMode: number;
  60241. /**
  60242. * The camera attached to the layer.
  60243. */
  60244. camera: Nullable<Camera>;
  60245. /**
  60246. * Should we display highlight as a solid stroke?
  60247. */
  60248. isStroke?: boolean;
  60249. /**
  60250. * The rendering group to draw the layer in.
  60251. */
  60252. renderingGroupId: number;
  60253. }
  60254. /**
  60255. * The highlight layer Helps adding a glow effect around a mesh.
  60256. *
  60257. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60258. * glowy meshes to your scene.
  60259. *
  60260. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60261. */
  60262. export class HighlightLayer extends EffectLayer {
  60263. name: string;
  60264. /**
  60265. * Effect Name of the highlight layer.
  60266. */
  60267. static readonly EffectName: string;
  60268. /**
  60269. * The neutral color used during the preparation of the glow effect.
  60270. * This is black by default as the blend operation is a blend operation.
  60271. */
  60272. static NeutralColor: Color4;
  60273. /**
  60274. * Stencil value used for glowing meshes.
  60275. */
  60276. static GlowingMeshStencilReference: number;
  60277. /**
  60278. * Stencil value used for the other meshes in the scene.
  60279. */
  60280. static NormalMeshStencilReference: number;
  60281. /**
  60282. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60283. */
  60284. innerGlow: boolean;
  60285. /**
  60286. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60287. */
  60288. outerGlow: boolean;
  60289. /**
  60290. * Specifies the horizontal size of the blur.
  60291. */
  60292. set blurHorizontalSize(value: number);
  60293. /**
  60294. * Specifies the vertical size of the blur.
  60295. */
  60296. set blurVerticalSize(value: number);
  60297. /**
  60298. * Gets the horizontal size of the blur.
  60299. */
  60300. get blurHorizontalSize(): number;
  60301. /**
  60302. * Gets the vertical size of the blur.
  60303. */
  60304. get blurVerticalSize(): number;
  60305. /**
  60306. * An event triggered when the highlight layer is being blurred.
  60307. */
  60308. onBeforeBlurObservable: Observable<HighlightLayer>;
  60309. /**
  60310. * An event triggered when the highlight layer has been blurred.
  60311. */
  60312. onAfterBlurObservable: Observable<HighlightLayer>;
  60313. private _instanceGlowingMeshStencilReference;
  60314. private _options;
  60315. private _downSamplePostprocess;
  60316. private _horizontalBlurPostprocess;
  60317. private _verticalBlurPostprocess;
  60318. private _blurTexture;
  60319. private _meshes;
  60320. private _excludedMeshes;
  60321. /**
  60322. * Instantiates a new highlight Layer and references it to the scene..
  60323. * @param name The name of the layer
  60324. * @param scene The scene to use the layer in
  60325. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60326. */
  60327. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60328. /**
  60329. * Get the effect name of the layer.
  60330. * @return The effect name
  60331. */
  60332. getEffectName(): string;
  60333. /**
  60334. * Create the merge effect. This is the shader use to blit the information back
  60335. * to the main canvas at the end of the scene rendering.
  60336. */
  60337. protected _createMergeEffect(): Effect;
  60338. /**
  60339. * Creates the render target textures and post processes used in the highlight layer.
  60340. */
  60341. protected _createTextureAndPostProcesses(): void;
  60342. /**
  60343. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60344. */
  60345. needStencil(): boolean;
  60346. /**
  60347. * Checks for the readiness of the element composing the layer.
  60348. * @param subMesh the mesh to check for
  60349. * @param useInstances specify wether or not to use instances to render the mesh
  60350. * @param emissiveTexture the associated emissive texture used to generate the glow
  60351. * @return true if ready otherwise, false
  60352. */
  60353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60354. /**
  60355. * Implementation specific of rendering the generating effect on the main canvas.
  60356. * @param effect The effect used to render through
  60357. */
  60358. protected _internalRender(effect: Effect): void;
  60359. /**
  60360. * Returns true if the layer contains information to display, otherwise false.
  60361. */
  60362. shouldRender(): boolean;
  60363. /**
  60364. * Returns true if the mesh should render, otherwise false.
  60365. * @param mesh The mesh to render
  60366. * @returns true if it should render otherwise false
  60367. */
  60368. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60369. /**
  60370. * Returns true if the mesh can be rendered, otherwise false.
  60371. * @param mesh The mesh to render
  60372. * @param material The material used on the mesh
  60373. * @returns true if it can be rendered otherwise false
  60374. */
  60375. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60376. /**
  60377. * Adds specific effects defines.
  60378. * @param defines The defines to add specifics to.
  60379. */
  60380. protected _addCustomEffectDefines(defines: string[]): void;
  60381. /**
  60382. * Sets the required values for both the emissive texture and and the main color.
  60383. */
  60384. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60385. /**
  60386. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60387. * @param mesh The mesh to exclude from the highlight layer
  60388. */
  60389. addExcludedMesh(mesh: Mesh): void;
  60390. /**
  60391. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60392. * @param mesh The mesh to highlight
  60393. */
  60394. removeExcludedMesh(mesh: Mesh): void;
  60395. /**
  60396. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60397. * @param mesh mesh to test
  60398. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60399. */
  60400. hasMesh(mesh: AbstractMesh): boolean;
  60401. /**
  60402. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60403. * @param mesh The mesh to highlight
  60404. * @param color The color of the highlight
  60405. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60406. */
  60407. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60408. /**
  60409. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60410. * @param mesh The mesh to highlight
  60411. */
  60412. removeMesh(mesh: Mesh): void;
  60413. /**
  60414. * Remove all the meshes currently referenced in the highlight layer
  60415. */
  60416. removeAllMeshes(): void;
  60417. /**
  60418. * Force the stencil to the normal expected value for none glowing parts
  60419. */
  60420. private _defaultStencilReference;
  60421. /**
  60422. * Free any resources and references associated to a mesh.
  60423. * Internal use
  60424. * @param mesh The mesh to free.
  60425. * @hidden
  60426. */
  60427. _disposeMesh(mesh: Mesh): void;
  60428. /**
  60429. * Dispose the highlight layer and free resources.
  60430. */
  60431. dispose(): void;
  60432. /**
  60433. * Gets the class name of the effect layer
  60434. * @returns the string with the class name of the effect layer
  60435. */
  60436. getClassName(): string;
  60437. /**
  60438. * Serializes this Highlight layer
  60439. * @returns a serialized Highlight layer object
  60440. */
  60441. serialize(): any;
  60442. /**
  60443. * Creates a Highlight layer from parsed Highlight layer data
  60444. * @param parsedHightlightLayer defines the Highlight layer data
  60445. * @param scene defines the current scene
  60446. * @param rootUrl defines the root URL containing the Highlight layer information
  60447. * @returns a parsed Highlight layer
  60448. */
  60449. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60450. }
  60451. }
  60452. declare module "babylonjs/Layers/layerSceneComponent" {
  60453. import { Scene } from "babylonjs/scene";
  60454. import { ISceneComponent } from "babylonjs/sceneComponent";
  60455. import { Layer } from "babylonjs/Layers/layer";
  60456. import { AbstractScene } from "babylonjs/abstractScene";
  60457. module "babylonjs/abstractScene" {
  60458. interface AbstractScene {
  60459. /**
  60460. * The list of layers (background and foreground) of the scene
  60461. */
  60462. layers: Array<Layer>;
  60463. }
  60464. }
  60465. /**
  60466. * Defines the layer scene component responsible to manage any layers
  60467. * in a given scene.
  60468. */
  60469. export class LayerSceneComponent implements ISceneComponent {
  60470. /**
  60471. * The component name helpfull to identify the component in the list of scene components.
  60472. */
  60473. readonly name: string;
  60474. /**
  60475. * The scene the component belongs to.
  60476. */
  60477. scene: Scene;
  60478. private _engine;
  60479. /**
  60480. * Creates a new instance of the component for the given scene
  60481. * @param scene Defines the scene to register the component in
  60482. */
  60483. constructor(scene: Scene);
  60484. /**
  60485. * Registers the component in a given scene
  60486. */
  60487. register(): void;
  60488. /**
  60489. * Rebuilds the elements related to this component in case of
  60490. * context lost for instance.
  60491. */
  60492. rebuild(): void;
  60493. /**
  60494. * Disposes the component and the associated ressources.
  60495. */
  60496. dispose(): void;
  60497. private _draw;
  60498. private _drawCameraPredicate;
  60499. private _drawCameraBackground;
  60500. private _drawCameraForeground;
  60501. private _drawRenderTargetPredicate;
  60502. private _drawRenderTargetBackground;
  60503. private _drawRenderTargetForeground;
  60504. /**
  60505. * Adds all the elements from the container to the scene
  60506. * @param container the container holding the elements
  60507. */
  60508. addFromContainer(container: AbstractScene): void;
  60509. /**
  60510. * Removes all the elements in the container from the scene
  60511. * @param container contains the elements to remove
  60512. * @param dispose if the removed element should be disposed (default: false)
  60513. */
  60514. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60515. }
  60516. }
  60517. declare module "babylonjs/Shaders/layer.fragment" {
  60518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60519. /** @hidden */
  60520. export var layerPixelShader: {
  60521. name: string;
  60522. shader: string;
  60523. };
  60524. }
  60525. declare module "babylonjs/Shaders/layer.vertex" {
  60526. /** @hidden */
  60527. export var layerVertexShader: {
  60528. name: string;
  60529. shader: string;
  60530. };
  60531. }
  60532. declare module "babylonjs/Layers/layer" {
  60533. import { Observable } from "babylonjs/Misc/observable";
  60534. import { Nullable } from "babylonjs/types";
  60535. import { Scene } from "babylonjs/scene";
  60536. import { Vector2 } from "babylonjs/Maths/math.vector";
  60537. import { Color4 } from "babylonjs/Maths/math.color";
  60538. import { Texture } from "babylonjs/Materials/Textures/texture";
  60539. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60540. import "babylonjs/Shaders/layer.fragment";
  60541. import "babylonjs/Shaders/layer.vertex";
  60542. /**
  60543. * This represents a full screen 2d layer.
  60544. * This can be useful to display a picture in the background of your scene for instance.
  60545. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60546. */
  60547. export class Layer {
  60548. /**
  60549. * Define the name of the layer.
  60550. */
  60551. name: string;
  60552. /**
  60553. * Define the texture the layer should display.
  60554. */
  60555. texture: Nullable<Texture>;
  60556. /**
  60557. * Is the layer in background or foreground.
  60558. */
  60559. isBackground: boolean;
  60560. /**
  60561. * Define the color of the layer (instead of texture).
  60562. */
  60563. color: Color4;
  60564. /**
  60565. * Define the scale of the layer in order to zoom in out of the texture.
  60566. */
  60567. scale: Vector2;
  60568. /**
  60569. * Define an offset for the layer in order to shift the texture.
  60570. */
  60571. offset: Vector2;
  60572. /**
  60573. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60574. */
  60575. alphaBlendingMode: number;
  60576. /**
  60577. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60578. * Alpha test will not mix with the background color in case of transparency.
  60579. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60580. */
  60581. alphaTest: boolean;
  60582. /**
  60583. * Define a mask to restrict the layer to only some of the scene cameras.
  60584. */
  60585. layerMask: number;
  60586. /**
  60587. * Define the list of render target the layer is visible into.
  60588. */
  60589. renderTargetTextures: RenderTargetTexture[];
  60590. /**
  60591. * Define if the layer is only used in renderTarget or if it also
  60592. * renders in the main frame buffer of the canvas.
  60593. */
  60594. renderOnlyInRenderTargetTextures: boolean;
  60595. private _scene;
  60596. private _vertexBuffers;
  60597. private _indexBuffer;
  60598. private _effect;
  60599. private _previousDefines;
  60600. /**
  60601. * An event triggered when the layer is disposed.
  60602. */
  60603. onDisposeObservable: Observable<Layer>;
  60604. private _onDisposeObserver;
  60605. /**
  60606. * Back compatibility with callback before the onDisposeObservable existed.
  60607. * The set callback will be triggered when the layer has been disposed.
  60608. */
  60609. set onDispose(callback: () => void);
  60610. /**
  60611. * An event triggered before rendering the scene
  60612. */
  60613. onBeforeRenderObservable: Observable<Layer>;
  60614. private _onBeforeRenderObserver;
  60615. /**
  60616. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60617. * The set callback will be triggered just before rendering the layer.
  60618. */
  60619. set onBeforeRender(callback: () => void);
  60620. /**
  60621. * An event triggered after rendering the scene
  60622. */
  60623. onAfterRenderObservable: Observable<Layer>;
  60624. private _onAfterRenderObserver;
  60625. /**
  60626. * Back compatibility with callback before the onAfterRenderObservable existed.
  60627. * The set callback will be triggered just after rendering the layer.
  60628. */
  60629. set onAfterRender(callback: () => void);
  60630. /**
  60631. * Instantiates a new layer.
  60632. * This represents a full screen 2d layer.
  60633. * This can be useful to display a picture in the background of your scene for instance.
  60634. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60635. * @param name Define the name of the layer in the scene
  60636. * @param imgUrl Define the url of the texture to display in the layer
  60637. * @param scene Define the scene the layer belongs to
  60638. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60639. * @param color Defines a color for the layer
  60640. */
  60641. constructor(
  60642. /**
  60643. * Define the name of the layer.
  60644. */
  60645. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60646. private _createIndexBuffer;
  60647. /** @hidden */
  60648. _rebuild(): void;
  60649. /**
  60650. * Renders the layer in the scene.
  60651. */
  60652. render(): void;
  60653. /**
  60654. * Disposes and releases the associated ressources.
  60655. */
  60656. dispose(): void;
  60657. }
  60658. }
  60659. declare module "babylonjs/Layers/index" {
  60660. export * from "babylonjs/Layers/effectLayer";
  60661. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60662. export * from "babylonjs/Layers/glowLayer";
  60663. export * from "babylonjs/Layers/highlightLayer";
  60664. export * from "babylonjs/Layers/layer";
  60665. export * from "babylonjs/Layers/layerSceneComponent";
  60666. }
  60667. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60668. /** @hidden */
  60669. export var lensFlarePixelShader: {
  60670. name: string;
  60671. shader: string;
  60672. };
  60673. }
  60674. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60675. /** @hidden */
  60676. export var lensFlareVertexShader: {
  60677. name: string;
  60678. shader: string;
  60679. };
  60680. }
  60681. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60682. import { Scene } from "babylonjs/scene";
  60683. import { Vector3 } from "babylonjs/Maths/math.vector";
  60684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60685. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60686. import "babylonjs/Shaders/lensFlare.fragment";
  60687. import "babylonjs/Shaders/lensFlare.vertex";
  60688. import { Viewport } from "babylonjs/Maths/math.viewport";
  60689. /**
  60690. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60691. * It is usually composed of several `lensFlare`.
  60692. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60693. */
  60694. export class LensFlareSystem {
  60695. /**
  60696. * Define the name of the lens flare system
  60697. */
  60698. name: string;
  60699. /**
  60700. * List of lens flares used in this system.
  60701. */
  60702. lensFlares: LensFlare[];
  60703. /**
  60704. * Define a limit from the border the lens flare can be visible.
  60705. */
  60706. borderLimit: number;
  60707. /**
  60708. * Define a viewport border we do not want to see the lens flare in.
  60709. */
  60710. viewportBorder: number;
  60711. /**
  60712. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60713. */
  60714. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60715. /**
  60716. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60717. */
  60718. layerMask: number;
  60719. /**
  60720. * Define the id of the lens flare system in the scene.
  60721. * (equal to name by default)
  60722. */
  60723. id: string;
  60724. private _scene;
  60725. private _emitter;
  60726. private _vertexBuffers;
  60727. private _indexBuffer;
  60728. private _effect;
  60729. private _positionX;
  60730. private _positionY;
  60731. private _isEnabled;
  60732. /** @hidden */
  60733. static _SceneComponentInitialization: (scene: Scene) => void;
  60734. /**
  60735. * Instantiates a lens flare system.
  60736. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60737. * It is usually composed of several `lensFlare`.
  60738. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60739. * @param name Define the name of the lens flare system in the scene
  60740. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60741. * @param scene Define the scene the lens flare system belongs to
  60742. */
  60743. constructor(
  60744. /**
  60745. * Define the name of the lens flare system
  60746. */
  60747. name: string, emitter: any, scene: Scene);
  60748. /**
  60749. * Define if the lens flare system is enabled.
  60750. */
  60751. get isEnabled(): boolean;
  60752. set isEnabled(value: boolean);
  60753. /**
  60754. * Get the scene the effects belongs to.
  60755. * @returns the scene holding the lens flare system
  60756. */
  60757. getScene(): Scene;
  60758. /**
  60759. * Get the emitter of the lens flare system.
  60760. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60761. * @returns the emitter of the lens flare system
  60762. */
  60763. getEmitter(): any;
  60764. /**
  60765. * Set the emitter of the lens flare system.
  60766. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60767. * @param newEmitter Define the new emitter of the system
  60768. */
  60769. setEmitter(newEmitter: any): void;
  60770. /**
  60771. * Get the lens flare system emitter position.
  60772. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60773. * @returns the position
  60774. */
  60775. getEmitterPosition(): Vector3;
  60776. /**
  60777. * @hidden
  60778. */
  60779. computeEffectivePosition(globalViewport: Viewport): boolean;
  60780. /** @hidden */
  60781. _isVisible(): boolean;
  60782. /**
  60783. * @hidden
  60784. */
  60785. render(): boolean;
  60786. /**
  60787. * Dispose and release the lens flare with its associated resources.
  60788. */
  60789. dispose(): void;
  60790. /**
  60791. * Parse a lens flare system from a JSON repressentation
  60792. * @param parsedLensFlareSystem Define the JSON to parse
  60793. * @param scene Define the scene the parsed system should be instantiated in
  60794. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60795. * @returns the parsed system
  60796. */
  60797. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60798. /**
  60799. * Serialize the current Lens Flare System into a JSON representation.
  60800. * @returns the serialized JSON
  60801. */
  60802. serialize(): any;
  60803. }
  60804. }
  60805. declare module "babylonjs/LensFlares/lensFlare" {
  60806. import { Nullable } from "babylonjs/types";
  60807. import { Color3 } from "babylonjs/Maths/math.color";
  60808. import { Texture } from "babylonjs/Materials/Textures/texture";
  60809. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60810. /**
  60811. * This represents one of the lens effect in a `lensFlareSystem`.
  60812. * It controls one of the indiviual texture used in the effect.
  60813. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60814. */
  60815. export class LensFlare {
  60816. /**
  60817. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60818. */
  60819. size: number;
  60820. /**
  60821. * 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.
  60822. */
  60823. position: number;
  60824. /**
  60825. * Define the lens color.
  60826. */
  60827. color: Color3;
  60828. /**
  60829. * Define the lens texture.
  60830. */
  60831. texture: Nullable<Texture>;
  60832. /**
  60833. * Define the alpha mode to render this particular lens.
  60834. */
  60835. alphaMode: number;
  60836. private _system;
  60837. /**
  60838. * Creates a new Lens Flare.
  60839. * This represents one of the lens effect in a `lensFlareSystem`.
  60840. * It controls one of the indiviual texture used in the effect.
  60841. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60842. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60843. * @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.
  60844. * @param color Define the lens color
  60845. * @param imgUrl Define the lens texture url
  60846. * @param system Define the `lensFlareSystem` this flare is part of
  60847. * @returns The newly created Lens Flare
  60848. */
  60849. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60850. /**
  60851. * Instantiates a new Lens Flare.
  60852. * This represents one of the lens effect in a `lensFlareSystem`.
  60853. * It controls one of the indiviual texture used in the effect.
  60854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60855. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60856. * @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.
  60857. * @param color Define the lens color
  60858. * @param imgUrl Define the lens texture url
  60859. * @param system Define the `lensFlareSystem` this flare is part of
  60860. */
  60861. constructor(
  60862. /**
  60863. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60864. */
  60865. size: number,
  60866. /**
  60867. * 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.
  60868. */
  60869. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60870. /**
  60871. * Dispose and release the lens flare with its associated resources.
  60872. */
  60873. dispose(): void;
  60874. }
  60875. }
  60876. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60877. import { Nullable } from "babylonjs/types";
  60878. import { Scene } from "babylonjs/scene";
  60879. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60880. import { AbstractScene } from "babylonjs/abstractScene";
  60881. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60882. module "babylonjs/abstractScene" {
  60883. interface AbstractScene {
  60884. /**
  60885. * The list of lens flare system added to the scene
  60886. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60887. */
  60888. lensFlareSystems: Array<LensFlareSystem>;
  60889. /**
  60890. * Removes the given lens flare system from this scene.
  60891. * @param toRemove The lens flare system to remove
  60892. * @returns The index of the removed lens flare system
  60893. */
  60894. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60895. /**
  60896. * Adds the given lens flare system to this scene
  60897. * @param newLensFlareSystem The lens flare system to add
  60898. */
  60899. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60900. /**
  60901. * Gets a lens flare system using its name
  60902. * @param name defines the name to look for
  60903. * @returns the lens flare system or null if not found
  60904. */
  60905. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60906. /**
  60907. * Gets a lens flare system using its id
  60908. * @param id defines the id to look for
  60909. * @returns the lens flare system or null if not found
  60910. */
  60911. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60912. }
  60913. }
  60914. /**
  60915. * Defines the lens flare scene component responsible to manage any lens flares
  60916. * in a given scene.
  60917. */
  60918. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60919. /**
  60920. * The component name helpfull to identify the component in the list of scene components.
  60921. */
  60922. readonly name: string;
  60923. /**
  60924. * The scene the component belongs to.
  60925. */
  60926. scene: Scene;
  60927. /**
  60928. * Creates a new instance of the component for the given scene
  60929. * @param scene Defines the scene to register the component in
  60930. */
  60931. constructor(scene: Scene);
  60932. /**
  60933. * Registers the component in a given scene
  60934. */
  60935. register(): void;
  60936. /**
  60937. * Rebuilds the elements related to this component in case of
  60938. * context lost for instance.
  60939. */
  60940. rebuild(): void;
  60941. /**
  60942. * Adds all the elements from the container to the scene
  60943. * @param container the container holding the elements
  60944. */
  60945. addFromContainer(container: AbstractScene): void;
  60946. /**
  60947. * Removes all the elements in the container from the scene
  60948. * @param container contains the elements to remove
  60949. * @param dispose if the removed element should be disposed (default: false)
  60950. */
  60951. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60952. /**
  60953. * Serializes the component data to the specified json object
  60954. * @param serializationObject The object to serialize to
  60955. */
  60956. serialize(serializationObject: any): void;
  60957. /**
  60958. * Disposes the component and the associated ressources.
  60959. */
  60960. dispose(): void;
  60961. private _draw;
  60962. }
  60963. }
  60964. declare module "babylonjs/LensFlares/index" {
  60965. export * from "babylonjs/LensFlares/lensFlare";
  60966. export * from "babylonjs/LensFlares/lensFlareSystem";
  60967. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60968. }
  60969. declare module "babylonjs/Shaders/depth.fragment" {
  60970. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60971. /** @hidden */
  60972. export var depthPixelShader: {
  60973. name: string;
  60974. shader: string;
  60975. };
  60976. }
  60977. declare module "babylonjs/Shaders/depth.vertex" {
  60978. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60982. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60983. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60984. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60985. /** @hidden */
  60986. export var depthVertexShader: {
  60987. name: string;
  60988. shader: string;
  60989. };
  60990. }
  60991. declare module "babylonjs/Rendering/depthRenderer" {
  60992. import { Nullable } from "babylonjs/types";
  60993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60994. import { Scene } from "babylonjs/scene";
  60995. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60996. import { Camera } from "babylonjs/Cameras/camera";
  60997. import "babylonjs/Shaders/depth.fragment";
  60998. import "babylonjs/Shaders/depth.vertex";
  60999. /**
  61000. * This represents a depth renderer in Babylon.
  61001. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61002. */
  61003. export class DepthRenderer {
  61004. private _scene;
  61005. private _depthMap;
  61006. private _effect;
  61007. private readonly _storeNonLinearDepth;
  61008. private readonly _clearColor;
  61009. /** Get if the depth renderer is using packed depth or not */
  61010. readonly isPacked: boolean;
  61011. private _cachedDefines;
  61012. private _camera;
  61013. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61014. enabled: boolean;
  61015. /**
  61016. * Specifiess that the depth renderer will only be used within
  61017. * the camera it is created for.
  61018. * This can help forcing its rendering during the camera processing.
  61019. */
  61020. useOnlyInActiveCamera: boolean;
  61021. /** @hidden */
  61022. static _SceneComponentInitialization: (scene: Scene) => void;
  61023. /**
  61024. * Instantiates a depth renderer
  61025. * @param scene The scene the renderer belongs to
  61026. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61027. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61028. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61029. */
  61030. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61031. /**
  61032. * Creates the depth rendering effect and checks if the effect is ready.
  61033. * @param subMesh The submesh to be used to render the depth map of
  61034. * @param useInstances If multiple world instances should be used
  61035. * @returns if the depth renderer is ready to render the depth map
  61036. */
  61037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61038. /**
  61039. * Gets the texture which the depth map will be written to.
  61040. * @returns The depth map texture
  61041. */
  61042. getDepthMap(): RenderTargetTexture;
  61043. /**
  61044. * Disposes of the depth renderer.
  61045. */
  61046. dispose(): void;
  61047. }
  61048. }
  61049. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61050. /** @hidden */
  61051. export var minmaxReduxPixelShader: {
  61052. name: string;
  61053. shader: string;
  61054. };
  61055. }
  61056. declare module "babylonjs/Misc/minMaxReducer" {
  61057. import { Nullable } from "babylonjs/types";
  61058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61059. import { Camera } from "babylonjs/Cameras/camera";
  61060. import { Observer } from "babylonjs/Misc/observable";
  61061. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61062. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61063. import { Observable } from "babylonjs/Misc/observable";
  61064. import "babylonjs/Shaders/minmaxRedux.fragment";
  61065. /**
  61066. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61067. * and maximum values from all values of the texture.
  61068. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61069. * The source values are read from the red channel of the texture.
  61070. */
  61071. export class MinMaxReducer {
  61072. /**
  61073. * Observable triggered when the computation has been performed
  61074. */
  61075. onAfterReductionPerformed: Observable<{
  61076. min: number;
  61077. max: number;
  61078. }>;
  61079. protected _camera: Camera;
  61080. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61081. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61082. protected _postProcessManager: PostProcessManager;
  61083. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61084. protected _forceFullscreenViewport: boolean;
  61085. /**
  61086. * Creates a min/max reducer
  61087. * @param camera The camera to use for the post processes
  61088. */
  61089. constructor(camera: Camera);
  61090. /**
  61091. * Gets the texture used to read the values from.
  61092. */
  61093. get sourceTexture(): Nullable<RenderTargetTexture>;
  61094. /**
  61095. * Sets the source texture to read the values from.
  61096. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61097. * because in such textures '1' value must not be taken into account to compute the maximum
  61098. * as this value is used to clear the texture.
  61099. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61100. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61101. * @param depthRedux Indicates if the texture is a depth texture or not
  61102. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61103. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61104. */
  61105. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61106. /**
  61107. * Defines the refresh rate of the computation.
  61108. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61109. */
  61110. get refreshRate(): number;
  61111. set refreshRate(value: number);
  61112. protected _activated: boolean;
  61113. /**
  61114. * Gets the activation status of the reducer
  61115. */
  61116. get activated(): boolean;
  61117. /**
  61118. * Activates the reduction computation.
  61119. * When activated, the observers registered in onAfterReductionPerformed are
  61120. * called after the compuation is performed
  61121. */
  61122. activate(): void;
  61123. /**
  61124. * Deactivates the reduction computation.
  61125. */
  61126. deactivate(): void;
  61127. /**
  61128. * Disposes the min/max reducer
  61129. * @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.
  61130. */
  61131. dispose(disposeAll?: boolean): void;
  61132. }
  61133. }
  61134. declare module "babylonjs/Misc/depthReducer" {
  61135. import { Nullable } from "babylonjs/types";
  61136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61137. import { Camera } from "babylonjs/Cameras/camera";
  61138. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61139. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61140. /**
  61141. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61142. */
  61143. export class DepthReducer extends MinMaxReducer {
  61144. private _depthRenderer;
  61145. private _depthRendererId;
  61146. /**
  61147. * Gets the depth renderer used for the computation.
  61148. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61149. */
  61150. get depthRenderer(): Nullable<DepthRenderer>;
  61151. /**
  61152. * Creates a depth reducer
  61153. * @param camera The camera used to render the depth texture
  61154. */
  61155. constructor(camera: Camera);
  61156. /**
  61157. * Sets the depth renderer to use to generate the depth map
  61158. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61159. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61160. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61161. */
  61162. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61163. /** @hidden */
  61164. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61165. /**
  61166. * Activates the reduction computation.
  61167. * When activated, the observers registered in onAfterReductionPerformed are
  61168. * called after the compuation is performed
  61169. */
  61170. activate(): void;
  61171. /**
  61172. * Deactivates the reduction computation.
  61173. */
  61174. deactivate(): void;
  61175. /**
  61176. * Disposes the depth reducer
  61177. * @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.
  61178. */
  61179. dispose(disposeAll?: boolean): void;
  61180. }
  61181. }
  61182. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61183. import { Nullable } from "babylonjs/types";
  61184. import { Scene } from "babylonjs/scene";
  61185. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61188. import { Effect } from "babylonjs/Materials/effect";
  61189. import "babylonjs/Shaders/shadowMap.fragment";
  61190. import "babylonjs/Shaders/shadowMap.vertex";
  61191. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61192. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61193. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61194. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61195. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61196. /**
  61197. * A CSM implementation allowing casting shadows on large scenes.
  61198. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61199. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61200. */
  61201. export class CascadedShadowGenerator extends ShadowGenerator {
  61202. private static readonly frustumCornersNDCSpace;
  61203. /**
  61204. * Name of the CSM class
  61205. */
  61206. static CLASSNAME: string;
  61207. /**
  61208. * Defines the default number of cascades used by the CSM.
  61209. */
  61210. static readonly DEFAULT_CASCADES_COUNT: number;
  61211. /**
  61212. * Defines the minimum number of cascades used by the CSM.
  61213. */
  61214. static readonly MIN_CASCADES_COUNT: number;
  61215. /**
  61216. * Defines the maximum number of cascades used by the CSM.
  61217. */
  61218. static readonly MAX_CASCADES_COUNT: number;
  61219. protected _validateFilter(filter: number): number;
  61220. /**
  61221. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61222. */
  61223. penumbraDarkness: number;
  61224. private _numCascades;
  61225. /**
  61226. * Gets or set the number of cascades used by the CSM.
  61227. */
  61228. get numCascades(): number;
  61229. set numCascades(value: number);
  61230. /**
  61231. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61232. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61233. */
  61234. stabilizeCascades: boolean;
  61235. private _freezeShadowCastersBoundingInfo;
  61236. private _freezeShadowCastersBoundingInfoObservable;
  61237. /**
  61238. * Enables or disables the shadow casters bounding info computation.
  61239. * If your shadow casters don't move, you can disable this feature.
  61240. * If it is enabled, the bounding box computation is done every frame.
  61241. */
  61242. get freezeShadowCastersBoundingInfo(): boolean;
  61243. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61244. private _scbiMin;
  61245. private _scbiMax;
  61246. protected _computeShadowCastersBoundingInfo(): void;
  61247. protected _shadowCastersBoundingInfo: BoundingInfo;
  61248. /**
  61249. * Gets or sets the shadow casters bounding info.
  61250. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61251. * so that the system won't overwrite the bounds you provide
  61252. */
  61253. get shadowCastersBoundingInfo(): BoundingInfo;
  61254. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61255. protected _breaksAreDirty: boolean;
  61256. protected _minDistance: number;
  61257. protected _maxDistance: number;
  61258. /**
  61259. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61260. *
  61261. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61262. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61263. * @param min minimal distance for the breaks (default to 0.)
  61264. * @param max maximal distance for the breaks (default to 1.)
  61265. */
  61266. setMinMaxDistance(min: number, max: number): void;
  61267. /** Gets the minimal distance used in the cascade break computation */
  61268. get minDistance(): number;
  61269. /** Gets the maximal distance used in the cascade break computation */
  61270. get maxDistance(): number;
  61271. /**
  61272. * Gets the class name of that object
  61273. * @returns "CascadedShadowGenerator"
  61274. */
  61275. getClassName(): string;
  61276. private _cascadeMinExtents;
  61277. private _cascadeMaxExtents;
  61278. /**
  61279. * Gets a cascade minimum extents
  61280. * @param cascadeIndex index of the cascade
  61281. * @returns the minimum cascade extents
  61282. */
  61283. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61284. /**
  61285. * Gets a cascade maximum extents
  61286. * @param cascadeIndex index of the cascade
  61287. * @returns the maximum cascade extents
  61288. */
  61289. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61290. private _cascades;
  61291. private _currentLayer;
  61292. private _viewSpaceFrustumsZ;
  61293. private _viewMatrices;
  61294. private _projectionMatrices;
  61295. private _transformMatrices;
  61296. private _transformMatricesAsArray;
  61297. private _frustumLengths;
  61298. private _lightSizeUVCorrection;
  61299. private _depthCorrection;
  61300. private _frustumCornersWorldSpace;
  61301. private _frustumCenter;
  61302. private _shadowCameraPos;
  61303. private _shadowMaxZ;
  61304. /**
  61305. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61306. * It defaults to camera.maxZ
  61307. */
  61308. get shadowMaxZ(): number;
  61309. /**
  61310. * Sets the shadow max z distance.
  61311. */
  61312. set shadowMaxZ(value: number);
  61313. protected _debug: boolean;
  61314. /**
  61315. * Gets or sets the debug flag.
  61316. * When enabled, the cascades are materialized by different colors on the screen.
  61317. */
  61318. get debug(): boolean;
  61319. set debug(dbg: boolean);
  61320. private _depthClamp;
  61321. /**
  61322. * Gets or sets the depth clamping value.
  61323. *
  61324. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61325. * to account for the shadow casters far away.
  61326. *
  61327. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61328. */
  61329. get depthClamp(): boolean;
  61330. set depthClamp(value: boolean);
  61331. private _cascadeBlendPercentage;
  61332. /**
  61333. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61334. * It defaults to 0.1 (10% blending).
  61335. */
  61336. get cascadeBlendPercentage(): number;
  61337. set cascadeBlendPercentage(value: number);
  61338. private _lambda;
  61339. /**
  61340. * Gets or set the lambda parameter.
  61341. * This parameter is used to split the camera frustum and create the cascades.
  61342. * 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.
  61343. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61344. */
  61345. get lambda(): number;
  61346. set lambda(value: number);
  61347. /**
  61348. * Gets the view matrix corresponding to a given cascade
  61349. * @param cascadeNum cascade to retrieve the view matrix from
  61350. * @returns the cascade view matrix
  61351. */
  61352. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61353. /**
  61354. * Gets the projection matrix corresponding to a given cascade
  61355. * @param cascadeNum cascade to retrieve the projection matrix from
  61356. * @returns the cascade projection matrix
  61357. */
  61358. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61359. /**
  61360. * Gets the transformation matrix corresponding to a given cascade
  61361. * @param cascadeNum cascade to retrieve the transformation matrix from
  61362. * @returns the cascade transformation matrix
  61363. */
  61364. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61365. private _depthRenderer;
  61366. /**
  61367. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61368. *
  61369. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61370. *
  61371. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61372. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61373. * @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
  61374. */
  61375. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61376. private _depthReducer;
  61377. private _autoCalcDepthBounds;
  61378. /**
  61379. * Gets or sets the autoCalcDepthBounds property.
  61380. *
  61381. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61382. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61383. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61384. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61385. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61386. */
  61387. get autoCalcDepthBounds(): boolean;
  61388. set autoCalcDepthBounds(value: boolean);
  61389. /**
  61390. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61391. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61392. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61393. * for setting the refresh rate on the renderer yourself!
  61394. */
  61395. get autoCalcDepthBoundsRefreshRate(): number;
  61396. set autoCalcDepthBoundsRefreshRate(value: number);
  61397. /**
  61398. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61399. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61400. * you change the camera near/far planes!
  61401. */
  61402. splitFrustum(): void;
  61403. private _splitFrustum;
  61404. private _computeMatrices;
  61405. private _computeFrustumInWorldSpace;
  61406. private _computeCascadeFrustum;
  61407. /**
  61408. * Support test.
  61409. */
  61410. static get IsSupported(): boolean;
  61411. /** @hidden */
  61412. static _SceneComponentInitialization: (scene: Scene) => void;
  61413. /**
  61414. * Creates a Cascaded Shadow Generator object.
  61415. * A ShadowGenerator is the required tool to use the shadows.
  61416. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61417. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61418. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61419. * @param light The directional light object generating the shadows.
  61420. * @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.
  61421. */
  61422. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61423. protected _initializeGenerator(): void;
  61424. protected _createTargetRenderTexture(): void;
  61425. protected _initializeShadowMap(): void;
  61426. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61427. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61428. /**
  61429. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61430. * @param defines Defines of the material we want to update
  61431. * @param lightIndex Index of the light in the enabled light list of the material
  61432. */
  61433. prepareDefines(defines: any, lightIndex: number): void;
  61434. /**
  61435. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61436. * defined in the generator but impacting the effect).
  61437. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61438. * @param effect The effect we are binfing the information for
  61439. */
  61440. bindShadowLight(lightIndex: string, effect: Effect): void;
  61441. /**
  61442. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61443. * (eq to view projection * shadow projection matrices)
  61444. * @returns The transform matrix used to create the shadow map
  61445. */
  61446. getTransformMatrix(): Matrix;
  61447. /**
  61448. * Disposes the ShadowGenerator.
  61449. * Returns nothing.
  61450. */
  61451. dispose(): void;
  61452. /**
  61453. * Serializes the shadow generator setup to a json object.
  61454. * @returns The serialized JSON object
  61455. */
  61456. serialize(): any;
  61457. /**
  61458. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61459. * @param parsedShadowGenerator The JSON object to parse
  61460. * @param scene The scene to create the shadow map for
  61461. * @returns The parsed shadow generator
  61462. */
  61463. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61464. }
  61465. }
  61466. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61467. import { Scene } from "babylonjs/scene";
  61468. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61469. import { AbstractScene } from "babylonjs/abstractScene";
  61470. /**
  61471. * Defines the shadow generator component responsible to manage any shadow generators
  61472. * in a given scene.
  61473. */
  61474. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61475. /**
  61476. * The component name helpfull to identify the component in the list of scene components.
  61477. */
  61478. readonly name: string;
  61479. /**
  61480. * The scene the component belongs to.
  61481. */
  61482. scene: Scene;
  61483. /**
  61484. * Creates a new instance of the component for the given scene
  61485. * @param scene Defines the scene to register the component in
  61486. */
  61487. constructor(scene: Scene);
  61488. /**
  61489. * Registers the component in a given scene
  61490. */
  61491. register(): void;
  61492. /**
  61493. * Rebuilds the elements related to this component in case of
  61494. * context lost for instance.
  61495. */
  61496. rebuild(): void;
  61497. /**
  61498. * Serializes the component data to the specified json object
  61499. * @param serializationObject The object to serialize to
  61500. */
  61501. serialize(serializationObject: any): void;
  61502. /**
  61503. * Adds all the elements from the container to the scene
  61504. * @param container the container holding the elements
  61505. */
  61506. addFromContainer(container: AbstractScene): void;
  61507. /**
  61508. * Removes all the elements in the container from the scene
  61509. * @param container contains the elements to remove
  61510. * @param dispose if the removed element should be disposed (default: false)
  61511. */
  61512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61513. /**
  61514. * Rebuilds the elements related to this component in case of
  61515. * context lost for instance.
  61516. */
  61517. dispose(): void;
  61518. private _gatherRenderTargets;
  61519. }
  61520. }
  61521. declare module "babylonjs/Lights/Shadows/index" {
  61522. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61523. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61524. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61525. }
  61526. declare module "babylonjs/Lights/pointLight" {
  61527. import { Scene } from "babylonjs/scene";
  61528. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61530. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61531. import { Effect } from "babylonjs/Materials/effect";
  61532. /**
  61533. * A point light is a light defined by an unique point in world space.
  61534. * The light is emitted in every direction from this point.
  61535. * A good example of a point light is a standard light bulb.
  61536. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61537. */
  61538. export class PointLight extends ShadowLight {
  61539. private _shadowAngle;
  61540. /**
  61541. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61542. * This specifies what angle the shadow will use to be created.
  61543. *
  61544. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61545. */
  61546. get shadowAngle(): number;
  61547. /**
  61548. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61549. * This specifies what angle the shadow will use to be created.
  61550. *
  61551. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61552. */
  61553. set shadowAngle(value: number);
  61554. /**
  61555. * Gets the direction if it has been set.
  61556. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61557. */
  61558. get direction(): Vector3;
  61559. /**
  61560. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61561. */
  61562. set direction(value: Vector3);
  61563. /**
  61564. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61565. * A PointLight emits the light in every direction.
  61566. * It can cast shadows.
  61567. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61568. * ```javascript
  61569. * var pointLight = new PointLight("pl", camera.position, scene);
  61570. * ```
  61571. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61572. * @param name The light friendly name
  61573. * @param position The position of the point light in the scene
  61574. * @param scene The scene the lights belongs to
  61575. */
  61576. constructor(name: string, position: Vector3, scene: Scene);
  61577. /**
  61578. * Returns the string "PointLight"
  61579. * @returns the class name
  61580. */
  61581. getClassName(): string;
  61582. /**
  61583. * Returns the integer 0.
  61584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61585. */
  61586. getTypeID(): number;
  61587. /**
  61588. * Specifies wether or not the shadowmap should be a cube texture.
  61589. * @returns true if the shadowmap needs to be a cube texture.
  61590. */
  61591. needCube(): boolean;
  61592. /**
  61593. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61594. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61595. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61596. */
  61597. getShadowDirection(faceIndex?: number): Vector3;
  61598. /**
  61599. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61600. * - fov = PI / 2
  61601. * - aspect ratio : 1.0
  61602. * - z-near and far equal to the active camera minZ and maxZ.
  61603. * Returns the PointLight.
  61604. */
  61605. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61606. protected _buildUniformLayout(): void;
  61607. /**
  61608. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61609. * @param effect The effect to update
  61610. * @param lightIndex The index of the light in the effect to update
  61611. * @returns The point light
  61612. */
  61613. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61614. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61615. /**
  61616. * Prepares the list of defines specific to the light type.
  61617. * @param defines the list of defines
  61618. * @param lightIndex defines the index of the light for the effect
  61619. */
  61620. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61621. }
  61622. }
  61623. declare module "babylonjs/Lights/index" {
  61624. export * from "babylonjs/Lights/light";
  61625. export * from "babylonjs/Lights/shadowLight";
  61626. export * from "babylonjs/Lights/Shadows/index";
  61627. export * from "babylonjs/Lights/directionalLight";
  61628. export * from "babylonjs/Lights/hemisphericLight";
  61629. export * from "babylonjs/Lights/pointLight";
  61630. export * from "babylonjs/Lights/spotLight";
  61631. }
  61632. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61633. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61634. /**
  61635. * Header information of HDR texture files.
  61636. */
  61637. export interface HDRInfo {
  61638. /**
  61639. * The height of the texture in pixels.
  61640. */
  61641. height: number;
  61642. /**
  61643. * The width of the texture in pixels.
  61644. */
  61645. width: number;
  61646. /**
  61647. * The index of the beginning of the data in the binary file.
  61648. */
  61649. dataPosition: number;
  61650. }
  61651. /**
  61652. * This groups tools to convert HDR texture to native colors array.
  61653. */
  61654. export class HDRTools {
  61655. private static Ldexp;
  61656. private static Rgbe2float;
  61657. private static readStringLine;
  61658. /**
  61659. * Reads header information from an RGBE texture stored in a native array.
  61660. * More information on this format are available here:
  61661. * https://en.wikipedia.org/wiki/RGBE_image_format
  61662. *
  61663. * @param uint8array The binary file stored in native array.
  61664. * @return The header information.
  61665. */
  61666. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61667. /**
  61668. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61669. * This RGBE texture needs to store the information as a panorama.
  61670. *
  61671. * More information on this format are available here:
  61672. * https://en.wikipedia.org/wiki/RGBE_image_format
  61673. *
  61674. * @param buffer The binary file stored in an array buffer.
  61675. * @param size The expected size of the extracted cubemap.
  61676. * @return The Cube Map information.
  61677. */
  61678. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61679. /**
  61680. * Returns the pixels data extracted from an RGBE texture.
  61681. * This pixels will be stored left to right up to down in the R G B order in one array.
  61682. *
  61683. * More information on this format are available here:
  61684. * https://en.wikipedia.org/wiki/RGBE_image_format
  61685. *
  61686. * @param uint8array The binary file stored in an array buffer.
  61687. * @param hdrInfo The header information of the file.
  61688. * @return The pixels data in RGB right to left up to down order.
  61689. */
  61690. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61691. private static RGBE_ReadPixels_RLE;
  61692. }
  61693. }
  61694. declare module "babylonjs/Materials/effectRenderer" {
  61695. import { Nullable } from "babylonjs/types";
  61696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61698. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61699. import { Viewport } from "babylonjs/Maths/math.viewport";
  61700. import { Observable } from "babylonjs/Misc/observable";
  61701. import { Effect } from "babylonjs/Materials/effect";
  61702. import "babylonjs/Shaders/postprocess.vertex";
  61703. /**
  61704. * Effect Render Options
  61705. */
  61706. export interface IEffectRendererOptions {
  61707. /**
  61708. * Defines the vertices positions.
  61709. */
  61710. positions?: number[];
  61711. /**
  61712. * Defines the indices.
  61713. */
  61714. indices?: number[];
  61715. }
  61716. /**
  61717. * Helper class to render one or more effects.
  61718. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61719. */
  61720. export class EffectRenderer {
  61721. private engine;
  61722. private static _DefaultOptions;
  61723. private _vertexBuffers;
  61724. private _indexBuffer;
  61725. private _fullscreenViewport;
  61726. /**
  61727. * Creates an effect renderer
  61728. * @param engine the engine to use for rendering
  61729. * @param options defines the options of the effect renderer
  61730. */
  61731. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61732. /**
  61733. * Sets the current viewport in normalized coordinates 0-1
  61734. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61735. */
  61736. setViewport(viewport?: Viewport): void;
  61737. /**
  61738. * Binds the embedded attributes buffer to the effect.
  61739. * @param effect Defines the effect to bind the attributes for
  61740. */
  61741. bindBuffers(effect: Effect): void;
  61742. /**
  61743. * Sets the current effect wrapper to use during draw.
  61744. * The effect needs to be ready before calling this api.
  61745. * This also sets the default full screen position attribute.
  61746. * @param effectWrapper Defines the effect to draw with
  61747. */
  61748. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61749. /**
  61750. * Restores engine states
  61751. */
  61752. restoreStates(): void;
  61753. /**
  61754. * Draws a full screen quad.
  61755. */
  61756. draw(): void;
  61757. private isRenderTargetTexture;
  61758. /**
  61759. * renders one or more effects to a specified texture
  61760. * @param effectWrapper the effect to renderer
  61761. * @param outputTexture texture to draw to, if null it will render to the screen.
  61762. */
  61763. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61764. /**
  61765. * Disposes of the effect renderer
  61766. */
  61767. dispose(): void;
  61768. }
  61769. /**
  61770. * Options to create an EffectWrapper
  61771. */
  61772. interface EffectWrapperCreationOptions {
  61773. /**
  61774. * Engine to use to create the effect
  61775. */
  61776. engine: ThinEngine;
  61777. /**
  61778. * Fragment shader for the effect
  61779. */
  61780. fragmentShader: string;
  61781. /**
  61782. * Use the shader store instead of direct source code
  61783. */
  61784. useShaderStore?: boolean;
  61785. /**
  61786. * Vertex shader for the effect
  61787. */
  61788. vertexShader?: string;
  61789. /**
  61790. * Attributes to use in the shader
  61791. */
  61792. attributeNames?: Array<string>;
  61793. /**
  61794. * Uniforms to use in the shader
  61795. */
  61796. uniformNames?: Array<string>;
  61797. /**
  61798. * Texture sampler names to use in the shader
  61799. */
  61800. samplerNames?: Array<string>;
  61801. /**
  61802. * Defines to use in the shader
  61803. */
  61804. defines?: Array<string>;
  61805. /**
  61806. * Callback when effect is compiled
  61807. */
  61808. onCompiled?: Nullable<(effect: Effect) => void>;
  61809. /**
  61810. * The friendly name of the effect displayed in Spector.
  61811. */
  61812. name?: string;
  61813. }
  61814. /**
  61815. * Wraps an effect to be used for rendering
  61816. */
  61817. export class EffectWrapper {
  61818. /**
  61819. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61820. */
  61821. onApplyObservable: Observable<{}>;
  61822. /**
  61823. * The underlying effect
  61824. */
  61825. effect: Effect;
  61826. /**
  61827. * Creates an effect to be renderer
  61828. * @param creationOptions options to create the effect
  61829. */
  61830. constructor(creationOptions: EffectWrapperCreationOptions);
  61831. /**
  61832. * Disposes of the effect wrapper
  61833. */
  61834. dispose(): void;
  61835. }
  61836. }
  61837. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61838. /** @hidden */
  61839. export var hdrFilteringVertexShader: {
  61840. name: string;
  61841. shader: string;
  61842. };
  61843. }
  61844. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61846. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61847. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61848. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61849. /** @hidden */
  61850. export var hdrFilteringPixelShader: {
  61851. name: string;
  61852. shader: string;
  61853. };
  61854. }
  61855. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61857. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61858. import { Nullable } from "babylonjs/types";
  61859. import "babylonjs/Shaders/hdrFiltering.vertex";
  61860. import "babylonjs/Shaders/hdrFiltering.fragment";
  61861. /**
  61862. * Options for texture filtering
  61863. */
  61864. interface IHDRFilteringOptions {
  61865. /**
  61866. * Scales pixel intensity for the input HDR map.
  61867. */
  61868. hdrScale?: number;
  61869. /**
  61870. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61871. */
  61872. quality?: number;
  61873. }
  61874. /**
  61875. * Filters HDR maps to get correct renderings of PBR reflections
  61876. */
  61877. export class HDRFiltering {
  61878. private _engine;
  61879. private _effectRenderer;
  61880. private _effectWrapper;
  61881. private _lodGenerationOffset;
  61882. private _lodGenerationScale;
  61883. /**
  61884. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61885. * you care about baking speed.
  61886. */
  61887. quality: number;
  61888. /**
  61889. * Scales pixel intensity for the input HDR map.
  61890. */
  61891. hdrScale: number;
  61892. /**
  61893. * Instantiates HDR filter for reflection maps
  61894. *
  61895. * @param engine Thin engine
  61896. * @param options Options
  61897. */
  61898. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61899. private _createRenderTarget;
  61900. private _prefilterInternal;
  61901. private _createEffect;
  61902. /**
  61903. * Get a value indicating if the filter is ready to be used
  61904. * @param texture Texture to filter
  61905. * @returns true if the filter is ready
  61906. */
  61907. isReady(texture: BaseTexture): boolean;
  61908. /**
  61909. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61910. * Prefiltering will be invoked at the end of next rendering pass.
  61911. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61912. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61913. * @param texture Texture to filter
  61914. * @param onFinished Callback when filtering is done
  61915. * @return Promise called when prefiltering is done
  61916. */
  61917. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61918. }
  61919. }
  61920. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61921. import { Nullable } from "babylonjs/types";
  61922. import { Scene } from "babylonjs/scene";
  61923. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61925. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61926. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61927. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61928. /**
  61929. * This represents a texture coming from an HDR input.
  61930. *
  61931. * The only supported format is currently panorama picture stored in RGBE format.
  61932. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61933. */
  61934. export class HDRCubeTexture extends BaseTexture {
  61935. private static _facesMapping;
  61936. private _generateHarmonics;
  61937. private _noMipmap;
  61938. private _prefilterOnLoad;
  61939. private _textureMatrix;
  61940. private _size;
  61941. private _onLoad;
  61942. private _onError;
  61943. /**
  61944. * The texture URL.
  61945. */
  61946. url: string;
  61947. /**
  61948. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61949. */
  61950. coordinatesMode: number;
  61951. protected _isBlocking: boolean;
  61952. /**
  61953. * Sets wether or not the texture is blocking during loading.
  61954. */
  61955. set isBlocking(value: boolean);
  61956. /**
  61957. * Gets wether or not the texture is blocking during loading.
  61958. */
  61959. get isBlocking(): boolean;
  61960. protected _rotationY: number;
  61961. /**
  61962. * Sets texture matrix rotation angle around Y axis in radians.
  61963. */
  61964. set rotationY(value: number);
  61965. /**
  61966. * Gets texture matrix rotation angle around Y axis radians.
  61967. */
  61968. get rotationY(): number;
  61969. /**
  61970. * Gets or sets the center of the bounding box associated with the cube texture
  61971. * It must define where the camera used to render the texture was set
  61972. */
  61973. boundingBoxPosition: Vector3;
  61974. private _boundingBoxSize;
  61975. /**
  61976. * Gets or sets the size of the bounding box associated with the cube texture
  61977. * When defined, the cubemap will switch to local mode
  61978. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61979. * @example https://www.babylonjs-playground.com/#RNASML
  61980. */
  61981. set boundingBoxSize(value: Vector3);
  61982. get boundingBoxSize(): Vector3;
  61983. /**
  61984. * Instantiates an HDRTexture from the following parameters.
  61985. *
  61986. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61987. * @param sceneOrEngine The scene or engine the texture will be used in
  61988. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61989. * @param noMipmap Forces to not generate the mipmap if true
  61990. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61991. * @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)
  61992. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61993. */
  61994. 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>);
  61995. /**
  61996. * Get the current class name of the texture useful for serialization or dynamic coding.
  61997. * @returns "HDRCubeTexture"
  61998. */
  61999. getClassName(): string;
  62000. /**
  62001. * Occurs when the file is raw .hdr file.
  62002. */
  62003. private loadTexture;
  62004. clone(): HDRCubeTexture;
  62005. delayLoad(): void;
  62006. /**
  62007. * Get the texture reflection matrix used to rotate/transform the reflection.
  62008. * @returns the reflection matrix
  62009. */
  62010. getReflectionTextureMatrix(): Matrix;
  62011. /**
  62012. * Set the texture reflection matrix used to rotate/transform the reflection.
  62013. * @param value Define the reflection matrix to set
  62014. */
  62015. setReflectionTextureMatrix(value: Matrix): void;
  62016. /**
  62017. * Parses a JSON representation of an HDR Texture in order to create the texture
  62018. * @param parsedTexture Define the JSON representation
  62019. * @param scene Define the scene the texture should be created in
  62020. * @param rootUrl Define the root url in case we need to load relative dependencies
  62021. * @returns the newly created texture after parsing
  62022. */
  62023. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62024. serialize(): any;
  62025. }
  62026. }
  62027. declare module "babylonjs/Physics/physicsEngine" {
  62028. import { Nullable } from "babylonjs/types";
  62029. import { Vector3 } from "babylonjs/Maths/math.vector";
  62030. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62031. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62032. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62033. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62034. /**
  62035. * Class used to control physics engine
  62036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62037. */
  62038. export class PhysicsEngine implements IPhysicsEngine {
  62039. private _physicsPlugin;
  62040. /**
  62041. * Global value used to control the smallest number supported by the simulation
  62042. */
  62043. static Epsilon: number;
  62044. private _impostors;
  62045. private _joints;
  62046. private _subTimeStep;
  62047. /**
  62048. * Gets the gravity vector used by the simulation
  62049. */
  62050. gravity: Vector3;
  62051. /**
  62052. * Factory used to create the default physics plugin.
  62053. * @returns The default physics plugin
  62054. */
  62055. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62056. /**
  62057. * Creates a new Physics Engine
  62058. * @param gravity defines the gravity vector used by the simulation
  62059. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62060. */
  62061. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62062. /**
  62063. * Sets the gravity vector used by the simulation
  62064. * @param gravity defines the gravity vector to use
  62065. */
  62066. setGravity(gravity: Vector3): void;
  62067. /**
  62068. * Set the time step of the physics engine.
  62069. * Default is 1/60.
  62070. * To slow it down, enter 1/600 for example.
  62071. * To speed it up, 1/30
  62072. * @param newTimeStep defines the new timestep to apply to this world.
  62073. */
  62074. setTimeStep(newTimeStep?: number): void;
  62075. /**
  62076. * Get the time step of the physics engine.
  62077. * @returns the current time step
  62078. */
  62079. getTimeStep(): number;
  62080. /**
  62081. * Set the sub time step of the physics engine.
  62082. * Default is 0 meaning there is no sub steps
  62083. * To increase physics resolution precision, set a small value (like 1 ms)
  62084. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62085. */
  62086. setSubTimeStep(subTimeStep?: number): void;
  62087. /**
  62088. * Get the sub time step of the physics engine.
  62089. * @returns the current sub time step
  62090. */
  62091. getSubTimeStep(): number;
  62092. /**
  62093. * Release all resources
  62094. */
  62095. dispose(): void;
  62096. /**
  62097. * Gets the name of the current physics plugin
  62098. * @returns the name of the plugin
  62099. */
  62100. getPhysicsPluginName(): string;
  62101. /**
  62102. * Adding a new impostor for the impostor tracking.
  62103. * This will be done by the impostor itself.
  62104. * @param impostor the impostor to add
  62105. */
  62106. addImpostor(impostor: PhysicsImpostor): void;
  62107. /**
  62108. * Remove an impostor from the engine.
  62109. * This impostor and its mesh will not longer be updated by the physics engine.
  62110. * @param impostor the impostor to remove
  62111. */
  62112. removeImpostor(impostor: PhysicsImpostor): void;
  62113. /**
  62114. * Add a joint to the physics engine
  62115. * @param mainImpostor defines the main impostor to which the joint is added.
  62116. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62117. * @param joint defines the joint that will connect both impostors.
  62118. */
  62119. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62120. /**
  62121. * Removes a joint from the simulation
  62122. * @param mainImpostor defines the impostor used with the joint
  62123. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62124. * @param joint defines the joint to remove
  62125. */
  62126. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62127. /**
  62128. * Called by the scene. No need to call it.
  62129. * @param delta defines the timespam between frames
  62130. */
  62131. _step(delta: number): void;
  62132. /**
  62133. * Gets the current plugin used to run the simulation
  62134. * @returns current plugin
  62135. */
  62136. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62137. /**
  62138. * Gets the list of physic impostors
  62139. * @returns an array of PhysicsImpostor
  62140. */
  62141. getImpostors(): Array<PhysicsImpostor>;
  62142. /**
  62143. * Gets the impostor for a physics enabled object
  62144. * @param object defines the object impersonated by the impostor
  62145. * @returns the PhysicsImpostor or null if not found
  62146. */
  62147. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62148. /**
  62149. * Gets the impostor for a physics body object
  62150. * @param body defines physics body used by the impostor
  62151. * @returns the PhysicsImpostor or null if not found
  62152. */
  62153. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62154. /**
  62155. * Does a raycast in the physics world
  62156. * @param from when should the ray start?
  62157. * @param to when should the ray end?
  62158. * @returns PhysicsRaycastResult
  62159. */
  62160. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62161. }
  62162. }
  62163. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62164. import { Nullable } from "babylonjs/types";
  62165. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62167. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62168. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62169. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62170. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62171. /** @hidden */
  62172. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62173. private _useDeltaForWorldStep;
  62174. world: any;
  62175. name: string;
  62176. private _physicsMaterials;
  62177. private _fixedTimeStep;
  62178. private _cannonRaycastResult;
  62179. private _raycastResult;
  62180. private _physicsBodysToRemoveAfterStep;
  62181. private _firstFrame;
  62182. BJSCANNON: any;
  62183. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62184. setGravity(gravity: Vector3): void;
  62185. setTimeStep(timeStep: number): void;
  62186. getTimeStep(): number;
  62187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62188. private _removeMarkedPhysicsBodiesFromWorld;
  62189. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62190. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62191. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62192. private _processChildMeshes;
  62193. removePhysicsBody(impostor: PhysicsImpostor): void;
  62194. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62195. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62196. private _addMaterial;
  62197. private _checkWithEpsilon;
  62198. private _createShape;
  62199. private _createHeightmap;
  62200. private _minus90X;
  62201. private _plus90X;
  62202. private _tmpPosition;
  62203. private _tmpDeltaPosition;
  62204. private _tmpUnityRotation;
  62205. private _updatePhysicsBodyTransformation;
  62206. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62207. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62208. isSupported(): boolean;
  62209. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62210. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62211. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62212. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62213. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62214. getBodyMass(impostor: PhysicsImpostor): number;
  62215. getBodyFriction(impostor: PhysicsImpostor): number;
  62216. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62217. getBodyRestitution(impostor: PhysicsImpostor): number;
  62218. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62219. sleepBody(impostor: PhysicsImpostor): void;
  62220. wakeUpBody(impostor: PhysicsImpostor): void;
  62221. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62222. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62223. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62224. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62225. getRadius(impostor: PhysicsImpostor): number;
  62226. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62227. dispose(): void;
  62228. private _extendNamespace;
  62229. /**
  62230. * Does a raycast in the physics world
  62231. * @param from when should the ray start?
  62232. * @param to when should the ray end?
  62233. * @returns PhysicsRaycastResult
  62234. */
  62235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62236. }
  62237. }
  62238. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62239. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62240. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62241. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62243. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62244. import { Nullable } from "babylonjs/types";
  62245. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62246. /** @hidden */
  62247. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62248. private _useDeltaForWorldStep;
  62249. world: any;
  62250. name: string;
  62251. BJSOIMO: any;
  62252. private _raycastResult;
  62253. private _fixedTimeStep;
  62254. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62255. setGravity(gravity: Vector3): void;
  62256. setTimeStep(timeStep: number): void;
  62257. getTimeStep(): number;
  62258. private _tmpImpostorsArray;
  62259. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62261. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62262. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62263. private _tmpPositionVector;
  62264. removePhysicsBody(impostor: PhysicsImpostor): void;
  62265. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62266. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62267. isSupported(): boolean;
  62268. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62270. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62275. getBodyMass(impostor: PhysicsImpostor): number;
  62276. getBodyFriction(impostor: PhysicsImpostor): number;
  62277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62278. getBodyRestitution(impostor: PhysicsImpostor): number;
  62279. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62280. sleepBody(impostor: PhysicsImpostor): void;
  62281. wakeUpBody(impostor: PhysicsImpostor): void;
  62282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62283. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62286. getRadius(impostor: PhysicsImpostor): number;
  62287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62288. dispose(): void;
  62289. /**
  62290. * Does a raycast in the physics world
  62291. * @param from when should the ray start?
  62292. * @param to when should the ray end?
  62293. * @returns PhysicsRaycastResult
  62294. */
  62295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62296. }
  62297. }
  62298. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62299. import { Nullable } from "babylonjs/types";
  62300. import { Scene } from "babylonjs/scene";
  62301. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62302. import { Color4 } from "babylonjs/Maths/math.color";
  62303. import { Mesh } from "babylonjs/Meshes/mesh";
  62304. /**
  62305. * Class containing static functions to help procedurally build meshes
  62306. */
  62307. export class RibbonBuilder {
  62308. /**
  62309. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62310. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62311. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62312. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62313. * * 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
  62314. * * 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
  62315. * * 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
  62316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62317. * * 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
  62318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62319. * * 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
  62320. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62321. * * 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
  62322. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62324. * @param name defines the name of the mesh
  62325. * @param options defines the options used to create the mesh
  62326. * @param scene defines the hosting scene
  62327. * @returns the ribbon mesh
  62328. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62329. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62330. */
  62331. static CreateRibbon(name: string, options: {
  62332. pathArray: Vector3[][];
  62333. closeArray?: boolean;
  62334. closePath?: boolean;
  62335. offset?: number;
  62336. updatable?: boolean;
  62337. sideOrientation?: number;
  62338. frontUVs?: Vector4;
  62339. backUVs?: Vector4;
  62340. instance?: Mesh;
  62341. invertUV?: boolean;
  62342. uvs?: Vector2[];
  62343. colors?: Color4[];
  62344. }, scene?: Nullable<Scene>): Mesh;
  62345. }
  62346. }
  62347. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62348. import { Nullable } from "babylonjs/types";
  62349. import { Scene } from "babylonjs/scene";
  62350. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62351. import { Mesh } from "babylonjs/Meshes/mesh";
  62352. /**
  62353. * Class containing static functions to help procedurally build meshes
  62354. */
  62355. export class ShapeBuilder {
  62356. /**
  62357. * 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.
  62358. * * 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.
  62359. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62360. * * 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.
  62361. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62362. * * 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
  62363. * * 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
  62364. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62366. * * 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
  62367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62369. * @param name defines the name of the mesh
  62370. * @param options defines the options used to create the mesh
  62371. * @param scene defines the hosting scene
  62372. * @returns the extruded shape mesh
  62373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62375. */
  62376. static ExtrudeShape(name: string, options: {
  62377. shape: Vector3[];
  62378. path: Vector3[];
  62379. scale?: number;
  62380. rotation?: number;
  62381. cap?: number;
  62382. updatable?: boolean;
  62383. sideOrientation?: number;
  62384. frontUVs?: Vector4;
  62385. backUVs?: Vector4;
  62386. instance?: Mesh;
  62387. invertUV?: boolean;
  62388. }, scene?: Nullable<Scene>): Mesh;
  62389. /**
  62390. * Creates an custom extruded shape mesh.
  62391. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62392. * * 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.
  62393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62394. * * 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
  62395. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62396. * * 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
  62397. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62398. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62399. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62400. * * 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
  62401. * * 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
  62402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62404. * * 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
  62405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62407. * @param name defines the name of the mesh
  62408. * @param options defines the options used to create the mesh
  62409. * @param scene defines the hosting scene
  62410. * @returns the custom extruded shape mesh
  62411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62414. */
  62415. static ExtrudeShapeCustom(name: string, options: {
  62416. shape: Vector3[];
  62417. path: Vector3[];
  62418. scaleFunction?: any;
  62419. rotationFunction?: any;
  62420. ribbonCloseArray?: boolean;
  62421. ribbonClosePath?: boolean;
  62422. cap?: number;
  62423. updatable?: boolean;
  62424. sideOrientation?: number;
  62425. frontUVs?: Vector4;
  62426. backUVs?: Vector4;
  62427. instance?: Mesh;
  62428. invertUV?: boolean;
  62429. }, scene?: Nullable<Scene>): Mesh;
  62430. private static _ExtrudeShapeGeneric;
  62431. }
  62432. }
  62433. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62434. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62435. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62436. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62437. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62438. import { Nullable } from "babylonjs/types";
  62439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62440. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62441. /**
  62442. * AmmoJS Physics plugin
  62443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62444. * @see https://github.com/kripken/ammo.js/
  62445. */
  62446. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62447. private _useDeltaForWorldStep;
  62448. /**
  62449. * Reference to the Ammo library
  62450. */
  62451. bjsAMMO: any;
  62452. /**
  62453. * Created ammoJS world which physics bodies are added to
  62454. */
  62455. world: any;
  62456. /**
  62457. * Name of the plugin
  62458. */
  62459. name: string;
  62460. private _timeStep;
  62461. private _fixedTimeStep;
  62462. private _maxSteps;
  62463. private _tmpQuaternion;
  62464. private _tmpAmmoTransform;
  62465. private _tmpAmmoQuaternion;
  62466. private _tmpAmmoConcreteContactResultCallback;
  62467. private _collisionConfiguration;
  62468. private _dispatcher;
  62469. private _overlappingPairCache;
  62470. private _solver;
  62471. private _softBodySolver;
  62472. private _tmpAmmoVectorA;
  62473. private _tmpAmmoVectorB;
  62474. private _tmpAmmoVectorC;
  62475. private _tmpAmmoVectorD;
  62476. private _tmpContactCallbackResult;
  62477. private _tmpAmmoVectorRCA;
  62478. private _tmpAmmoVectorRCB;
  62479. private _raycastResult;
  62480. private static readonly DISABLE_COLLISION_FLAG;
  62481. private static readonly KINEMATIC_FLAG;
  62482. private static readonly DISABLE_DEACTIVATION_FLAG;
  62483. /**
  62484. * Initializes the ammoJS plugin
  62485. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62486. * @param ammoInjection can be used to inject your own ammo reference
  62487. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62488. */
  62489. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62490. /**
  62491. * Sets the gravity of the physics world (m/(s^2))
  62492. * @param gravity Gravity to set
  62493. */
  62494. setGravity(gravity: Vector3): void;
  62495. /**
  62496. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62497. * @param timeStep timestep to use in seconds
  62498. */
  62499. setTimeStep(timeStep: number): void;
  62500. /**
  62501. * 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)
  62502. * @param fixedTimeStep fixedTimeStep to use in seconds
  62503. */
  62504. setFixedTimeStep(fixedTimeStep: number): void;
  62505. /**
  62506. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62507. * @param maxSteps the maximum number of steps by the physics engine per frame
  62508. */
  62509. setMaxSteps(maxSteps: number): void;
  62510. /**
  62511. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62512. * @returns the current timestep in seconds
  62513. */
  62514. getTimeStep(): number;
  62515. /**
  62516. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62517. */
  62518. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62519. private _isImpostorInContact;
  62520. private _isImpostorPairInContact;
  62521. private _stepSimulation;
  62522. /**
  62523. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62524. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62525. * After the step the babylon meshes are set to the position of the physics imposters
  62526. * @param delta amount of time to step forward
  62527. * @param impostors array of imposters to update before/after the step
  62528. */
  62529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62530. /**
  62531. * Update babylon mesh to match physics world object
  62532. * @param impostor imposter to match
  62533. */
  62534. private _afterSoftStep;
  62535. /**
  62536. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62537. * @param impostor imposter to match
  62538. */
  62539. private _ropeStep;
  62540. /**
  62541. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62542. * @param impostor imposter to match
  62543. */
  62544. private _softbodyOrClothStep;
  62545. private _tmpMatrix;
  62546. /**
  62547. * Applies an impulse on the imposter
  62548. * @param impostor imposter to apply impulse to
  62549. * @param force amount of force to be applied to the imposter
  62550. * @param contactPoint the location to apply the impulse on the imposter
  62551. */
  62552. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62553. /**
  62554. * Applies a force on the imposter
  62555. * @param impostor imposter to apply force
  62556. * @param force amount of force to be applied to the imposter
  62557. * @param contactPoint the location to apply the force on the imposter
  62558. */
  62559. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62560. /**
  62561. * Creates a physics body using the plugin
  62562. * @param impostor the imposter to create the physics body on
  62563. */
  62564. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62565. /**
  62566. * Removes the physics body from the imposter and disposes of the body's memory
  62567. * @param impostor imposter to remove the physics body from
  62568. */
  62569. removePhysicsBody(impostor: PhysicsImpostor): void;
  62570. /**
  62571. * Generates a joint
  62572. * @param impostorJoint the imposter joint to create the joint with
  62573. */
  62574. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62575. /**
  62576. * Removes a joint
  62577. * @param impostorJoint the imposter joint to remove the joint from
  62578. */
  62579. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62580. private _addMeshVerts;
  62581. /**
  62582. * Initialise the soft body vertices to match its object's (mesh) vertices
  62583. * Softbody vertices (nodes) are in world space and to match this
  62584. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62585. * @param impostor to create the softbody for
  62586. */
  62587. private _softVertexData;
  62588. /**
  62589. * Create an impostor's soft body
  62590. * @param impostor to create the softbody for
  62591. */
  62592. private _createSoftbody;
  62593. /**
  62594. * Create cloth for an impostor
  62595. * @param impostor to create the softbody for
  62596. */
  62597. private _createCloth;
  62598. /**
  62599. * Create rope for an impostor
  62600. * @param impostor to create the softbody for
  62601. */
  62602. private _createRope;
  62603. /**
  62604. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62605. * @param impostor to create the custom physics shape for
  62606. */
  62607. private _createCustom;
  62608. private _addHullVerts;
  62609. private _createShape;
  62610. /**
  62611. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62612. * @param impostor imposter containing the physics body and babylon object
  62613. */
  62614. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62615. /**
  62616. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62617. * @param impostor imposter containing the physics body and babylon object
  62618. * @param newPosition new position
  62619. * @param newRotation new rotation
  62620. */
  62621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62622. /**
  62623. * If this plugin is supported
  62624. * @returns true if its supported
  62625. */
  62626. isSupported(): boolean;
  62627. /**
  62628. * Sets the linear velocity of the physics body
  62629. * @param impostor imposter to set the velocity on
  62630. * @param velocity velocity to set
  62631. */
  62632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62633. /**
  62634. * Sets the angular velocity of the physics body
  62635. * @param impostor imposter to set the velocity on
  62636. * @param velocity velocity to set
  62637. */
  62638. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62639. /**
  62640. * gets the linear velocity
  62641. * @param impostor imposter to get linear velocity from
  62642. * @returns linear velocity
  62643. */
  62644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62645. /**
  62646. * gets the angular velocity
  62647. * @param impostor imposter to get angular velocity from
  62648. * @returns angular velocity
  62649. */
  62650. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62651. /**
  62652. * Sets the mass of physics body
  62653. * @param impostor imposter to set the mass on
  62654. * @param mass mass to set
  62655. */
  62656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62657. /**
  62658. * Gets the mass of the physics body
  62659. * @param impostor imposter to get the mass from
  62660. * @returns mass
  62661. */
  62662. getBodyMass(impostor: PhysicsImpostor): number;
  62663. /**
  62664. * Gets friction of the impostor
  62665. * @param impostor impostor to get friction from
  62666. * @returns friction value
  62667. */
  62668. getBodyFriction(impostor: PhysicsImpostor): number;
  62669. /**
  62670. * Sets friction of the impostor
  62671. * @param impostor impostor to set friction on
  62672. * @param friction friction value
  62673. */
  62674. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62675. /**
  62676. * Gets restitution of the impostor
  62677. * @param impostor impostor to get restitution from
  62678. * @returns restitution value
  62679. */
  62680. getBodyRestitution(impostor: PhysicsImpostor): number;
  62681. /**
  62682. * Sets resitution of the impostor
  62683. * @param impostor impostor to set resitution on
  62684. * @param restitution resitution value
  62685. */
  62686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62687. /**
  62688. * Gets pressure inside the impostor
  62689. * @param impostor impostor to get pressure from
  62690. * @returns pressure value
  62691. */
  62692. getBodyPressure(impostor: PhysicsImpostor): number;
  62693. /**
  62694. * Sets pressure inside a soft body impostor
  62695. * Cloth and rope must remain 0 pressure
  62696. * @param impostor impostor to set pressure on
  62697. * @param pressure pressure value
  62698. */
  62699. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62700. /**
  62701. * Gets stiffness of the impostor
  62702. * @param impostor impostor to get stiffness from
  62703. * @returns pressure value
  62704. */
  62705. getBodyStiffness(impostor: PhysicsImpostor): number;
  62706. /**
  62707. * Sets stiffness of the impostor
  62708. * @param impostor impostor to set stiffness on
  62709. * @param stiffness stiffness value from 0 to 1
  62710. */
  62711. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62712. /**
  62713. * Gets velocityIterations of the impostor
  62714. * @param impostor impostor to get velocity iterations from
  62715. * @returns velocityIterations value
  62716. */
  62717. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62718. /**
  62719. * Sets velocityIterations of the impostor
  62720. * @param impostor impostor to set velocity iterations on
  62721. * @param velocityIterations velocityIterations value
  62722. */
  62723. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62724. /**
  62725. * Gets positionIterations of the impostor
  62726. * @param impostor impostor to get position iterations from
  62727. * @returns positionIterations value
  62728. */
  62729. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62730. /**
  62731. * Sets positionIterations of the impostor
  62732. * @param impostor impostor to set position on
  62733. * @param positionIterations positionIterations value
  62734. */
  62735. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62736. /**
  62737. * Append an anchor to a cloth object
  62738. * @param impostor is the cloth impostor to add anchor to
  62739. * @param otherImpostor is the rigid impostor to anchor to
  62740. * @param width ratio across width from 0 to 1
  62741. * @param height ratio up height from 0 to 1
  62742. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62743. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62744. */
  62745. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62746. /**
  62747. * Append an hook to a rope object
  62748. * @param impostor is the rope impostor to add hook to
  62749. * @param otherImpostor is the rigid impostor to hook to
  62750. * @param length ratio along the rope from 0 to 1
  62751. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62752. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62753. */
  62754. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62755. /**
  62756. * Sleeps the physics body and stops it from being active
  62757. * @param impostor impostor to sleep
  62758. */
  62759. sleepBody(impostor: PhysicsImpostor): void;
  62760. /**
  62761. * Activates the physics body
  62762. * @param impostor impostor to activate
  62763. */
  62764. wakeUpBody(impostor: PhysicsImpostor): void;
  62765. /**
  62766. * Updates the distance parameters of the joint
  62767. * @param joint joint to update
  62768. * @param maxDistance maximum distance of the joint
  62769. * @param minDistance minimum distance of the joint
  62770. */
  62771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62772. /**
  62773. * Sets a motor on the joint
  62774. * @param joint joint to set motor on
  62775. * @param speed speed of the motor
  62776. * @param maxForce maximum force of the motor
  62777. * @param motorIndex index of the motor
  62778. */
  62779. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62780. /**
  62781. * Sets the motors limit
  62782. * @param joint joint to set limit on
  62783. * @param upperLimit upper limit
  62784. * @param lowerLimit lower limit
  62785. */
  62786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62787. /**
  62788. * Syncs the position and rotation of a mesh with the impostor
  62789. * @param mesh mesh to sync
  62790. * @param impostor impostor to update the mesh with
  62791. */
  62792. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62793. /**
  62794. * Gets the radius of the impostor
  62795. * @param impostor impostor to get radius from
  62796. * @returns the radius
  62797. */
  62798. getRadius(impostor: PhysicsImpostor): number;
  62799. /**
  62800. * Gets the box size of the impostor
  62801. * @param impostor impostor to get box size from
  62802. * @param result the resulting box size
  62803. */
  62804. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62805. /**
  62806. * Disposes of the impostor
  62807. */
  62808. dispose(): void;
  62809. /**
  62810. * Does a raycast in the physics world
  62811. * @param from when should the ray start?
  62812. * @param to when should the ray end?
  62813. * @returns PhysicsRaycastResult
  62814. */
  62815. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62816. }
  62817. }
  62818. declare module "babylonjs/Probes/reflectionProbe" {
  62819. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62820. import { Vector3 } from "babylonjs/Maths/math.vector";
  62821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62822. import { Nullable } from "babylonjs/types";
  62823. import { Scene } from "babylonjs/scene";
  62824. module "babylonjs/abstractScene" {
  62825. interface AbstractScene {
  62826. /**
  62827. * The list of reflection probes added to the scene
  62828. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62829. */
  62830. reflectionProbes: Array<ReflectionProbe>;
  62831. /**
  62832. * Removes the given reflection probe from this scene.
  62833. * @param toRemove The reflection probe to remove
  62834. * @returns The index of the removed reflection probe
  62835. */
  62836. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62837. /**
  62838. * Adds the given reflection probe to this scene.
  62839. * @param newReflectionProbe The reflection probe to add
  62840. */
  62841. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62842. }
  62843. }
  62844. /**
  62845. * Class used to generate realtime reflection / refraction cube textures
  62846. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62847. */
  62848. export class ReflectionProbe {
  62849. /** defines the name of the probe */
  62850. name: string;
  62851. private _scene;
  62852. private _renderTargetTexture;
  62853. private _projectionMatrix;
  62854. private _viewMatrix;
  62855. private _target;
  62856. private _add;
  62857. private _attachedMesh;
  62858. private _invertYAxis;
  62859. /** Gets or sets probe position (center of the cube map) */
  62860. position: Vector3;
  62861. /**
  62862. * Creates a new reflection probe
  62863. * @param name defines the name of the probe
  62864. * @param size defines the texture resolution (for each face)
  62865. * @param scene defines the hosting scene
  62866. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62867. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62868. */
  62869. constructor(
  62870. /** defines the name of the probe */
  62871. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62872. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62873. get samples(): number;
  62874. set samples(value: number);
  62875. /** Gets or sets the refresh rate to use (on every frame by default) */
  62876. get refreshRate(): number;
  62877. set refreshRate(value: number);
  62878. /**
  62879. * Gets the hosting scene
  62880. * @returns a Scene
  62881. */
  62882. getScene(): Scene;
  62883. /** Gets the internal CubeTexture used to render to */
  62884. get cubeTexture(): RenderTargetTexture;
  62885. /** Gets the list of meshes to render */
  62886. get renderList(): Nullable<AbstractMesh[]>;
  62887. /**
  62888. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62889. * @param mesh defines the mesh to attach to
  62890. */
  62891. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62892. /**
  62893. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62894. * @param renderingGroupId The rendering group id corresponding to its index
  62895. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62896. */
  62897. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62898. /**
  62899. * Clean all associated resources
  62900. */
  62901. dispose(): void;
  62902. /**
  62903. * Converts the reflection probe information to a readable string for debug purpose.
  62904. * @param fullDetails Supports for multiple levels of logging within scene loading
  62905. * @returns the human readable reflection probe info
  62906. */
  62907. toString(fullDetails?: boolean): string;
  62908. /**
  62909. * Get the class name of the relfection probe.
  62910. * @returns "ReflectionProbe"
  62911. */
  62912. getClassName(): string;
  62913. /**
  62914. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62915. * @returns The JSON representation of the texture
  62916. */
  62917. serialize(): any;
  62918. /**
  62919. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62920. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62921. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62922. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62923. * @returns The parsed reflection probe if successful
  62924. */
  62925. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62926. }
  62927. }
  62928. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62929. /** @hidden */
  62930. export var _BabylonLoaderRegistered: boolean;
  62931. /**
  62932. * Helps setting up some configuration for the babylon file loader.
  62933. */
  62934. export class BabylonFileLoaderConfiguration {
  62935. /**
  62936. * The loader does not allow injecting custom physix engine into the plugins.
  62937. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62938. * So you could set this variable to your engine import to make it work.
  62939. */
  62940. static LoaderInjectedPhysicsEngine: any;
  62941. }
  62942. }
  62943. declare module "babylonjs/Loading/Plugins/index" {
  62944. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62945. }
  62946. declare module "babylonjs/Loading/index" {
  62947. export * from "babylonjs/Loading/loadingScreen";
  62948. export * from "babylonjs/Loading/Plugins/index";
  62949. export * from "babylonjs/Loading/sceneLoader";
  62950. export * from "babylonjs/Loading/sceneLoaderFlags";
  62951. }
  62952. declare module "babylonjs/Materials/Background/index" {
  62953. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62954. }
  62955. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62956. import { Scene } from "babylonjs/scene";
  62957. import { Color3 } from "babylonjs/Maths/math.color";
  62958. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62960. /**
  62961. * The Physically based simple base material of BJS.
  62962. *
  62963. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62964. * It is used as the base class for both the specGloss and metalRough conventions.
  62965. */
  62966. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62967. /**
  62968. * Number of Simultaneous lights allowed on the material.
  62969. */
  62970. maxSimultaneousLights: number;
  62971. /**
  62972. * If sets to true, disables all the lights affecting the material.
  62973. */
  62974. disableLighting: boolean;
  62975. /**
  62976. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62977. */
  62978. environmentTexture: BaseTexture;
  62979. /**
  62980. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62981. */
  62982. invertNormalMapX: boolean;
  62983. /**
  62984. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62985. */
  62986. invertNormalMapY: boolean;
  62987. /**
  62988. * Normal map used in the model.
  62989. */
  62990. normalTexture: BaseTexture;
  62991. /**
  62992. * Emissivie color used to self-illuminate the model.
  62993. */
  62994. emissiveColor: Color3;
  62995. /**
  62996. * Emissivie texture used to self-illuminate the model.
  62997. */
  62998. emissiveTexture: BaseTexture;
  62999. /**
  63000. * Occlusion Channel Strenght.
  63001. */
  63002. occlusionStrength: number;
  63003. /**
  63004. * Occlusion Texture of the material (adding extra occlusion effects).
  63005. */
  63006. occlusionTexture: BaseTexture;
  63007. /**
  63008. * Defines the alpha limits in alpha test mode.
  63009. */
  63010. alphaCutOff: number;
  63011. /**
  63012. * Gets the current double sided mode.
  63013. */
  63014. get doubleSided(): boolean;
  63015. /**
  63016. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63017. */
  63018. set doubleSided(value: boolean);
  63019. /**
  63020. * Stores the pre-calculated light information of a mesh in a texture.
  63021. */
  63022. lightmapTexture: BaseTexture;
  63023. /**
  63024. * If true, the light map contains occlusion information instead of lighting info.
  63025. */
  63026. useLightmapAsShadowmap: boolean;
  63027. /**
  63028. * Instantiates a new PBRMaterial instance.
  63029. *
  63030. * @param name The material name
  63031. * @param scene The scene the material will be use in.
  63032. */
  63033. constructor(name: string, scene: Scene);
  63034. getClassName(): string;
  63035. }
  63036. }
  63037. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63038. import { Scene } from "babylonjs/scene";
  63039. import { Color3 } from "babylonjs/Maths/math.color";
  63040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63041. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63042. /**
  63043. * The PBR material of BJS following the metal roughness convention.
  63044. *
  63045. * This fits to the PBR convention in the GLTF definition:
  63046. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63047. */
  63048. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63049. /**
  63050. * The base color has two different interpretations depending on the value of metalness.
  63051. * When the material is a metal, the base color is the specific measured reflectance value
  63052. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63053. * of the material.
  63054. */
  63055. baseColor: Color3;
  63056. /**
  63057. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63058. * well as opacity information in the alpha channel.
  63059. */
  63060. baseTexture: BaseTexture;
  63061. /**
  63062. * Specifies the metallic scalar value of the material.
  63063. * Can also be used to scale the metalness values of the metallic texture.
  63064. */
  63065. metallic: number;
  63066. /**
  63067. * Specifies the roughness scalar value of the material.
  63068. * Can also be used to scale the roughness values of the metallic texture.
  63069. */
  63070. roughness: number;
  63071. /**
  63072. * Texture containing both the metallic value in the B channel and the
  63073. * roughness value in the G channel to keep better precision.
  63074. */
  63075. metallicRoughnessTexture: BaseTexture;
  63076. /**
  63077. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63078. *
  63079. * @param name The material name
  63080. * @param scene The scene the material will be use in.
  63081. */
  63082. constructor(name: string, scene: Scene);
  63083. /**
  63084. * Return the currrent class name of the material.
  63085. */
  63086. getClassName(): string;
  63087. /**
  63088. * Makes a duplicate of the current material.
  63089. * @param name - name to use for the new material.
  63090. */
  63091. clone(name: string): PBRMetallicRoughnessMaterial;
  63092. /**
  63093. * Serialize the material to a parsable JSON object.
  63094. */
  63095. serialize(): any;
  63096. /**
  63097. * Parses a JSON object correponding to the serialize function.
  63098. */
  63099. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63100. }
  63101. }
  63102. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63103. import { Scene } from "babylonjs/scene";
  63104. import { Color3 } from "babylonjs/Maths/math.color";
  63105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63106. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63107. /**
  63108. * The PBR material of BJS following the specular glossiness convention.
  63109. *
  63110. * This fits to the PBR convention in the GLTF definition:
  63111. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63112. */
  63113. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63114. /**
  63115. * Specifies the diffuse color of the material.
  63116. */
  63117. diffuseColor: Color3;
  63118. /**
  63119. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63120. * channel.
  63121. */
  63122. diffuseTexture: BaseTexture;
  63123. /**
  63124. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63125. */
  63126. specularColor: Color3;
  63127. /**
  63128. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63129. */
  63130. glossiness: number;
  63131. /**
  63132. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63133. */
  63134. specularGlossinessTexture: BaseTexture;
  63135. /**
  63136. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63137. *
  63138. * @param name The material name
  63139. * @param scene The scene the material will be use in.
  63140. */
  63141. constructor(name: string, scene: Scene);
  63142. /**
  63143. * Return the currrent class name of the material.
  63144. */
  63145. getClassName(): string;
  63146. /**
  63147. * Makes a duplicate of the current material.
  63148. * @param name - name to use for the new material.
  63149. */
  63150. clone(name: string): PBRSpecularGlossinessMaterial;
  63151. /**
  63152. * Serialize the material to a parsable JSON object.
  63153. */
  63154. serialize(): any;
  63155. /**
  63156. * Parses a JSON object correponding to the serialize function.
  63157. */
  63158. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63159. }
  63160. }
  63161. declare module "babylonjs/Materials/PBR/index" {
  63162. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63163. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63164. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63165. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63166. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63167. }
  63168. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63169. import { Nullable } from "babylonjs/types";
  63170. import { Scene } from "babylonjs/scene";
  63171. import { Matrix } from "babylonjs/Maths/math.vector";
  63172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63173. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63174. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63175. /**
  63176. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63177. * It can help converting any input color in a desired output one. This can then be used to create effects
  63178. * from sepia, black and white to sixties or futuristic rendering...
  63179. *
  63180. * The only supported format is currently 3dl.
  63181. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63182. */
  63183. export class ColorGradingTexture extends BaseTexture {
  63184. /**
  63185. * The texture URL.
  63186. */
  63187. url: string;
  63188. /**
  63189. * Empty line regex stored for GC.
  63190. */
  63191. private static _noneEmptyLineRegex;
  63192. private _textureMatrix;
  63193. private _onLoad;
  63194. /**
  63195. * Instantiates a ColorGradingTexture from the following parameters.
  63196. *
  63197. * @param url The location of the color gradind data (currently only supporting 3dl)
  63198. * @param sceneOrEngine The scene or engine the texture will be used in
  63199. * @param onLoad defines a callback triggered when the texture has been loaded
  63200. */
  63201. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63202. /**
  63203. * Fires the onload event from the constructor if requested.
  63204. */
  63205. private _triggerOnLoad;
  63206. /**
  63207. * Returns the texture matrix used in most of the material.
  63208. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63209. */
  63210. getTextureMatrix(): Matrix;
  63211. /**
  63212. * Occurs when the file being loaded is a .3dl LUT file.
  63213. */
  63214. private load3dlTexture;
  63215. /**
  63216. * Starts the loading process of the texture.
  63217. */
  63218. private loadTexture;
  63219. /**
  63220. * Clones the color gradind texture.
  63221. */
  63222. clone(): ColorGradingTexture;
  63223. /**
  63224. * Called during delayed load for textures.
  63225. */
  63226. delayLoad(): void;
  63227. /**
  63228. * Parses a color grading texture serialized by Babylon.
  63229. * @param parsedTexture The texture information being parsedTexture
  63230. * @param scene The scene to load the texture in
  63231. * @param rootUrl The root url of the data assets to load
  63232. * @return A color gradind texture
  63233. */
  63234. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63235. /**
  63236. * Serializes the LUT texture to json format.
  63237. */
  63238. serialize(): any;
  63239. }
  63240. }
  63241. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63243. import { Scene } from "babylonjs/scene";
  63244. import { Nullable } from "babylonjs/types";
  63245. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63246. /**
  63247. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63248. */
  63249. export class EquiRectangularCubeTexture extends BaseTexture {
  63250. /** The six faces of the cube. */
  63251. private static _FacesMapping;
  63252. private _noMipmap;
  63253. private _onLoad;
  63254. private _onError;
  63255. /** The size of the cubemap. */
  63256. private _size;
  63257. /** The buffer of the image. */
  63258. private _buffer;
  63259. /** The width of the input image. */
  63260. private _width;
  63261. /** The height of the input image. */
  63262. private _height;
  63263. /** The URL to the image. */
  63264. url: string;
  63265. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63266. coordinatesMode: number;
  63267. /**
  63268. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63269. * @param url The location of the image
  63270. * @param scene The scene the texture will be used in
  63271. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63272. * @param noMipmap Forces to not generate the mipmap if true
  63273. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63274. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63275. * @param onLoad — defines a callback called when texture is loaded
  63276. * @param onError — defines a callback called if there is an error
  63277. */
  63278. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63279. /**
  63280. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63281. */
  63282. private loadImage;
  63283. /**
  63284. * Convert the image buffer into a cubemap and create a CubeTexture.
  63285. */
  63286. private loadTexture;
  63287. /**
  63288. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63289. * @param buffer The ArrayBuffer that should be converted.
  63290. * @returns The buffer as Float32Array.
  63291. */
  63292. private getFloat32ArrayFromArrayBuffer;
  63293. /**
  63294. * Get the current class name of the texture useful for serialization or dynamic coding.
  63295. * @returns "EquiRectangularCubeTexture"
  63296. */
  63297. getClassName(): string;
  63298. /**
  63299. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63300. * @returns A clone of the current EquiRectangularCubeTexture.
  63301. */
  63302. clone(): EquiRectangularCubeTexture;
  63303. }
  63304. }
  63305. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63306. import { Nullable } from "babylonjs/types";
  63307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63308. import { Matrix } from "babylonjs/Maths/math.vector";
  63309. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63310. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63311. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63312. import { Scene } from "babylonjs/scene";
  63313. /**
  63314. * Defines the options related to the creation of an HtmlElementTexture
  63315. */
  63316. export interface IHtmlElementTextureOptions {
  63317. /**
  63318. * Defines wether mip maps should be created or not.
  63319. */
  63320. generateMipMaps?: boolean;
  63321. /**
  63322. * Defines the sampling mode of the texture.
  63323. */
  63324. samplingMode?: number;
  63325. /**
  63326. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63327. */
  63328. engine: Nullable<ThinEngine>;
  63329. /**
  63330. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63331. */
  63332. scene: Nullable<Scene>;
  63333. }
  63334. /**
  63335. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63336. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63337. * is automatically managed.
  63338. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63339. * in your application.
  63340. *
  63341. * As the update is not automatic, you need to call them manually.
  63342. */
  63343. export class HtmlElementTexture extends BaseTexture {
  63344. /**
  63345. * The texture URL.
  63346. */
  63347. element: HTMLVideoElement | HTMLCanvasElement;
  63348. private static readonly DefaultOptions;
  63349. private _textureMatrix;
  63350. private _isVideo;
  63351. private _generateMipMaps;
  63352. private _samplingMode;
  63353. /**
  63354. * Instantiates a HtmlElementTexture from the following parameters.
  63355. *
  63356. * @param name Defines the name of the texture
  63357. * @param element Defines the video or canvas the texture is filled with
  63358. * @param options Defines the other none mandatory texture creation options
  63359. */
  63360. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63361. private _createInternalTexture;
  63362. /**
  63363. * Returns the texture matrix used in most of the material.
  63364. */
  63365. getTextureMatrix(): Matrix;
  63366. /**
  63367. * Updates the content of the texture.
  63368. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63369. */
  63370. update(invertY?: Nullable<boolean>): void;
  63371. }
  63372. }
  63373. declare module "babylonjs/Misc/tga" {
  63374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63375. /**
  63376. * Based on jsTGALoader - Javascript loader for TGA file
  63377. * By Vincent Thibault
  63378. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63379. */
  63380. export class TGATools {
  63381. private static _TYPE_INDEXED;
  63382. private static _TYPE_RGB;
  63383. private static _TYPE_GREY;
  63384. private static _TYPE_RLE_INDEXED;
  63385. private static _TYPE_RLE_RGB;
  63386. private static _TYPE_RLE_GREY;
  63387. private static _ORIGIN_MASK;
  63388. private static _ORIGIN_SHIFT;
  63389. private static _ORIGIN_BL;
  63390. private static _ORIGIN_BR;
  63391. private static _ORIGIN_UL;
  63392. private static _ORIGIN_UR;
  63393. /**
  63394. * Gets the header of a TGA file
  63395. * @param data defines the TGA data
  63396. * @returns the header
  63397. */
  63398. static GetTGAHeader(data: Uint8Array): any;
  63399. /**
  63400. * Uploads TGA content to a Babylon Texture
  63401. * @hidden
  63402. */
  63403. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63404. /** @hidden */
  63405. 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;
  63406. /** @hidden */
  63407. 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;
  63408. /** @hidden */
  63409. 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;
  63410. /** @hidden */
  63411. 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;
  63412. /** @hidden */
  63413. 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;
  63414. /** @hidden */
  63415. 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;
  63416. }
  63417. }
  63418. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63419. import { Nullable } from "babylonjs/types";
  63420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63421. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63422. /**
  63423. * Implementation of the TGA Texture Loader.
  63424. * @hidden
  63425. */
  63426. export class _TGATextureLoader implements IInternalTextureLoader {
  63427. /**
  63428. * Defines wether the loader supports cascade loading the different faces.
  63429. */
  63430. readonly supportCascades: boolean;
  63431. /**
  63432. * This returns if the loader support the current file information.
  63433. * @param extension defines the file extension of the file being loaded
  63434. * @returns true if the loader can load the specified file
  63435. */
  63436. canLoad(extension: string): boolean;
  63437. /**
  63438. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63439. * @param data contains the texture data
  63440. * @param texture defines the BabylonJS internal texture
  63441. * @param createPolynomials will be true if polynomials have been requested
  63442. * @param onLoad defines the callback to trigger once the texture is ready
  63443. * @param onError defines the callback to trigger in case of error
  63444. */
  63445. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63446. /**
  63447. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63448. * @param data contains the texture data
  63449. * @param texture defines the BabylonJS internal texture
  63450. * @param callback defines the method to call once ready to upload
  63451. */
  63452. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63453. }
  63454. }
  63455. declare module "babylonjs/Misc/basis" {
  63456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63457. /**
  63458. * Info about the .basis files
  63459. */
  63460. class BasisFileInfo {
  63461. /**
  63462. * If the file has alpha
  63463. */
  63464. hasAlpha: boolean;
  63465. /**
  63466. * Info about each image of the basis file
  63467. */
  63468. images: Array<{
  63469. levels: Array<{
  63470. width: number;
  63471. height: number;
  63472. transcodedPixels: ArrayBufferView;
  63473. }>;
  63474. }>;
  63475. }
  63476. /**
  63477. * Result of transcoding a basis file
  63478. */
  63479. class TranscodeResult {
  63480. /**
  63481. * Info about the .basis file
  63482. */
  63483. fileInfo: BasisFileInfo;
  63484. /**
  63485. * Format to use when loading the file
  63486. */
  63487. format: number;
  63488. }
  63489. /**
  63490. * Configuration options for the Basis transcoder
  63491. */
  63492. export class BasisTranscodeConfiguration {
  63493. /**
  63494. * Supported compression formats used to determine the supported output format of the transcoder
  63495. */
  63496. supportedCompressionFormats?: {
  63497. /**
  63498. * etc1 compression format
  63499. */
  63500. etc1?: boolean;
  63501. /**
  63502. * s3tc compression format
  63503. */
  63504. s3tc?: boolean;
  63505. /**
  63506. * pvrtc compression format
  63507. */
  63508. pvrtc?: boolean;
  63509. /**
  63510. * etc2 compression format
  63511. */
  63512. etc2?: boolean;
  63513. };
  63514. /**
  63515. * If mipmap levels should be loaded for transcoded images (Default: true)
  63516. */
  63517. loadMipmapLevels?: boolean;
  63518. /**
  63519. * Index of a single image to load (Default: all images)
  63520. */
  63521. loadSingleImage?: number;
  63522. }
  63523. /**
  63524. * Used to load .Basis files
  63525. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63526. */
  63527. export class BasisTools {
  63528. private static _IgnoreSupportedFormats;
  63529. /**
  63530. * URL to use when loading the basis transcoder
  63531. */
  63532. static JSModuleURL: string;
  63533. /**
  63534. * URL to use when loading the wasm module for the transcoder
  63535. */
  63536. static WasmModuleURL: string;
  63537. /**
  63538. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63539. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63540. * @returns internal format corresponding to the Basis format
  63541. */
  63542. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63543. private static _WorkerPromise;
  63544. private static _Worker;
  63545. private static _actionId;
  63546. private static _CreateWorkerAsync;
  63547. /**
  63548. * Transcodes a loaded image file to compressed pixel data
  63549. * @param data image data to transcode
  63550. * @param config configuration options for the transcoding
  63551. * @returns a promise resulting in the transcoded image
  63552. */
  63553. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63554. /**
  63555. * Loads a texture from the transcode result
  63556. * @param texture texture load to
  63557. * @param transcodeResult the result of transcoding the basis file to load from
  63558. */
  63559. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63560. }
  63561. }
  63562. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63563. import { Nullable } from "babylonjs/types";
  63564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63565. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63566. /**
  63567. * Loader for .basis file format
  63568. */
  63569. export class _BasisTextureLoader implements IInternalTextureLoader {
  63570. /**
  63571. * Defines whether the loader supports cascade loading the different faces.
  63572. */
  63573. readonly supportCascades: boolean;
  63574. /**
  63575. * This returns if the loader support the current file information.
  63576. * @param extension defines the file extension of the file being loaded
  63577. * @returns true if the loader can load the specified file
  63578. */
  63579. canLoad(extension: string): boolean;
  63580. /**
  63581. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63582. * @param data contains the texture data
  63583. * @param texture defines the BabylonJS internal texture
  63584. * @param createPolynomials will be true if polynomials have been requested
  63585. * @param onLoad defines the callback to trigger once the texture is ready
  63586. * @param onError defines the callback to trigger in case of error
  63587. */
  63588. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63589. /**
  63590. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63591. * @param data contains the texture data
  63592. * @param texture defines the BabylonJS internal texture
  63593. * @param callback defines the method to call once ready to upload
  63594. */
  63595. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63596. }
  63597. }
  63598. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63599. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63600. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63601. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63602. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63603. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63604. }
  63605. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63606. import { Vector2 } from "babylonjs/Maths/math.vector";
  63607. /**
  63608. * Defines the basic options interface of a TexturePacker Frame
  63609. */
  63610. export interface ITexturePackerFrame {
  63611. /**
  63612. * The frame ID
  63613. */
  63614. id: number;
  63615. /**
  63616. * The frames Scale
  63617. */
  63618. scale: Vector2;
  63619. /**
  63620. * The Frames offset
  63621. */
  63622. offset: Vector2;
  63623. }
  63624. /**
  63625. * This is a support class for frame Data on texture packer sets.
  63626. */
  63627. export class TexturePackerFrame implements ITexturePackerFrame {
  63628. /**
  63629. * The frame ID
  63630. */
  63631. id: number;
  63632. /**
  63633. * The frames Scale
  63634. */
  63635. scale: Vector2;
  63636. /**
  63637. * The Frames offset
  63638. */
  63639. offset: Vector2;
  63640. /**
  63641. * Initializes a texture package frame.
  63642. * @param id The numerical frame identifier
  63643. * @param scale Scalar Vector2 for UV frame
  63644. * @param offset Vector2 for the frame position in UV units.
  63645. * @returns TexturePackerFrame
  63646. */
  63647. constructor(id: number, scale: Vector2, offset: Vector2);
  63648. }
  63649. }
  63650. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63652. import { Scene } from "babylonjs/scene";
  63653. import { Nullable } from "babylonjs/types";
  63654. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63655. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63656. /**
  63657. * Defines the basic options interface of a TexturePacker
  63658. */
  63659. export interface ITexturePackerOptions {
  63660. /**
  63661. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63662. */
  63663. map?: string[];
  63664. /**
  63665. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63666. */
  63667. uvsIn?: string;
  63668. /**
  63669. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63670. */
  63671. uvsOut?: string;
  63672. /**
  63673. * number representing the layout style. Defaults to LAYOUT_STRIP
  63674. */
  63675. layout?: number;
  63676. /**
  63677. * number of columns if using custom column count layout(2). This defaults to 4.
  63678. */
  63679. colnum?: number;
  63680. /**
  63681. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63682. */
  63683. updateInputMeshes?: boolean;
  63684. /**
  63685. * boolean flag to dispose all the source textures. Defaults to true.
  63686. */
  63687. disposeSources?: boolean;
  63688. /**
  63689. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63690. */
  63691. fillBlanks?: boolean;
  63692. /**
  63693. * string value representing the context fill style color. Defaults to 'black'.
  63694. */
  63695. customFillColor?: string;
  63696. /**
  63697. * Width and Height Value of each Frame in the TexturePacker Sets
  63698. */
  63699. frameSize?: number;
  63700. /**
  63701. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63702. */
  63703. paddingRatio?: number;
  63704. /**
  63705. * Number that declares the fill method for the padding gutter.
  63706. */
  63707. paddingMode?: number;
  63708. /**
  63709. * If in SUBUV_COLOR padding mode what color to use.
  63710. */
  63711. paddingColor?: Color3 | Color4;
  63712. }
  63713. /**
  63714. * Defines the basic interface of a TexturePacker JSON File
  63715. */
  63716. export interface ITexturePackerJSON {
  63717. /**
  63718. * The frame ID
  63719. */
  63720. name: string;
  63721. /**
  63722. * The base64 channel data
  63723. */
  63724. sets: any;
  63725. /**
  63726. * The options of the Packer
  63727. */
  63728. options: ITexturePackerOptions;
  63729. /**
  63730. * The frame data of the Packer
  63731. */
  63732. frames: Array<number>;
  63733. }
  63734. /**
  63735. * This is a support class that generates a series of packed texture sets.
  63736. * @see https://doc.babylonjs.com/babylon101/materials
  63737. */
  63738. export class TexturePacker {
  63739. /** Packer Layout Constant 0 */
  63740. static readonly LAYOUT_STRIP: number;
  63741. /** Packer Layout Constant 1 */
  63742. static readonly LAYOUT_POWER2: number;
  63743. /** Packer Layout Constant 2 */
  63744. static readonly LAYOUT_COLNUM: number;
  63745. /** Packer Layout Constant 0 */
  63746. static readonly SUBUV_WRAP: number;
  63747. /** Packer Layout Constant 1 */
  63748. static readonly SUBUV_EXTEND: number;
  63749. /** Packer Layout Constant 2 */
  63750. static readonly SUBUV_COLOR: number;
  63751. /** The Name of the Texture Package */
  63752. name: string;
  63753. /** The scene scope of the TexturePacker */
  63754. scene: Scene;
  63755. /** The Meshes to target */
  63756. meshes: AbstractMesh[];
  63757. /** Arguments passed with the Constructor */
  63758. options: ITexturePackerOptions;
  63759. /** The promise that is started upon initialization */
  63760. promise: Nullable<Promise<TexturePacker | string>>;
  63761. /** The Container object for the channel sets that are generated */
  63762. sets: object;
  63763. /** The Container array for the frames that are generated */
  63764. frames: TexturePackerFrame[];
  63765. /** The expected number of textures the system is parsing. */
  63766. private _expecting;
  63767. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63768. private _paddingValue;
  63769. /**
  63770. * Initializes a texture package series from an array of meshes or a single mesh.
  63771. * @param name The name of the package
  63772. * @param meshes The target meshes to compose the package from
  63773. * @param options The arguments that texture packer should follow while building.
  63774. * @param scene The scene which the textures are scoped to.
  63775. * @returns TexturePacker
  63776. */
  63777. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63778. /**
  63779. * Starts the package process
  63780. * @param resolve The promises resolution function
  63781. * @returns TexturePacker
  63782. */
  63783. private _createFrames;
  63784. /**
  63785. * Calculates the Size of the Channel Sets
  63786. * @returns Vector2
  63787. */
  63788. private _calculateSize;
  63789. /**
  63790. * Calculates the UV data for the frames.
  63791. * @param baseSize the base frameSize
  63792. * @param padding the base frame padding
  63793. * @param dtSize size of the Dynamic Texture for that channel
  63794. * @param dtUnits is 1/dtSize
  63795. * @param update flag to update the input meshes
  63796. */
  63797. private _calculateMeshUVFrames;
  63798. /**
  63799. * Calculates the frames Offset.
  63800. * @param index of the frame
  63801. * @returns Vector2
  63802. */
  63803. private _getFrameOffset;
  63804. /**
  63805. * Updates a Mesh to the frame data
  63806. * @param mesh that is the target
  63807. * @param frameID or the frame index
  63808. */
  63809. private _updateMeshUV;
  63810. /**
  63811. * Updates a Meshes materials to use the texture packer channels
  63812. * @param m is the mesh to target
  63813. * @param force all channels on the packer to be set.
  63814. */
  63815. private _updateTextureReferences;
  63816. /**
  63817. * Public method to set a Mesh to a frame
  63818. * @param m that is the target
  63819. * @param frameID or the frame index
  63820. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63821. */
  63822. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63823. /**
  63824. * Starts the async promise to compile the texture packer.
  63825. * @returns Promise<void>
  63826. */
  63827. processAsync(): Promise<void>;
  63828. /**
  63829. * Disposes all textures associated with this packer
  63830. */
  63831. dispose(): void;
  63832. /**
  63833. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63834. * @param imageType is the image type to use.
  63835. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63836. */
  63837. download(imageType?: string, quality?: number): void;
  63838. /**
  63839. * Public method to load a texturePacker JSON file.
  63840. * @param data of the JSON file in string format.
  63841. */
  63842. updateFromJSON(data: string): void;
  63843. }
  63844. }
  63845. declare module "babylonjs/Materials/Textures/Packer/index" {
  63846. export * from "babylonjs/Materials/Textures/Packer/packer";
  63847. export * from "babylonjs/Materials/Textures/Packer/frame";
  63848. }
  63849. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63850. import { Scene } from "babylonjs/scene";
  63851. import { Texture } from "babylonjs/Materials/Textures/texture";
  63852. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63853. /**
  63854. * 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.
  63855. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63856. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63857. */
  63858. export class CustomProceduralTexture extends ProceduralTexture {
  63859. private _animate;
  63860. private _time;
  63861. private _config;
  63862. private _texturePath;
  63863. /**
  63864. * Instantiates a new Custom Procedural Texture.
  63865. * 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.
  63866. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63867. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63868. * @param name Define the name of the texture
  63869. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63870. * @param size Define the size of the texture to create
  63871. * @param scene Define the scene the texture belongs to
  63872. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63873. * @param generateMipMaps Define if the texture should creates mip maps or not
  63874. */
  63875. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63876. private _loadJson;
  63877. /**
  63878. * Is the texture ready to be used ? (rendered at least once)
  63879. * @returns true if ready, otherwise, false.
  63880. */
  63881. isReady(): boolean;
  63882. /**
  63883. * Render the texture to its associated render target.
  63884. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63885. */
  63886. render(useCameraPostProcess?: boolean): void;
  63887. /**
  63888. * Update the list of dependant textures samplers in the shader.
  63889. */
  63890. updateTextures(): void;
  63891. /**
  63892. * Update the uniform values of the procedural texture in the shader.
  63893. */
  63894. updateShaderUniforms(): void;
  63895. /**
  63896. * Define if the texture animates or not.
  63897. */
  63898. get animate(): boolean;
  63899. set animate(value: boolean);
  63900. }
  63901. }
  63902. declare module "babylonjs/Shaders/noise.fragment" {
  63903. /** @hidden */
  63904. export var noisePixelShader: {
  63905. name: string;
  63906. shader: string;
  63907. };
  63908. }
  63909. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63910. import { Nullable } from "babylonjs/types";
  63911. import { Scene } from "babylonjs/scene";
  63912. import { Texture } from "babylonjs/Materials/Textures/texture";
  63913. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63914. import "babylonjs/Shaders/noise.fragment";
  63915. /**
  63916. * Class used to generate noise procedural textures
  63917. */
  63918. export class NoiseProceduralTexture extends ProceduralTexture {
  63919. private _time;
  63920. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63921. brightness: number;
  63922. /** Defines the number of octaves to process */
  63923. octaves: number;
  63924. /** Defines the level of persistence (0.8 by default) */
  63925. persistence: number;
  63926. /** Gets or sets animation speed factor (default is 1) */
  63927. animationSpeedFactor: number;
  63928. /**
  63929. * Creates a new NoiseProceduralTexture
  63930. * @param name defines the name fo the texture
  63931. * @param size defines the size of the texture (default is 256)
  63932. * @param scene defines the hosting scene
  63933. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63934. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63935. */
  63936. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63937. private _updateShaderUniforms;
  63938. protected _getDefines(): string;
  63939. /** Generate the current state of the procedural texture */
  63940. render(useCameraPostProcess?: boolean): void;
  63941. /**
  63942. * Serializes this noise procedural texture
  63943. * @returns a serialized noise procedural texture object
  63944. */
  63945. serialize(): any;
  63946. /**
  63947. * Clone the texture.
  63948. * @returns the cloned texture
  63949. */
  63950. clone(): NoiseProceduralTexture;
  63951. /**
  63952. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63953. * @param parsedTexture defines parsed texture data
  63954. * @param scene defines the current scene
  63955. * @param rootUrl defines the root URL containing noise procedural texture information
  63956. * @returns a parsed NoiseProceduralTexture
  63957. */
  63958. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63959. }
  63960. }
  63961. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63962. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63963. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63964. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63965. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63966. }
  63967. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63968. import { Nullable } from "babylonjs/types";
  63969. import { Scene } from "babylonjs/scene";
  63970. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63972. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63973. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63974. /**
  63975. * Raw cube texture where the raw buffers are passed in
  63976. */
  63977. export class RawCubeTexture extends CubeTexture {
  63978. /**
  63979. * Creates a cube texture where the raw buffers are passed in.
  63980. * @param scene defines the scene the texture is attached to
  63981. * @param data defines the array of data to use to create each face
  63982. * @param size defines the size of the textures
  63983. * @param format defines the format of the data
  63984. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63985. * @param generateMipMaps defines if the engine should generate the mip levels
  63986. * @param invertY defines if data must be stored with Y axis inverted
  63987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63988. * @param compression defines the compression used (null by default)
  63989. */
  63990. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63991. /**
  63992. * Updates the raw cube texture.
  63993. * @param data defines the data to store
  63994. * @param format defines the data format
  63995. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63996. * @param invertY defines if data must be stored with Y axis inverted
  63997. * @param compression defines the compression used (null by default)
  63998. * @param level defines which level of the texture to update
  63999. */
  64000. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64001. /**
  64002. * Updates a raw cube texture with RGBD encoded data.
  64003. * @param data defines the array of data [mipmap][face] to use to create each face
  64004. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64005. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64006. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64007. * @returns a promsie that resolves when the operation is complete
  64008. */
  64009. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64010. /**
  64011. * Clones the raw cube texture.
  64012. * @return a new cube texture
  64013. */
  64014. clone(): CubeTexture;
  64015. /** @hidden */
  64016. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64017. }
  64018. }
  64019. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64020. import { Scene } from "babylonjs/scene";
  64021. import { Texture } from "babylonjs/Materials/Textures/texture";
  64022. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64023. /**
  64024. * Class used to store 2D array textures containing user data
  64025. */
  64026. export class RawTexture2DArray extends Texture {
  64027. /** Gets or sets the texture format to use */
  64028. format: number;
  64029. /**
  64030. * Create a new RawTexture2DArray
  64031. * @param data defines the data of the texture
  64032. * @param width defines the width of the texture
  64033. * @param height defines the height of the texture
  64034. * @param depth defines the number of layers of the texture
  64035. * @param format defines the texture format to use
  64036. * @param scene defines the hosting scene
  64037. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64038. * @param invertY defines if texture must be stored with Y axis inverted
  64039. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64040. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64041. */
  64042. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64043. /** Gets or sets the texture format to use */
  64044. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64045. /**
  64046. * Update the texture with new data
  64047. * @param data defines the data to store in the texture
  64048. */
  64049. update(data: ArrayBufferView): void;
  64050. }
  64051. }
  64052. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64053. import { Scene } from "babylonjs/scene";
  64054. import { Texture } from "babylonjs/Materials/Textures/texture";
  64055. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64056. /**
  64057. * Class used to store 3D textures containing user data
  64058. */
  64059. export class RawTexture3D extends Texture {
  64060. /** Gets or sets the texture format to use */
  64061. format: number;
  64062. /**
  64063. * Create a new RawTexture3D
  64064. * @param data defines the data of the texture
  64065. * @param width defines the width of the texture
  64066. * @param height defines the height of the texture
  64067. * @param depth defines the depth of the texture
  64068. * @param format defines the texture format to use
  64069. * @param scene defines the hosting scene
  64070. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64071. * @param invertY defines if texture must be stored with Y axis inverted
  64072. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64073. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64074. */
  64075. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64076. /** Gets or sets the texture format to use */
  64077. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64078. /**
  64079. * Update the texture with new data
  64080. * @param data defines the data to store in the texture
  64081. */
  64082. update(data: ArrayBufferView): void;
  64083. }
  64084. }
  64085. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64086. import { Scene } from "babylonjs/scene";
  64087. import { Plane } from "babylonjs/Maths/math.plane";
  64088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64089. /**
  64090. * Creates a refraction texture used by refraction channel of the standard material.
  64091. * It is like a mirror but to see through a material.
  64092. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64093. */
  64094. export class RefractionTexture extends RenderTargetTexture {
  64095. /**
  64096. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64097. * 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.
  64098. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64099. */
  64100. refractionPlane: Plane;
  64101. /**
  64102. * Define how deep under the surface we should see.
  64103. */
  64104. depth: number;
  64105. /**
  64106. * Creates a refraction texture used by refraction channel of the standard material.
  64107. * It is like a mirror but to see through a material.
  64108. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64109. * @param name Define the texture name
  64110. * @param size Define the size of the underlying texture
  64111. * @param scene Define the scene the refraction belongs to
  64112. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64113. */
  64114. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64115. /**
  64116. * Clone the refraction texture.
  64117. * @returns the cloned texture
  64118. */
  64119. clone(): RefractionTexture;
  64120. /**
  64121. * Serialize the texture to a JSON representation you could use in Parse later on
  64122. * @returns the serialized JSON representation
  64123. */
  64124. serialize(): any;
  64125. }
  64126. }
  64127. declare module "babylonjs/Materials/Textures/index" {
  64128. export * from "babylonjs/Materials/Textures/baseTexture";
  64129. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64130. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64131. export * from "babylonjs/Materials/Textures/cubeTexture";
  64132. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64133. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64134. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64135. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64136. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64137. export * from "babylonjs/Materials/Textures/internalTexture";
  64138. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64139. export * from "babylonjs/Materials/Textures/Loaders/index";
  64140. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64141. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64142. export * from "babylonjs/Materials/Textures/Packer/index";
  64143. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64144. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64145. export * from "babylonjs/Materials/Textures/rawTexture";
  64146. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64147. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64148. export * from "babylonjs/Materials/Textures/refractionTexture";
  64149. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64150. export * from "babylonjs/Materials/Textures/texture";
  64151. export * from "babylonjs/Materials/Textures/videoTexture";
  64152. }
  64153. declare module "babylonjs/Materials/Node/Enums/index" {
  64154. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64155. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64156. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64157. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64158. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64159. }
  64160. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64164. import { Mesh } from "babylonjs/Meshes/mesh";
  64165. import { Effect } from "babylonjs/Materials/effect";
  64166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64167. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64168. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64169. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64170. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64171. /**
  64172. * Block used to add support for vertex skinning (bones)
  64173. */
  64174. export class BonesBlock extends NodeMaterialBlock {
  64175. /**
  64176. * Creates a new BonesBlock
  64177. * @param name defines the block name
  64178. */
  64179. constructor(name: string);
  64180. /**
  64181. * Initialize the block and prepare the context for build
  64182. * @param state defines the state that will be used for the build
  64183. */
  64184. initialize(state: NodeMaterialBuildState): void;
  64185. /**
  64186. * Gets the current class name
  64187. * @returns the class name
  64188. */
  64189. getClassName(): string;
  64190. /**
  64191. * Gets the matrix indices input component
  64192. */
  64193. get matricesIndices(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the matrix weights input component
  64196. */
  64197. get matricesWeights(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the extra matrix indices input component
  64200. */
  64201. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the extra matrix weights input component
  64204. */
  64205. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the world input component
  64208. */
  64209. get world(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the output component
  64212. */
  64213. get output(): NodeMaterialConnectionPoint;
  64214. autoConfigure(material: NodeMaterial): void;
  64215. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64218. protected _buildBlock(state: NodeMaterialBuildState): this;
  64219. }
  64220. }
  64221. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64226. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64228. /**
  64229. * Block used to add support for instances
  64230. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64231. */
  64232. export class InstancesBlock extends NodeMaterialBlock {
  64233. /**
  64234. * Creates a new InstancesBlock
  64235. * @param name defines the block name
  64236. */
  64237. constructor(name: string);
  64238. /**
  64239. * Gets the current class name
  64240. * @returns the class name
  64241. */
  64242. getClassName(): string;
  64243. /**
  64244. * Gets the first world row input component
  64245. */
  64246. get world0(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the second world row input component
  64249. */
  64250. get world1(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the third world row input component
  64253. */
  64254. get world2(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the forth world row input component
  64257. */
  64258. get world3(): NodeMaterialConnectionPoint;
  64259. /**
  64260. * Gets the world input component
  64261. */
  64262. get world(): NodeMaterialConnectionPoint;
  64263. /**
  64264. * Gets the output component
  64265. */
  64266. get output(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the isntanceID component
  64269. */
  64270. get instanceID(): NodeMaterialConnectionPoint;
  64271. autoConfigure(material: NodeMaterial): void;
  64272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64273. protected _buildBlock(state: NodeMaterialBuildState): this;
  64274. }
  64275. }
  64276. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64281. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64282. import { Effect } from "babylonjs/Materials/effect";
  64283. import { Mesh } from "babylonjs/Meshes/mesh";
  64284. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64286. /**
  64287. * Block used to add morph targets support to vertex shader
  64288. */
  64289. export class MorphTargetsBlock extends NodeMaterialBlock {
  64290. private _repeatableContentAnchor;
  64291. /**
  64292. * Create a new MorphTargetsBlock
  64293. * @param name defines the block name
  64294. */
  64295. constructor(name: string);
  64296. /**
  64297. * Gets the current class name
  64298. * @returns the class name
  64299. */
  64300. getClassName(): string;
  64301. /**
  64302. * Gets the position input component
  64303. */
  64304. get position(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the normal input component
  64307. */
  64308. get normal(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the tangent input component
  64311. */
  64312. get tangent(): NodeMaterialConnectionPoint;
  64313. /**
  64314. * Gets the tangent input component
  64315. */
  64316. get uv(): NodeMaterialConnectionPoint;
  64317. /**
  64318. * Gets the position output component
  64319. */
  64320. get positionOutput(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the normal output component
  64323. */
  64324. get normalOutput(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the tangent output component
  64327. */
  64328. get tangentOutput(): NodeMaterialConnectionPoint;
  64329. /**
  64330. * Gets the tangent output component
  64331. */
  64332. get uvOutput(): NodeMaterialConnectionPoint;
  64333. initialize(state: NodeMaterialBuildState): void;
  64334. autoConfigure(material: NodeMaterial): void;
  64335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64336. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64337. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64338. protected _buildBlock(state: NodeMaterialBuildState): this;
  64339. }
  64340. }
  64341. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64345. import { Nullable } from "babylonjs/types";
  64346. import { Scene } from "babylonjs/scene";
  64347. import { Effect } from "babylonjs/Materials/effect";
  64348. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64349. import { Mesh } from "babylonjs/Meshes/mesh";
  64350. import { Light } from "babylonjs/Lights/light";
  64351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64352. /**
  64353. * Block used to get data information from a light
  64354. */
  64355. export class LightInformationBlock extends NodeMaterialBlock {
  64356. private _lightDataUniformName;
  64357. private _lightColorUniformName;
  64358. private _lightTypeDefineName;
  64359. /**
  64360. * Gets or sets the light associated with this block
  64361. */
  64362. light: Nullable<Light>;
  64363. /**
  64364. * Creates a new LightInformationBlock
  64365. * @param name defines the block name
  64366. */
  64367. constructor(name: string);
  64368. /**
  64369. * Gets the current class name
  64370. * @returns the class name
  64371. */
  64372. getClassName(): string;
  64373. /**
  64374. * Gets the world position input component
  64375. */
  64376. get worldPosition(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the direction output component
  64379. */
  64380. get direction(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the direction output component
  64383. */
  64384. get color(): NodeMaterialConnectionPoint;
  64385. /**
  64386. * Gets the direction output component
  64387. */
  64388. get intensity(): NodeMaterialConnectionPoint;
  64389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64391. protected _buildBlock(state: NodeMaterialBuildState): this;
  64392. serialize(): any;
  64393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64394. }
  64395. }
  64396. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64397. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64398. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64399. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64400. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64401. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64402. }
  64403. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64408. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64409. import { Effect } from "babylonjs/Materials/effect";
  64410. import { Mesh } from "babylonjs/Meshes/mesh";
  64411. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64412. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64413. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64414. /**
  64415. * Block used to add image processing support to fragment shader
  64416. */
  64417. export class ImageProcessingBlock extends NodeMaterialBlock {
  64418. /**
  64419. * Create a new ImageProcessingBlock
  64420. * @param name defines the block name
  64421. */
  64422. constructor(name: string);
  64423. /**
  64424. * Gets the current class name
  64425. * @returns the class name
  64426. */
  64427. getClassName(): string;
  64428. /**
  64429. * Gets the color input component
  64430. */
  64431. get color(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the output component
  64434. */
  64435. get output(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Initialize the block and prepare the context for build
  64438. * @param state defines the state that will be used for the build
  64439. */
  64440. initialize(state: NodeMaterialBuildState): void;
  64441. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64444. protected _buildBlock(state: NodeMaterialBuildState): this;
  64445. }
  64446. }
  64447. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64451. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64453. import { Effect } from "babylonjs/Materials/effect";
  64454. import { Mesh } from "babylonjs/Meshes/mesh";
  64455. import { Scene } from "babylonjs/scene";
  64456. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64457. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64458. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64459. /**
  64460. * Block used to pertub normals based on a normal map
  64461. */
  64462. export class PerturbNormalBlock extends NodeMaterialBlock {
  64463. private _tangentSpaceParameterName;
  64464. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64465. invertX: boolean;
  64466. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64467. invertY: boolean;
  64468. /**
  64469. * Create a new PerturbNormalBlock
  64470. * @param name defines the block name
  64471. */
  64472. constructor(name: string);
  64473. /**
  64474. * Gets the current class name
  64475. * @returns the class name
  64476. */
  64477. getClassName(): string;
  64478. /**
  64479. * Gets the world position input component
  64480. */
  64481. get worldPosition(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the world normal input component
  64484. */
  64485. get worldNormal(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the world tangent input component
  64488. */
  64489. get worldTangent(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the uv input component
  64492. */
  64493. get uv(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the normal map color input component
  64496. */
  64497. get normalMapColor(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the strength input component
  64500. */
  64501. get strength(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the output component
  64504. */
  64505. get output(): NodeMaterialConnectionPoint;
  64506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64508. autoConfigure(material: NodeMaterial): void;
  64509. protected _buildBlock(state: NodeMaterialBuildState): this;
  64510. protected _dumpPropertiesCode(): string;
  64511. serialize(): any;
  64512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64513. }
  64514. }
  64515. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64519. /**
  64520. * Block used to discard a pixel if a value is smaller than a cutoff
  64521. */
  64522. export class DiscardBlock extends NodeMaterialBlock {
  64523. /**
  64524. * Create a new DiscardBlock
  64525. * @param name defines the block name
  64526. */
  64527. constructor(name: string);
  64528. /**
  64529. * Gets the current class name
  64530. * @returns the class name
  64531. */
  64532. getClassName(): string;
  64533. /**
  64534. * Gets the color input component
  64535. */
  64536. get value(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the cutoff input component
  64539. */
  64540. get cutoff(): NodeMaterialConnectionPoint;
  64541. protected _buildBlock(state: NodeMaterialBuildState): this;
  64542. }
  64543. }
  64544. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64548. /**
  64549. * Block used to test if the fragment shader is front facing
  64550. */
  64551. export class FrontFacingBlock extends NodeMaterialBlock {
  64552. /**
  64553. * Creates a new FrontFacingBlock
  64554. * @param name defines the block name
  64555. */
  64556. constructor(name: string);
  64557. /**
  64558. * Gets the current class name
  64559. * @returns the class name
  64560. */
  64561. getClassName(): string;
  64562. /**
  64563. * Gets the output component
  64564. */
  64565. get output(): NodeMaterialConnectionPoint;
  64566. protected _buildBlock(state: NodeMaterialBuildState): this;
  64567. }
  64568. }
  64569. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64573. /**
  64574. * Block used to get the derivative value on x and y of a given input
  64575. */
  64576. export class DerivativeBlock extends NodeMaterialBlock {
  64577. /**
  64578. * Create a new DerivativeBlock
  64579. * @param name defines the block name
  64580. */
  64581. constructor(name: string);
  64582. /**
  64583. * Gets the current class name
  64584. * @returns the class name
  64585. */
  64586. getClassName(): string;
  64587. /**
  64588. * Gets the input component
  64589. */
  64590. get input(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the derivative output on x
  64593. */
  64594. get dx(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the derivative output on y
  64597. */
  64598. get dy(): NodeMaterialConnectionPoint;
  64599. protected _buildBlock(state: NodeMaterialBuildState): this;
  64600. }
  64601. }
  64602. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64606. /**
  64607. * Block used to make gl_FragCoord available
  64608. */
  64609. export class FragCoordBlock extends NodeMaterialBlock {
  64610. /**
  64611. * Creates a new FragCoordBlock
  64612. * @param name defines the block name
  64613. */
  64614. constructor(name: string);
  64615. /**
  64616. * Gets the current class name
  64617. * @returns the class name
  64618. */
  64619. getClassName(): string;
  64620. /**
  64621. * Gets the xy component
  64622. */
  64623. get xy(): NodeMaterialConnectionPoint;
  64624. /**
  64625. * Gets the xyz component
  64626. */
  64627. get xyz(): NodeMaterialConnectionPoint;
  64628. /**
  64629. * Gets the xyzw component
  64630. */
  64631. get xyzw(): NodeMaterialConnectionPoint;
  64632. /**
  64633. * Gets the x component
  64634. */
  64635. get x(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the y component
  64638. */
  64639. get y(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the z component
  64642. */
  64643. get z(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the w component
  64646. */
  64647. get output(): NodeMaterialConnectionPoint;
  64648. protected writeOutputs(state: NodeMaterialBuildState): string;
  64649. protected _buildBlock(state: NodeMaterialBuildState): this;
  64650. }
  64651. }
  64652. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64656. import { Effect } from "babylonjs/Materials/effect";
  64657. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64658. import { Mesh } from "babylonjs/Meshes/mesh";
  64659. /**
  64660. * Block used to get the screen sizes
  64661. */
  64662. export class ScreenSizeBlock extends NodeMaterialBlock {
  64663. private _varName;
  64664. private _scene;
  64665. /**
  64666. * Creates a new ScreenSizeBlock
  64667. * @param name defines the block name
  64668. */
  64669. constructor(name: string);
  64670. /**
  64671. * Gets the current class name
  64672. * @returns the class name
  64673. */
  64674. getClassName(): string;
  64675. /**
  64676. * Gets the xy component
  64677. */
  64678. get xy(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the x component
  64681. */
  64682. get x(): NodeMaterialConnectionPoint;
  64683. /**
  64684. * Gets the y component
  64685. */
  64686. get y(): NodeMaterialConnectionPoint;
  64687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64688. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64689. protected _buildBlock(state: NodeMaterialBuildState): this;
  64690. }
  64691. }
  64692. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64693. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64694. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64695. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64696. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64697. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64698. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64699. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64700. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64701. }
  64702. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64705. import { Mesh } from "babylonjs/Meshes/mesh";
  64706. import { Effect } from "babylonjs/Materials/effect";
  64707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64709. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64710. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64711. /**
  64712. * Block used to add support for scene fog
  64713. */
  64714. export class FogBlock extends NodeMaterialBlock {
  64715. private _fogDistanceName;
  64716. private _fogParameters;
  64717. /**
  64718. * Create a new FogBlock
  64719. * @param name defines the block name
  64720. */
  64721. constructor(name: string);
  64722. /**
  64723. * Gets the current class name
  64724. * @returns the class name
  64725. */
  64726. getClassName(): string;
  64727. /**
  64728. * Gets the world position input component
  64729. */
  64730. get worldPosition(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the view input component
  64733. */
  64734. get view(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the color input component
  64737. */
  64738. get input(): NodeMaterialConnectionPoint;
  64739. /**
  64740. * Gets the fog color input component
  64741. */
  64742. get fogColor(): NodeMaterialConnectionPoint;
  64743. /**
  64744. * Gets the output component
  64745. */
  64746. get output(): NodeMaterialConnectionPoint;
  64747. autoConfigure(material: NodeMaterial): void;
  64748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64750. protected _buildBlock(state: NodeMaterialBuildState): this;
  64751. }
  64752. }
  64753. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64758. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64759. import { Effect } from "babylonjs/Materials/effect";
  64760. import { Mesh } from "babylonjs/Meshes/mesh";
  64761. import { Light } from "babylonjs/Lights/light";
  64762. import { Nullable } from "babylonjs/types";
  64763. import { Scene } from "babylonjs/scene";
  64764. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64765. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64766. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64768. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64769. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64770. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64771. /**
  64772. * Block used to add light in the fragment shader
  64773. */
  64774. export class LightBlock extends NodeMaterialBlock {
  64775. private _lightId;
  64776. /**
  64777. * Gets or sets the light associated with this block
  64778. */
  64779. light: Nullable<Light>;
  64780. /**
  64781. * Create a new LightBlock
  64782. * @param name defines the block name
  64783. */
  64784. constructor(name: string);
  64785. /**
  64786. * Gets the current class name
  64787. * @returns the class name
  64788. */
  64789. getClassName(): string;
  64790. /**
  64791. * Gets the world position input component
  64792. */
  64793. get worldPosition(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the world normal input component
  64796. */
  64797. get worldNormal(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the camera (or eye) position component
  64800. */
  64801. get cameraPosition(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the glossiness component
  64804. */
  64805. get glossiness(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the glossinness power component
  64808. */
  64809. get glossPower(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the diffuse color component
  64812. */
  64813. get diffuseColor(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the specular color component
  64816. */
  64817. get specularColor(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the diffuse output component
  64820. */
  64821. get diffuseOutput(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the specular output component
  64824. */
  64825. get specularOutput(): NodeMaterialConnectionPoint;
  64826. /**
  64827. * Gets the shadow output component
  64828. */
  64829. get shadow(): NodeMaterialConnectionPoint;
  64830. autoConfigure(material: NodeMaterial): void;
  64831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64832. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64834. private _injectVertexCode;
  64835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64836. serialize(): any;
  64837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64838. }
  64839. }
  64840. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64843. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64844. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64845. /**
  64846. * Block used to read a reflection texture from a sampler
  64847. */
  64848. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64849. /**
  64850. * Create a new ReflectionTextureBlock
  64851. * @param name defines the block name
  64852. */
  64853. constructor(name: string);
  64854. /**
  64855. * Gets the current class name
  64856. * @returns the class name
  64857. */
  64858. getClassName(): string;
  64859. /**
  64860. * Gets the world position input component
  64861. */
  64862. get position(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the world position input component
  64865. */
  64866. get worldPosition(): NodeMaterialConnectionPoint;
  64867. /**
  64868. * Gets the world normal input component
  64869. */
  64870. get worldNormal(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the world input component
  64873. */
  64874. get world(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the camera (or eye) position component
  64877. */
  64878. get cameraPosition(): NodeMaterialConnectionPoint;
  64879. /**
  64880. * Gets the view input component
  64881. */
  64882. get view(): NodeMaterialConnectionPoint;
  64883. /**
  64884. * Gets the rgb output component
  64885. */
  64886. get rgb(): NodeMaterialConnectionPoint;
  64887. /**
  64888. * Gets the rgba output component
  64889. */
  64890. get rgba(): NodeMaterialConnectionPoint;
  64891. /**
  64892. * Gets the r output component
  64893. */
  64894. get r(): NodeMaterialConnectionPoint;
  64895. /**
  64896. * Gets the g output component
  64897. */
  64898. get g(): NodeMaterialConnectionPoint;
  64899. /**
  64900. * Gets the b output component
  64901. */
  64902. get b(): NodeMaterialConnectionPoint;
  64903. /**
  64904. * Gets the a output component
  64905. */
  64906. get a(): NodeMaterialConnectionPoint;
  64907. autoConfigure(material: NodeMaterial): void;
  64908. protected _buildBlock(state: NodeMaterialBuildState): this;
  64909. }
  64910. }
  64911. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64912. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64913. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64914. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64915. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64916. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64917. }
  64918. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64919. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64920. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64921. }
  64922. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64926. /**
  64927. * Block used to add 2 vectors
  64928. */
  64929. export class AddBlock extends NodeMaterialBlock {
  64930. /**
  64931. * Creates a new AddBlock
  64932. * @param name defines the block name
  64933. */
  64934. constructor(name: string);
  64935. /**
  64936. * Gets the current class name
  64937. * @returns the class name
  64938. */
  64939. getClassName(): string;
  64940. /**
  64941. * Gets the left operand input component
  64942. */
  64943. get left(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the right operand input component
  64946. */
  64947. get right(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the output component
  64950. */
  64951. get output(): NodeMaterialConnectionPoint;
  64952. protected _buildBlock(state: NodeMaterialBuildState): this;
  64953. }
  64954. }
  64955. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64959. /**
  64960. * Block used to scale a vector by a float
  64961. */
  64962. export class ScaleBlock extends NodeMaterialBlock {
  64963. /**
  64964. * Creates a new ScaleBlock
  64965. * @param name defines the block name
  64966. */
  64967. constructor(name: string);
  64968. /**
  64969. * Gets the current class name
  64970. * @returns the class name
  64971. */
  64972. getClassName(): string;
  64973. /**
  64974. * Gets the input component
  64975. */
  64976. get input(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the factor input component
  64979. */
  64980. get factor(): NodeMaterialConnectionPoint;
  64981. /**
  64982. * Gets the output component
  64983. */
  64984. get output(): NodeMaterialConnectionPoint;
  64985. protected _buildBlock(state: NodeMaterialBuildState): this;
  64986. }
  64987. }
  64988. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64992. import { Scene } from "babylonjs/scene";
  64993. /**
  64994. * Block used to clamp a float
  64995. */
  64996. export class ClampBlock extends NodeMaterialBlock {
  64997. /** Gets or sets the minimum range */
  64998. minimum: number;
  64999. /** Gets or sets the maximum range */
  65000. maximum: number;
  65001. /**
  65002. * Creates a new ClampBlock
  65003. * @param name defines the block name
  65004. */
  65005. constructor(name: string);
  65006. /**
  65007. * Gets the current class name
  65008. * @returns the class name
  65009. */
  65010. getClassName(): string;
  65011. /**
  65012. * Gets the value input component
  65013. */
  65014. get value(): NodeMaterialConnectionPoint;
  65015. /**
  65016. * Gets the output component
  65017. */
  65018. get output(): NodeMaterialConnectionPoint;
  65019. protected _buildBlock(state: NodeMaterialBuildState): this;
  65020. protected _dumpPropertiesCode(): string;
  65021. serialize(): any;
  65022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65023. }
  65024. }
  65025. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65027. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65029. /**
  65030. * Block used to apply a cross product between 2 vectors
  65031. */
  65032. export class CrossBlock extends NodeMaterialBlock {
  65033. /**
  65034. * Creates a new CrossBlock
  65035. * @param name defines the block name
  65036. */
  65037. constructor(name: string);
  65038. /**
  65039. * Gets the current class name
  65040. * @returns the class name
  65041. */
  65042. getClassName(): string;
  65043. /**
  65044. * Gets the left operand input component
  65045. */
  65046. get left(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the right operand input component
  65049. */
  65050. get right(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the output component
  65053. */
  65054. get output(): NodeMaterialConnectionPoint;
  65055. protected _buildBlock(state: NodeMaterialBuildState): this;
  65056. }
  65057. }
  65058. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65062. /**
  65063. * Block used to apply a dot product between 2 vectors
  65064. */
  65065. export class DotBlock extends NodeMaterialBlock {
  65066. /**
  65067. * Creates a new DotBlock
  65068. * @param name defines the block name
  65069. */
  65070. constructor(name: string);
  65071. /**
  65072. * Gets the current class name
  65073. * @returns the class name
  65074. */
  65075. getClassName(): string;
  65076. /**
  65077. * Gets the left operand input component
  65078. */
  65079. get left(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the right operand input component
  65082. */
  65083. get right(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Gets the output component
  65086. */
  65087. get output(): NodeMaterialConnectionPoint;
  65088. protected _buildBlock(state: NodeMaterialBuildState): this;
  65089. }
  65090. }
  65091. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65095. /**
  65096. * Block used to normalize a vector
  65097. */
  65098. export class NormalizeBlock extends NodeMaterialBlock {
  65099. /**
  65100. * Creates a new NormalizeBlock
  65101. * @param name defines the block name
  65102. */
  65103. constructor(name: string);
  65104. /**
  65105. * Gets the current class name
  65106. * @returns the class name
  65107. */
  65108. getClassName(): string;
  65109. /**
  65110. * Gets the input component
  65111. */
  65112. get input(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the output component
  65115. */
  65116. get output(): NodeMaterialConnectionPoint;
  65117. protected _buildBlock(state: NodeMaterialBuildState): this;
  65118. }
  65119. }
  65120. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65124. import { Scene } from "babylonjs/scene";
  65125. /**
  65126. * Operations supported by the Trigonometry block
  65127. */
  65128. export enum TrigonometryBlockOperations {
  65129. /** Cos */
  65130. Cos = 0,
  65131. /** Sin */
  65132. Sin = 1,
  65133. /** Abs */
  65134. Abs = 2,
  65135. /** Exp */
  65136. Exp = 3,
  65137. /** Exp2 */
  65138. Exp2 = 4,
  65139. /** Round */
  65140. Round = 5,
  65141. /** Floor */
  65142. Floor = 6,
  65143. /** Ceiling */
  65144. Ceiling = 7,
  65145. /** Square root */
  65146. Sqrt = 8,
  65147. /** Log */
  65148. Log = 9,
  65149. /** Tangent */
  65150. Tan = 10,
  65151. /** Arc tangent */
  65152. ArcTan = 11,
  65153. /** Arc cosinus */
  65154. ArcCos = 12,
  65155. /** Arc sinus */
  65156. ArcSin = 13,
  65157. /** Fraction */
  65158. Fract = 14,
  65159. /** Sign */
  65160. Sign = 15,
  65161. /** To radians (from degrees) */
  65162. Radians = 16,
  65163. /** To degrees (from radians) */
  65164. Degrees = 17
  65165. }
  65166. /**
  65167. * Block used to apply trigonometry operation to floats
  65168. */
  65169. export class TrigonometryBlock extends NodeMaterialBlock {
  65170. /**
  65171. * Gets or sets the operation applied by the block
  65172. */
  65173. operation: TrigonometryBlockOperations;
  65174. /**
  65175. * Creates a new TrigonometryBlock
  65176. * @param name defines the block name
  65177. */
  65178. constructor(name: string);
  65179. /**
  65180. * Gets the current class name
  65181. * @returns the class name
  65182. */
  65183. getClassName(): string;
  65184. /**
  65185. * Gets the input component
  65186. */
  65187. get input(): NodeMaterialConnectionPoint;
  65188. /**
  65189. * Gets the output component
  65190. */
  65191. get output(): NodeMaterialConnectionPoint;
  65192. protected _buildBlock(state: NodeMaterialBuildState): this;
  65193. serialize(): any;
  65194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65195. protected _dumpPropertiesCode(): string;
  65196. }
  65197. }
  65198. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65202. /**
  65203. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65204. */
  65205. export class ColorMergerBlock extends NodeMaterialBlock {
  65206. /**
  65207. * Create a new ColorMergerBlock
  65208. * @param name defines the block name
  65209. */
  65210. constructor(name: string);
  65211. /**
  65212. * Gets the current class name
  65213. * @returns the class name
  65214. */
  65215. getClassName(): string;
  65216. /**
  65217. * Gets the rgb component (input)
  65218. */
  65219. get rgbIn(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the r component (input)
  65222. */
  65223. get r(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the g component (input)
  65226. */
  65227. get g(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the b component (input)
  65230. */
  65231. get b(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the a component (input)
  65234. */
  65235. get a(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the rgba component (output)
  65238. */
  65239. get rgba(): NodeMaterialConnectionPoint;
  65240. /**
  65241. * Gets the rgb component (output)
  65242. */
  65243. get rgbOut(): NodeMaterialConnectionPoint;
  65244. /**
  65245. * Gets the rgb component (output)
  65246. * @deprecated Please use rgbOut instead.
  65247. */
  65248. get rgb(): NodeMaterialConnectionPoint;
  65249. protected _buildBlock(state: NodeMaterialBuildState): this;
  65250. }
  65251. }
  65252. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65256. /**
  65257. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65258. */
  65259. export class VectorSplitterBlock extends NodeMaterialBlock {
  65260. /**
  65261. * Create a new VectorSplitterBlock
  65262. * @param name defines the block name
  65263. */
  65264. constructor(name: string);
  65265. /**
  65266. * Gets the current class name
  65267. * @returns the class name
  65268. */
  65269. getClassName(): string;
  65270. /**
  65271. * Gets the xyzw component (input)
  65272. */
  65273. get xyzw(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the xyz component (input)
  65276. */
  65277. get xyzIn(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the xy component (input)
  65280. */
  65281. get xyIn(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the xyz component (output)
  65284. */
  65285. get xyzOut(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the xy component (output)
  65288. */
  65289. get xyOut(): NodeMaterialConnectionPoint;
  65290. /**
  65291. * Gets the x component (output)
  65292. */
  65293. get x(): NodeMaterialConnectionPoint;
  65294. /**
  65295. * Gets the y component (output)
  65296. */
  65297. get y(): NodeMaterialConnectionPoint;
  65298. /**
  65299. * Gets the z component (output)
  65300. */
  65301. get z(): NodeMaterialConnectionPoint;
  65302. /**
  65303. * Gets the w component (output)
  65304. */
  65305. get w(): NodeMaterialConnectionPoint;
  65306. protected _inputRename(name: string): string;
  65307. protected _outputRename(name: string): string;
  65308. protected _buildBlock(state: NodeMaterialBuildState): this;
  65309. }
  65310. }
  65311. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65315. /**
  65316. * Block used to lerp between 2 values
  65317. */
  65318. export class LerpBlock extends NodeMaterialBlock {
  65319. /**
  65320. * Creates a new LerpBlock
  65321. * @param name defines the block name
  65322. */
  65323. constructor(name: string);
  65324. /**
  65325. * Gets the current class name
  65326. * @returns the class name
  65327. */
  65328. getClassName(): string;
  65329. /**
  65330. * Gets the left operand input component
  65331. */
  65332. get left(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the right operand input component
  65335. */
  65336. get right(): NodeMaterialConnectionPoint;
  65337. /**
  65338. * Gets the gradient operand input component
  65339. */
  65340. get gradient(): NodeMaterialConnectionPoint;
  65341. /**
  65342. * Gets the output component
  65343. */
  65344. get output(): NodeMaterialConnectionPoint;
  65345. protected _buildBlock(state: NodeMaterialBuildState): this;
  65346. }
  65347. }
  65348. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65352. /**
  65353. * Block used to divide 2 vectors
  65354. */
  65355. export class DivideBlock extends NodeMaterialBlock {
  65356. /**
  65357. * Creates a new DivideBlock
  65358. * @param name defines the block name
  65359. */
  65360. constructor(name: string);
  65361. /**
  65362. * Gets the current class name
  65363. * @returns the class name
  65364. */
  65365. getClassName(): string;
  65366. /**
  65367. * Gets the left operand input component
  65368. */
  65369. get left(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the right operand input component
  65372. */
  65373. get right(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the output component
  65376. */
  65377. get output(): NodeMaterialConnectionPoint;
  65378. protected _buildBlock(state: NodeMaterialBuildState): this;
  65379. }
  65380. }
  65381. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65385. /**
  65386. * Block used to subtract 2 vectors
  65387. */
  65388. export class SubtractBlock extends NodeMaterialBlock {
  65389. /**
  65390. * Creates a new SubtractBlock
  65391. * @param name defines the block name
  65392. */
  65393. constructor(name: string);
  65394. /**
  65395. * Gets the current class name
  65396. * @returns the class name
  65397. */
  65398. getClassName(): string;
  65399. /**
  65400. * Gets the left operand input component
  65401. */
  65402. get left(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the right operand input component
  65405. */
  65406. get right(): NodeMaterialConnectionPoint;
  65407. /**
  65408. * Gets the output component
  65409. */
  65410. get output(): NodeMaterialConnectionPoint;
  65411. protected _buildBlock(state: NodeMaterialBuildState): this;
  65412. }
  65413. }
  65414. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65418. /**
  65419. * Block used to step a value
  65420. */
  65421. export class StepBlock extends NodeMaterialBlock {
  65422. /**
  65423. * Creates a new StepBlock
  65424. * @param name defines the block name
  65425. */
  65426. constructor(name: string);
  65427. /**
  65428. * Gets the current class name
  65429. * @returns the class name
  65430. */
  65431. getClassName(): string;
  65432. /**
  65433. * Gets the value operand input component
  65434. */
  65435. get value(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the edge operand input component
  65438. */
  65439. get edge(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the output component
  65442. */
  65443. get output(): NodeMaterialConnectionPoint;
  65444. protected _buildBlock(state: NodeMaterialBuildState): this;
  65445. }
  65446. }
  65447. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65451. /**
  65452. * Block used to get the opposite (1 - x) of a value
  65453. */
  65454. export class OneMinusBlock extends NodeMaterialBlock {
  65455. /**
  65456. * Creates a new OneMinusBlock
  65457. * @param name defines the block name
  65458. */
  65459. constructor(name: string);
  65460. /**
  65461. * Gets the current class name
  65462. * @returns the class name
  65463. */
  65464. getClassName(): string;
  65465. /**
  65466. * Gets the input component
  65467. */
  65468. get input(): NodeMaterialConnectionPoint;
  65469. /**
  65470. * Gets the output component
  65471. */
  65472. get output(): NodeMaterialConnectionPoint;
  65473. protected _buildBlock(state: NodeMaterialBuildState): this;
  65474. }
  65475. }
  65476. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65480. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65481. /**
  65482. * Block used to get the view direction
  65483. */
  65484. export class ViewDirectionBlock extends NodeMaterialBlock {
  65485. /**
  65486. * Creates a new ViewDirectionBlock
  65487. * @param name defines the block name
  65488. */
  65489. constructor(name: string);
  65490. /**
  65491. * Gets the current class name
  65492. * @returns the class name
  65493. */
  65494. getClassName(): string;
  65495. /**
  65496. * Gets the world position component
  65497. */
  65498. get worldPosition(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the camera position component
  65501. */
  65502. get cameraPosition(): NodeMaterialConnectionPoint;
  65503. /**
  65504. * Gets the output component
  65505. */
  65506. get output(): NodeMaterialConnectionPoint;
  65507. autoConfigure(material: NodeMaterial): void;
  65508. protected _buildBlock(state: NodeMaterialBuildState): this;
  65509. }
  65510. }
  65511. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65515. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65516. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65517. /**
  65518. * Block used to compute fresnel value
  65519. */
  65520. export class FresnelBlock extends NodeMaterialBlock {
  65521. /**
  65522. * Create a new FresnelBlock
  65523. * @param name defines the block name
  65524. */
  65525. constructor(name: string);
  65526. /**
  65527. * Gets the current class name
  65528. * @returns the class name
  65529. */
  65530. getClassName(): string;
  65531. /**
  65532. * Gets the world normal input component
  65533. */
  65534. get worldNormal(): NodeMaterialConnectionPoint;
  65535. /**
  65536. * Gets the view direction input component
  65537. */
  65538. get viewDirection(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the bias input component
  65541. */
  65542. get bias(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the camera (or eye) position component
  65545. */
  65546. get power(): NodeMaterialConnectionPoint;
  65547. /**
  65548. * Gets the fresnel output component
  65549. */
  65550. get fresnel(): NodeMaterialConnectionPoint;
  65551. autoConfigure(material: NodeMaterial): void;
  65552. protected _buildBlock(state: NodeMaterialBuildState): this;
  65553. }
  65554. }
  65555. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65559. /**
  65560. * Block used to get the max of 2 values
  65561. */
  65562. export class MaxBlock extends NodeMaterialBlock {
  65563. /**
  65564. * Creates a new MaxBlock
  65565. * @param name defines the block name
  65566. */
  65567. constructor(name: string);
  65568. /**
  65569. * Gets the current class name
  65570. * @returns the class name
  65571. */
  65572. getClassName(): string;
  65573. /**
  65574. * Gets the left operand input component
  65575. */
  65576. get left(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the right operand input component
  65579. */
  65580. get right(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the output component
  65583. */
  65584. get output(): NodeMaterialConnectionPoint;
  65585. protected _buildBlock(state: NodeMaterialBuildState): this;
  65586. }
  65587. }
  65588. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65592. /**
  65593. * Block used to get the min of 2 values
  65594. */
  65595. export class MinBlock extends NodeMaterialBlock {
  65596. /**
  65597. * Creates a new MinBlock
  65598. * @param name defines the block name
  65599. */
  65600. constructor(name: string);
  65601. /**
  65602. * Gets the current class name
  65603. * @returns the class name
  65604. */
  65605. getClassName(): string;
  65606. /**
  65607. * Gets the left operand input component
  65608. */
  65609. get left(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the right operand input component
  65612. */
  65613. get right(): NodeMaterialConnectionPoint;
  65614. /**
  65615. * Gets the output component
  65616. */
  65617. get output(): NodeMaterialConnectionPoint;
  65618. protected _buildBlock(state: NodeMaterialBuildState): this;
  65619. }
  65620. }
  65621. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65625. /**
  65626. * Block used to get the distance between 2 values
  65627. */
  65628. export class DistanceBlock extends NodeMaterialBlock {
  65629. /**
  65630. * Creates a new DistanceBlock
  65631. * @param name defines the block name
  65632. */
  65633. constructor(name: string);
  65634. /**
  65635. * Gets the current class name
  65636. * @returns the class name
  65637. */
  65638. getClassName(): string;
  65639. /**
  65640. * Gets the left operand input component
  65641. */
  65642. get left(): NodeMaterialConnectionPoint;
  65643. /**
  65644. * Gets the right operand input component
  65645. */
  65646. get right(): NodeMaterialConnectionPoint;
  65647. /**
  65648. * Gets the output component
  65649. */
  65650. get output(): NodeMaterialConnectionPoint;
  65651. protected _buildBlock(state: NodeMaterialBuildState): this;
  65652. }
  65653. }
  65654. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65658. /**
  65659. * Block used to get the length of a vector
  65660. */
  65661. export class LengthBlock extends NodeMaterialBlock {
  65662. /**
  65663. * Creates a new LengthBlock
  65664. * @param name defines the block name
  65665. */
  65666. constructor(name: string);
  65667. /**
  65668. * Gets the current class name
  65669. * @returns the class name
  65670. */
  65671. getClassName(): string;
  65672. /**
  65673. * Gets the value input component
  65674. */
  65675. get value(): NodeMaterialConnectionPoint;
  65676. /**
  65677. * Gets the output component
  65678. */
  65679. get output(): NodeMaterialConnectionPoint;
  65680. protected _buildBlock(state: NodeMaterialBuildState): this;
  65681. }
  65682. }
  65683. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65687. /**
  65688. * Block used to get negative version of a value (i.e. x * -1)
  65689. */
  65690. export class NegateBlock extends NodeMaterialBlock {
  65691. /**
  65692. * Creates a new NegateBlock
  65693. * @param name defines the block name
  65694. */
  65695. constructor(name: string);
  65696. /**
  65697. * Gets the current class name
  65698. * @returns the class name
  65699. */
  65700. getClassName(): string;
  65701. /**
  65702. * Gets the value input component
  65703. */
  65704. get value(): NodeMaterialConnectionPoint;
  65705. /**
  65706. * Gets the output component
  65707. */
  65708. get output(): NodeMaterialConnectionPoint;
  65709. protected _buildBlock(state: NodeMaterialBuildState): this;
  65710. }
  65711. }
  65712. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65716. /**
  65717. * Block used to get the value of the first parameter raised to the power of the second
  65718. */
  65719. export class PowBlock extends NodeMaterialBlock {
  65720. /**
  65721. * Creates a new PowBlock
  65722. * @param name defines the block name
  65723. */
  65724. constructor(name: string);
  65725. /**
  65726. * Gets the current class name
  65727. * @returns the class name
  65728. */
  65729. getClassName(): string;
  65730. /**
  65731. * Gets the value operand input component
  65732. */
  65733. get value(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the power operand input component
  65736. */
  65737. get power(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Gets the output component
  65740. */
  65741. get output(): NodeMaterialConnectionPoint;
  65742. protected _buildBlock(state: NodeMaterialBuildState): this;
  65743. }
  65744. }
  65745. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65749. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65750. /**
  65751. * Block used to get a random number
  65752. */
  65753. export class RandomNumberBlock extends NodeMaterialBlock {
  65754. /**
  65755. * Creates a new RandomNumberBlock
  65756. * @param name defines the block name
  65757. */
  65758. constructor(name: string);
  65759. /**
  65760. * Gets the current class name
  65761. * @returns the class name
  65762. */
  65763. getClassName(): string;
  65764. /**
  65765. * Gets the seed input component
  65766. */
  65767. get seed(): NodeMaterialConnectionPoint;
  65768. /**
  65769. * Gets the output component
  65770. */
  65771. get output(): NodeMaterialConnectionPoint;
  65772. protected _buildBlock(state: NodeMaterialBuildState): this;
  65773. }
  65774. }
  65775. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65779. /**
  65780. * Block used to compute arc tangent of 2 values
  65781. */
  65782. export class ArcTan2Block extends NodeMaterialBlock {
  65783. /**
  65784. * Creates a new ArcTan2Block
  65785. * @param name defines the block name
  65786. */
  65787. constructor(name: string);
  65788. /**
  65789. * Gets the current class name
  65790. * @returns the class name
  65791. */
  65792. getClassName(): string;
  65793. /**
  65794. * Gets the x operand input component
  65795. */
  65796. get x(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the y operand input component
  65799. */
  65800. get y(): NodeMaterialConnectionPoint;
  65801. /**
  65802. * Gets the output component
  65803. */
  65804. get output(): NodeMaterialConnectionPoint;
  65805. protected _buildBlock(state: NodeMaterialBuildState): this;
  65806. }
  65807. }
  65808. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65812. /**
  65813. * Block used to smooth step a value
  65814. */
  65815. export class SmoothStepBlock extends NodeMaterialBlock {
  65816. /**
  65817. * Creates a new SmoothStepBlock
  65818. * @param name defines the block name
  65819. */
  65820. constructor(name: string);
  65821. /**
  65822. * Gets the current class name
  65823. * @returns the class name
  65824. */
  65825. getClassName(): string;
  65826. /**
  65827. * Gets the value operand input component
  65828. */
  65829. get value(): NodeMaterialConnectionPoint;
  65830. /**
  65831. * Gets the first edge operand input component
  65832. */
  65833. get edge0(): NodeMaterialConnectionPoint;
  65834. /**
  65835. * Gets the second edge operand input component
  65836. */
  65837. get edge1(): NodeMaterialConnectionPoint;
  65838. /**
  65839. * Gets the output component
  65840. */
  65841. get output(): NodeMaterialConnectionPoint;
  65842. protected _buildBlock(state: NodeMaterialBuildState): this;
  65843. }
  65844. }
  65845. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65849. /**
  65850. * Block used to get the reciprocal (1 / x) of a value
  65851. */
  65852. export class ReciprocalBlock extends NodeMaterialBlock {
  65853. /**
  65854. * Creates a new ReciprocalBlock
  65855. * @param name defines the block name
  65856. */
  65857. constructor(name: string);
  65858. /**
  65859. * Gets the current class name
  65860. * @returns the class name
  65861. */
  65862. getClassName(): string;
  65863. /**
  65864. * Gets the input component
  65865. */
  65866. get input(): NodeMaterialConnectionPoint;
  65867. /**
  65868. * Gets the output component
  65869. */
  65870. get output(): NodeMaterialConnectionPoint;
  65871. protected _buildBlock(state: NodeMaterialBuildState): this;
  65872. }
  65873. }
  65874. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65878. /**
  65879. * Block used to replace a color by another one
  65880. */
  65881. export class ReplaceColorBlock extends NodeMaterialBlock {
  65882. /**
  65883. * Creates a new ReplaceColorBlock
  65884. * @param name defines the block name
  65885. */
  65886. constructor(name: string);
  65887. /**
  65888. * Gets the current class name
  65889. * @returns the class name
  65890. */
  65891. getClassName(): string;
  65892. /**
  65893. * Gets the value input component
  65894. */
  65895. get value(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the reference input component
  65898. */
  65899. get reference(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the distance input component
  65902. */
  65903. get distance(): NodeMaterialConnectionPoint;
  65904. /**
  65905. * Gets the replacement input component
  65906. */
  65907. get replacement(): NodeMaterialConnectionPoint;
  65908. /**
  65909. * Gets the output component
  65910. */
  65911. get output(): NodeMaterialConnectionPoint;
  65912. protected _buildBlock(state: NodeMaterialBuildState): this;
  65913. }
  65914. }
  65915. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65919. /**
  65920. * Block used to posterize a value
  65921. * @see https://en.wikipedia.org/wiki/Posterization
  65922. */
  65923. export class PosterizeBlock extends NodeMaterialBlock {
  65924. /**
  65925. * Creates a new PosterizeBlock
  65926. * @param name defines the block name
  65927. */
  65928. constructor(name: string);
  65929. /**
  65930. * Gets the current class name
  65931. * @returns the class name
  65932. */
  65933. getClassName(): string;
  65934. /**
  65935. * Gets the value input component
  65936. */
  65937. get value(): NodeMaterialConnectionPoint;
  65938. /**
  65939. * Gets the steps input component
  65940. */
  65941. get steps(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the output component
  65944. */
  65945. get output(): NodeMaterialConnectionPoint;
  65946. protected _buildBlock(state: NodeMaterialBuildState): this;
  65947. }
  65948. }
  65949. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65953. import { Scene } from "babylonjs/scene";
  65954. /**
  65955. * Operations supported by the Wave block
  65956. */
  65957. export enum WaveBlockKind {
  65958. /** SawTooth */
  65959. SawTooth = 0,
  65960. /** Square */
  65961. Square = 1,
  65962. /** Triangle */
  65963. Triangle = 2
  65964. }
  65965. /**
  65966. * Block used to apply wave operation to floats
  65967. */
  65968. export class WaveBlock extends NodeMaterialBlock {
  65969. /**
  65970. * Gets or sets the kibnd of wave to be applied by the block
  65971. */
  65972. kind: WaveBlockKind;
  65973. /**
  65974. * Creates a new WaveBlock
  65975. * @param name defines the block name
  65976. */
  65977. constructor(name: string);
  65978. /**
  65979. * Gets the current class name
  65980. * @returns the class name
  65981. */
  65982. getClassName(): string;
  65983. /**
  65984. * Gets the input component
  65985. */
  65986. get input(): NodeMaterialConnectionPoint;
  65987. /**
  65988. * Gets the output component
  65989. */
  65990. get output(): NodeMaterialConnectionPoint;
  65991. protected _buildBlock(state: NodeMaterialBuildState): this;
  65992. serialize(): any;
  65993. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65994. }
  65995. }
  65996. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66000. import { Color3 } from "babylonjs/Maths/math.color";
  66001. import { Scene } from "babylonjs/scene";
  66002. /**
  66003. * Class used to store a color step for the GradientBlock
  66004. */
  66005. export class GradientBlockColorStep {
  66006. /**
  66007. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66008. */
  66009. step: number;
  66010. /**
  66011. * Gets or sets the color associated with this step
  66012. */
  66013. color: Color3;
  66014. /**
  66015. * Creates a new GradientBlockColorStep
  66016. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66017. * @param color defines the color associated with this step
  66018. */
  66019. constructor(
  66020. /**
  66021. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66022. */
  66023. step: number,
  66024. /**
  66025. * Gets or sets the color associated with this step
  66026. */
  66027. color: Color3);
  66028. }
  66029. /**
  66030. * Block used to return a color from a gradient based on an input value between 0 and 1
  66031. */
  66032. export class GradientBlock extends NodeMaterialBlock {
  66033. /**
  66034. * Gets or sets the list of color steps
  66035. */
  66036. colorSteps: GradientBlockColorStep[];
  66037. /**
  66038. * Creates a new GradientBlock
  66039. * @param name defines the block name
  66040. */
  66041. constructor(name: string);
  66042. /**
  66043. * Gets the current class name
  66044. * @returns the class name
  66045. */
  66046. getClassName(): string;
  66047. /**
  66048. * Gets the gradient input component
  66049. */
  66050. get gradient(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the output component
  66053. */
  66054. get output(): NodeMaterialConnectionPoint;
  66055. private _writeColorConstant;
  66056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66057. serialize(): any;
  66058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66059. protected _dumpPropertiesCode(): string;
  66060. }
  66061. }
  66062. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66066. /**
  66067. * Block used to normalize lerp between 2 values
  66068. */
  66069. export class NLerpBlock extends NodeMaterialBlock {
  66070. /**
  66071. * Creates a new NLerpBlock
  66072. * @param name defines the block name
  66073. */
  66074. constructor(name: string);
  66075. /**
  66076. * Gets the current class name
  66077. * @returns the class name
  66078. */
  66079. getClassName(): string;
  66080. /**
  66081. * Gets the left operand input component
  66082. */
  66083. get left(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the right operand input component
  66086. */
  66087. get right(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the gradient operand input component
  66090. */
  66091. get gradient(): NodeMaterialConnectionPoint;
  66092. /**
  66093. * Gets the output component
  66094. */
  66095. get output(): NodeMaterialConnectionPoint;
  66096. protected _buildBlock(state: NodeMaterialBuildState): this;
  66097. }
  66098. }
  66099. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66103. import { Scene } from "babylonjs/scene";
  66104. /**
  66105. * block used to Generate a Worley Noise 3D Noise Pattern
  66106. */
  66107. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66108. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66109. manhattanDistance: boolean;
  66110. /**
  66111. * Creates a new WorleyNoise3DBlock
  66112. * @param name defines the block name
  66113. */
  66114. constructor(name: string);
  66115. /**
  66116. * Gets the current class name
  66117. * @returns the class name
  66118. */
  66119. getClassName(): string;
  66120. /**
  66121. * Gets the seed input component
  66122. */
  66123. get seed(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the jitter input component
  66126. */
  66127. get jitter(): NodeMaterialConnectionPoint;
  66128. /**
  66129. * Gets the output component
  66130. */
  66131. get output(): NodeMaterialConnectionPoint;
  66132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66133. /**
  66134. * Exposes the properties to the UI?
  66135. */
  66136. protected _dumpPropertiesCode(): string;
  66137. /**
  66138. * Exposes the properties to the Seralize?
  66139. */
  66140. serialize(): any;
  66141. /**
  66142. * Exposes the properties to the deseralize?
  66143. */
  66144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66145. }
  66146. }
  66147. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66151. /**
  66152. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66153. */
  66154. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66155. /**
  66156. * Creates a new SimplexPerlin3DBlock
  66157. * @param name defines the block name
  66158. */
  66159. constructor(name: string);
  66160. /**
  66161. * Gets the current class name
  66162. * @returns the class name
  66163. */
  66164. getClassName(): string;
  66165. /**
  66166. * Gets the seed operand input component
  66167. */
  66168. get seed(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the output component
  66171. */
  66172. get output(): NodeMaterialConnectionPoint;
  66173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66174. }
  66175. }
  66176. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66180. /**
  66181. * Block used to blend normals
  66182. */
  66183. export class NormalBlendBlock extends NodeMaterialBlock {
  66184. /**
  66185. * Creates a new NormalBlendBlock
  66186. * @param name defines the block name
  66187. */
  66188. constructor(name: string);
  66189. /**
  66190. * Gets the current class name
  66191. * @returns the class name
  66192. */
  66193. getClassName(): string;
  66194. /**
  66195. * Gets the first input component
  66196. */
  66197. get normalMap0(): NodeMaterialConnectionPoint;
  66198. /**
  66199. * Gets the second input component
  66200. */
  66201. get normalMap1(): NodeMaterialConnectionPoint;
  66202. /**
  66203. * Gets the output component
  66204. */
  66205. get output(): NodeMaterialConnectionPoint;
  66206. protected _buildBlock(state: NodeMaterialBuildState): this;
  66207. }
  66208. }
  66209. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66213. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66214. /**
  66215. * Block used to rotate a 2d vector by a given angle
  66216. */
  66217. export class Rotate2dBlock extends NodeMaterialBlock {
  66218. /**
  66219. * Creates a new Rotate2dBlock
  66220. * @param name defines the block name
  66221. */
  66222. constructor(name: string);
  66223. /**
  66224. * Gets the current class name
  66225. * @returns the class name
  66226. */
  66227. getClassName(): string;
  66228. /**
  66229. * Gets the input vector
  66230. */
  66231. get input(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the input angle
  66234. */
  66235. get angle(): NodeMaterialConnectionPoint;
  66236. /**
  66237. * Gets the output component
  66238. */
  66239. get output(): NodeMaterialConnectionPoint;
  66240. autoConfigure(material: NodeMaterial): void;
  66241. protected _buildBlock(state: NodeMaterialBuildState): this;
  66242. }
  66243. }
  66244. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66248. /**
  66249. * Block used to get the reflected vector from a direction and a normal
  66250. */
  66251. export class ReflectBlock extends NodeMaterialBlock {
  66252. /**
  66253. * Creates a new ReflectBlock
  66254. * @param name defines the block name
  66255. */
  66256. constructor(name: string);
  66257. /**
  66258. * Gets the current class name
  66259. * @returns the class name
  66260. */
  66261. getClassName(): string;
  66262. /**
  66263. * Gets the incident component
  66264. */
  66265. get incident(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the normal component
  66268. */
  66269. get normal(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the output component
  66272. */
  66273. get output(): NodeMaterialConnectionPoint;
  66274. protected _buildBlock(state: NodeMaterialBuildState): this;
  66275. }
  66276. }
  66277. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66281. /**
  66282. * Block used to get the refracted vector from a direction and a normal
  66283. */
  66284. export class RefractBlock extends NodeMaterialBlock {
  66285. /**
  66286. * Creates a new RefractBlock
  66287. * @param name defines the block name
  66288. */
  66289. constructor(name: string);
  66290. /**
  66291. * Gets the current class name
  66292. * @returns the class name
  66293. */
  66294. getClassName(): string;
  66295. /**
  66296. * Gets the incident component
  66297. */
  66298. get incident(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the normal component
  66301. */
  66302. get normal(): NodeMaterialConnectionPoint;
  66303. /**
  66304. * Gets the index of refraction component
  66305. */
  66306. get ior(): NodeMaterialConnectionPoint;
  66307. /**
  66308. * Gets the output component
  66309. */
  66310. get output(): NodeMaterialConnectionPoint;
  66311. protected _buildBlock(state: NodeMaterialBuildState): this;
  66312. }
  66313. }
  66314. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66318. /**
  66319. * Block used to desaturate a color
  66320. */
  66321. export class DesaturateBlock extends NodeMaterialBlock {
  66322. /**
  66323. * Creates a new DesaturateBlock
  66324. * @param name defines the block name
  66325. */
  66326. constructor(name: string);
  66327. /**
  66328. * Gets the current class name
  66329. * @returns the class name
  66330. */
  66331. getClassName(): string;
  66332. /**
  66333. * Gets the color operand input component
  66334. */
  66335. get color(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the level operand input component
  66338. */
  66339. get level(): NodeMaterialConnectionPoint;
  66340. /**
  66341. * Gets the output component
  66342. */
  66343. get output(): NodeMaterialConnectionPoint;
  66344. protected _buildBlock(state: NodeMaterialBuildState): this;
  66345. }
  66346. }
  66347. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66351. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66352. import { Nullable } from "babylonjs/types";
  66353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66354. import { Scene } from "babylonjs/scene";
  66355. /**
  66356. * Block used to implement the ambient occlusion module of the PBR material
  66357. */
  66358. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66359. /**
  66360. * Create a new AmbientOcclusionBlock
  66361. * @param name defines the block name
  66362. */
  66363. constructor(name: string);
  66364. /**
  66365. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66366. */
  66367. useAmbientInGrayScale: boolean;
  66368. /**
  66369. * Initialize the block and prepare the context for build
  66370. * @param state defines the state that will be used for the build
  66371. */
  66372. initialize(state: NodeMaterialBuildState): void;
  66373. /**
  66374. * Gets the current class name
  66375. * @returns the class name
  66376. */
  66377. getClassName(): string;
  66378. /**
  66379. * Gets the texture input component
  66380. */
  66381. get texture(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the texture intensity component
  66384. */
  66385. get intensity(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the direct light intensity input component
  66388. */
  66389. get directLightIntensity(): NodeMaterialConnectionPoint;
  66390. /**
  66391. * Gets the ambient occlusion object output component
  66392. */
  66393. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66394. /**
  66395. * Gets the main code of the block (fragment side)
  66396. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66397. * @returns the shader code
  66398. */
  66399. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66401. protected _buildBlock(state: NodeMaterialBuildState): this;
  66402. protected _dumpPropertiesCode(): string;
  66403. serialize(): any;
  66404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66405. }
  66406. }
  66407. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66410. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66411. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66413. import { Nullable } from "babylonjs/types";
  66414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66415. import { Mesh } from "babylonjs/Meshes/mesh";
  66416. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66417. import { Effect } from "babylonjs/Materials/effect";
  66418. import { Scene } from "babylonjs/scene";
  66419. /**
  66420. * Block used to implement the reflection module of the PBR material
  66421. */
  66422. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66423. /** @hidden */
  66424. _defineLODReflectionAlpha: string;
  66425. /** @hidden */
  66426. _defineLinearSpecularReflection: string;
  66427. private _vEnvironmentIrradianceName;
  66428. /** @hidden */
  66429. _vReflectionMicrosurfaceInfosName: string;
  66430. /** @hidden */
  66431. _vReflectionInfosName: string;
  66432. /** @hidden */
  66433. _vReflectionFilteringInfoName: string;
  66434. private _scene;
  66435. /**
  66436. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66437. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66438. * It's less burden on the user side in the editor part.
  66439. */
  66440. /** @hidden */
  66441. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66442. /** @hidden */
  66443. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66444. /** @hidden */
  66445. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66446. /**
  66447. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66448. * diffuse part of the IBL.
  66449. */
  66450. useSphericalHarmonics: boolean;
  66451. /**
  66452. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66453. */
  66454. forceIrradianceInFragment: boolean;
  66455. /**
  66456. * Create a new ReflectionBlock
  66457. * @param name defines the block name
  66458. */
  66459. constructor(name: string);
  66460. /**
  66461. * Gets the current class name
  66462. * @returns the class name
  66463. */
  66464. getClassName(): string;
  66465. /**
  66466. * Gets the position input component
  66467. */
  66468. get position(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the world position input component
  66471. */
  66472. get worldPosition(): NodeMaterialConnectionPoint;
  66473. /**
  66474. * Gets the world normal input component
  66475. */
  66476. get worldNormal(): NodeMaterialConnectionPoint;
  66477. /**
  66478. * Gets the world input component
  66479. */
  66480. get world(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the camera (or eye) position component
  66483. */
  66484. get cameraPosition(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the view input component
  66487. */
  66488. get view(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the color input component
  66491. */
  66492. get color(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Gets the reflection object output component
  66495. */
  66496. get reflection(): NodeMaterialConnectionPoint;
  66497. /**
  66498. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66499. */
  66500. get hasTexture(): boolean;
  66501. /**
  66502. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66503. */
  66504. get reflectionColor(): string;
  66505. protected _getTexture(): Nullable<BaseTexture>;
  66506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66508. /**
  66509. * Gets the code to inject in the vertex shader
  66510. * @param state current state of the node material building
  66511. * @returns the shader code
  66512. */
  66513. handleVertexSide(state: NodeMaterialBuildState): string;
  66514. /**
  66515. * Gets the main code of the block (fragment side)
  66516. * @param state current state of the node material building
  66517. * @param normalVarName name of the existing variable corresponding to the normal
  66518. * @returns the shader code
  66519. */
  66520. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66521. protected _buildBlock(state: NodeMaterialBuildState): this;
  66522. protected _dumpPropertiesCode(): string;
  66523. serialize(): any;
  66524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66525. }
  66526. }
  66527. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66531. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66533. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66534. import { Scene } from "babylonjs/scene";
  66535. import { Nullable } from "babylonjs/types";
  66536. /**
  66537. * Block used to implement the sheen module of the PBR material
  66538. */
  66539. export class SheenBlock extends NodeMaterialBlock {
  66540. /**
  66541. * Create a new SheenBlock
  66542. * @param name defines the block name
  66543. */
  66544. constructor(name: string);
  66545. /**
  66546. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66547. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66548. * making it easier to setup and tweak the effect
  66549. */
  66550. albedoScaling: boolean;
  66551. /**
  66552. * Defines if the sheen is linked to the sheen color.
  66553. */
  66554. linkSheenWithAlbedo: boolean;
  66555. /**
  66556. * Initialize the block and prepare the context for build
  66557. * @param state defines the state that will be used for the build
  66558. */
  66559. initialize(state: NodeMaterialBuildState): void;
  66560. /**
  66561. * Gets the current class name
  66562. * @returns the class name
  66563. */
  66564. getClassName(): string;
  66565. /**
  66566. * Gets the intensity input component
  66567. */
  66568. get intensity(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the color input component
  66571. */
  66572. get color(): NodeMaterialConnectionPoint;
  66573. /**
  66574. * Gets the roughness input component
  66575. */
  66576. get roughness(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the sheen object output component
  66579. */
  66580. get sheen(): NodeMaterialConnectionPoint;
  66581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66582. /**
  66583. * Gets the main code of the block (fragment side)
  66584. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66585. * @returns the shader code
  66586. */
  66587. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66588. protected _buildBlock(state: NodeMaterialBuildState): this;
  66589. protected _dumpPropertiesCode(): string;
  66590. serialize(): any;
  66591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66592. }
  66593. }
  66594. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66595. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66600. import { Scene } from "babylonjs/scene";
  66601. import { Nullable } from "babylonjs/types";
  66602. import { Mesh } from "babylonjs/Meshes/mesh";
  66603. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66604. import { Effect } from "babylonjs/Materials/effect";
  66605. /**
  66606. * Block used to implement the reflectivity module of the PBR material
  66607. */
  66608. export class ReflectivityBlock extends NodeMaterialBlock {
  66609. private _metallicReflectanceColor;
  66610. private _metallicF0Factor;
  66611. /** @hidden */
  66612. _vMetallicReflectanceFactorsName: string;
  66613. /**
  66614. * The property below is set by the main PBR block prior to calling methods of this class.
  66615. */
  66616. /** @hidden */
  66617. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66618. /**
  66619. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66620. */
  66621. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66622. /**
  66623. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66624. */
  66625. useMetallnessFromMetallicTextureBlue: boolean;
  66626. /**
  66627. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66628. */
  66629. useRoughnessFromMetallicTextureAlpha: boolean;
  66630. /**
  66631. * Specifies if the metallic texture contains the roughness information in its green channel.
  66632. */
  66633. useRoughnessFromMetallicTextureGreen: boolean;
  66634. /**
  66635. * Create a new ReflectivityBlock
  66636. * @param name defines the block name
  66637. */
  66638. constructor(name: string);
  66639. /**
  66640. * Initialize the block and prepare the context for build
  66641. * @param state defines the state that will be used for the build
  66642. */
  66643. initialize(state: NodeMaterialBuildState): void;
  66644. /**
  66645. * Gets the current class name
  66646. * @returns the class name
  66647. */
  66648. getClassName(): string;
  66649. /**
  66650. * Gets the metallic input component
  66651. */
  66652. get metallic(): NodeMaterialConnectionPoint;
  66653. /**
  66654. * Gets the roughness input component
  66655. */
  66656. get roughness(): NodeMaterialConnectionPoint;
  66657. /**
  66658. * Gets the texture input component
  66659. */
  66660. get texture(): NodeMaterialConnectionPoint;
  66661. /**
  66662. * Gets the reflectivity object output component
  66663. */
  66664. get reflectivity(): NodeMaterialConnectionPoint;
  66665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66666. /**
  66667. * Gets the main code of the block (fragment side)
  66668. * @param state current state of the node material building
  66669. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66670. * @returns the shader code
  66671. */
  66672. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66674. protected _buildBlock(state: NodeMaterialBuildState): this;
  66675. protected _dumpPropertiesCode(): string;
  66676. serialize(): any;
  66677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66678. }
  66679. }
  66680. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66686. /**
  66687. * Block used to implement the anisotropy module of the PBR material
  66688. */
  66689. export class AnisotropyBlock extends NodeMaterialBlock {
  66690. /**
  66691. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66692. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66693. * It's less burden on the user side in the editor part.
  66694. */
  66695. /** @hidden */
  66696. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66697. /** @hidden */
  66698. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66699. /**
  66700. * Create a new AnisotropyBlock
  66701. * @param name defines the block name
  66702. */
  66703. constructor(name: string);
  66704. /**
  66705. * Initialize the block and prepare the context for build
  66706. * @param state defines the state that will be used for the build
  66707. */
  66708. initialize(state: NodeMaterialBuildState): void;
  66709. /**
  66710. * Gets the current class name
  66711. * @returns the class name
  66712. */
  66713. getClassName(): string;
  66714. /**
  66715. * Gets the intensity input component
  66716. */
  66717. get intensity(): NodeMaterialConnectionPoint;
  66718. /**
  66719. * Gets the direction input component
  66720. */
  66721. get direction(): NodeMaterialConnectionPoint;
  66722. /**
  66723. * Gets the texture input component
  66724. */
  66725. get texture(): NodeMaterialConnectionPoint;
  66726. /**
  66727. * Gets the uv input component
  66728. */
  66729. get uv(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the worldTangent input component
  66732. */
  66733. get worldTangent(): NodeMaterialConnectionPoint;
  66734. /**
  66735. * Gets the anisotropy object output component
  66736. */
  66737. get anisotropy(): NodeMaterialConnectionPoint;
  66738. private _generateTBNSpace;
  66739. /**
  66740. * Gets the main code of the block (fragment side)
  66741. * @param state current state of the node material building
  66742. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66743. * @returns the shader code
  66744. */
  66745. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66747. protected _buildBlock(state: NodeMaterialBuildState): this;
  66748. }
  66749. }
  66750. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66752. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66753. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66754. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66756. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66757. import { Nullable } from "babylonjs/types";
  66758. import { Mesh } from "babylonjs/Meshes/mesh";
  66759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66760. import { Effect } from "babylonjs/Materials/effect";
  66761. /**
  66762. * Block used to implement the clear coat module of the PBR material
  66763. */
  66764. export class ClearCoatBlock extends NodeMaterialBlock {
  66765. private _scene;
  66766. /**
  66767. * Create a new ClearCoatBlock
  66768. * @param name defines the block name
  66769. */
  66770. constructor(name: string);
  66771. /**
  66772. * Initialize the block and prepare the context for build
  66773. * @param state defines the state that will be used for the build
  66774. */
  66775. initialize(state: NodeMaterialBuildState): void;
  66776. /**
  66777. * Gets the current class name
  66778. * @returns the class name
  66779. */
  66780. getClassName(): string;
  66781. /**
  66782. * Gets the intensity input component
  66783. */
  66784. get intensity(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the roughness input component
  66787. */
  66788. get roughness(): NodeMaterialConnectionPoint;
  66789. /**
  66790. * Gets the ior input component
  66791. */
  66792. get ior(): NodeMaterialConnectionPoint;
  66793. /**
  66794. * Gets the texture input component
  66795. */
  66796. get texture(): NodeMaterialConnectionPoint;
  66797. /**
  66798. * Gets the bump texture input component
  66799. */
  66800. get bumpTexture(): NodeMaterialConnectionPoint;
  66801. /**
  66802. * Gets the uv input component
  66803. */
  66804. get uv(): NodeMaterialConnectionPoint;
  66805. /**
  66806. * Gets the tint color input component
  66807. */
  66808. get tintColor(): NodeMaterialConnectionPoint;
  66809. /**
  66810. * Gets the tint "at distance" input component
  66811. */
  66812. get tintAtDistance(): NodeMaterialConnectionPoint;
  66813. /**
  66814. * Gets the tint thickness input component
  66815. */
  66816. get tintThickness(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the world tangent input component
  66819. */
  66820. get worldTangent(): NodeMaterialConnectionPoint;
  66821. /**
  66822. * Gets the clear coat object output component
  66823. */
  66824. get clearcoat(): NodeMaterialConnectionPoint;
  66825. autoConfigure(material: NodeMaterial): void;
  66826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66828. private _generateTBNSpace;
  66829. /**
  66830. * Gets the main code of the block (fragment side)
  66831. * @param state current state of the node material building
  66832. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66833. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66834. * @param worldPosVarName name of the variable holding the world position
  66835. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66836. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66837. * @param worldNormalVarName name of the variable holding the world normal
  66838. * @returns the shader code
  66839. */
  66840. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66841. protected _buildBlock(state: NodeMaterialBuildState): this;
  66842. }
  66843. }
  66844. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66848. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66850. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66851. import { Nullable } from "babylonjs/types";
  66852. /**
  66853. * Block used to implement the sub surface module of the PBR material
  66854. */
  66855. export class SubSurfaceBlock extends NodeMaterialBlock {
  66856. /**
  66857. * Create a new SubSurfaceBlock
  66858. * @param name defines the block name
  66859. */
  66860. constructor(name: string);
  66861. /**
  66862. * Stores the intensity of the different subsurface effects in the thickness texture.
  66863. * * the green channel is the translucency intensity.
  66864. * * the blue channel is the scattering intensity.
  66865. * * the alpha channel is the refraction intensity.
  66866. */
  66867. useMaskFromThicknessTexture: boolean;
  66868. /**
  66869. * Initialize the block and prepare the context for build
  66870. * @param state defines the state that will be used for the build
  66871. */
  66872. initialize(state: NodeMaterialBuildState): void;
  66873. /**
  66874. * Gets the current class name
  66875. * @returns the class name
  66876. */
  66877. getClassName(): string;
  66878. /**
  66879. * Gets the min thickness input component
  66880. */
  66881. get minThickness(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the max thickness input component
  66884. */
  66885. get maxThickness(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the thickness texture component
  66888. */
  66889. get thicknessTexture(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the tint color input component
  66892. */
  66893. get tintColor(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the translucency intensity input component
  66896. */
  66897. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the translucency diffusion distance input component
  66900. */
  66901. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the refraction object parameters
  66904. */
  66905. get refraction(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the sub surface object output component
  66908. */
  66909. get subsurface(): NodeMaterialConnectionPoint;
  66910. autoConfigure(material: NodeMaterial): void;
  66911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66912. /**
  66913. * Gets the main code of the block (fragment side)
  66914. * @param state current state of the node material building
  66915. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66916. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66917. * @param worldPosVarName name of the variable holding the world position
  66918. * @returns the shader code
  66919. */
  66920. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66921. protected _buildBlock(state: NodeMaterialBuildState): this;
  66922. }
  66923. }
  66924. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66928. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66929. import { Light } from "babylonjs/Lights/light";
  66930. import { Nullable } from "babylonjs/types";
  66931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66932. import { Effect } from "babylonjs/Materials/effect";
  66933. import { Mesh } from "babylonjs/Meshes/mesh";
  66934. import { Scene } from "babylonjs/scene";
  66935. /**
  66936. * Block used to implement the PBR metallic/roughness model
  66937. */
  66938. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66939. /**
  66940. * Gets or sets the light associated with this block
  66941. */
  66942. light: Nullable<Light>;
  66943. private _lightId;
  66944. private _scene;
  66945. private _environmentBRDFTexture;
  66946. private _environmentBrdfSamplerName;
  66947. private _vNormalWName;
  66948. private _invertNormalName;
  66949. /**
  66950. * Create a new ReflectionBlock
  66951. * @param name defines the block name
  66952. */
  66953. constructor(name: string);
  66954. /**
  66955. * Intensity of the direct lights e.g. the four lights available in your scene.
  66956. * This impacts both the direct diffuse and specular highlights.
  66957. */
  66958. directIntensity: number;
  66959. /**
  66960. * Intensity of the environment e.g. how much the environment will light the object
  66961. * either through harmonics for rough material or through the refelction for shiny ones.
  66962. */
  66963. environmentIntensity: number;
  66964. /**
  66965. * This is a special control allowing the reduction of the specular highlights coming from the
  66966. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66967. */
  66968. specularIntensity: number;
  66969. /**
  66970. * Defines the falloff type used in this material.
  66971. * It by default is Physical.
  66972. */
  66973. lightFalloff: number;
  66974. /**
  66975. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66976. */
  66977. useAlphaFromAlbedoTexture: boolean;
  66978. /**
  66979. * Specifies that alpha test should be used
  66980. */
  66981. useAlphaTest: boolean;
  66982. /**
  66983. * Defines the alpha limits in alpha test mode.
  66984. */
  66985. alphaTestCutoff: number;
  66986. /**
  66987. * Specifies that alpha blending should be used
  66988. */
  66989. useAlphaBlending: boolean;
  66990. /**
  66991. * Defines if the alpha value should be determined via the rgb values.
  66992. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66993. */
  66994. opacityRGB: boolean;
  66995. /**
  66996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66998. */
  66999. useRadianceOverAlpha: boolean;
  67000. /**
  67001. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67003. */
  67004. useSpecularOverAlpha: boolean;
  67005. /**
  67006. * Enables specular anti aliasing in the PBR shader.
  67007. * It will both interacts on the Geometry for analytical and IBL lighting.
  67008. * It also prefilter the roughness map based on the bump values.
  67009. */
  67010. enableSpecularAntiAliasing: boolean;
  67011. /**
  67012. * Enables realtime filtering on the texture.
  67013. */
  67014. realTimeFiltering: boolean;
  67015. /**
  67016. * Quality switch for realtime filtering
  67017. */
  67018. realTimeFilteringQuality: number;
  67019. /**
  67020. * Defines if the material uses energy conservation.
  67021. */
  67022. useEnergyConservation: boolean;
  67023. /**
  67024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67025. * too much the area relying on ambient texture to define their ambient occlusion.
  67026. */
  67027. useRadianceOcclusion: boolean;
  67028. /**
  67029. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67030. * makes the reflect vector face the model (under horizon).
  67031. */
  67032. useHorizonOcclusion: boolean;
  67033. /**
  67034. * If set to true, no lighting calculations will be applied.
  67035. */
  67036. unlit: boolean;
  67037. /**
  67038. * Force normal to face away from face.
  67039. */
  67040. forceNormalForward: boolean;
  67041. /**
  67042. * Defines the material debug mode.
  67043. * It helps seeing only some components of the material while troubleshooting.
  67044. */
  67045. debugMode: number;
  67046. /**
  67047. * Specify from where on screen the debug mode should start.
  67048. * The value goes from -1 (full screen) to 1 (not visible)
  67049. * It helps with side by side comparison against the final render
  67050. * This defaults to 0
  67051. */
  67052. debugLimit: number;
  67053. /**
  67054. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67055. * You can use the factor to better multiply the final value.
  67056. */
  67057. debugFactor: number;
  67058. /**
  67059. * Initialize the block and prepare the context for build
  67060. * @param state defines the state that will be used for the build
  67061. */
  67062. initialize(state: NodeMaterialBuildState): void;
  67063. /**
  67064. * Gets the current class name
  67065. * @returns the class name
  67066. */
  67067. getClassName(): string;
  67068. /**
  67069. * Gets the world position input component
  67070. */
  67071. get worldPosition(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the world normal input component
  67074. */
  67075. get worldNormal(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the perturbed normal input component
  67078. */
  67079. get perturbedNormal(): NodeMaterialConnectionPoint;
  67080. /**
  67081. * Gets the camera position input component
  67082. */
  67083. get cameraPosition(): NodeMaterialConnectionPoint;
  67084. /**
  67085. * Gets the base color input component
  67086. */
  67087. get baseColor(): NodeMaterialConnectionPoint;
  67088. /**
  67089. * Gets the opacity texture input component
  67090. */
  67091. get opacityTexture(): NodeMaterialConnectionPoint;
  67092. /**
  67093. * Gets the ambient color input component
  67094. */
  67095. get ambientColor(): NodeMaterialConnectionPoint;
  67096. /**
  67097. * Gets the reflectivity object parameters
  67098. */
  67099. get reflectivity(): NodeMaterialConnectionPoint;
  67100. /**
  67101. * Gets the ambient occlusion object parameters
  67102. */
  67103. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67104. /**
  67105. * Gets the reflection object parameters
  67106. */
  67107. get reflection(): NodeMaterialConnectionPoint;
  67108. /**
  67109. * Gets the sheen object parameters
  67110. */
  67111. get sheen(): NodeMaterialConnectionPoint;
  67112. /**
  67113. * Gets the clear coat object parameters
  67114. */
  67115. get clearcoat(): NodeMaterialConnectionPoint;
  67116. /**
  67117. * Gets the sub surface object parameters
  67118. */
  67119. get subsurface(): NodeMaterialConnectionPoint;
  67120. /**
  67121. * Gets the anisotropy object parameters
  67122. */
  67123. get anisotropy(): NodeMaterialConnectionPoint;
  67124. /**
  67125. * Gets the ambient output component
  67126. */
  67127. get ambient(): NodeMaterialConnectionPoint;
  67128. /**
  67129. * Gets the diffuse output component
  67130. */
  67131. get diffuse(): NodeMaterialConnectionPoint;
  67132. /**
  67133. * Gets the specular output component
  67134. */
  67135. get specular(): NodeMaterialConnectionPoint;
  67136. /**
  67137. * Gets the sheen output component
  67138. */
  67139. get sheenDir(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the clear coat output component
  67142. */
  67143. get clearcoatDir(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the indirect diffuse output component
  67146. */
  67147. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the indirect specular output component
  67150. */
  67151. get specularIndirect(): NodeMaterialConnectionPoint;
  67152. /**
  67153. * Gets the indirect sheen output component
  67154. */
  67155. get sheenIndirect(): NodeMaterialConnectionPoint;
  67156. /**
  67157. * Gets the indirect clear coat output component
  67158. */
  67159. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67160. /**
  67161. * Gets the refraction output component
  67162. */
  67163. get refraction(): NodeMaterialConnectionPoint;
  67164. /**
  67165. * Gets the global lighting output component
  67166. */
  67167. get lighting(): NodeMaterialConnectionPoint;
  67168. /**
  67169. * Gets the shadow output component
  67170. */
  67171. get shadow(): NodeMaterialConnectionPoint;
  67172. /**
  67173. * Gets the alpha output component
  67174. */
  67175. get alpha(): NodeMaterialConnectionPoint;
  67176. autoConfigure(material: NodeMaterial): void;
  67177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67178. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67180. private _injectVertexCode;
  67181. /**
  67182. * Gets the code corresponding to the albedo/opacity module
  67183. * @returns the shader code
  67184. */
  67185. getAlbedoOpacityCode(): string;
  67186. protected _buildBlock(state: NodeMaterialBuildState): this;
  67187. protected _dumpPropertiesCode(): string;
  67188. serialize(): any;
  67189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67190. }
  67191. }
  67192. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67193. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67194. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67199. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67200. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67201. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67202. }
  67203. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67204. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67205. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67206. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67207. }
  67208. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67212. /**
  67213. * Block used to compute value of one parameter modulo another
  67214. */
  67215. export class ModBlock extends NodeMaterialBlock {
  67216. /**
  67217. * Creates a new ModBlock
  67218. * @param name defines the block name
  67219. */
  67220. constructor(name: string);
  67221. /**
  67222. * Gets the current class name
  67223. * @returns the class name
  67224. */
  67225. getClassName(): string;
  67226. /**
  67227. * Gets the left operand input component
  67228. */
  67229. get left(): NodeMaterialConnectionPoint;
  67230. /**
  67231. * Gets the right operand input component
  67232. */
  67233. get right(): NodeMaterialConnectionPoint;
  67234. /**
  67235. * Gets the output component
  67236. */
  67237. get output(): NodeMaterialConnectionPoint;
  67238. protected _buildBlock(state: NodeMaterialBuildState): this;
  67239. }
  67240. }
  67241. declare module "babylonjs/Materials/Node/Blocks/index" {
  67242. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67243. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67244. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67245. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67246. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67247. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67248. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67249. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67251. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67252. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67253. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67254. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67255. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67256. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67257. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67258. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67259. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67260. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67261. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67262. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67263. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67264. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67265. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67266. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67267. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67268. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67271. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67272. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67275. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67276. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67277. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67278. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67279. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67280. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67281. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67282. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67283. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67284. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67285. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67286. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67287. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67288. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67289. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67290. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67291. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67292. }
  67293. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67294. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67295. }
  67296. declare module "babylonjs/Materials/Node/index" {
  67297. export * from "babylonjs/Materials/Node/Enums/index";
  67298. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67299. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67300. export * from "babylonjs/Materials/Node/nodeMaterial";
  67301. export * from "babylonjs/Materials/Node/Blocks/index";
  67302. export * from "babylonjs/Materials/Node/Optimizers/index";
  67303. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67304. }
  67305. declare module "babylonjs/Materials/index" {
  67306. export * from "babylonjs/Materials/Background/index";
  67307. export * from "babylonjs/Materials/colorCurves";
  67308. export * from "babylonjs/Materials/iEffectFallbacks";
  67309. export * from "babylonjs/Materials/effectFallbacks";
  67310. export * from "babylonjs/Materials/effect";
  67311. export * from "babylonjs/Materials/fresnelParameters";
  67312. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67313. export * from "babylonjs/Materials/material";
  67314. export * from "babylonjs/Materials/materialDefines";
  67315. export * from "babylonjs/Materials/materialHelper";
  67316. export * from "babylonjs/Materials/multiMaterial";
  67317. export * from "babylonjs/Materials/PBR/index";
  67318. export * from "babylonjs/Materials/pushMaterial";
  67319. export * from "babylonjs/Materials/shaderMaterial";
  67320. export * from "babylonjs/Materials/standardMaterial";
  67321. export * from "babylonjs/Materials/Textures/index";
  67322. export * from "babylonjs/Materials/uniformBuffer";
  67323. export * from "babylonjs/Materials/materialFlags";
  67324. export * from "babylonjs/Materials/Node/index";
  67325. export * from "babylonjs/Materials/effectRenderer";
  67326. export * from "babylonjs/Materials/shadowDepthWrapper";
  67327. }
  67328. declare module "babylonjs/Maths/index" {
  67329. export * from "babylonjs/Maths/math.scalar";
  67330. export * from "babylonjs/Maths/math";
  67331. export * from "babylonjs/Maths/sphericalPolynomial";
  67332. }
  67333. declare module "babylonjs/Misc/workerPool" {
  67334. import { IDisposable } from "babylonjs/scene";
  67335. /**
  67336. * Helper class to push actions to a pool of workers.
  67337. */
  67338. export class WorkerPool implements IDisposable {
  67339. private _workerInfos;
  67340. private _pendingActions;
  67341. /**
  67342. * Constructor
  67343. * @param workers Array of workers to use for actions
  67344. */
  67345. constructor(workers: Array<Worker>);
  67346. /**
  67347. * Terminates all workers and clears any pending actions.
  67348. */
  67349. dispose(): void;
  67350. /**
  67351. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67352. * pended until a worker has completed its action.
  67353. * @param action The action to perform. Call onComplete when the action is complete.
  67354. */
  67355. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67356. private _execute;
  67357. }
  67358. }
  67359. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67360. import { IDisposable } from "babylonjs/scene";
  67361. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67362. /**
  67363. * Configuration for Draco compression
  67364. */
  67365. export interface IDracoCompressionConfiguration {
  67366. /**
  67367. * Configuration for the decoder.
  67368. */
  67369. decoder: {
  67370. /**
  67371. * The url to the WebAssembly module.
  67372. */
  67373. wasmUrl?: string;
  67374. /**
  67375. * The url to the WebAssembly binary.
  67376. */
  67377. wasmBinaryUrl?: string;
  67378. /**
  67379. * The url to the fallback JavaScript module.
  67380. */
  67381. fallbackUrl?: string;
  67382. };
  67383. }
  67384. /**
  67385. * Draco compression (https://google.github.io/draco/)
  67386. *
  67387. * This class wraps the Draco module.
  67388. *
  67389. * **Encoder**
  67390. *
  67391. * The encoder is not currently implemented.
  67392. *
  67393. * **Decoder**
  67394. *
  67395. * 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.
  67396. *
  67397. * To update the configuration, use the following code:
  67398. * ```javascript
  67399. * DracoCompression.Configuration = {
  67400. * decoder: {
  67401. * wasmUrl: "<url to the WebAssembly library>",
  67402. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67403. * fallbackUrl: "<url to the fallback JavaScript library>",
  67404. * }
  67405. * };
  67406. * ```
  67407. *
  67408. * 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.
  67409. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67410. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67411. *
  67412. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67413. * ```javascript
  67414. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67415. * ```
  67416. *
  67417. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67418. */
  67419. export class DracoCompression implements IDisposable {
  67420. private _workerPoolPromise?;
  67421. private _decoderModulePromise?;
  67422. /**
  67423. * The configuration. Defaults to the following urls:
  67424. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67425. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67426. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67427. */
  67428. static Configuration: IDracoCompressionConfiguration;
  67429. /**
  67430. * Returns true if the decoder configuration is available.
  67431. */
  67432. static get DecoderAvailable(): boolean;
  67433. /**
  67434. * Default number of workers to create when creating the draco compression object.
  67435. */
  67436. static DefaultNumWorkers: number;
  67437. private static GetDefaultNumWorkers;
  67438. private static _Default;
  67439. /**
  67440. * Default instance for the draco compression object.
  67441. */
  67442. static get Default(): DracoCompression;
  67443. /**
  67444. * Constructor
  67445. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67446. */
  67447. constructor(numWorkers?: number);
  67448. /**
  67449. * Stop all async operations and release resources.
  67450. */
  67451. dispose(): void;
  67452. /**
  67453. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67454. * @returns a promise that resolves when ready
  67455. */
  67456. whenReadyAsync(): Promise<void>;
  67457. /**
  67458. * Decode Draco compressed mesh data to vertex data.
  67459. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67460. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67461. * @returns A promise that resolves with the decoded vertex data
  67462. */
  67463. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67464. [kind: string]: number;
  67465. }): Promise<VertexData>;
  67466. }
  67467. }
  67468. declare module "babylonjs/Meshes/Compression/index" {
  67469. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67470. }
  67471. declare module "babylonjs/Meshes/csg" {
  67472. import { Nullable } from "babylonjs/types";
  67473. import { Scene } from "babylonjs/scene";
  67474. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67475. import { Mesh } from "babylonjs/Meshes/mesh";
  67476. import { Material } from "babylonjs/Materials/material";
  67477. /**
  67478. * Class for building Constructive Solid Geometry
  67479. */
  67480. export class CSG {
  67481. private polygons;
  67482. /**
  67483. * The world matrix
  67484. */
  67485. matrix: Matrix;
  67486. /**
  67487. * Stores the position
  67488. */
  67489. position: Vector3;
  67490. /**
  67491. * Stores the rotation
  67492. */
  67493. rotation: Vector3;
  67494. /**
  67495. * Stores the rotation quaternion
  67496. */
  67497. rotationQuaternion: Nullable<Quaternion>;
  67498. /**
  67499. * Stores the scaling vector
  67500. */
  67501. scaling: Vector3;
  67502. /**
  67503. * Convert the Mesh to CSG
  67504. * @param mesh The Mesh to convert to CSG
  67505. * @returns A new CSG from the Mesh
  67506. */
  67507. static FromMesh(mesh: Mesh): CSG;
  67508. /**
  67509. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67510. * @param polygons Polygons used to construct a CSG solid
  67511. */
  67512. private static FromPolygons;
  67513. /**
  67514. * Clones, or makes a deep copy, of the CSG
  67515. * @returns A new CSG
  67516. */
  67517. clone(): CSG;
  67518. /**
  67519. * Unions this CSG with another CSG
  67520. * @param csg The CSG to union against this CSG
  67521. * @returns The unioned CSG
  67522. */
  67523. union(csg: CSG): CSG;
  67524. /**
  67525. * Unions this CSG with another CSG in place
  67526. * @param csg The CSG to union against this CSG
  67527. */
  67528. unionInPlace(csg: CSG): void;
  67529. /**
  67530. * Subtracts this CSG with another CSG
  67531. * @param csg The CSG to subtract against this CSG
  67532. * @returns A new CSG
  67533. */
  67534. subtract(csg: CSG): CSG;
  67535. /**
  67536. * Subtracts this CSG with another CSG in place
  67537. * @param csg The CSG to subtact against this CSG
  67538. */
  67539. subtractInPlace(csg: CSG): void;
  67540. /**
  67541. * Intersect this CSG with another CSG
  67542. * @param csg The CSG to intersect against this CSG
  67543. * @returns A new CSG
  67544. */
  67545. intersect(csg: CSG): CSG;
  67546. /**
  67547. * Intersects this CSG with another CSG in place
  67548. * @param csg The CSG to intersect against this CSG
  67549. */
  67550. intersectInPlace(csg: CSG): void;
  67551. /**
  67552. * Return a new CSG solid with solid and empty space switched. This solid is
  67553. * not modified.
  67554. * @returns A new CSG solid with solid and empty space switched
  67555. */
  67556. inverse(): CSG;
  67557. /**
  67558. * Inverses the CSG in place
  67559. */
  67560. inverseInPlace(): void;
  67561. /**
  67562. * This is used to keep meshes transformations so they can be restored
  67563. * when we build back a Babylon Mesh
  67564. * NB : All CSG operations are performed in world coordinates
  67565. * @param csg The CSG to copy the transform attributes from
  67566. * @returns This CSG
  67567. */
  67568. copyTransformAttributes(csg: CSG): CSG;
  67569. /**
  67570. * Build Raw mesh from CSG
  67571. * Coordinates here are in world space
  67572. * @param name The name of the mesh geometry
  67573. * @param scene The Scene
  67574. * @param keepSubMeshes Specifies if the submeshes should be kept
  67575. * @returns A new Mesh
  67576. */
  67577. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67578. /**
  67579. * Build Mesh from CSG taking material and transforms into account
  67580. * @param name The name of the Mesh
  67581. * @param material The material of the Mesh
  67582. * @param scene The Scene
  67583. * @param keepSubMeshes Specifies if submeshes should be kept
  67584. * @returns The new Mesh
  67585. */
  67586. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67587. }
  67588. }
  67589. declare module "babylonjs/Meshes/trailMesh" {
  67590. import { Mesh } from "babylonjs/Meshes/mesh";
  67591. import { Scene } from "babylonjs/scene";
  67592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67593. /**
  67594. * Class used to create a trail following a mesh
  67595. */
  67596. export class TrailMesh extends Mesh {
  67597. private _generator;
  67598. private _autoStart;
  67599. private _running;
  67600. private _diameter;
  67601. private _length;
  67602. private _sectionPolygonPointsCount;
  67603. private _sectionVectors;
  67604. private _sectionNormalVectors;
  67605. private _beforeRenderObserver;
  67606. /**
  67607. * @constructor
  67608. * @param name The value used by scene.getMeshByName() to do a lookup.
  67609. * @param generator The mesh or transform node to generate a trail.
  67610. * @param scene The scene to add this mesh to.
  67611. * @param diameter Diameter of trailing mesh. Default is 1.
  67612. * @param length Length of trailing mesh. Default is 60.
  67613. * @param autoStart Automatically start trailing mesh. Default true.
  67614. */
  67615. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67616. /**
  67617. * "TrailMesh"
  67618. * @returns "TrailMesh"
  67619. */
  67620. getClassName(): string;
  67621. private _createMesh;
  67622. /**
  67623. * Start trailing mesh.
  67624. */
  67625. start(): void;
  67626. /**
  67627. * Stop trailing mesh.
  67628. */
  67629. stop(): void;
  67630. /**
  67631. * Update trailing mesh geometry.
  67632. */
  67633. update(): void;
  67634. /**
  67635. * Returns a new TrailMesh object.
  67636. * @param name is a string, the name given to the new mesh
  67637. * @param newGenerator use new generator object for cloned trail mesh
  67638. * @returns a new mesh
  67639. */
  67640. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67641. /**
  67642. * Serializes this trail mesh
  67643. * @param serializationObject object to write serialization to
  67644. */
  67645. serialize(serializationObject: any): void;
  67646. /**
  67647. * Parses a serialized trail mesh
  67648. * @param parsedMesh the serialized mesh
  67649. * @param scene the scene to create the trail mesh in
  67650. * @returns the created trail mesh
  67651. */
  67652. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67653. }
  67654. }
  67655. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67656. import { Nullable } from "babylonjs/types";
  67657. import { Scene } from "babylonjs/scene";
  67658. import { Vector4 } from "babylonjs/Maths/math.vector";
  67659. import { Color4 } from "babylonjs/Maths/math.color";
  67660. import { Mesh } from "babylonjs/Meshes/mesh";
  67661. /**
  67662. * Class containing static functions to help procedurally build meshes
  67663. */
  67664. export class TiledBoxBuilder {
  67665. /**
  67666. * Creates a box mesh
  67667. * 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)
  67668. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67670. * * 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
  67671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67672. * @param name defines the name of the mesh
  67673. * @param options defines the options used to create the mesh
  67674. * @param scene defines the hosting scene
  67675. * @returns the box mesh
  67676. */
  67677. static CreateTiledBox(name: string, options: {
  67678. pattern?: number;
  67679. width?: number;
  67680. height?: number;
  67681. depth?: number;
  67682. tileSize?: number;
  67683. tileWidth?: number;
  67684. tileHeight?: number;
  67685. alignHorizontal?: number;
  67686. alignVertical?: number;
  67687. faceUV?: Vector4[];
  67688. faceColors?: Color4[];
  67689. sideOrientation?: number;
  67690. updatable?: boolean;
  67691. }, scene?: Nullable<Scene>): Mesh;
  67692. }
  67693. }
  67694. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67695. import { Vector4 } from "babylonjs/Maths/math.vector";
  67696. import { Mesh } from "babylonjs/Meshes/mesh";
  67697. /**
  67698. * Class containing static functions to help procedurally build meshes
  67699. */
  67700. export class TorusKnotBuilder {
  67701. /**
  67702. * Creates a torus knot mesh
  67703. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67704. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67705. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67706. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67708. * * 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
  67709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67710. * @param name defines the name of the mesh
  67711. * @param options defines the options used to create the mesh
  67712. * @param scene defines the hosting scene
  67713. * @returns the torus knot mesh
  67714. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67715. */
  67716. static CreateTorusKnot(name: string, options: {
  67717. radius?: number;
  67718. tube?: number;
  67719. radialSegments?: number;
  67720. tubularSegments?: number;
  67721. p?: number;
  67722. q?: number;
  67723. updatable?: boolean;
  67724. sideOrientation?: number;
  67725. frontUVs?: Vector4;
  67726. backUVs?: Vector4;
  67727. }, scene: any): Mesh;
  67728. }
  67729. }
  67730. declare module "babylonjs/Meshes/polygonMesh" {
  67731. import { Scene } from "babylonjs/scene";
  67732. import { Vector2 } from "babylonjs/Maths/math.vector";
  67733. import { Mesh } from "babylonjs/Meshes/mesh";
  67734. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67735. import { Path2 } from "babylonjs/Maths/math.path";
  67736. /**
  67737. * Polygon
  67738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67739. */
  67740. export class Polygon {
  67741. /**
  67742. * Creates a rectangle
  67743. * @param xmin bottom X coord
  67744. * @param ymin bottom Y coord
  67745. * @param xmax top X coord
  67746. * @param ymax top Y coord
  67747. * @returns points that make the resulting rectation
  67748. */
  67749. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67750. /**
  67751. * Creates a circle
  67752. * @param radius radius of circle
  67753. * @param cx scale in x
  67754. * @param cy scale in y
  67755. * @param numberOfSides number of sides that make up the circle
  67756. * @returns points that make the resulting circle
  67757. */
  67758. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67759. /**
  67760. * Creates a polygon from input string
  67761. * @param input Input polygon data
  67762. * @returns the parsed points
  67763. */
  67764. static Parse(input: string): Vector2[];
  67765. /**
  67766. * Starts building a polygon from x and y coordinates
  67767. * @param x x coordinate
  67768. * @param y y coordinate
  67769. * @returns the started path2
  67770. */
  67771. static StartingAt(x: number, y: number): Path2;
  67772. }
  67773. /**
  67774. * Builds a polygon
  67775. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67776. */
  67777. export class PolygonMeshBuilder {
  67778. private _points;
  67779. private _outlinepoints;
  67780. private _holes;
  67781. private _name;
  67782. private _scene;
  67783. private _epoints;
  67784. private _eholes;
  67785. private _addToepoint;
  67786. /**
  67787. * Babylon reference to the earcut plugin.
  67788. */
  67789. bjsEarcut: any;
  67790. /**
  67791. * Creates a PolygonMeshBuilder
  67792. * @param name name of the builder
  67793. * @param contours Path of the polygon
  67794. * @param scene scene to add to when creating the mesh
  67795. * @param earcutInjection can be used to inject your own earcut reference
  67796. */
  67797. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67798. /**
  67799. * Adds a whole within the polygon
  67800. * @param hole Array of points defining the hole
  67801. * @returns this
  67802. */
  67803. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67804. /**
  67805. * Creates the polygon
  67806. * @param updatable If the mesh should be updatable
  67807. * @param depth The depth of the mesh created
  67808. * @returns the created mesh
  67809. */
  67810. build(updatable?: boolean, depth?: number): Mesh;
  67811. /**
  67812. * Creates the polygon
  67813. * @param depth The depth of the mesh created
  67814. * @returns the created VertexData
  67815. */
  67816. buildVertexData(depth?: number): VertexData;
  67817. /**
  67818. * Adds a side to the polygon
  67819. * @param positions points that make the polygon
  67820. * @param normals normals of the polygon
  67821. * @param uvs uvs of the polygon
  67822. * @param indices indices of the polygon
  67823. * @param bounds bounds of the polygon
  67824. * @param points points of the polygon
  67825. * @param depth depth of the polygon
  67826. * @param flip flip of the polygon
  67827. */
  67828. private addSide;
  67829. }
  67830. }
  67831. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67832. import { Scene } from "babylonjs/scene";
  67833. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67834. import { Color4 } from "babylonjs/Maths/math.color";
  67835. import { Mesh } from "babylonjs/Meshes/mesh";
  67836. import { Nullable } from "babylonjs/types";
  67837. /**
  67838. * Class containing static functions to help procedurally build meshes
  67839. */
  67840. export class PolygonBuilder {
  67841. /**
  67842. * Creates a polygon mesh
  67843. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67844. * * 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
  67845. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67847. * * 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)
  67848. * * Remember you can only change the shape positions, not their number when updating a polygon
  67849. * @param name defines the name of the mesh
  67850. * @param options defines the options used to create the mesh
  67851. * @param scene defines the hosting scene
  67852. * @param earcutInjection can be used to inject your own earcut reference
  67853. * @returns the polygon mesh
  67854. */
  67855. static CreatePolygon(name: string, options: {
  67856. shape: Vector3[];
  67857. holes?: Vector3[][];
  67858. depth?: number;
  67859. faceUV?: Vector4[];
  67860. faceColors?: Color4[];
  67861. updatable?: boolean;
  67862. sideOrientation?: number;
  67863. frontUVs?: Vector4;
  67864. backUVs?: Vector4;
  67865. wrap?: boolean;
  67866. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67867. /**
  67868. * Creates an extruded polygon mesh, with depth in the Y direction.
  67869. * * 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)
  67870. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67871. * @param name defines the name of the mesh
  67872. * @param options defines the options used to create the mesh
  67873. * @param scene defines the hosting scene
  67874. * @param earcutInjection can be used to inject your own earcut reference
  67875. * @returns the polygon mesh
  67876. */
  67877. static ExtrudePolygon(name: string, options: {
  67878. shape: Vector3[];
  67879. holes?: Vector3[][];
  67880. depth?: number;
  67881. faceUV?: Vector4[];
  67882. faceColors?: Color4[];
  67883. updatable?: boolean;
  67884. sideOrientation?: number;
  67885. frontUVs?: Vector4;
  67886. backUVs?: Vector4;
  67887. wrap?: boolean;
  67888. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67889. }
  67890. }
  67891. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67892. import { Scene } from "babylonjs/scene";
  67893. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67894. import { Mesh } from "babylonjs/Meshes/mesh";
  67895. import { Nullable } from "babylonjs/types";
  67896. /**
  67897. * Class containing static functions to help procedurally build meshes
  67898. */
  67899. export class LatheBuilder {
  67900. /**
  67901. * Creates lathe mesh.
  67902. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67903. * * 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
  67904. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67905. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67906. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67907. * * 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
  67908. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67909. * * 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
  67910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67911. * * 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
  67912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67914. * @param name defines the name of the mesh
  67915. * @param options defines the options used to create the mesh
  67916. * @param scene defines the hosting scene
  67917. * @returns the lathe mesh
  67918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67919. */
  67920. static CreateLathe(name: string, options: {
  67921. shape: Vector3[];
  67922. radius?: number;
  67923. tessellation?: number;
  67924. clip?: number;
  67925. arc?: number;
  67926. closed?: boolean;
  67927. updatable?: boolean;
  67928. sideOrientation?: number;
  67929. frontUVs?: Vector4;
  67930. backUVs?: Vector4;
  67931. cap?: number;
  67932. invertUV?: boolean;
  67933. }, scene?: Nullable<Scene>): Mesh;
  67934. }
  67935. }
  67936. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67937. import { Nullable } from "babylonjs/types";
  67938. import { Scene } from "babylonjs/scene";
  67939. import { Vector4 } from "babylonjs/Maths/math.vector";
  67940. import { Mesh } from "babylonjs/Meshes/mesh";
  67941. /**
  67942. * Class containing static functions to help procedurally build meshes
  67943. */
  67944. export class TiledPlaneBuilder {
  67945. /**
  67946. * Creates a tiled plane mesh
  67947. * * The parameter `pattern` will, depending on value, do nothing or
  67948. * * * flip (reflect about central vertical) alternate tiles across and up
  67949. * * * flip every tile on alternate rows
  67950. * * * rotate (180 degs) alternate tiles across and up
  67951. * * * rotate every tile on alternate rows
  67952. * * * flip and rotate alternate tiles across and up
  67953. * * * flip and rotate every tile on alternate rows
  67954. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67955. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67956. * * 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
  67957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67958. * * 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)
  67959. * * 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)
  67960. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67961. * @param name defines the name of the mesh
  67962. * @param options defines the options used to create the mesh
  67963. * @param scene defines the hosting scene
  67964. * @returns the box mesh
  67965. */
  67966. static CreateTiledPlane(name: string, options: {
  67967. pattern?: number;
  67968. tileSize?: number;
  67969. tileWidth?: number;
  67970. tileHeight?: number;
  67971. size?: number;
  67972. width?: number;
  67973. height?: number;
  67974. alignHorizontal?: number;
  67975. alignVertical?: number;
  67976. sideOrientation?: number;
  67977. frontUVs?: Vector4;
  67978. backUVs?: Vector4;
  67979. updatable?: boolean;
  67980. }, scene?: Nullable<Scene>): Mesh;
  67981. }
  67982. }
  67983. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67984. import { Nullable } from "babylonjs/types";
  67985. import { Scene } from "babylonjs/scene";
  67986. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67987. import { Mesh } from "babylonjs/Meshes/mesh";
  67988. /**
  67989. * Class containing static functions to help procedurally build meshes
  67990. */
  67991. export class TubeBuilder {
  67992. /**
  67993. * Creates a tube mesh.
  67994. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67995. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67996. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67997. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67998. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67999. * * 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)
  68000. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68001. * * 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
  68002. * * 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
  68003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68004. * * 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
  68005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68007. * @param name defines the name of the mesh
  68008. * @param options defines the options used to create the mesh
  68009. * @param scene defines the hosting scene
  68010. * @returns the tube mesh
  68011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68012. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68013. */
  68014. static CreateTube(name: string, options: {
  68015. path: Vector3[];
  68016. radius?: number;
  68017. tessellation?: number;
  68018. radiusFunction?: {
  68019. (i: number, distance: number): number;
  68020. };
  68021. cap?: number;
  68022. arc?: number;
  68023. updatable?: boolean;
  68024. sideOrientation?: number;
  68025. frontUVs?: Vector4;
  68026. backUVs?: Vector4;
  68027. instance?: Mesh;
  68028. invertUV?: boolean;
  68029. }, scene?: Nullable<Scene>): Mesh;
  68030. }
  68031. }
  68032. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68033. import { Scene } from "babylonjs/scene";
  68034. import { Vector4 } from "babylonjs/Maths/math.vector";
  68035. import { Mesh } from "babylonjs/Meshes/mesh";
  68036. import { Nullable } from "babylonjs/types";
  68037. /**
  68038. * Class containing static functions to help procedurally build meshes
  68039. */
  68040. export class IcoSphereBuilder {
  68041. /**
  68042. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68043. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68044. * * 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`)
  68045. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68046. * * 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
  68047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68048. * * 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
  68049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68050. * @param name defines the name of the mesh
  68051. * @param options defines the options used to create the mesh
  68052. * @param scene defines the hosting scene
  68053. * @returns the icosahedron mesh
  68054. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68055. */
  68056. static CreateIcoSphere(name: string, options: {
  68057. radius?: number;
  68058. radiusX?: number;
  68059. radiusY?: number;
  68060. radiusZ?: number;
  68061. flat?: boolean;
  68062. subdivisions?: number;
  68063. sideOrientation?: number;
  68064. frontUVs?: Vector4;
  68065. backUVs?: Vector4;
  68066. updatable?: boolean;
  68067. }, scene?: Nullable<Scene>): Mesh;
  68068. }
  68069. }
  68070. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68071. import { Vector3 } from "babylonjs/Maths/math.vector";
  68072. import { Mesh } from "babylonjs/Meshes/mesh";
  68073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68074. /**
  68075. * Class containing static functions to help procedurally build meshes
  68076. */
  68077. export class DecalBuilder {
  68078. /**
  68079. * Creates a decal mesh.
  68080. * 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
  68081. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68082. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68083. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68084. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68085. * @param name defines the name of the mesh
  68086. * @param sourceMesh defines the mesh where the decal must be applied
  68087. * @param options defines the options used to create the mesh
  68088. * @param scene defines the hosting scene
  68089. * @returns the decal mesh
  68090. * @see https://doc.babylonjs.com/how_to/decals
  68091. */
  68092. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68093. position?: Vector3;
  68094. normal?: Vector3;
  68095. size?: Vector3;
  68096. angle?: number;
  68097. }): Mesh;
  68098. }
  68099. }
  68100. declare module "babylonjs/Meshes/meshBuilder" {
  68101. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68102. import { Nullable } from "babylonjs/types";
  68103. import { Scene } from "babylonjs/scene";
  68104. import { Mesh } from "babylonjs/Meshes/mesh";
  68105. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68106. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68108. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68109. import { Plane } from "babylonjs/Maths/math.plane";
  68110. /**
  68111. * Class containing static functions to help procedurally build meshes
  68112. */
  68113. export class MeshBuilder {
  68114. /**
  68115. * Creates a box mesh
  68116. * * The parameter `size` sets the size (float) of each box side (default 1)
  68117. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68118. * * 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)
  68119. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68121. * * 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
  68122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68123. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68124. * @param name defines the name of the mesh
  68125. * @param options defines the options used to create the mesh
  68126. * @param scene defines the hosting scene
  68127. * @returns the box mesh
  68128. */
  68129. static CreateBox(name: string, options: {
  68130. size?: number;
  68131. width?: number;
  68132. height?: number;
  68133. depth?: number;
  68134. faceUV?: Vector4[];
  68135. faceColors?: Color4[];
  68136. sideOrientation?: number;
  68137. frontUVs?: Vector4;
  68138. backUVs?: Vector4;
  68139. wrap?: boolean;
  68140. topBaseAt?: number;
  68141. bottomBaseAt?: number;
  68142. updatable?: boolean;
  68143. }, scene?: Nullable<Scene>): Mesh;
  68144. /**
  68145. * Creates a tiled box mesh
  68146. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68148. * @param name defines the name of the mesh
  68149. * @param options defines the options used to create the mesh
  68150. * @param scene defines the hosting scene
  68151. * @returns the tiled box mesh
  68152. */
  68153. static CreateTiledBox(name: string, options: {
  68154. pattern?: number;
  68155. size?: number;
  68156. width?: number;
  68157. height?: number;
  68158. depth: number;
  68159. tileSize?: number;
  68160. tileWidth?: number;
  68161. tileHeight?: number;
  68162. faceUV?: Vector4[];
  68163. faceColors?: Color4[];
  68164. alignHorizontal?: number;
  68165. alignVertical?: number;
  68166. sideOrientation?: number;
  68167. updatable?: boolean;
  68168. }, scene?: Nullable<Scene>): Mesh;
  68169. /**
  68170. * Creates a sphere mesh
  68171. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68172. * * 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`)
  68173. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68174. * * 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
  68175. * * 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)
  68176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68177. * * 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
  68178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68179. * @param name defines the name of the mesh
  68180. * @param options defines the options used to create the mesh
  68181. * @param scene defines the hosting scene
  68182. * @returns the sphere mesh
  68183. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68184. */
  68185. static CreateSphere(name: string, options: {
  68186. segments?: number;
  68187. diameter?: number;
  68188. diameterX?: number;
  68189. diameterY?: number;
  68190. diameterZ?: number;
  68191. arc?: number;
  68192. slice?: number;
  68193. sideOrientation?: number;
  68194. frontUVs?: Vector4;
  68195. backUVs?: Vector4;
  68196. updatable?: boolean;
  68197. }, scene?: Nullable<Scene>): Mesh;
  68198. /**
  68199. * Creates a plane polygonal mesh. By default, this is a disc
  68200. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68201. * * 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
  68202. * * 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
  68203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68204. * * 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
  68205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68206. * @param name defines the name of the mesh
  68207. * @param options defines the options used to create the mesh
  68208. * @param scene defines the hosting scene
  68209. * @returns the plane polygonal mesh
  68210. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68211. */
  68212. static CreateDisc(name: string, options: {
  68213. radius?: number;
  68214. tessellation?: number;
  68215. arc?: number;
  68216. updatable?: boolean;
  68217. sideOrientation?: number;
  68218. frontUVs?: Vector4;
  68219. backUVs?: Vector4;
  68220. }, scene?: Nullable<Scene>): Mesh;
  68221. /**
  68222. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68223. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68224. * * 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`)
  68225. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68226. * * 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
  68227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68228. * * 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
  68229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68230. * @param name defines the name of the mesh
  68231. * @param options defines the options used to create the mesh
  68232. * @param scene defines the hosting scene
  68233. * @returns the icosahedron mesh
  68234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68235. */
  68236. static CreateIcoSphere(name: string, options: {
  68237. radius?: number;
  68238. radiusX?: number;
  68239. radiusY?: number;
  68240. radiusZ?: number;
  68241. flat?: boolean;
  68242. subdivisions?: number;
  68243. sideOrientation?: number;
  68244. frontUVs?: Vector4;
  68245. backUVs?: Vector4;
  68246. updatable?: boolean;
  68247. }, scene?: Nullable<Scene>): Mesh;
  68248. /**
  68249. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68250. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68251. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68252. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68253. * * 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
  68254. * * 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
  68255. * * 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
  68256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68257. * * 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
  68258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68259. * * 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
  68260. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68261. * * 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
  68262. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68264. * @param name defines the name of the mesh
  68265. * @param options defines the options used to create the mesh
  68266. * @param scene defines the hosting scene
  68267. * @returns the ribbon mesh
  68268. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68269. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68270. */
  68271. static CreateRibbon(name: string, options: {
  68272. pathArray: Vector3[][];
  68273. closeArray?: boolean;
  68274. closePath?: boolean;
  68275. offset?: number;
  68276. updatable?: boolean;
  68277. sideOrientation?: number;
  68278. frontUVs?: Vector4;
  68279. backUVs?: Vector4;
  68280. instance?: Mesh;
  68281. invertUV?: boolean;
  68282. uvs?: Vector2[];
  68283. colors?: Color4[];
  68284. }, scene?: Nullable<Scene>): Mesh;
  68285. /**
  68286. * Creates a cylinder or a cone mesh
  68287. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68288. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68289. * * 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.
  68290. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68291. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68292. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68293. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68294. * * 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).
  68295. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68296. * * 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).
  68297. * * 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
  68298. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68299. * * 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
  68300. * * 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.
  68301. * * If `enclose` is false, a ring surface is one element.
  68302. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68303. * * 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
  68304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68305. * * 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
  68306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68307. * @param name defines the name of the mesh
  68308. * @param options defines the options used to create the mesh
  68309. * @param scene defines the hosting scene
  68310. * @returns the cylinder mesh
  68311. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68312. */
  68313. static CreateCylinder(name: string, options: {
  68314. height?: number;
  68315. diameterTop?: number;
  68316. diameterBottom?: number;
  68317. diameter?: number;
  68318. tessellation?: number;
  68319. subdivisions?: number;
  68320. arc?: number;
  68321. faceColors?: Color4[];
  68322. faceUV?: Vector4[];
  68323. updatable?: boolean;
  68324. hasRings?: boolean;
  68325. enclose?: boolean;
  68326. cap?: number;
  68327. sideOrientation?: number;
  68328. frontUVs?: Vector4;
  68329. backUVs?: Vector4;
  68330. }, scene?: Nullable<Scene>): Mesh;
  68331. /**
  68332. * Creates a torus mesh
  68333. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68334. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68335. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68337. * * 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
  68338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68339. * @param name defines the name of the mesh
  68340. * @param options defines the options used to create the mesh
  68341. * @param scene defines the hosting scene
  68342. * @returns the torus mesh
  68343. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68344. */
  68345. static CreateTorus(name: string, options: {
  68346. diameter?: number;
  68347. thickness?: number;
  68348. tessellation?: number;
  68349. updatable?: boolean;
  68350. sideOrientation?: number;
  68351. frontUVs?: Vector4;
  68352. backUVs?: Vector4;
  68353. }, scene?: Nullable<Scene>): Mesh;
  68354. /**
  68355. * Creates a torus knot mesh
  68356. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68357. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68358. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68359. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68361. * * 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
  68362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68363. * @param name defines the name of the mesh
  68364. * @param options defines the options used to create the mesh
  68365. * @param scene defines the hosting scene
  68366. * @returns the torus knot mesh
  68367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68368. */
  68369. static CreateTorusKnot(name: string, options: {
  68370. radius?: number;
  68371. tube?: number;
  68372. radialSegments?: number;
  68373. tubularSegments?: number;
  68374. p?: number;
  68375. q?: number;
  68376. updatable?: boolean;
  68377. sideOrientation?: number;
  68378. frontUVs?: Vector4;
  68379. backUVs?: Vector4;
  68380. }, scene?: Nullable<Scene>): Mesh;
  68381. /**
  68382. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68383. * * 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
  68384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68385. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68386. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68387. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68389. * * 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
  68390. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68393. * @param name defines the name of the new line system
  68394. * @param options defines the options used to create the line system
  68395. * @param scene defines the hosting scene
  68396. * @returns a new line system mesh
  68397. */
  68398. static CreateLineSystem(name: string, options: {
  68399. lines: Vector3[][];
  68400. updatable?: boolean;
  68401. instance?: Nullable<LinesMesh>;
  68402. colors?: Nullable<Color4[][]>;
  68403. useVertexAlpha?: boolean;
  68404. }, scene: Nullable<Scene>): LinesMesh;
  68405. /**
  68406. * Creates a line mesh
  68407. * 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
  68408. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68409. * * The parameter `points` is an array successive Vector3
  68410. * * 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
  68411. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68412. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68413. * * When updating an instance, remember that only point positions can change, not the number of points
  68414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68416. * @param name defines the name of the new line system
  68417. * @param options defines the options used to create the line system
  68418. * @param scene defines the hosting scene
  68419. * @returns a new line mesh
  68420. */
  68421. static CreateLines(name: string, options: {
  68422. points: Vector3[];
  68423. updatable?: boolean;
  68424. instance?: Nullable<LinesMesh>;
  68425. colors?: Color4[];
  68426. useVertexAlpha?: boolean;
  68427. }, scene?: Nullable<Scene>): LinesMesh;
  68428. /**
  68429. * Creates a dashed line mesh
  68430. * * 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
  68431. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68432. * * The parameter `points` is an array successive Vector3
  68433. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68434. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68435. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68436. * * 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
  68437. * * When updating an instance, remember that only point positions can change, not the number of points
  68438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68439. * @param name defines the name of the mesh
  68440. * @param options defines the options used to create the mesh
  68441. * @param scene defines the hosting scene
  68442. * @returns the dashed line mesh
  68443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68444. */
  68445. static CreateDashedLines(name: string, options: {
  68446. points: Vector3[];
  68447. dashSize?: number;
  68448. gapSize?: number;
  68449. dashNb?: number;
  68450. updatable?: boolean;
  68451. instance?: LinesMesh;
  68452. }, scene?: Nullable<Scene>): LinesMesh;
  68453. /**
  68454. * 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.
  68455. * * 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.
  68456. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68457. * * 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.
  68458. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68459. * * 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
  68460. * * 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
  68461. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68463. * * 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
  68464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68466. * @param name defines the name of the mesh
  68467. * @param options defines the options used to create the mesh
  68468. * @param scene defines the hosting scene
  68469. * @returns the extruded shape mesh
  68470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68472. */
  68473. static ExtrudeShape(name: string, options: {
  68474. shape: Vector3[];
  68475. path: Vector3[];
  68476. scale?: number;
  68477. rotation?: number;
  68478. cap?: number;
  68479. updatable?: boolean;
  68480. sideOrientation?: number;
  68481. frontUVs?: Vector4;
  68482. backUVs?: Vector4;
  68483. instance?: Mesh;
  68484. invertUV?: boolean;
  68485. }, scene?: Nullable<Scene>): Mesh;
  68486. /**
  68487. * Creates an custom extruded shape mesh.
  68488. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68489. * * 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.
  68490. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68491. * * 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
  68492. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68493. * * 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
  68494. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68495. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68496. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68497. * * 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
  68498. * * 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
  68499. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68501. * * 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
  68502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68504. * @param name defines the name of the mesh
  68505. * @param options defines the options used to create the mesh
  68506. * @param scene defines the hosting scene
  68507. * @returns the custom extruded shape mesh
  68508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68511. */
  68512. static ExtrudeShapeCustom(name: string, options: {
  68513. shape: Vector3[];
  68514. path: Vector3[];
  68515. scaleFunction?: any;
  68516. rotationFunction?: any;
  68517. ribbonCloseArray?: boolean;
  68518. ribbonClosePath?: boolean;
  68519. cap?: number;
  68520. updatable?: boolean;
  68521. sideOrientation?: number;
  68522. frontUVs?: Vector4;
  68523. backUVs?: Vector4;
  68524. instance?: Mesh;
  68525. invertUV?: boolean;
  68526. }, scene?: Nullable<Scene>): Mesh;
  68527. /**
  68528. * Creates lathe mesh.
  68529. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68530. * * 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
  68531. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68532. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68533. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68534. * * 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
  68535. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68536. * * 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
  68537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68538. * * 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
  68539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68541. * @param name defines the name of the mesh
  68542. * @param options defines the options used to create the mesh
  68543. * @param scene defines the hosting scene
  68544. * @returns the lathe mesh
  68545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68546. */
  68547. static CreateLathe(name: string, options: {
  68548. shape: Vector3[];
  68549. radius?: number;
  68550. tessellation?: number;
  68551. clip?: number;
  68552. arc?: number;
  68553. closed?: boolean;
  68554. updatable?: boolean;
  68555. sideOrientation?: number;
  68556. frontUVs?: Vector4;
  68557. backUVs?: Vector4;
  68558. cap?: number;
  68559. invertUV?: boolean;
  68560. }, scene?: Nullable<Scene>): Mesh;
  68561. /**
  68562. * Creates a tiled plane mesh
  68563. * * You can set a limited pattern arrangement with the tiles
  68564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68565. * * 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
  68566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68567. * @param name defines the name of the mesh
  68568. * @param options defines the options used to create the mesh
  68569. * @param scene defines the hosting scene
  68570. * @returns the plane mesh
  68571. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68572. */
  68573. static CreateTiledPlane(name: string, options: {
  68574. pattern?: number;
  68575. tileSize?: number;
  68576. tileWidth?: number;
  68577. tileHeight?: number;
  68578. size?: number;
  68579. width?: number;
  68580. height?: number;
  68581. alignHorizontal?: number;
  68582. alignVertical?: number;
  68583. sideOrientation?: number;
  68584. frontUVs?: Vector4;
  68585. backUVs?: Vector4;
  68586. updatable?: boolean;
  68587. }, scene?: Nullable<Scene>): Mesh;
  68588. /**
  68589. * Creates a plane mesh
  68590. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68591. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68592. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68594. * * 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
  68595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68596. * @param name defines the name of the mesh
  68597. * @param options defines the options used to create the mesh
  68598. * @param scene defines the hosting scene
  68599. * @returns the plane mesh
  68600. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68601. */
  68602. static CreatePlane(name: string, options: {
  68603. size?: number;
  68604. width?: number;
  68605. height?: number;
  68606. sideOrientation?: number;
  68607. frontUVs?: Vector4;
  68608. backUVs?: Vector4;
  68609. updatable?: boolean;
  68610. sourcePlane?: Plane;
  68611. }, scene?: Nullable<Scene>): Mesh;
  68612. /**
  68613. * Creates a ground mesh
  68614. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68615. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68617. * @param name defines the name of the mesh
  68618. * @param options defines the options used to create the mesh
  68619. * @param scene defines the hosting scene
  68620. * @returns the ground mesh
  68621. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68622. */
  68623. static CreateGround(name: string, options: {
  68624. width?: number;
  68625. height?: number;
  68626. subdivisions?: number;
  68627. subdivisionsX?: number;
  68628. subdivisionsY?: number;
  68629. updatable?: boolean;
  68630. }, scene?: Nullable<Scene>): Mesh;
  68631. /**
  68632. * Creates a tiled ground mesh
  68633. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68634. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68635. * * 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
  68636. * * 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
  68637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68638. * @param name defines the name of the mesh
  68639. * @param options defines the options used to create the mesh
  68640. * @param scene defines the hosting scene
  68641. * @returns the tiled ground mesh
  68642. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68643. */
  68644. static CreateTiledGround(name: string, options: {
  68645. xmin: number;
  68646. zmin: number;
  68647. xmax: number;
  68648. zmax: number;
  68649. subdivisions?: {
  68650. w: number;
  68651. h: number;
  68652. };
  68653. precision?: {
  68654. w: number;
  68655. h: number;
  68656. };
  68657. updatable?: boolean;
  68658. }, scene?: Nullable<Scene>): Mesh;
  68659. /**
  68660. * Creates a ground mesh from a height map
  68661. * * The parameter `url` sets the URL of the height map image resource.
  68662. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68663. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68664. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68665. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68666. * * 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.
  68667. * * 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).
  68668. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68670. * @param name defines the name of the mesh
  68671. * @param url defines the url to the height map
  68672. * @param options defines the options used to create the mesh
  68673. * @param scene defines the hosting scene
  68674. * @returns the ground mesh
  68675. * @see https://doc.babylonjs.com/babylon101/height_map
  68676. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68677. */
  68678. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68679. width?: number;
  68680. height?: number;
  68681. subdivisions?: number;
  68682. minHeight?: number;
  68683. maxHeight?: number;
  68684. colorFilter?: Color3;
  68685. alphaFilter?: number;
  68686. updatable?: boolean;
  68687. onReady?: (mesh: GroundMesh) => void;
  68688. }, scene?: Nullable<Scene>): GroundMesh;
  68689. /**
  68690. * Creates a polygon mesh
  68691. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68692. * * 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
  68693. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68695. * * 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)
  68696. * * Remember you can only change the shape positions, not their number when updating a polygon
  68697. * @param name defines the name of the mesh
  68698. * @param options defines the options used to create the mesh
  68699. * @param scene defines the hosting scene
  68700. * @param earcutInjection can be used to inject your own earcut reference
  68701. * @returns the polygon mesh
  68702. */
  68703. static CreatePolygon(name: string, options: {
  68704. shape: Vector3[];
  68705. holes?: Vector3[][];
  68706. depth?: number;
  68707. faceUV?: Vector4[];
  68708. faceColors?: Color4[];
  68709. updatable?: boolean;
  68710. sideOrientation?: number;
  68711. frontUVs?: Vector4;
  68712. backUVs?: Vector4;
  68713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68714. /**
  68715. * Creates an extruded polygon mesh, with depth in the Y direction.
  68716. * * 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)
  68717. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68718. * @param name defines the name of the mesh
  68719. * @param options defines the options used to create the mesh
  68720. * @param scene defines the hosting scene
  68721. * @param earcutInjection can be used to inject your own earcut reference
  68722. * @returns the polygon mesh
  68723. */
  68724. static ExtrudePolygon(name: string, options: {
  68725. shape: Vector3[];
  68726. holes?: Vector3[][];
  68727. depth?: number;
  68728. faceUV?: Vector4[];
  68729. faceColors?: Color4[];
  68730. updatable?: boolean;
  68731. sideOrientation?: number;
  68732. frontUVs?: Vector4;
  68733. backUVs?: Vector4;
  68734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68735. /**
  68736. * Creates a tube mesh.
  68737. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68738. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68739. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68740. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68741. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68742. * * 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)
  68743. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68744. * * 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
  68745. * * 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
  68746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68747. * * 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
  68748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68750. * @param name defines the name of the mesh
  68751. * @param options defines the options used to create the mesh
  68752. * @param scene defines the hosting scene
  68753. * @returns the tube mesh
  68754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68755. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68756. */
  68757. static CreateTube(name: string, options: {
  68758. path: Vector3[];
  68759. radius?: number;
  68760. tessellation?: number;
  68761. radiusFunction?: {
  68762. (i: number, distance: number): number;
  68763. };
  68764. cap?: number;
  68765. arc?: number;
  68766. updatable?: boolean;
  68767. sideOrientation?: number;
  68768. frontUVs?: Vector4;
  68769. backUVs?: Vector4;
  68770. instance?: Mesh;
  68771. invertUV?: boolean;
  68772. }, scene?: Nullable<Scene>): Mesh;
  68773. /**
  68774. * Creates a polyhedron mesh
  68775. * * 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
  68776. * * The parameter `size` (positive float, default 1) sets the polygon size
  68777. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68778. * * 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`
  68779. * * 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
  68780. * * 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)`)
  68781. * * 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
  68782. * * 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
  68783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68784. * * 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
  68785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68786. * @param name defines the name of the mesh
  68787. * @param options defines the options used to create the mesh
  68788. * @param scene defines the hosting scene
  68789. * @returns the polyhedron mesh
  68790. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68791. */
  68792. static CreatePolyhedron(name: string, options: {
  68793. type?: number;
  68794. size?: number;
  68795. sizeX?: number;
  68796. sizeY?: number;
  68797. sizeZ?: number;
  68798. custom?: any;
  68799. faceUV?: Vector4[];
  68800. faceColors?: Color4[];
  68801. flat?: boolean;
  68802. updatable?: boolean;
  68803. sideOrientation?: number;
  68804. frontUVs?: Vector4;
  68805. backUVs?: Vector4;
  68806. }, scene?: Nullable<Scene>): Mesh;
  68807. /**
  68808. * Creates a decal mesh.
  68809. * 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
  68810. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68811. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68812. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68813. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68814. * @param name defines the name of the mesh
  68815. * @param sourceMesh defines the mesh where the decal must be applied
  68816. * @param options defines the options used to create the mesh
  68817. * @param scene defines the hosting scene
  68818. * @returns the decal mesh
  68819. * @see https://doc.babylonjs.com/how_to/decals
  68820. */
  68821. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68822. position?: Vector3;
  68823. normal?: Vector3;
  68824. size?: Vector3;
  68825. angle?: number;
  68826. }): Mesh;
  68827. }
  68828. }
  68829. declare module "babylonjs/Meshes/meshSimplification" {
  68830. import { Mesh } from "babylonjs/Meshes/mesh";
  68831. /**
  68832. * A simplifier interface for future simplification implementations
  68833. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68834. */
  68835. export interface ISimplifier {
  68836. /**
  68837. * Simplification of a given mesh according to the given settings.
  68838. * Since this requires computation, it is assumed that the function runs async.
  68839. * @param settings The settings of the simplification, including quality and distance
  68840. * @param successCallback A callback that will be called after the mesh was simplified.
  68841. * @param errorCallback in case of an error, this callback will be called. optional.
  68842. */
  68843. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68844. }
  68845. /**
  68846. * Expected simplification settings.
  68847. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68848. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68849. */
  68850. export interface ISimplificationSettings {
  68851. /**
  68852. * Gets or sets the expected quality
  68853. */
  68854. quality: number;
  68855. /**
  68856. * Gets or sets the distance when this optimized version should be used
  68857. */
  68858. distance: number;
  68859. /**
  68860. * Gets an already optimized mesh
  68861. */
  68862. optimizeMesh?: boolean;
  68863. }
  68864. /**
  68865. * Class used to specify simplification options
  68866. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68867. */
  68868. export class SimplificationSettings implements ISimplificationSettings {
  68869. /** expected quality */
  68870. quality: number;
  68871. /** distance when this optimized version should be used */
  68872. distance: number;
  68873. /** already optimized mesh */
  68874. optimizeMesh?: boolean | undefined;
  68875. /**
  68876. * Creates a SimplificationSettings
  68877. * @param quality expected quality
  68878. * @param distance distance when this optimized version should be used
  68879. * @param optimizeMesh already optimized mesh
  68880. */
  68881. constructor(
  68882. /** expected quality */
  68883. quality: number,
  68884. /** distance when this optimized version should be used */
  68885. distance: number,
  68886. /** already optimized mesh */
  68887. optimizeMesh?: boolean | undefined);
  68888. }
  68889. /**
  68890. * Interface used to define a simplification task
  68891. */
  68892. export interface ISimplificationTask {
  68893. /**
  68894. * Array of settings
  68895. */
  68896. settings: Array<ISimplificationSettings>;
  68897. /**
  68898. * Simplification type
  68899. */
  68900. simplificationType: SimplificationType;
  68901. /**
  68902. * Mesh to simplify
  68903. */
  68904. mesh: Mesh;
  68905. /**
  68906. * Callback called on success
  68907. */
  68908. successCallback?: () => void;
  68909. /**
  68910. * Defines if parallel processing can be used
  68911. */
  68912. parallelProcessing: boolean;
  68913. }
  68914. /**
  68915. * Queue used to order the simplification tasks
  68916. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68917. */
  68918. export class SimplificationQueue {
  68919. private _simplificationArray;
  68920. /**
  68921. * Gets a boolean indicating that the process is still running
  68922. */
  68923. running: boolean;
  68924. /**
  68925. * Creates a new queue
  68926. */
  68927. constructor();
  68928. /**
  68929. * Adds a new simplification task
  68930. * @param task defines a task to add
  68931. */
  68932. addTask(task: ISimplificationTask): void;
  68933. /**
  68934. * Execute next task
  68935. */
  68936. executeNext(): void;
  68937. /**
  68938. * Execute a simplification task
  68939. * @param task defines the task to run
  68940. */
  68941. runSimplification(task: ISimplificationTask): void;
  68942. private getSimplifier;
  68943. }
  68944. /**
  68945. * The implemented types of simplification
  68946. * At the moment only Quadratic Error Decimation is implemented
  68947. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68948. */
  68949. export enum SimplificationType {
  68950. /** Quadratic error decimation */
  68951. QUADRATIC = 0
  68952. }
  68953. /**
  68954. * An implementation of the Quadratic Error simplification algorithm.
  68955. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68956. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68957. * @author RaananW
  68958. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68959. */
  68960. export class QuadraticErrorSimplification implements ISimplifier {
  68961. private _mesh;
  68962. private triangles;
  68963. private vertices;
  68964. private references;
  68965. private _reconstructedMesh;
  68966. /** Gets or sets the number pf sync interations */
  68967. syncIterations: number;
  68968. /** Gets or sets the aggressiveness of the simplifier */
  68969. aggressiveness: number;
  68970. /** Gets or sets the number of allowed iterations for decimation */
  68971. decimationIterations: number;
  68972. /** Gets or sets the espilon to use for bounding box computation */
  68973. boundingBoxEpsilon: number;
  68974. /**
  68975. * Creates a new QuadraticErrorSimplification
  68976. * @param _mesh defines the target mesh
  68977. */
  68978. constructor(_mesh: Mesh);
  68979. /**
  68980. * Simplification of a given mesh according to the given settings.
  68981. * Since this requires computation, it is assumed that the function runs async.
  68982. * @param settings The settings of the simplification, including quality and distance
  68983. * @param successCallback A callback that will be called after the mesh was simplified.
  68984. */
  68985. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68986. private runDecimation;
  68987. private initWithMesh;
  68988. private init;
  68989. private reconstructMesh;
  68990. private initDecimatedMesh;
  68991. private isFlipped;
  68992. private updateTriangles;
  68993. private identifyBorder;
  68994. private updateMesh;
  68995. private vertexError;
  68996. private calculateError;
  68997. }
  68998. }
  68999. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69000. import { Scene } from "babylonjs/scene";
  69001. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69002. import { ISceneComponent } from "babylonjs/sceneComponent";
  69003. module "babylonjs/scene" {
  69004. interface Scene {
  69005. /** @hidden (Backing field) */
  69006. _simplificationQueue: SimplificationQueue;
  69007. /**
  69008. * Gets or sets the simplification queue attached to the scene
  69009. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69010. */
  69011. simplificationQueue: SimplificationQueue;
  69012. }
  69013. }
  69014. module "babylonjs/Meshes/mesh" {
  69015. interface Mesh {
  69016. /**
  69017. * Simplify the mesh according to the given array of settings.
  69018. * Function will return immediately and will simplify async
  69019. * @param settings a collection of simplification settings
  69020. * @param parallelProcessing should all levels calculate parallel or one after the other
  69021. * @param simplificationType the type of simplification to run
  69022. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69023. * @returns the current mesh
  69024. */
  69025. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69026. }
  69027. }
  69028. /**
  69029. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69030. * created in a scene
  69031. */
  69032. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69033. /**
  69034. * The component name helpfull to identify the component in the list of scene components.
  69035. */
  69036. readonly name: string;
  69037. /**
  69038. * The scene the component belongs to.
  69039. */
  69040. scene: Scene;
  69041. /**
  69042. * Creates a new instance of the component for the given scene
  69043. * @param scene Defines the scene to register the component in
  69044. */
  69045. constructor(scene: Scene);
  69046. /**
  69047. * Registers the component in a given scene
  69048. */
  69049. register(): void;
  69050. /**
  69051. * Rebuilds the elements related to this component in case of
  69052. * context lost for instance.
  69053. */
  69054. rebuild(): void;
  69055. /**
  69056. * Disposes the component and the associated ressources
  69057. */
  69058. dispose(): void;
  69059. private _beforeCameraUpdate;
  69060. }
  69061. }
  69062. declare module "babylonjs/Meshes/Builders/index" {
  69063. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69064. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69065. export * from "babylonjs/Meshes/Builders/discBuilder";
  69066. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69067. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69068. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69069. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69070. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69071. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69072. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69073. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69074. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69075. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69076. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69077. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69078. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69079. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69080. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69081. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69082. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69083. }
  69084. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69085. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69086. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69087. import { Matrix } from "babylonjs/Maths/math.vector";
  69088. module "babylonjs/Meshes/mesh" {
  69089. interface Mesh {
  69090. /**
  69091. * Creates a new thin instance
  69092. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69093. * @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
  69094. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69095. */
  69096. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69097. /**
  69098. * Adds the transformation (matrix) of the current mesh as a thin instance
  69099. * @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
  69100. * @returns the thin instance index number
  69101. */
  69102. thinInstanceAddSelf(refresh: boolean): number;
  69103. /**
  69104. * Registers a custom attribute to be used with thin instances
  69105. * @param kind name of the attribute
  69106. * @param stride size in floats of the attribute
  69107. */
  69108. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69109. /**
  69110. * Sets the matrix of a thin instance
  69111. * @param index index of the thin instance
  69112. * @param matrix matrix to set
  69113. * @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
  69114. */
  69115. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69116. /**
  69117. * Sets the value of a custom attribute for a thin instance
  69118. * @param kind name of the attribute
  69119. * @param index index of the thin instance
  69120. * @param value value to set
  69121. * @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
  69122. */
  69123. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69124. /**
  69125. * 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.
  69126. */
  69127. thinInstanceCount: number;
  69128. /**
  69129. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69130. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69131. * @param buffer buffer to set
  69132. * @param stride size in floats of each value of the buffer
  69133. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69134. */
  69135. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69136. /**
  69137. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69138. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69139. */
  69140. thinInstanceBufferUpdated(kind: string): void;
  69141. /**
  69142. * Refreshes the bounding info, taking into account all the thin instances defined
  69143. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69144. */
  69145. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69146. /** @hidden */
  69147. _thinInstanceInitializeUserStorage(): void;
  69148. /** @hidden */
  69149. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69150. /** @hidden */
  69151. _userThinInstanceBuffersStorage: {
  69152. data: {
  69153. [key: string]: Float32Array;
  69154. };
  69155. sizes: {
  69156. [key: string]: number;
  69157. };
  69158. vertexBuffers: {
  69159. [key: string]: Nullable<VertexBuffer>;
  69160. };
  69161. strides: {
  69162. [key: string]: number;
  69163. };
  69164. };
  69165. }
  69166. }
  69167. }
  69168. declare module "babylonjs/Meshes/index" {
  69169. export * from "babylonjs/Meshes/abstractMesh";
  69170. export * from "babylonjs/Meshes/buffer";
  69171. export * from "babylonjs/Meshes/Compression/index";
  69172. export * from "babylonjs/Meshes/csg";
  69173. export * from "babylonjs/Meshes/geometry";
  69174. export * from "babylonjs/Meshes/groundMesh";
  69175. export * from "babylonjs/Meshes/trailMesh";
  69176. export * from "babylonjs/Meshes/instancedMesh";
  69177. export * from "babylonjs/Meshes/linesMesh";
  69178. export * from "babylonjs/Meshes/mesh";
  69179. export * from "babylonjs/Meshes/mesh.vertexData";
  69180. export * from "babylonjs/Meshes/meshBuilder";
  69181. export * from "babylonjs/Meshes/meshSimplification";
  69182. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69183. export * from "babylonjs/Meshes/polygonMesh";
  69184. export * from "babylonjs/Meshes/subMesh";
  69185. export * from "babylonjs/Meshes/meshLODLevel";
  69186. export * from "babylonjs/Meshes/transformNode";
  69187. export * from "babylonjs/Meshes/Builders/index";
  69188. export * from "babylonjs/Meshes/dataBuffer";
  69189. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69190. import "babylonjs/Meshes/thinInstanceMesh";
  69191. export * from "babylonjs/Meshes/thinInstanceMesh";
  69192. }
  69193. declare module "babylonjs/Morph/index" {
  69194. export * from "babylonjs/Morph/morphTarget";
  69195. export * from "babylonjs/Morph/morphTargetManager";
  69196. }
  69197. declare module "babylonjs/Navigation/INavigationEngine" {
  69198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69199. import { Vector3 } from "babylonjs/Maths/math";
  69200. import { Mesh } from "babylonjs/Meshes/mesh";
  69201. import { Scene } from "babylonjs/scene";
  69202. /**
  69203. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69204. */
  69205. export interface INavigationEnginePlugin {
  69206. /**
  69207. * plugin name
  69208. */
  69209. name: string;
  69210. /**
  69211. * Creates a navigation mesh
  69212. * @param meshes array of all the geometry used to compute the navigatio mesh
  69213. * @param parameters bunch of parameters used to filter geometry
  69214. */
  69215. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69216. /**
  69217. * Create a navigation mesh debug mesh
  69218. * @param scene is where the mesh will be added
  69219. * @returns debug display mesh
  69220. */
  69221. createDebugNavMesh(scene: Scene): Mesh;
  69222. /**
  69223. * Get a navigation mesh constrained position, closest to the parameter position
  69224. * @param position world position
  69225. * @returns the closest point to position constrained by the navigation mesh
  69226. */
  69227. getClosestPoint(position: Vector3): Vector3;
  69228. /**
  69229. * Get a navigation mesh constrained position, closest to the parameter position
  69230. * @param position world position
  69231. * @param result output the closest point to position constrained by the navigation mesh
  69232. */
  69233. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69234. /**
  69235. * Get a navigation mesh constrained position, within a particular radius
  69236. * @param position world position
  69237. * @param maxRadius the maximum distance to the constrained world position
  69238. * @returns the closest point to position constrained by the navigation mesh
  69239. */
  69240. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69241. /**
  69242. * Get a navigation mesh constrained position, within a particular radius
  69243. * @param position world position
  69244. * @param maxRadius the maximum distance to the constrained world position
  69245. * @param result output the closest point to position constrained by the navigation mesh
  69246. */
  69247. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69248. /**
  69249. * Compute the final position from a segment made of destination-position
  69250. * @param position world position
  69251. * @param destination world position
  69252. * @returns the resulting point along the navmesh
  69253. */
  69254. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69255. /**
  69256. * Compute the final position from a segment made of destination-position
  69257. * @param position world position
  69258. * @param destination world position
  69259. * @param result output the resulting point along the navmesh
  69260. */
  69261. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69262. /**
  69263. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69264. * @param start world position
  69265. * @param end world position
  69266. * @returns array containing world position composing the path
  69267. */
  69268. computePath(start: Vector3, end: Vector3): Vector3[];
  69269. /**
  69270. * If this plugin is supported
  69271. * @returns true if plugin is supported
  69272. */
  69273. isSupported(): boolean;
  69274. /**
  69275. * Create a new Crowd so you can add agents
  69276. * @param maxAgents the maximum agent count in the crowd
  69277. * @param maxAgentRadius the maximum radius an agent can have
  69278. * @param scene to attach the crowd to
  69279. * @returns the crowd you can add agents to
  69280. */
  69281. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69282. /**
  69283. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69284. * The queries will try to find a solution within those bounds
  69285. * default is (1,1,1)
  69286. * @param extent x,y,z value that define the extent around the queries point of reference
  69287. */
  69288. setDefaultQueryExtent(extent: Vector3): void;
  69289. /**
  69290. * Get the Bounding box extent specified by setDefaultQueryExtent
  69291. * @returns the box extent values
  69292. */
  69293. getDefaultQueryExtent(): Vector3;
  69294. /**
  69295. * build the navmesh from a previously saved state using getNavmeshData
  69296. * @param data the Uint8Array returned by getNavmeshData
  69297. */
  69298. buildFromNavmeshData(data: Uint8Array): void;
  69299. /**
  69300. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69301. * @returns data the Uint8Array that can be saved and reused
  69302. */
  69303. getNavmeshData(): Uint8Array;
  69304. /**
  69305. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69306. * @param result output the box extent values
  69307. */
  69308. getDefaultQueryExtentToRef(result: Vector3): void;
  69309. /**
  69310. * Release all resources
  69311. */
  69312. dispose(): void;
  69313. }
  69314. /**
  69315. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69316. */
  69317. export interface ICrowd {
  69318. /**
  69319. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69320. * You can attach anything to that node. The node position is updated in the scene update tick.
  69321. * @param pos world position that will be constrained by the navigation mesh
  69322. * @param parameters agent parameters
  69323. * @param transform hooked to the agent that will be update by the scene
  69324. * @returns agent index
  69325. */
  69326. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69327. /**
  69328. * Returns the agent position in world space
  69329. * @param index agent index returned by addAgent
  69330. * @returns world space position
  69331. */
  69332. getAgentPosition(index: number): Vector3;
  69333. /**
  69334. * Gets the agent position result in world space
  69335. * @param index agent index returned by addAgent
  69336. * @param result output world space position
  69337. */
  69338. getAgentPositionToRef(index: number, result: Vector3): void;
  69339. /**
  69340. * Gets the agent velocity in world space
  69341. * @param index agent index returned by addAgent
  69342. * @returns world space velocity
  69343. */
  69344. getAgentVelocity(index: number): Vector3;
  69345. /**
  69346. * Gets the agent velocity result in world space
  69347. * @param index agent index returned by addAgent
  69348. * @param result output world space velocity
  69349. */
  69350. getAgentVelocityToRef(index: number, result: Vector3): void;
  69351. /**
  69352. * remove a particular agent previously created
  69353. * @param index agent index returned by addAgent
  69354. */
  69355. removeAgent(index: number): void;
  69356. /**
  69357. * get the list of all agents attached to this crowd
  69358. * @returns list of agent indices
  69359. */
  69360. getAgents(): number[];
  69361. /**
  69362. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69363. * @param deltaTime in seconds
  69364. */
  69365. update(deltaTime: number): void;
  69366. /**
  69367. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69368. * @param index agent index returned by addAgent
  69369. * @param destination targeted world position
  69370. */
  69371. agentGoto(index: number, destination: Vector3): void;
  69372. /**
  69373. * Teleport the agent to a new position
  69374. * @param index agent index returned by addAgent
  69375. * @param destination targeted world position
  69376. */
  69377. agentTeleport(index: number, destination: Vector3): void;
  69378. /**
  69379. * Update agent parameters
  69380. * @param index agent index returned by addAgent
  69381. * @param parameters agent parameters
  69382. */
  69383. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69384. /**
  69385. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69386. * The queries will try to find a solution within those bounds
  69387. * default is (1,1,1)
  69388. * @param extent x,y,z value that define the extent around the queries point of reference
  69389. */
  69390. setDefaultQueryExtent(extent: Vector3): void;
  69391. /**
  69392. * Get the Bounding box extent specified by setDefaultQueryExtent
  69393. * @returns the box extent values
  69394. */
  69395. getDefaultQueryExtent(): Vector3;
  69396. /**
  69397. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69398. * @param result output the box extent values
  69399. */
  69400. getDefaultQueryExtentToRef(result: Vector3): void;
  69401. /**
  69402. * Release all resources
  69403. */
  69404. dispose(): void;
  69405. }
  69406. /**
  69407. * Configures an agent
  69408. */
  69409. export interface IAgentParameters {
  69410. /**
  69411. * Agent radius. [Limit: >= 0]
  69412. */
  69413. radius: number;
  69414. /**
  69415. * Agent height. [Limit: > 0]
  69416. */
  69417. height: number;
  69418. /**
  69419. * Maximum allowed acceleration. [Limit: >= 0]
  69420. */
  69421. maxAcceleration: number;
  69422. /**
  69423. * Maximum allowed speed. [Limit: >= 0]
  69424. */
  69425. maxSpeed: number;
  69426. /**
  69427. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69428. */
  69429. collisionQueryRange: number;
  69430. /**
  69431. * The path visibility optimization range. [Limit: > 0]
  69432. */
  69433. pathOptimizationRange: number;
  69434. /**
  69435. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69436. */
  69437. separationWeight: number;
  69438. }
  69439. /**
  69440. * Configures the navigation mesh creation
  69441. */
  69442. export interface INavMeshParameters {
  69443. /**
  69444. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69445. */
  69446. cs: number;
  69447. /**
  69448. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69449. */
  69450. ch: number;
  69451. /**
  69452. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69453. */
  69454. walkableSlopeAngle: number;
  69455. /**
  69456. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69457. * be considered walkable. [Limit: >= 3] [Units: vx]
  69458. */
  69459. walkableHeight: number;
  69460. /**
  69461. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69462. */
  69463. walkableClimb: number;
  69464. /**
  69465. * The distance to erode/shrink the walkable area of the heightfield away from
  69466. * obstructions. [Limit: >=0] [Units: vx]
  69467. */
  69468. walkableRadius: number;
  69469. /**
  69470. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69471. */
  69472. maxEdgeLen: number;
  69473. /**
  69474. * The maximum distance a simplfied contour's border edges should deviate
  69475. * the original raw contour. [Limit: >=0] [Units: vx]
  69476. */
  69477. maxSimplificationError: number;
  69478. /**
  69479. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69480. */
  69481. minRegionArea: number;
  69482. /**
  69483. * Any regions with a span count smaller than this value will, if possible,
  69484. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69485. */
  69486. mergeRegionArea: number;
  69487. /**
  69488. * The maximum number of vertices allowed for polygons generated during the
  69489. * contour to polygon conversion process. [Limit: >= 3]
  69490. */
  69491. maxVertsPerPoly: number;
  69492. /**
  69493. * Sets the sampling distance to use when generating the detail mesh.
  69494. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69495. */
  69496. detailSampleDist: number;
  69497. /**
  69498. * The maximum distance the detail mesh surface should deviate from heightfield
  69499. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69500. */
  69501. detailSampleMaxError: number;
  69502. }
  69503. }
  69504. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69505. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69506. import { Mesh } from "babylonjs/Meshes/mesh";
  69507. import { Scene } from "babylonjs/scene";
  69508. import { Vector3 } from "babylonjs/Maths/math";
  69509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69510. /**
  69511. * RecastJS navigation plugin
  69512. */
  69513. export class RecastJSPlugin implements INavigationEnginePlugin {
  69514. /**
  69515. * Reference to the Recast library
  69516. */
  69517. bjsRECAST: any;
  69518. /**
  69519. * plugin name
  69520. */
  69521. name: string;
  69522. /**
  69523. * the first navmesh created. We might extend this to support multiple navmeshes
  69524. */
  69525. navMesh: any;
  69526. /**
  69527. * Initializes the recastJS plugin
  69528. * @param recastInjection can be used to inject your own recast reference
  69529. */
  69530. constructor(recastInjection?: any);
  69531. /**
  69532. * Creates a navigation mesh
  69533. * @param meshes array of all the geometry used to compute the navigatio mesh
  69534. * @param parameters bunch of parameters used to filter geometry
  69535. */
  69536. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69537. /**
  69538. * Create a navigation mesh debug mesh
  69539. * @param scene is where the mesh will be added
  69540. * @returns debug display mesh
  69541. */
  69542. createDebugNavMesh(scene: Scene): Mesh;
  69543. /**
  69544. * Get a navigation mesh constrained position, closest to the parameter position
  69545. * @param position world position
  69546. * @returns the closest point to position constrained by the navigation mesh
  69547. */
  69548. getClosestPoint(position: Vector3): Vector3;
  69549. /**
  69550. * Get a navigation mesh constrained position, closest to the parameter position
  69551. * @param position world position
  69552. * @param result output the closest point to position constrained by the navigation mesh
  69553. */
  69554. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69555. /**
  69556. * Get a navigation mesh constrained position, within a particular radius
  69557. * @param position world position
  69558. * @param maxRadius the maximum distance to the constrained world position
  69559. * @returns the closest point to position constrained by the navigation mesh
  69560. */
  69561. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69562. /**
  69563. * Get a navigation mesh constrained position, within a particular radius
  69564. * @param position world position
  69565. * @param maxRadius the maximum distance to the constrained world position
  69566. * @param result output the closest point to position constrained by the navigation mesh
  69567. */
  69568. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69569. /**
  69570. * Compute the final position from a segment made of destination-position
  69571. * @param position world position
  69572. * @param destination world position
  69573. * @returns the resulting point along the navmesh
  69574. */
  69575. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69576. /**
  69577. * Compute the final position from a segment made of destination-position
  69578. * @param position world position
  69579. * @param destination world position
  69580. * @param result output the resulting point along the navmesh
  69581. */
  69582. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69583. /**
  69584. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69585. * @param start world position
  69586. * @param end world position
  69587. * @returns array containing world position composing the path
  69588. */
  69589. computePath(start: Vector3, end: Vector3): Vector3[];
  69590. /**
  69591. * Create a new Crowd so you can add agents
  69592. * @param maxAgents the maximum agent count in the crowd
  69593. * @param maxAgentRadius the maximum radius an agent can have
  69594. * @param scene to attach the crowd to
  69595. * @returns the crowd you can add agents to
  69596. */
  69597. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69598. /**
  69599. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69600. * The queries will try to find a solution within those bounds
  69601. * default is (1,1,1)
  69602. * @param extent x,y,z value that define the extent around the queries point of reference
  69603. */
  69604. setDefaultQueryExtent(extent: Vector3): void;
  69605. /**
  69606. * Get the Bounding box extent specified by setDefaultQueryExtent
  69607. * @returns the box extent values
  69608. */
  69609. getDefaultQueryExtent(): Vector3;
  69610. /**
  69611. * build the navmesh from a previously saved state using getNavmeshData
  69612. * @param data the Uint8Array returned by getNavmeshData
  69613. */
  69614. buildFromNavmeshData(data: Uint8Array): void;
  69615. /**
  69616. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69617. * @returns data the Uint8Array that can be saved and reused
  69618. */
  69619. getNavmeshData(): Uint8Array;
  69620. /**
  69621. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69622. * @param result output the box extent values
  69623. */
  69624. getDefaultQueryExtentToRef(result: Vector3): void;
  69625. /**
  69626. * Disposes
  69627. */
  69628. dispose(): void;
  69629. /**
  69630. * If this plugin is supported
  69631. * @returns true if plugin is supported
  69632. */
  69633. isSupported(): boolean;
  69634. }
  69635. /**
  69636. * Recast detour crowd implementation
  69637. */
  69638. export class RecastJSCrowd implements ICrowd {
  69639. /**
  69640. * Recast/detour plugin
  69641. */
  69642. bjsRECASTPlugin: RecastJSPlugin;
  69643. /**
  69644. * Link to the detour crowd
  69645. */
  69646. recastCrowd: any;
  69647. /**
  69648. * One transform per agent
  69649. */
  69650. transforms: TransformNode[];
  69651. /**
  69652. * All agents created
  69653. */
  69654. agents: number[];
  69655. /**
  69656. * Link to the scene is kept to unregister the crowd from the scene
  69657. */
  69658. private _scene;
  69659. /**
  69660. * Observer for crowd updates
  69661. */
  69662. private _onBeforeAnimationsObserver;
  69663. /**
  69664. * Constructor
  69665. * @param plugin recastJS plugin
  69666. * @param maxAgents the maximum agent count in the crowd
  69667. * @param maxAgentRadius the maximum radius an agent can have
  69668. * @param scene to attach the crowd to
  69669. * @returns the crowd you can add agents to
  69670. */
  69671. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69672. /**
  69673. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69674. * You can attach anything to that node. The node position is updated in the scene update tick.
  69675. * @param pos world position that will be constrained by the navigation mesh
  69676. * @param parameters agent parameters
  69677. * @param transform hooked to the agent that will be update by the scene
  69678. * @returns agent index
  69679. */
  69680. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69681. /**
  69682. * Returns the agent position in world space
  69683. * @param index agent index returned by addAgent
  69684. * @returns world space position
  69685. */
  69686. getAgentPosition(index: number): Vector3;
  69687. /**
  69688. * Returns the agent position result in world space
  69689. * @param index agent index returned by addAgent
  69690. * @param result output world space position
  69691. */
  69692. getAgentPositionToRef(index: number, result: Vector3): void;
  69693. /**
  69694. * Returns the agent velocity in world space
  69695. * @param index agent index returned by addAgent
  69696. * @returns world space velocity
  69697. */
  69698. getAgentVelocity(index: number): Vector3;
  69699. /**
  69700. * Returns the agent velocity result in world space
  69701. * @param index agent index returned by addAgent
  69702. * @param result output world space velocity
  69703. */
  69704. getAgentVelocityToRef(index: number, result: Vector3): void;
  69705. /**
  69706. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69707. * @param index agent index returned by addAgent
  69708. * @param destination targeted world position
  69709. */
  69710. agentGoto(index: number, destination: Vector3): void;
  69711. /**
  69712. * Teleport the agent to a new position
  69713. * @param index agent index returned by addAgent
  69714. * @param destination targeted world position
  69715. */
  69716. agentTeleport(index: number, destination: Vector3): void;
  69717. /**
  69718. * Update agent parameters
  69719. * @param index agent index returned by addAgent
  69720. * @param parameters agent parameters
  69721. */
  69722. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69723. /**
  69724. * remove a particular agent previously created
  69725. * @param index agent index returned by addAgent
  69726. */
  69727. removeAgent(index: number): void;
  69728. /**
  69729. * get the list of all agents attached to this crowd
  69730. * @returns list of agent indices
  69731. */
  69732. getAgents(): number[];
  69733. /**
  69734. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69735. * @param deltaTime in seconds
  69736. */
  69737. update(deltaTime: number): void;
  69738. /**
  69739. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69740. * The queries will try to find a solution within those bounds
  69741. * default is (1,1,1)
  69742. * @param extent x,y,z value that define the extent around the queries point of reference
  69743. */
  69744. setDefaultQueryExtent(extent: Vector3): void;
  69745. /**
  69746. * Get the Bounding box extent specified by setDefaultQueryExtent
  69747. * @returns the box extent values
  69748. */
  69749. getDefaultQueryExtent(): Vector3;
  69750. /**
  69751. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69752. * @param result output the box extent values
  69753. */
  69754. getDefaultQueryExtentToRef(result: Vector3): void;
  69755. /**
  69756. * Release all resources
  69757. */
  69758. dispose(): void;
  69759. }
  69760. }
  69761. declare module "babylonjs/Navigation/Plugins/index" {
  69762. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69763. }
  69764. declare module "babylonjs/Navigation/index" {
  69765. export * from "babylonjs/Navigation/INavigationEngine";
  69766. export * from "babylonjs/Navigation/Plugins/index";
  69767. }
  69768. declare module "babylonjs/Offline/database" {
  69769. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69770. /**
  69771. * Class used to enable access to IndexedDB
  69772. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69773. */
  69774. export class Database implements IOfflineProvider {
  69775. private _callbackManifestChecked;
  69776. private _currentSceneUrl;
  69777. private _db;
  69778. private _enableSceneOffline;
  69779. private _enableTexturesOffline;
  69780. private _manifestVersionFound;
  69781. private _mustUpdateRessources;
  69782. private _hasReachedQuota;
  69783. private _isSupported;
  69784. private _idbFactory;
  69785. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69786. private static IsUASupportingBlobStorage;
  69787. /**
  69788. * Gets a boolean indicating if Database storate is enabled (off by default)
  69789. */
  69790. static IDBStorageEnabled: boolean;
  69791. /**
  69792. * Gets a boolean indicating if scene must be saved in the database
  69793. */
  69794. get enableSceneOffline(): boolean;
  69795. /**
  69796. * Gets a boolean indicating if textures must be saved in the database
  69797. */
  69798. get enableTexturesOffline(): boolean;
  69799. /**
  69800. * Creates a new Database
  69801. * @param urlToScene defines the url to load the scene
  69802. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69803. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69804. */
  69805. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69806. private static _ParseURL;
  69807. private static _ReturnFullUrlLocation;
  69808. private _checkManifestFile;
  69809. /**
  69810. * Open the database and make it available
  69811. * @param successCallback defines the callback to call on success
  69812. * @param errorCallback defines the callback to call on error
  69813. */
  69814. open(successCallback: () => void, errorCallback: () => void): void;
  69815. /**
  69816. * Loads an image from the database
  69817. * @param url defines the url to load from
  69818. * @param image defines the target DOM image
  69819. */
  69820. loadImage(url: string, image: HTMLImageElement): void;
  69821. private _loadImageFromDBAsync;
  69822. private _saveImageIntoDBAsync;
  69823. private _checkVersionFromDB;
  69824. private _loadVersionFromDBAsync;
  69825. private _saveVersionIntoDBAsync;
  69826. /**
  69827. * Loads a file from database
  69828. * @param url defines the URL to load from
  69829. * @param sceneLoaded defines a callback to call on success
  69830. * @param progressCallBack defines a callback to call when progress changed
  69831. * @param errorCallback defines a callback to call on error
  69832. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69833. */
  69834. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69835. private _loadFileAsync;
  69836. private _saveFileAsync;
  69837. /**
  69838. * Validates if xhr data is correct
  69839. * @param xhr defines the request to validate
  69840. * @param dataType defines the expected data type
  69841. * @returns true if data is correct
  69842. */
  69843. private static _ValidateXHRData;
  69844. }
  69845. }
  69846. declare module "babylonjs/Offline/index" {
  69847. export * from "babylonjs/Offline/database";
  69848. export * from "babylonjs/Offline/IOfflineProvider";
  69849. }
  69850. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69851. /** @hidden */
  69852. export var gpuUpdateParticlesPixelShader: {
  69853. name: string;
  69854. shader: string;
  69855. };
  69856. }
  69857. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69858. /** @hidden */
  69859. export var gpuUpdateParticlesVertexShader: {
  69860. name: string;
  69861. shader: string;
  69862. };
  69863. }
  69864. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69865. /** @hidden */
  69866. export var clipPlaneFragmentDeclaration2: {
  69867. name: string;
  69868. shader: string;
  69869. };
  69870. }
  69871. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69872. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69873. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69875. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69876. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69877. /** @hidden */
  69878. export var gpuRenderParticlesPixelShader: {
  69879. name: string;
  69880. shader: string;
  69881. };
  69882. }
  69883. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69884. /** @hidden */
  69885. export var clipPlaneVertexDeclaration2: {
  69886. name: string;
  69887. shader: string;
  69888. };
  69889. }
  69890. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69891. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69893. /** @hidden */
  69894. export var gpuRenderParticlesVertexShader: {
  69895. name: string;
  69896. shader: string;
  69897. };
  69898. }
  69899. declare module "babylonjs/Particles/gpuParticleSystem" {
  69900. import { Nullable } from "babylonjs/types";
  69901. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69902. import { Observable } from "babylonjs/Misc/observable";
  69903. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69904. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69905. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69906. import { Scene, IDisposable } from "babylonjs/scene";
  69907. import { Effect } from "babylonjs/Materials/effect";
  69908. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69909. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69910. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69911. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69912. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69913. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69914. /**
  69915. * This represents a GPU particle system in Babylon
  69916. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69917. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69918. */
  69919. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69920. /**
  69921. * The layer mask we are rendering the particles through.
  69922. */
  69923. layerMask: number;
  69924. private _capacity;
  69925. private _activeCount;
  69926. private _currentActiveCount;
  69927. private _accumulatedCount;
  69928. private _renderEffect;
  69929. private _updateEffect;
  69930. private _buffer0;
  69931. private _buffer1;
  69932. private _spriteBuffer;
  69933. private _updateVAO;
  69934. private _renderVAO;
  69935. private _targetIndex;
  69936. private _sourceBuffer;
  69937. private _targetBuffer;
  69938. private _engine;
  69939. private _currentRenderId;
  69940. private _started;
  69941. private _stopped;
  69942. private _timeDelta;
  69943. private _randomTexture;
  69944. private _randomTexture2;
  69945. private _attributesStrideSize;
  69946. private _updateEffectOptions;
  69947. private _randomTextureSize;
  69948. private _actualFrame;
  69949. private _customEffect;
  69950. private readonly _rawTextureWidth;
  69951. /**
  69952. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69953. */
  69954. static get IsSupported(): boolean;
  69955. /**
  69956. * An event triggered when the system is disposed.
  69957. */
  69958. onDisposeObservable: Observable<IParticleSystem>;
  69959. /**
  69960. * Gets the maximum number of particles active at the same time.
  69961. * @returns The max number of active particles.
  69962. */
  69963. getCapacity(): number;
  69964. /**
  69965. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69966. * to override the particles.
  69967. */
  69968. forceDepthWrite: boolean;
  69969. /**
  69970. * Gets or set the number of active particles
  69971. */
  69972. get activeParticleCount(): number;
  69973. set activeParticleCount(value: number);
  69974. private _preWarmDone;
  69975. /**
  69976. * Specifies if the particles are updated in emitter local space or world space.
  69977. */
  69978. isLocal: boolean;
  69979. /**
  69980. * Is this system ready to be used/rendered
  69981. * @return true if the system is ready
  69982. */
  69983. isReady(): boolean;
  69984. /**
  69985. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69986. * @returns True if it has been started, otherwise false.
  69987. */
  69988. isStarted(): boolean;
  69989. /**
  69990. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69991. * @returns True if it has been stopped, otherwise false.
  69992. */
  69993. isStopped(): boolean;
  69994. /**
  69995. * Gets a boolean indicating that the system is stopping
  69996. * @returns true if the system is currently stopping
  69997. */
  69998. isStopping(): boolean;
  69999. /**
  70000. * Gets the number of particles active at the same time.
  70001. * @returns The number of active particles.
  70002. */
  70003. getActiveCount(): number;
  70004. /**
  70005. * Starts the particle system and begins to emit
  70006. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70007. */
  70008. start(delay?: number): void;
  70009. /**
  70010. * Stops the particle system.
  70011. */
  70012. stop(): void;
  70013. /**
  70014. * Remove all active particles
  70015. */
  70016. reset(): void;
  70017. /**
  70018. * Returns the string "GPUParticleSystem"
  70019. * @returns a string containing the class name
  70020. */
  70021. getClassName(): string;
  70022. /**
  70023. * Gets the custom effect used to render the particles
  70024. * @param blendMode Blend mode for which the effect should be retrieved
  70025. * @returns The effect
  70026. */
  70027. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70028. /**
  70029. * Sets the custom effect used to render the particles
  70030. * @param effect The effect to set
  70031. * @param blendMode Blend mode for which the effect should be set
  70032. */
  70033. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70034. /** @hidden */
  70035. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70036. /**
  70037. * Observable that will be called just before the particles are drawn
  70038. */
  70039. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70040. /**
  70041. * Gets the name of the particle vertex shader
  70042. */
  70043. get vertexShaderName(): string;
  70044. private _colorGradientsTexture;
  70045. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70046. /**
  70047. * Adds a new color gradient
  70048. * @param gradient defines the gradient to use (between 0 and 1)
  70049. * @param color1 defines the color to affect to the specified gradient
  70050. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70051. * @returns the current particle system
  70052. */
  70053. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70054. private _refreshColorGradient;
  70055. /** Force the system to rebuild all gradients that need to be resync */
  70056. forceRefreshGradients(): void;
  70057. /**
  70058. * Remove a specific color gradient
  70059. * @param gradient defines the gradient to remove
  70060. * @returns the current particle system
  70061. */
  70062. removeColorGradient(gradient: number): GPUParticleSystem;
  70063. private _angularSpeedGradientsTexture;
  70064. private _sizeGradientsTexture;
  70065. private _velocityGradientsTexture;
  70066. private _limitVelocityGradientsTexture;
  70067. private _dragGradientsTexture;
  70068. private _addFactorGradient;
  70069. /**
  70070. * Adds a new size gradient
  70071. * @param gradient defines the gradient to use (between 0 and 1)
  70072. * @param factor defines the size factor to affect to the specified gradient
  70073. * @returns the current particle system
  70074. */
  70075. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70076. /**
  70077. * Remove a specific size gradient
  70078. * @param gradient defines the gradient to remove
  70079. * @returns the current particle system
  70080. */
  70081. removeSizeGradient(gradient: number): GPUParticleSystem;
  70082. private _refreshFactorGradient;
  70083. /**
  70084. * Adds a new angular speed gradient
  70085. * @param gradient defines the gradient to use (between 0 and 1)
  70086. * @param factor defines the angular speed to affect to the specified gradient
  70087. * @returns the current particle system
  70088. */
  70089. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70090. /**
  70091. * Remove a specific angular speed gradient
  70092. * @param gradient defines the gradient to remove
  70093. * @returns the current particle system
  70094. */
  70095. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70096. /**
  70097. * Adds a new velocity gradient
  70098. * @param gradient defines the gradient to use (between 0 and 1)
  70099. * @param factor defines the velocity to affect to the specified gradient
  70100. * @returns the current particle system
  70101. */
  70102. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70103. /**
  70104. * Remove a specific velocity gradient
  70105. * @param gradient defines the gradient to remove
  70106. * @returns the current particle system
  70107. */
  70108. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70109. /**
  70110. * Adds a new limit velocity gradient
  70111. * @param gradient defines the gradient to use (between 0 and 1)
  70112. * @param factor defines the limit velocity value to affect to the specified gradient
  70113. * @returns the current particle system
  70114. */
  70115. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70116. /**
  70117. * Remove a specific limit velocity gradient
  70118. * @param gradient defines the gradient to remove
  70119. * @returns the current particle system
  70120. */
  70121. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70122. /**
  70123. * Adds a new drag gradient
  70124. * @param gradient defines the gradient to use (between 0 and 1)
  70125. * @param factor defines the drag value to affect to the specified gradient
  70126. * @returns the current particle system
  70127. */
  70128. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70129. /**
  70130. * Remove a specific drag gradient
  70131. * @param gradient defines the gradient to remove
  70132. * @returns the current particle system
  70133. */
  70134. removeDragGradient(gradient: number): GPUParticleSystem;
  70135. /**
  70136. * Not supported by GPUParticleSystem
  70137. * @param gradient defines the gradient to use (between 0 and 1)
  70138. * @param factor defines the emit rate value to affect to the specified gradient
  70139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70140. * @returns the current particle system
  70141. */
  70142. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70143. /**
  70144. * Not supported by GPUParticleSystem
  70145. * @param gradient defines the gradient to remove
  70146. * @returns the current particle system
  70147. */
  70148. removeEmitRateGradient(gradient: number): IParticleSystem;
  70149. /**
  70150. * Not supported by GPUParticleSystem
  70151. * @param gradient defines the gradient to use (between 0 and 1)
  70152. * @param factor defines the start size value to affect to the specified gradient
  70153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70154. * @returns the current particle system
  70155. */
  70156. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70157. /**
  70158. * Not supported by GPUParticleSystem
  70159. * @param gradient defines the gradient to remove
  70160. * @returns the current particle system
  70161. */
  70162. removeStartSizeGradient(gradient: number): IParticleSystem;
  70163. /**
  70164. * Not supported by GPUParticleSystem
  70165. * @param gradient defines the gradient to use (between 0 and 1)
  70166. * @param min defines the color remap minimal range
  70167. * @param max defines the color remap maximal range
  70168. * @returns the current particle system
  70169. */
  70170. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70171. /**
  70172. * Not supported by GPUParticleSystem
  70173. * @param gradient defines the gradient to remove
  70174. * @returns the current particle system
  70175. */
  70176. removeColorRemapGradient(): IParticleSystem;
  70177. /**
  70178. * Not supported by GPUParticleSystem
  70179. * @param gradient defines the gradient to use (between 0 and 1)
  70180. * @param min defines the alpha remap minimal range
  70181. * @param max defines the alpha remap maximal range
  70182. * @returns the current particle system
  70183. */
  70184. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70185. /**
  70186. * Not supported by GPUParticleSystem
  70187. * @param gradient defines the gradient to remove
  70188. * @returns the current particle system
  70189. */
  70190. removeAlphaRemapGradient(): IParticleSystem;
  70191. /**
  70192. * Not supported by GPUParticleSystem
  70193. * @param gradient defines the gradient to use (between 0 and 1)
  70194. * @param color defines the color to affect to the specified gradient
  70195. * @returns the current particle system
  70196. */
  70197. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70198. /**
  70199. * Not supported by GPUParticleSystem
  70200. * @param gradient defines the gradient to remove
  70201. * @returns the current particle system
  70202. */
  70203. removeRampGradient(): IParticleSystem;
  70204. /**
  70205. * Not supported by GPUParticleSystem
  70206. * @returns the list of ramp gradients
  70207. */
  70208. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70209. /**
  70210. * Not supported by GPUParticleSystem
  70211. * Gets or sets a boolean indicating that ramp gradients must be used
  70212. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70213. */
  70214. get useRampGradients(): boolean;
  70215. set useRampGradients(value: boolean);
  70216. /**
  70217. * Not supported by GPUParticleSystem
  70218. * @param gradient defines the gradient to use (between 0 and 1)
  70219. * @param factor defines the life time factor to affect to the specified gradient
  70220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70221. * @returns the current particle system
  70222. */
  70223. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70224. /**
  70225. * Not supported by GPUParticleSystem
  70226. * @param gradient defines the gradient to remove
  70227. * @returns the current particle system
  70228. */
  70229. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70230. /**
  70231. * Instantiates a GPU particle system.
  70232. * 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.
  70233. * @param name The name of the particle system
  70234. * @param options The options used to create the system
  70235. * @param scene The scene the particle system belongs to
  70236. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70237. * @param customEffect a custom effect used to change the way particles are rendered by default
  70238. */
  70239. constructor(name: string, options: Partial<{
  70240. capacity: number;
  70241. randomTextureSize: number;
  70242. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70243. protected _reset(): void;
  70244. private _createUpdateVAO;
  70245. private _createRenderVAO;
  70246. private _initialize;
  70247. /** @hidden */
  70248. _recreateUpdateEffect(): void;
  70249. private _getEffect;
  70250. /**
  70251. * Fill the defines array according to the current settings of the particle system
  70252. * @param defines Array to be updated
  70253. * @param blendMode blend mode to take into account when updating the array
  70254. */
  70255. fillDefines(defines: Array<string>, blendMode?: number): void;
  70256. /**
  70257. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70258. * @param uniforms Uniforms array to fill
  70259. * @param attributes Attributes array to fill
  70260. * @param samplers Samplers array to fill
  70261. */
  70262. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70263. /** @hidden */
  70264. _recreateRenderEffect(): Effect;
  70265. /**
  70266. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70267. * @param preWarm defines if we are in the pre-warmimg phase
  70268. */
  70269. animate(preWarm?: boolean): void;
  70270. private _createFactorGradientTexture;
  70271. private _createSizeGradientTexture;
  70272. private _createAngularSpeedGradientTexture;
  70273. private _createVelocityGradientTexture;
  70274. private _createLimitVelocityGradientTexture;
  70275. private _createDragGradientTexture;
  70276. private _createColorGradientTexture;
  70277. /**
  70278. * Renders the particle system in its current state
  70279. * @param preWarm defines if the system should only update the particles but not render them
  70280. * @returns the current number of particles
  70281. */
  70282. render(preWarm?: boolean): number;
  70283. /**
  70284. * Rebuilds the particle system
  70285. */
  70286. rebuild(): void;
  70287. private _releaseBuffers;
  70288. private _releaseVAOs;
  70289. /**
  70290. * Disposes the particle system and free the associated resources
  70291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70292. */
  70293. dispose(disposeTexture?: boolean): void;
  70294. /**
  70295. * Clones the particle system.
  70296. * @param name The name of the cloned object
  70297. * @param newEmitter The new emitter to use
  70298. * @returns the cloned particle system
  70299. */
  70300. clone(name: string, newEmitter: any): GPUParticleSystem;
  70301. /**
  70302. * Serializes the particle system to a JSON object
  70303. * @param serializeTexture defines if the texture must be serialized as well
  70304. * @returns the JSON object
  70305. */
  70306. serialize(serializeTexture?: boolean): any;
  70307. /**
  70308. * Parses a JSON object to create a GPU particle system.
  70309. * @param parsedParticleSystem The JSON object to parse
  70310. * @param scene The scene to create the particle system in
  70311. * @param rootUrl The root url to use to load external dependencies like texture
  70312. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70313. * @returns the parsed GPU particle system
  70314. */
  70315. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70316. }
  70317. }
  70318. declare module "babylonjs/Particles/particleSystemSet" {
  70319. import { Nullable } from "babylonjs/types";
  70320. import { Color3 } from "babylonjs/Maths/math.color";
  70321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70324. import { Scene, IDisposable } from "babylonjs/scene";
  70325. /**
  70326. * Represents a set of particle systems working together to create a specific effect
  70327. */
  70328. export class ParticleSystemSet implements IDisposable {
  70329. /**
  70330. * Gets or sets base Assets URL
  70331. */
  70332. static BaseAssetsUrl: string;
  70333. private _emitterCreationOptions;
  70334. private _emitterNode;
  70335. /**
  70336. * Gets the particle system list
  70337. */
  70338. systems: IParticleSystem[];
  70339. /**
  70340. * Gets the emitter node used with this set
  70341. */
  70342. get emitterNode(): Nullable<TransformNode>;
  70343. /**
  70344. * Creates a new emitter mesh as a sphere
  70345. * @param options defines the options used to create the sphere
  70346. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70347. * @param scene defines the hosting scene
  70348. */
  70349. setEmitterAsSphere(options: {
  70350. diameter: number;
  70351. segments: number;
  70352. color: Color3;
  70353. }, renderingGroupId: number, scene: Scene): void;
  70354. /**
  70355. * Starts all particle systems of the set
  70356. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70357. */
  70358. start(emitter?: AbstractMesh): void;
  70359. /**
  70360. * Release all associated resources
  70361. */
  70362. dispose(): void;
  70363. /**
  70364. * Serialize the set into a JSON compatible object
  70365. * @param serializeTexture defines if the texture must be serialized as well
  70366. * @returns a JSON compatible representation of the set
  70367. */
  70368. serialize(serializeTexture?: boolean): any;
  70369. /**
  70370. * Parse a new ParticleSystemSet from a serialized source
  70371. * @param data defines a JSON compatible representation of the set
  70372. * @param scene defines the hosting scene
  70373. * @param gpu defines if we want GPU particles or CPU particles
  70374. * @returns a new ParticleSystemSet
  70375. */
  70376. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70377. }
  70378. }
  70379. declare module "babylonjs/Particles/particleHelper" {
  70380. import { Nullable } from "babylonjs/types";
  70381. import { Scene } from "babylonjs/scene";
  70382. import { Vector3 } from "babylonjs/Maths/math.vector";
  70383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70384. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70385. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70386. /**
  70387. * This class is made for on one-liner static method to help creating particle system set.
  70388. */
  70389. export class ParticleHelper {
  70390. /**
  70391. * Gets or sets base Assets URL
  70392. */
  70393. static BaseAssetsUrl: string;
  70394. /** Define the Url to load snippets */
  70395. static SnippetUrl: string;
  70396. /**
  70397. * Create a default particle system that you can tweak
  70398. * @param emitter defines the emitter to use
  70399. * @param capacity defines the system capacity (default is 500 particles)
  70400. * @param scene defines the hosting scene
  70401. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70402. * @returns the new Particle system
  70403. */
  70404. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70405. /**
  70406. * This is the main static method (one-liner) of this helper to create different particle systems
  70407. * @param type This string represents the type to the particle system to create
  70408. * @param scene The scene where the particle system should live
  70409. * @param gpu If the system will use gpu
  70410. * @returns the ParticleSystemSet created
  70411. */
  70412. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70413. /**
  70414. * Static function used to export a particle system to a ParticleSystemSet variable.
  70415. * Please note that the emitter shape is not exported
  70416. * @param systems defines the particle systems to export
  70417. * @returns the created particle system set
  70418. */
  70419. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70420. /**
  70421. * Creates a particle system from a snippet saved in a remote file
  70422. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70423. * @param url defines the url to load from
  70424. * @param scene defines the hosting scene
  70425. * @param gpu If the system will use gpu
  70426. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70427. * @returns a promise that will resolve to the new particle system
  70428. */
  70429. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70430. /**
  70431. * Creates a particle system from a snippet saved by the particle system editor
  70432. * @param snippetId defines the snippet to load
  70433. * @param scene defines the hosting scene
  70434. * @param gpu If the system will use gpu
  70435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70436. * @returns a promise that will resolve to the new particle system
  70437. */
  70438. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70439. }
  70440. }
  70441. declare module "babylonjs/Particles/particleSystemComponent" {
  70442. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70443. import { Effect } from "babylonjs/Materials/effect";
  70444. import "babylonjs/Shaders/particles.vertex";
  70445. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70446. module "babylonjs/Engines/engine" {
  70447. interface Engine {
  70448. /**
  70449. * Create an effect to use with particle systems.
  70450. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70451. * the particle system for which you want to create a custom effect in the last parameter
  70452. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70453. * @param uniformsNames defines a list of attribute names
  70454. * @param samplers defines an array of string used to represent textures
  70455. * @param defines defines the string containing the defines to use to compile the shaders
  70456. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70457. * @param onCompiled defines a function to call when the effect creation is successful
  70458. * @param onError defines a function to call when the effect creation has failed
  70459. * @param particleSystem the particle system you want to create the effect for
  70460. * @returns the new Effect
  70461. */
  70462. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70463. }
  70464. }
  70465. module "babylonjs/Meshes/mesh" {
  70466. interface Mesh {
  70467. /**
  70468. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70469. * @returns an array of IParticleSystem
  70470. */
  70471. getEmittedParticleSystems(): IParticleSystem[];
  70472. /**
  70473. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70474. * @returns an array of IParticleSystem
  70475. */
  70476. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70477. }
  70478. }
  70479. }
  70480. declare module "babylonjs/Particles/pointsCloudSystem" {
  70481. import { Color4 } from "babylonjs/Maths/math";
  70482. import { Mesh } from "babylonjs/Meshes/mesh";
  70483. import { Scene, IDisposable } from "babylonjs/scene";
  70484. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70485. /** Defines the 4 color options */
  70486. export enum PointColor {
  70487. /** color value */
  70488. Color = 2,
  70489. /** uv value */
  70490. UV = 1,
  70491. /** random value */
  70492. Random = 0,
  70493. /** stated value */
  70494. Stated = 3
  70495. }
  70496. /**
  70497. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70498. * 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.
  70499. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70500. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70501. *
  70502. * Full documentation here : TO BE ENTERED
  70503. */
  70504. export class PointsCloudSystem implements IDisposable {
  70505. /**
  70506. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70507. * Example : var p = SPS.particles[i];
  70508. */
  70509. particles: CloudPoint[];
  70510. /**
  70511. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70512. */
  70513. nbParticles: number;
  70514. /**
  70515. * This a counter for your own usage. It's not set by any SPS functions.
  70516. */
  70517. counter: number;
  70518. /**
  70519. * The PCS name. This name is also given to the underlying mesh.
  70520. */
  70521. name: string;
  70522. /**
  70523. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70524. */
  70525. mesh: Mesh;
  70526. /**
  70527. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70528. * Please read :
  70529. */
  70530. vars: any;
  70531. /**
  70532. * @hidden
  70533. */
  70534. _size: number;
  70535. private _scene;
  70536. private _promises;
  70537. private _positions;
  70538. private _indices;
  70539. private _normals;
  70540. private _colors;
  70541. private _uvs;
  70542. private _indices32;
  70543. private _positions32;
  70544. private _colors32;
  70545. private _uvs32;
  70546. private _updatable;
  70547. private _isVisibilityBoxLocked;
  70548. private _alwaysVisible;
  70549. private _groups;
  70550. private _groupCounter;
  70551. private _computeParticleColor;
  70552. private _computeParticleTexture;
  70553. private _computeParticleRotation;
  70554. private _computeBoundingBox;
  70555. private _isReady;
  70556. /**
  70557. * Creates a PCS (Points Cloud System) object
  70558. * @param name (String) is the PCS name, this will be the underlying mesh name
  70559. * @param pointSize (number) is the size for each point
  70560. * @param scene (Scene) is the scene in which the PCS is added
  70561. * @param options defines the options of the PCS e.g.
  70562. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70563. */
  70564. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70565. updatable?: boolean;
  70566. });
  70567. /**
  70568. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70569. * If no points were added to the PCS, the returned mesh is just a single point.
  70570. * @returns a promise for the created mesh
  70571. */
  70572. buildMeshAsync(): Promise<Mesh>;
  70573. /**
  70574. * @hidden
  70575. */
  70576. private _buildMesh;
  70577. private _addParticle;
  70578. private _randomUnitVector;
  70579. private _getColorIndicesForCoord;
  70580. private _setPointsColorOrUV;
  70581. private _colorFromTexture;
  70582. private _calculateDensity;
  70583. /**
  70584. * Adds points to the PCS in random positions within a unit sphere
  70585. * @param nb (positive integer) the number of particles to be created from this model
  70586. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70587. * @returns the number of groups in the system
  70588. */
  70589. addPoints(nb: number, pointFunction?: any): number;
  70590. /**
  70591. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70600. /**
  70601. * Adds points to the PCS inside the model shape
  70602. * @param mesh is any Mesh object that will be used as a surface model for the points
  70603. * @param nb (positive integer) the number of particles to be created from this model
  70604. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70605. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70606. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70607. * @returns the number of groups in the system
  70608. */
  70609. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70610. /**
  70611. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70612. * This method calls `updateParticle()` for each particle of the SPS.
  70613. * For an animated SPS, it is usually called within the render loop.
  70614. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70615. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70616. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70617. * @returns the PCS.
  70618. */
  70619. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70620. /**
  70621. * Disposes the PCS.
  70622. */
  70623. dispose(): void;
  70624. /**
  70625. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70626. * doc :
  70627. * @returns the PCS.
  70628. */
  70629. refreshVisibleSize(): PointsCloudSystem;
  70630. /**
  70631. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70632. * @param size the size (float) of the visibility box
  70633. * note : this doesn't lock the PCS mesh bounding box.
  70634. * doc :
  70635. */
  70636. setVisibilityBox(size: number): void;
  70637. /**
  70638. * Gets whether the PCS is always visible or not
  70639. * doc :
  70640. */
  70641. get isAlwaysVisible(): boolean;
  70642. /**
  70643. * Sets the PCS as always visible or not
  70644. * doc :
  70645. */
  70646. set isAlwaysVisible(val: boolean);
  70647. /**
  70648. * Tells to `setParticles()` to compute the particle rotations or not
  70649. * Default value : false. The PCS is faster when it's set to false
  70650. * Note : particle rotations are only applied to parent particles
  70651. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70652. */
  70653. set computeParticleRotation(val: boolean);
  70654. /**
  70655. * Tells to `setParticles()` to compute the particle colors or not.
  70656. * Default value : true. The PCS is faster when it's set to false.
  70657. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70658. */
  70659. set computeParticleColor(val: boolean);
  70660. set computeParticleTexture(val: boolean);
  70661. /**
  70662. * Gets if `setParticles()` computes the particle colors or not.
  70663. * Default value : false. The PCS is faster when it's set to false.
  70664. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70665. */
  70666. get computeParticleColor(): boolean;
  70667. /**
  70668. * Gets if `setParticles()` computes the particle textures or not.
  70669. * Default value : false. The PCS is faster when it's set to false.
  70670. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70671. */
  70672. get computeParticleTexture(): boolean;
  70673. /**
  70674. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70675. */
  70676. set computeBoundingBox(val: boolean);
  70677. /**
  70678. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70679. */
  70680. get computeBoundingBox(): boolean;
  70681. /**
  70682. * This function does nothing. It may be overwritten to set all the particle first values.
  70683. * The PCS doesn't call this function, you may have to call it by your own.
  70684. * doc :
  70685. */
  70686. initParticles(): void;
  70687. /**
  70688. * This function does nothing. It may be overwritten to recycle a particle
  70689. * The PCS doesn't call this function, you can to call it
  70690. * doc :
  70691. * @param particle The particle to recycle
  70692. * @returns the recycled particle
  70693. */
  70694. recycleParticle(particle: CloudPoint): CloudPoint;
  70695. /**
  70696. * Updates a particle : this function should be overwritten by the user.
  70697. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70698. * doc :
  70699. * @example : just set a particle position or velocity and recycle conditions
  70700. * @param particle The particle to update
  70701. * @returns the updated particle
  70702. */
  70703. updateParticle(particle: CloudPoint): CloudPoint;
  70704. /**
  70705. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70706. * This does nothing and may be overwritten by the user.
  70707. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70708. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70709. * @param update the boolean update value actually passed to setParticles()
  70710. */
  70711. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70712. /**
  70713. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70714. * This will be passed three parameters.
  70715. * This does nothing and may be overwritten by the user.
  70716. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70717. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70718. * @param update the boolean update value actually passed to setParticles()
  70719. */
  70720. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70721. }
  70722. }
  70723. declare module "babylonjs/Particles/cloudPoint" {
  70724. import { Nullable } from "babylonjs/types";
  70725. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70726. import { Mesh } from "babylonjs/Meshes/mesh";
  70727. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70728. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70729. /**
  70730. * Represents one particle of a points cloud system.
  70731. */
  70732. export class CloudPoint {
  70733. /**
  70734. * particle global index
  70735. */
  70736. idx: number;
  70737. /**
  70738. * The color of the particle
  70739. */
  70740. color: Nullable<Color4>;
  70741. /**
  70742. * The world space position of the particle.
  70743. */
  70744. position: Vector3;
  70745. /**
  70746. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70747. */
  70748. rotation: Vector3;
  70749. /**
  70750. * The world space rotation quaternion of the particle.
  70751. */
  70752. rotationQuaternion: Nullable<Quaternion>;
  70753. /**
  70754. * The uv of the particle.
  70755. */
  70756. uv: Nullable<Vector2>;
  70757. /**
  70758. * The current speed of the particle.
  70759. */
  70760. velocity: Vector3;
  70761. /**
  70762. * The pivot point in the particle local space.
  70763. */
  70764. pivot: Vector3;
  70765. /**
  70766. * Must the particle be translated from its pivot point in its local space ?
  70767. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70768. * Default : false
  70769. */
  70770. translateFromPivot: boolean;
  70771. /**
  70772. * Index of this particle in the global "positions" array (Internal use)
  70773. * @hidden
  70774. */
  70775. _pos: number;
  70776. /**
  70777. * @hidden Index of this particle in the global "indices" array (Internal use)
  70778. */
  70779. _ind: number;
  70780. /**
  70781. * Group this particle belongs to
  70782. */
  70783. _group: PointsGroup;
  70784. /**
  70785. * Group id of this particle
  70786. */
  70787. groupId: number;
  70788. /**
  70789. * Index of the particle in its group id (Internal use)
  70790. */
  70791. idxInGroup: number;
  70792. /**
  70793. * @hidden Particle BoundingInfo object (Internal use)
  70794. */
  70795. _boundingInfo: BoundingInfo;
  70796. /**
  70797. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70798. */
  70799. _pcs: PointsCloudSystem;
  70800. /**
  70801. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70802. */
  70803. _stillInvisible: boolean;
  70804. /**
  70805. * @hidden Last computed particle rotation matrix
  70806. */
  70807. _rotationMatrix: number[];
  70808. /**
  70809. * Parent particle Id, if any.
  70810. * Default null.
  70811. */
  70812. parentId: Nullable<number>;
  70813. /**
  70814. * @hidden Internal global position in the PCS.
  70815. */
  70816. _globalPosition: Vector3;
  70817. /**
  70818. * Creates a Point Cloud object.
  70819. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70820. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70821. * @param group (PointsGroup) is the group the particle belongs to
  70822. * @param groupId (integer) is the group identifier in the PCS.
  70823. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70824. * @param pcs defines the PCS it is associated to
  70825. */
  70826. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70827. /**
  70828. * get point size
  70829. */
  70830. get size(): Vector3;
  70831. /**
  70832. * Set point size
  70833. */
  70834. set size(scale: Vector3);
  70835. /**
  70836. * Legacy support, changed quaternion to rotationQuaternion
  70837. */
  70838. get quaternion(): Nullable<Quaternion>;
  70839. /**
  70840. * Legacy support, changed quaternion to rotationQuaternion
  70841. */
  70842. set quaternion(q: Nullable<Quaternion>);
  70843. /**
  70844. * Returns a boolean. True if the particle intersects a mesh, else false
  70845. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70846. * @param target is the object (point or mesh) what the intersection is computed against
  70847. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70848. * @returns true if it intersects
  70849. */
  70850. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70851. /**
  70852. * get the rotation matrix of the particle
  70853. * @hidden
  70854. */
  70855. getRotationMatrix(m: Matrix): void;
  70856. }
  70857. /**
  70858. * Represents a group of points in a points cloud system
  70859. * * PCS internal tool, don't use it manually.
  70860. */
  70861. export class PointsGroup {
  70862. /**
  70863. * The group id
  70864. * @hidden
  70865. */
  70866. groupID: number;
  70867. /**
  70868. * image data for group (internal use)
  70869. * @hidden
  70870. */
  70871. _groupImageData: Nullable<ArrayBufferView>;
  70872. /**
  70873. * Image Width (internal use)
  70874. * @hidden
  70875. */
  70876. _groupImgWidth: number;
  70877. /**
  70878. * Image Height (internal use)
  70879. * @hidden
  70880. */
  70881. _groupImgHeight: number;
  70882. /**
  70883. * Custom position function (internal use)
  70884. * @hidden
  70885. */
  70886. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70887. /**
  70888. * density per facet for surface points
  70889. * @hidden
  70890. */
  70891. _groupDensity: number[];
  70892. /**
  70893. * Only when points are colored by texture carries pointer to texture list array
  70894. * @hidden
  70895. */
  70896. _textureNb: number;
  70897. /**
  70898. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70899. * PCS internal tool, don't use it manually.
  70900. * @hidden
  70901. */
  70902. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70903. }
  70904. }
  70905. declare module "babylonjs/Particles/index" {
  70906. export * from "babylonjs/Particles/baseParticleSystem";
  70907. export * from "babylonjs/Particles/EmitterTypes/index";
  70908. export * from "babylonjs/Particles/gpuParticleSystem";
  70909. export * from "babylonjs/Particles/IParticleSystem";
  70910. export * from "babylonjs/Particles/particle";
  70911. export * from "babylonjs/Particles/particleHelper";
  70912. export * from "babylonjs/Particles/particleSystem";
  70913. import "babylonjs/Particles/particleSystemComponent";
  70914. export * from "babylonjs/Particles/particleSystemComponent";
  70915. export * from "babylonjs/Particles/particleSystemSet";
  70916. export * from "babylonjs/Particles/solidParticle";
  70917. export * from "babylonjs/Particles/solidParticleSystem";
  70918. export * from "babylonjs/Particles/cloudPoint";
  70919. export * from "babylonjs/Particles/pointsCloudSystem";
  70920. export * from "babylonjs/Particles/subEmitter";
  70921. }
  70922. declare module "babylonjs/Physics/physicsEngineComponent" {
  70923. import { Nullable } from "babylonjs/types";
  70924. import { Observable, Observer } from "babylonjs/Misc/observable";
  70925. import { Vector3 } from "babylonjs/Maths/math.vector";
  70926. import { Mesh } from "babylonjs/Meshes/mesh";
  70927. import { ISceneComponent } from "babylonjs/sceneComponent";
  70928. import { Scene } from "babylonjs/scene";
  70929. import { Node } from "babylonjs/node";
  70930. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70931. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70932. module "babylonjs/scene" {
  70933. interface Scene {
  70934. /** @hidden (Backing field) */
  70935. _physicsEngine: Nullable<IPhysicsEngine>;
  70936. /** @hidden */
  70937. _physicsTimeAccumulator: number;
  70938. /**
  70939. * Gets the current physics engine
  70940. * @returns a IPhysicsEngine or null if none attached
  70941. */
  70942. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70943. /**
  70944. * Enables physics to the current scene
  70945. * @param gravity defines the scene's gravity for the physics engine
  70946. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70947. * @return a boolean indicating if the physics engine was initialized
  70948. */
  70949. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70950. /**
  70951. * Disables and disposes the physics engine associated with the scene
  70952. */
  70953. disablePhysicsEngine(): void;
  70954. /**
  70955. * Gets a boolean indicating if there is an active physics engine
  70956. * @returns a boolean indicating if there is an active physics engine
  70957. */
  70958. isPhysicsEnabled(): boolean;
  70959. /**
  70960. * Deletes a physics compound impostor
  70961. * @param compound defines the compound to delete
  70962. */
  70963. deleteCompoundImpostor(compound: any): void;
  70964. /**
  70965. * An event triggered when physic simulation is about to be run
  70966. */
  70967. onBeforePhysicsObservable: Observable<Scene>;
  70968. /**
  70969. * An event triggered when physic simulation has been done
  70970. */
  70971. onAfterPhysicsObservable: Observable<Scene>;
  70972. }
  70973. }
  70974. module "babylonjs/Meshes/abstractMesh" {
  70975. interface AbstractMesh {
  70976. /** @hidden */
  70977. _physicsImpostor: Nullable<PhysicsImpostor>;
  70978. /**
  70979. * Gets or sets impostor used for physic simulation
  70980. * @see https://doc.babylonjs.com/features/physics_engine
  70981. */
  70982. physicsImpostor: Nullable<PhysicsImpostor>;
  70983. /**
  70984. * Gets the current physics impostor
  70985. * @see https://doc.babylonjs.com/features/physics_engine
  70986. * @returns a physics impostor or null
  70987. */
  70988. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70989. /** Apply a physic impulse to the mesh
  70990. * @param force defines the force to apply
  70991. * @param contactPoint defines where to apply the force
  70992. * @returns the current mesh
  70993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70994. */
  70995. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70996. /**
  70997. * Creates a physic joint between two meshes
  70998. * @param otherMesh defines the other mesh to use
  70999. * @param pivot1 defines the pivot to use on this mesh
  71000. * @param pivot2 defines the pivot to use on the other mesh
  71001. * @param options defines additional options (can be plugin dependent)
  71002. * @returns the current mesh
  71003. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71004. */
  71005. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71006. /** @hidden */
  71007. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71008. }
  71009. }
  71010. /**
  71011. * Defines the physics engine scene component responsible to manage a physics engine
  71012. */
  71013. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71014. /**
  71015. * The component name helpful to identify the component in the list of scene components.
  71016. */
  71017. readonly name: string;
  71018. /**
  71019. * The scene the component belongs to.
  71020. */
  71021. scene: Scene;
  71022. /**
  71023. * Creates a new instance of the component for the given scene
  71024. * @param scene Defines the scene to register the component in
  71025. */
  71026. constructor(scene: Scene);
  71027. /**
  71028. * Registers the component in a given scene
  71029. */
  71030. register(): void;
  71031. /**
  71032. * Rebuilds the elements related to this component in case of
  71033. * context lost for instance.
  71034. */
  71035. rebuild(): void;
  71036. /**
  71037. * Disposes the component and the associated ressources
  71038. */
  71039. dispose(): void;
  71040. }
  71041. }
  71042. declare module "babylonjs/Physics/physicsHelper" {
  71043. import { Nullable } from "babylonjs/types";
  71044. import { Vector3 } from "babylonjs/Maths/math.vector";
  71045. import { Mesh } from "babylonjs/Meshes/mesh";
  71046. import { Scene } from "babylonjs/scene";
  71047. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71048. /**
  71049. * A helper for physics simulations
  71050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71051. */
  71052. export class PhysicsHelper {
  71053. private _scene;
  71054. private _physicsEngine;
  71055. /**
  71056. * Initializes the Physics helper
  71057. * @param scene Babylon.js scene
  71058. */
  71059. constructor(scene: Scene);
  71060. /**
  71061. * Applies a radial explosion impulse
  71062. * @param origin the origin of the explosion
  71063. * @param radiusOrEventOptions the radius or the options of radial explosion
  71064. * @param strength the explosion strength
  71065. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71066. * @returns A physics radial explosion event, or null
  71067. */
  71068. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71069. /**
  71070. * Applies a radial explosion force
  71071. * @param origin the origin of the explosion
  71072. * @param radiusOrEventOptions the radius or the options of radial explosion
  71073. * @param strength the explosion strength
  71074. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71075. * @returns A physics radial explosion event, or null
  71076. */
  71077. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71078. /**
  71079. * Creates a gravitational field
  71080. * @param origin the origin of the explosion
  71081. * @param radiusOrEventOptions the radius or the options of radial explosion
  71082. * @param strength the explosion strength
  71083. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71084. * @returns A physics gravitational field event, or null
  71085. */
  71086. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71087. /**
  71088. * Creates a physics updraft event
  71089. * @param origin the origin of the updraft
  71090. * @param radiusOrEventOptions the radius or the options of the updraft
  71091. * @param strength the strength of the updraft
  71092. * @param height the height of the updraft
  71093. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71094. * @returns A physics updraft event, or null
  71095. */
  71096. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71097. /**
  71098. * Creates a physics vortex event
  71099. * @param origin the of the vortex
  71100. * @param radiusOrEventOptions the radius or the options of the vortex
  71101. * @param strength the strength of the vortex
  71102. * @param height the height of the vortex
  71103. * @returns a Physics vortex event, or null
  71104. * A physics vortex event or null
  71105. */
  71106. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71107. }
  71108. /**
  71109. * Represents a physics radial explosion event
  71110. */
  71111. class PhysicsRadialExplosionEvent {
  71112. private _scene;
  71113. private _options;
  71114. private _sphere;
  71115. private _dataFetched;
  71116. /**
  71117. * Initializes a radial explosioin event
  71118. * @param _scene BabylonJS scene
  71119. * @param _options The options for the vortex event
  71120. */
  71121. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71122. /**
  71123. * Returns the data related to the radial explosion event (sphere).
  71124. * @returns The radial explosion event data
  71125. */
  71126. getData(): PhysicsRadialExplosionEventData;
  71127. /**
  71128. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71129. * @param impostor A physics imposter
  71130. * @param origin the origin of the explosion
  71131. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71132. */
  71133. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71134. /**
  71135. * Triggers affecterd impostors callbacks
  71136. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71137. */
  71138. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71139. /**
  71140. * Disposes the sphere.
  71141. * @param force Specifies if the sphere should be disposed by force
  71142. */
  71143. dispose(force?: boolean): void;
  71144. /*** Helpers ***/
  71145. private _prepareSphere;
  71146. private _intersectsWithSphere;
  71147. }
  71148. /**
  71149. * Represents a gravitational field event
  71150. */
  71151. class PhysicsGravitationalFieldEvent {
  71152. private _physicsHelper;
  71153. private _scene;
  71154. private _origin;
  71155. private _options;
  71156. private _tickCallback;
  71157. private _sphere;
  71158. private _dataFetched;
  71159. /**
  71160. * Initializes the physics gravitational field event
  71161. * @param _physicsHelper A physics helper
  71162. * @param _scene BabylonJS scene
  71163. * @param _origin The origin position of the gravitational field event
  71164. * @param _options The options for the vortex event
  71165. */
  71166. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71167. /**
  71168. * Returns the data related to the gravitational field event (sphere).
  71169. * @returns A gravitational field event
  71170. */
  71171. getData(): PhysicsGravitationalFieldEventData;
  71172. /**
  71173. * Enables the gravitational field.
  71174. */
  71175. enable(): void;
  71176. /**
  71177. * Disables the gravitational field.
  71178. */
  71179. disable(): void;
  71180. /**
  71181. * Disposes the sphere.
  71182. * @param force The force to dispose from the gravitational field event
  71183. */
  71184. dispose(force?: boolean): void;
  71185. private _tick;
  71186. }
  71187. /**
  71188. * Represents a physics updraft event
  71189. */
  71190. class PhysicsUpdraftEvent {
  71191. private _scene;
  71192. private _origin;
  71193. private _options;
  71194. private _physicsEngine;
  71195. private _originTop;
  71196. private _originDirection;
  71197. private _tickCallback;
  71198. private _cylinder;
  71199. private _cylinderPosition;
  71200. private _dataFetched;
  71201. /**
  71202. * Initializes the physics updraft event
  71203. * @param _scene BabylonJS scene
  71204. * @param _origin The origin position of the updraft
  71205. * @param _options The options for the updraft event
  71206. */
  71207. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71208. /**
  71209. * Returns the data related to the updraft event (cylinder).
  71210. * @returns A physics updraft event
  71211. */
  71212. getData(): PhysicsUpdraftEventData;
  71213. /**
  71214. * Enables the updraft.
  71215. */
  71216. enable(): void;
  71217. /**
  71218. * Disables the updraft.
  71219. */
  71220. disable(): void;
  71221. /**
  71222. * Disposes the cylinder.
  71223. * @param force Specifies if the updraft should be disposed by force
  71224. */
  71225. dispose(force?: boolean): void;
  71226. private getImpostorHitData;
  71227. private _tick;
  71228. /*** Helpers ***/
  71229. private _prepareCylinder;
  71230. private _intersectsWithCylinder;
  71231. }
  71232. /**
  71233. * Represents a physics vortex event
  71234. */
  71235. class PhysicsVortexEvent {
  71236. private _scene;
  71237. private _origin;
  71238. private _options;
  71239. private _physicsEngine;
  71240. private _originTop;
  71241. private _tickCallback;
  71242. private _cylinder;
  71243. private _cylinderPosition;
  71244. private _dataFetched;
  71245. /**
  71246. * Initializes the physics vortex event
  71247. * @param _scene The BabylonJS scene
  71248. * @param _origin The origin position of the vortex
  71249. * @param _options The options for the vortex event
  71250. */
  71251. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71252. /**
  71253. * Returns the data related to the vortex event (cylinder).
  71254. * @returns The physics vortex event data
  71255. */
  71256. getData(): PhysicsVortexEventData;
  71257. /**
  71258. * Enables the vortex.
  71259. */
  71260. enable(): void;
  71261. /**
  71262. * Disables the cortex.
  71263. */
  71264. disable(): void;
  71265. /**
  71266. * Disposes the sphere.
  71267. * @param force
  71268. */
  71269. dispose(force?: boolean): void;
  71270. private getImpostorHitData;
  71271. private _tick;
  71272. /*** Helpers ***/
  71273. private _prepareCylinder;
  71274. private _intersectsWithCylinder;
  71275. }
  71276. /**
  71277. * Options fot the radial explosion event
  71278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71279. */
  71280. export class PhysicsRadialExplosionEventOptions {
  71281. /**
  71282. * The radius of the sphere for the radial explosion.
  71283. */
  71284. radius: number;
  71285. /**
  71286. * The strenth of the explosion.
  71287. */
  71288. strength: number;
  71289. /**
  71290. * The strenght of the force in correspondence to the distance of the affected object
  71291. */
  71292. falloff: PhysicsRadialImpulseFalloff;
  71293. /**
  71294. * Sphere options for the radial explosion.
  71295. */
  71296. sphere: {
  71297. segments: number;
  71298. diameter: number;
  71299. };
  71300. /**
  71301. * Sphere options for the radial explosion.
  71302. */
  71303. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71304. }
  71305. /**
  71306. * Options fot the updraft event
  71307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71308. */
  71309. export class PhysicsUpdraftEventOptions {
  71310. /**
  71311. * The radius of the cylinder for the vortex
  71312. */
  71313. radius: number;
  71314. /**
  71315. * The strenth of the updraft.
  71316. */
  71317. strength: number;
  71318. /**
  71319. * The height of the cylinder for the updraft.
  71320. */
  71321. height: number;
  71322. /**
  71323. * The mode for the the updraft.
  71324. */
  71325. updraftMode: PhysicsUpdraftMode;
  71326. }
  71327. /**
  71328. * Options fot the vortex event
  71329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71330. */
  71331. export class PhysicsVortexEventOptions {
  71332. /**
  71333. * The radius of the cylinder for the vortex
  71334. */
  71335. radius: number;
  71336. /**
  71337. * The strenth of the vortex.
  71338. */
  71339. strength: number;
  71340. /**
  71341. * The height of the cylinder for the vortex.
  71342. */
  71343. height: number;
  71344. /**
  71345. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71346. */
  71347. centripetalForceThreshold: number;
  71348. /**
  71349. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71350. */
  71351. centripetalForceMultiplier: number;
  71352. /**
  71353. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71354. */
  71355. centrifugalForceMultiplier: number;
  71356. /**
  71357. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71358. */
  71359. updraftForceMultiplier: number;
  71360. }
  71361. /**
  71362. * The strenght 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 PhysicsRadialImpulseFalloff {
  71366. /** Defines that impulse is constant in strength across it's whole radius */
  71367. Constant = 0,
  71368. /** Defines that impulse gets weaker if it's further from the origin */
  71369. Linear = 1
  71370. }
  71371. /**
  71372. * The strength of the force in correspondence to the distance of the affected object
  71373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71374. */
  71375. export enum PhysicsUpdraftMode {
  71376. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71377. Center = 0,
  71378. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71379. Perpendicular = 1
  71380. }
  71381. /**
  71382. * Interface for a physics hit data
  71383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71384. */
  71385. export interface PhysicsHitData {
  71386. /**
  71387. * The force applied at the contact point
  71388. */
  71389. force: Vector3;
  71390. /**
  71391. * The contact point
  71392. */
  71393. contactPoint: Vector3;
  71394. /**
  71395. * The distance from the origin to the contact point
  71396. */
  71397. distanceFromOrigin: number;
  71398. }
  71399. /**
  71400. * Interface for radial explosion event data
  71401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71402. */
  71403. export interface PhysicsRadialExplosionEventData {
  71404. /**
  71405. * A sphere used for the radial explosion event
  71406. */
  71407. sphere: Mesh;
  71408. }
  71409. /**
  71410. * Interface for gravitational field event data
  71411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71412. */
  71413. export interface PhysicsGravitationalFieldEventData {
  71414. /**
  71415. * A sphere mesh used for the gravitational field event
  71416. */
  71417. sphere: Mesh;
  71418. }
  71419. /**
  71420. * Interface for updraft event data
  71421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71422. */
  71423. export interface PhysicsUpdraftEventData {
  71424. /**
  71425. * A cylinder used for the updraft event
  71426. */
  71427. cylinder: Mesh;
  71428. }
  71429. /**
  71430. * Interface for vortex event data
  71431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71432. */
  71433. export interface PhysicsVortexEventData {
  71434. /**
  71435. * A cylinder used for the vortex event
  71436. */
  71437. cylinder: Mesh;
  71438. }
  71439. /**
  71440. * Interface for an affected physics impostor
  71441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71442. */
  71443. export interface PhysicsAffectedImpostorWithData {
  71444. /**
  71445. * The impostor affected by the effect
  71446. */
  71447. impostor: PhysicsImpostor;
  71448. /**
  71449. * The data about the hit/horce from the explosion
  71450. */
  71451. hitData: PhysicsHitData;
  71452. }
  71453. }
  71454. declare module "babylonjs/Physics/Plugins/index" {
  71455. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71456. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71457. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71458. }
  71459. declare module "babylonjs/Physics/index" {
  71460. export * from "babylonjs/Physics/IPhysicsEngine";
  71461. export * from "babylonjs/Physics/physicsEngine";
  71462. export * from "babylonjs/Physics/physicsEngineComponent";
  71463. export * from "babylonjs/Physics/physicsHelper";
  71464. export * from "babylonjs/Physics/physicsImpostor";
  71465. export * from "babylonjs/Physics/physicsJoint";
  71466. export * from "babylonjs/Physics/Plugins/index";
  71467. }
  71468. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71469. /** @hidden */
  71470. export var blackAndWhitePixelShader: {
  71471. name: string;
  71472. shader: string;
  71473. };
  71474. }
  71475. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71477. import { Camera } from "babylonjs/Cameras/camera";
  71478. import { Engine } from "babylonjs/Engines/engine";
  71479. import "babylonjs/Shaders/blackAndWhite.fragment";
  71480. /**
  71481. * Post process used to render in black and white
  71482. */
  71483. export class BlackAndWhitePostProcess extends PostProcess {
  71484. /**
  71485. * Linear about to convert he result to black and white (default: 1)
  71486. */
  71487. degree: number;
  71488. /**
  71489. * Creates a black and white post process
  71490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71491. * @param name The name of the effect.
  71492. * @param options The required width/height ratio to downsize to before computing the render pass.
  71493. * @param camera The camera to apply the render pass to.
  71494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71495. * @param engine The engine which the post process will be applied. (default: current engine)
  71496. * @param reusable If the post process can be reused on the same frame. (default: false)
  71497. */
  71498. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71499. }
  71500. }
  71501. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71502. import { Nullable } from "babylonjs/types";
  71503. import { Camera } from "babylonjs/Cameras/camera";
  71504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71505. import { Engine } from "babylonjs/Engines/engine";
  71506. /**
  71507. * This represents a set of one or more post processes in Babylon.
  71508. * A post process can be used to apply a shader to a texture after it is rendered.
  71509. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71510. */
  71511. export class PostProcessRenderEffect {
  71512. private _postProcesses;
  71513. private _getPostProcesses;
  71514. private _singleInstance;
  71515. private _cameras;
  71516. private _indicesForCamera;
  71517. /**
  71518. * Name of the effect
  71519. * @hidden
  71520. */
  71521. _name: string;
  71522. /**
  71523. * Instantiates a post process render effect.
  71524. * A post process can be used to apply a shader to a texture after it is rendered.
  71525. * @param engine The engine the effect is tied to
  71526. * @param name The name of the effect
  71527. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71528. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71529. */
  71530. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71531. /**
  71532. * Checks if all the post processes in the effect are supported.
  71533. */
  71534. get isSupported(): boolean;
  71535. /**
  71536. * Updates the current state of the effect
  71537. * @hidden
  71538. */
  71539. _update(): void;
  71540. /**
  71541. * Attaches the effect on cameras
  71542. * @param cameras The camera to attach to.
  71543. * @hidden
  71544. */
  71545. _attachCameras(cameras: Camera): void;
  71546. /**
  71547. * Attaches the effect on cameras
  71548. * @param cameras The camera to attach to.
  71549. * @hidden
  71550. */
  71551. _attachCameras(cameras: Camera[]): void;
  71552. /**
  71553. * Detaches the effect on cameras
  71554. * @param cameras The camera to detatch from.
  71555. * @hidden
  71556. */
  71557. _detachCameras(cameras: Camera): void;
  71558. /**
  71559. * Detatches the effect on cameras
  71560. * @param cameras The camera to detatch from.
  71561. * @hidden
  71562. */
  71563. _detachCameras(cameras: Camera[]): void;
  71564. /**
  71565. * Enables the effect on given cameras
  71566. * @param cameras The camera to enable.
  71567. * @hidden
  71568. */
  71569. _enable(cameras: Camera): void;
  71570. /**
  71571. * Enables the effect on given cameras
  71572. * @param cameras The camera to enable.
  71573. * @hidden
  71574. */
  71575. _enable(cameras: Nullable<Camera[]>): void;
  71576. /**
  71577. * Disables the effect on the given cameras
  71578. * @param cameras The camera to disable.
  71579. * @hidden
  71580. */
  71581. _disable(cameras: Camera): void;
  71582. /**
  71583. * Disables the effect on the given cameras
  71584. * @param cameras The camera to disable.
  71585. * @hidden
  71586. */
  71587. _disable(cameras: Nullable<Camera[]>): void;
  71588. /**
  71589. * Gets a list of the post processes contained in the effect.
  71590. * @param camera The camera to get the post processes on.
  71591. * @returns The list of the post processes in the effect.
  71592. */
  71593. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71594. }
  71595. }
  71596. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71598. /** @hidden */
  71599. export var extractHighlightsPixelShader: {
  71600. name: string;
  71601. shader: string;
  71602. };
  71603. }
  71604. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71605. import { Nullable } from "babylonjs/types";
  71606. import { Camera } from "babylonjs/Cameras/camera";
  71607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71608. import { Engine } from "babylonjs/Engines/engine";
  71609. import "babylonjs/Shaders/extractHighlights.fragment";
  71610. /**
  71611. * 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.
  71612. */
  71613. export class ExtractHighlightsPostProcess extends PostProcess {
  71614. /**
  71615. * The luminance threshold, pixels below this value will be set to black.
  71616. */
  71617. threshold: number;
  71618. /** @hidden */
  71619. _exposure: number;
  71620. /**
  71621. * Post process which has the input texture to be used when performing highlight extraction
  71622. * @hidden
  71623. */
  71624. _inputPostProcess: Nullable<PostProcess>;
  71625. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71626. }
  71627. }
  71628. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71629. /** @hidden */
  71630. export var bloomMergePixelShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71637. import { Nullable } from "babylonjs/types";
  71638. import { Engine } from "babylonjs/Engines/engine";
  71639. import { Camera } from "babylonjs/Cameras/camera";
  71640. import "babylonjs/Shaders/bloomMerge.fragment";
  71641. /**
  71642. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71643. */
  71644. export class BloomMergePostProcess extends PostProcess {
  71645. /** Weight of the bloom to be added to the original input. */
  71646. weight: number;
  71647. /**
  71648. * Creates a new instance of @see BloomMergePostProcess
  71649. * @param name The name of the effect.
  71650. * @param originalFromInput Post process which's input will be used for the merge.
  71651. * @param blurred Blurred highlights post process which's output will be used.
  71652. * @param weight Weight of the bloom to be added to the original input.
  71653. * @param options The required width/height ratio to downsize to before computing the render pass.
  71654. * @param camera The camera to apply the render pass to.
  71655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71656. * @param engine The engine which the post process will be applied. (default: current engine)
  71657. * @param reusable If the post process can be reused on the same frame. (default: false)
  71658. * @param textureType Type of textures used when performing the post process. (default: 0)
  71659. * @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)
  71660. */
  71661. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71662. /** Weight of the bloom to be added to the original input. */
  71663. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71664. }
  71665. }
  71666. declare module "babylonjs/PostProcesses/bloomEffect" {
  71667. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71669. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71670. import { Camera } from "babylonjs/Cameras/camera";
  71671. import { Scene } from "babylonjs/scene";
  71672. /**
  71673. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71674. */
  71675. export class BloomEffect extends PostProcessRenderEffect {
  71676. private bloomScale;
  71677. /**
  71678. * @hidden Internal
  71679. */
  71680. _effects: Array<PostProcess>;
  71681. /**
  71682. * @hidden Internal
  71683. */
  71684. _downscale: ExtractHighlightsPostProcess;
  71685. private _blurX;
  71686. private _blurY;
  71687. private _merge;
  71688. /**
  71689. * The luminance threshold to find bright areas of the image to bloom.
  71690. */
  71691. get threshold(): number;
  71692. set threshold(value: number);
  71693. /**
  71694. * The strength of the bloom.
  71695. */
  71696. get weight(): number;
  71697. set weight(value: number);
  71698. /**
  71699. * Specifies the size of the bloom blur kernel, relative to the final output size
  71700. */
  71701. get kernel(): number;
  71702. set kernel(value: number);
  71703. /**
  71704. * Creates a new instance of @see BloomEffect
  71705. * @param scene The scene the effect belongs to.
  71706. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71707. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71708. * @param bloomWeight The the strength of bloom.
  71709. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71710. * @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)
  71711. */
  71712. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71713. /**
  71714. * Disposes each of the internal effects for a given camera.
  71715. * @param camera The camera to dispose the effect on.
  71716. */
  71717. disposeEffects(camera: Camera): void;
  71718. /**
  71719. * @hidden Internal
  71720. */
  71721. _updateEffects(): void;
  71722. /**
  71723. * Internal
  71724. * @returns if all the contained post processes are ready.
  71725. * @hidden
  71726. */
  71727. _isReady(): boolean;
  71728. }
  71729. }
  71730. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71731. /** @hidden */
  71732. export var chromaticAberrationPixelShader: {
  71733. name: string;
  71734. shader: string;
  71735. };
  71736. }
  71737. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71738. import { Vector2 } from "babylonjs/Maths/math.vector";
  71739. import { Nullable } from "babylonjs/types";
  71740. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71741. import { Camera } from "babylonjs/Cameras/camera";
  71742. import { Engine } from "babylonjs/Engines/engine";
  71743. import "babylonjs/Shaders/chromaticAberration.fragment";
  71744. /**
  71745. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71746. */
  71747. export class ChromaticAberrationPostProcess extends PostProcess {
  71748. /**
  71749. * The amount of seperation of rgb channels (default: 30)
  71750. */
  71751. aberrationAmount: number;
  71752. /**
  71753. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71754. */
  71755. radialIntensity: number;
  71756. /**
  71757. * 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))
  71758. */
  71759. direction: Vector2;
  71760. /**
  71761. * 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))
  71762. */
  71763. centerPosition: Vector2;
  71764. /**
  71765. * Creates a new instance ChromaticAberrationPostProcess
  71766. * @param name The name of the effect.
  71767. * @param screenWidth The width of the screen to apply the effect on.
  71768. * @param screenHeight The height of the screen to apply the effect on.
  71769. * @param options The required width/height ratio to downsize to before computing the render pass.
  71770. * @param camera The camera to apply the render pass to.
  71771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71772. * @param engine The engine which the post process will be applied. (default: current engine)
  71773. * @param reusable If the post process can be reused on the same frame. (default: false)
  71774. * @param textureType Type of textures used when performing the post process. (default: 0)
  71775. * @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)
  71776. */
  71777. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71778. }
  71779. }
  71780. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71781. /** @hidden */
  71782. export var circleOfConfusionPixelShader: {
  71783. name: string;
  71784. shader: string;
  71785. };
  71786. }
  71787. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71788. import { Nullable } from "babylonjs/types";
  71789. import { Engine } from "babylonjs/Engines/engine";
  71790. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71792. import { Camera } from "babylonjs/Cameras/camera";
  71793. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71794. /**
  71795. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71796. */
  71797. export class CircleOfConfusionPostProcess extends PostProcess {
  71798. /**
  71799. * 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.
  71800. */
  71801. lensSize: number;
  71802. /**
  71803. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71804. */
  71805. fStop: number;
  71806. /**
  71807. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71808. */
  71809. focusDistance: number;
  71810. /**
  71811. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71812. */
  71813. focalLength: number;
  71814. private _depthTexture;
  71815. /**
  71816. * Creates a new instance CircleOfConfusionPostProcess
  71817. * @param name The name of the effect.
  71818. * @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.
  71819. * @param options The required width/height ratio to downsize to before computing the render pass.
  71820. * @param camera The camera to apply the render pass to.
  71821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71822. * @param engine The engine which the post process will be applied. (default: current engine)
  71823. * @param reusable If the post process can be reused on the same frame. (default: false)
  71824. * @param textureType Type of textures used when performing the post process. (default: 0)
  71825. * @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)
  71826. */
  71827. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71828. /**
  71829. * 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.
  71830. */
  71831. set depthTexture(value: RenderTargetTexture);
  71832. }
  71833. }
  71834. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71835. /** @hidden */
  71836. export var colorCorrectionPixelShader: {
  71837. name: string;
  71838. shader: string;
  71839. };
  71840. }
  71841. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71843. import { Engine } from "babylonjs/Engines/engine";
  71844. import { Camera } from "babylonjs/Cameras/camera";
  71845. import "babylonjs/Shaders/colorCorrection.fragment";
  71846. /**
  71847. *
  71848. * This post-process allows the modification of rendered colors by using
  71849. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71850. *
  71851. * The object needs to be provided an url to a texture containing the color
  71852. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71853. * Use an image editing software to tweak the LUT to match your needs.
  71854. *
  71855. * For an example of a color LUT, see here:
  71856. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71857. * For explanations on color grading, see here:
  71858. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71859. *
  71860. */
  71861. export class ColorCorrectionPostProcess extends PostProcess {
  71862. private _colorTableTexture;
  71863. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71864. }
  71865. }
  71866. declare module "babylonjs/Shaders/convolution.fragment" {
  71867. /** @hidden */
  71868. export var convolutionPixelShader: {
  71869. name: string;
  71870. shader: string;
  71871. };
  71872. }
  71873. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71874. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71875. import { Nullable } from "babylonjs/types";
  71876. import { Camera } from "babylonjs/Cameras/camera";
  71877. import { Engine } from "babylonjs/Engines/engine";
  71878. import "babylonjs/Shaders/convolution.fragment";
  71879. /**
  71880. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71881. * input texture to perform effects such as edge detection or sharpening
  71882. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71883. */
  71884. export class ConvolutionPostProcess extends PostProcess {
  71885. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71886. kernel: number[];
  71887. /**
  71888. * Creates a new instance ConvolutionPostProcess
  71889. * @param name The name of the effect.
  71890. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71891. * @param options The required width/height ratio to downsize to before computing the render pass.
  71892. * @param camera The camera to apply the render pass to.
  71893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71894. * @param engine The engine which the post process will be applied. (default: current engine)
  71895. * @param reusable If the post process can be reused on the same frame. (default: false)
  71896. * @param textureType Type of textures used when performing the post process. (default: 0)
  71897. */
  71898. constructor(name: string,
  71899. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71900. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71901. /**
  71902. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71903. */
  71904. static EdgeDetect0Kernel: number[];
  71905. /**
  71906. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71907. */
  71908. static EdgeDetect1Kernel: number[];
  71909. /**
  71910. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71911. */
  71912. static EdgeDetect2Kernel: number[];
  71913. /**
  71914. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71915. */
  71916. static SharpenKernel: number[];
  71917. /**
  71918. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71919. */
  71920. static EmbossKernel: number[];
  71921. /**
  71922. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71923. */
  71924. static GaussianKernel: number[];
  71925. }
  71926. }
  71927. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71928. import { Nullable } from "babylonjs/types";
  71929. import { Vector2 } from "babylonjs/Maths/math.vector";
  71930. import { Camera } from "babylonjs/Cameras/camera";
  71931. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71932. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71933. import { Engine } from "babylonjs/Engines/engine";
  71934. import { Scene } from "babylonjs/scene";
  71935. /**
  71936. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71937. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71938. * based on samples that have a large difference in distance than the center pixel.
  71939. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71940. */
  71941. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71942. direction: Vector2;
  71943. /**
  71944. * Creates a new instance CircleOfConfusionPostProcess
  71945. * @param name The name of the effect.
  71946. * @param scene The scene the effect belongs to.
  71947. * @param direction The direction the blur should be applied.
  71948. * @param kernel The size of the kernel used to blur.
  71949. * @param options The required width/height ratio to downsize to before computing the render pass.
  71950. * @param camera The camera to apply the render pass to.
  71951. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71952. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71954. * @param engine The engine which the post process will be applied. (default: current engine)
  71955. * @param reusable If the post process can be reused on the same frame. (default: false)
  71956. * @param textureType Type of textures used when performing the post process. (default: 0)
  71957. * @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)
  71958. */
  71959. 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);
  71960. }
  71961. }
  71962. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71963. /** @hidden */
  71964. export var depthOfFieldMergePixelShader: {
  71965. name: string;
  71966. shader: string;
  71967. };
  71968. }
  71969. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71970. import { Nullable } from "babylonjs/types";
  71971. import { Camera } from "babylonjs/Cameras/camera";
  71972. import { Effect } from "babylonjs/Materials/effect";
  71973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71974. import { Engine } from "babylonjs/Engines/engine";
  71975. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71976. /**
  71977. * Options to be set when merging outputs from the default pipeline.
  71978. */
  71979. export class DepthOfFieldMergePostProcessOptions {
  71980. /**
  71981. * The original image to merge on top of
  71982. */
  71983. originalFromInput: PostProcess;
  71984. /**
  71985. * Parameters to perform the merge of the depth of field effect
  71986. */
  71987. depthOfField?: {
  71988. circleOfConfusion: PostProcess;
  71989. blurSteps: Array<PostProcess>;
  71990. };
  71991. /**
  71992. * Parameters to perform the merge of bloom effect
  71993. */
  71994. bloom?: {
  71995. blurred: PostProcess;
  71996. weight: number;
  71997. };
  71998. }
  71999. /**
  72000. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72001. */
  72002. export class DepthOfFieldMergePostProcess extends PostProcess {
  72003. private blurSteps;
  72004. /**
  72005. * Creates a new instance of DepthOfFieldMergePostProcess
  72006. * @param name The name of the effect.
  72007. * @param originalFromInput Post process which's input will be used for the merge.
  72008. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72009. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72010. * @param options The required width/height ratio to downsize to before computing the render pass.
  72011. * @param camera The camera to apply the render pass to.
  72012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72013. * @param engine The engine which the post process will be applied. (default: current engine)
  72014. * @param reusable If the post process can be reused on the same frame. (default: false)
  72015. * @param textureType Type of textures used when performing the post process. (default: 0)
  72016. * @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)
  72017. */
  72018. 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);
  72019. /**
  72020. * Updates the effect with the current post process compile time values and recompiles the shader.
  72021. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72022. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72023. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72024. * @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
  72025. * @param onCompiled Called when the shader has been compiled.
  72026. * @param onError Called if there is an error when compiling a shader.
  72027. */
  72028. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72029. }
  72030. }
  72031. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72032. import { Nullable } from "babylonjs/types";
  72033. import { Camera } from "babylonjs/Cameras/camera";
  72034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72036. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72037. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72038. import { Scene } from "babylonjs/scene";
  72039. /**
  72040. * Specifies the level of max blur that should be applied when using the depth of field effect
  72041. */
  72042. export enum DepthOfFieldEffectBlurLevel {
  72043. /**
  72044. * Subtle blur
  72045. */
  72046. Low = 0,
  72047. /**
  72048. * Medium blur
  72049. */
  72050. Medium = 1,
  72051. /**
  72052. * Large blur
  72053. */
  72054. High = 2
  72055. }
  72056. /**
  72057. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72058. */
  72059. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72060. private _circleOfConfusion;
  72061. /**
  72062. * @hidden Internal, blurs from high to low
  72063. */
  72064. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72065. private _depthOfFieldBlurY;
  72066. private _dofMerge;
  72067. /**
  72068. * @hidden Internal post processes in depth of field effect
  72069. */
  72070. _effects: Array<PostProcess>;
  72071. /**
  72072. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72073. */
  72074. set focalLength(value: number);
  72075. get focalLength(): number;
  72076. /**
  72077. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72078. */
  72079. set fStop(value: number);
  72080. get fStop(): number;
  72081. /**
  72082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72083. */
  72084. set focusDistance(value: number);
  72085. get focusDistance(): number;
  72086. /**
  72087. * 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.
  72088. */
  72089. set lensSize(value: number);
  72090. get lensSize(): number;
  72091. /**
  72092. * Creates a new instance DepthOfFieldEffect
  72093. * @param scene The scene the effect belongs to.
  72094. * @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.
  72095. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72096. * @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)
  72097. */
  72098. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72099. /**
  72100. * Get the current class name of the current effet
  72101. * @returns "DepthOfFieldEffect"
  72102. */
  72103. getClassName(): string;
  72104. /**
  72105. * 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.
  72106. */
  72107. set depthTexture(value: RenderTargetTexture);
  72108. /**
  72109. * Disposes each of the internal effects for a given camera.
  72110. * @param camera The camera to dispose the effect on.
  72111. */
  72112. disposeEffects(camera: Camera): void;
  72113. /**
  72114. * @hidden Internal
  72115. */
  72116. _updateEffects(): void;
  72117. /**
  72118. * Internal
  72119. * @returns if all the contained post processes are ready.
  72120. * @hidden
  72121. */
  72122. _isReady(): boolean;
  72123. }
  72124. }
  72125. declare module "babylonjs/Shaders/displayPass.fragment" {
  72126. /** @hidden */
  72127. export var displayPassPixelShader: {
  72128. name: string;
  72129. shader: string;
  72130. };
  72131. }
  72132. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72133. import { Nullable } from "babylonjs/types";
  72134. import { Camera } from "babylonjs/Cameras/camera";
  72135. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72136. import { Engine } from "babylonjs/Engines/engine";
  72137. import "babylonjs/Shaders/displayPass.fragment";
  72138. /**
  72139. * DisplayPassPostProcess which produces an output the same as it's input
  72140. */
  72141. export class DisplayPassPostProcess extends PostProcess {
  72142. /**
  72143. * Creates the DisplayPassPostProcess
  72144. * @param name The name of the effect.
  72145. * @param options The required width/height ratio to downsize to before computing the render pass.
  72146. * @param camera The camera to apply the render pass to.
  72147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72148. * @param engine The engine which the post process will be applied. (default: current engine)
  72149. * @param reusable If the post process can be reused on the same frame. (default: false)
  72150. */
  72151. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72152. }
  72153. }
  72154. declare module "babylonjs/Shaders/filter.fragment" {
  72155. /** @hidden */
  72156. export var filterPixelShader: {
  72157. name: string;
  72158. shader: string;
  72159. };
  72160. }
  72161. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72162. import { Nullable } from "babylonjs/types";
  72163. import { Matrix } from "babylonjs/Maths/math.vector";
  72164. import { Camera } from "babylonjs/Cameras/camera";
  72165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72166. import { Engine } from "babylonjs/Engines/engine";
  72167. import "babylonjs/Shaders/filter.fragment";
  72168. /**
  72169. * Applies a kernel filter to the image
  72170. */
  72171. export class FilterPostProcess extends PostProcess {
  72172. /** The matrix to be applied to the image */
  72173. kernelMatrix: Matrix;
  72174. /**
  72175. *
  72176. * @param name The name of the effect.
  72177. * @param kernelMatrix The matrix to be applied to the image
  72178. * @param options The required width/height ratio to downsize to before computing the render pass.
  72179. * @param camera The camera to apply the render pass to.
  72180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72181. * @param engine The engine which the post process will be applied. (default: current engine)
  72182. * @param reusable If the post process can be reused on the same frame. (default: false)
  72183. */
  72184. constructor(name: string,
  72185. /** The matrix to be applied to the image */
  72186. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72187. }
  72188. }
  72189. declare module "babylonjs/Shaders/fxaa.fragment" {
  72190. /** @hidden */
  72191. export var fxaaPixelShader: {
  72192. name: string;
  72193. shader: string;
  72194. };
  72195. }
  72196. declare module "babylonjs/Shaders/fxaa.vertex" {
  72197. /** @hidden */
  72198. export var fxaaVertexShader: {
  72199. name: string;
  72200. shader: string;
  72201. };
  72202. }
  72203. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72204. import { Nullable } from "babylonjs/types";
  72205. import { Camera } from "babylonjs/Cameras/camera";
  72206. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72207. import { Engine } from "babylonjs/Engines/engine";
  72208. import "babylonjs/Shaders/fxaa.fragment";
  72209. import "babylonjs/Shaders/fxaa.vertex";
  72210. /**
  72211. * Fxaa post process
  72212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72213. */
  72214. export class FxaaPostProcess extends PostProcess {
  72215. /** @hidden */
  72216. texelWidth: number;
  72217. /** @hidden */
  72218. texelHeight: number;
  72219. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72220. private _getDefines;
  72221. }
  72222. }
  72223. declare module "babylonjs/Shaders/grain.fragment" {
  72224. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72225. /** @hidden */
  72226. export var grainPixelShader: {
  72227. name: string;
  72228. shader: string;
  72229. };
  72230. }
  72231. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72232. import { Nullable } from "babylonjs/types";
  72233. import { Camera } from "babylonjs/Cameras/camera";
  72234. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72235. import { Engine } from "babylonjs/Engines/engine";
  72236. import "babylonjs/Shaders/grain.fragment";
  72237. /**
  72238. * The GrainPostProcess adds noise to the image at mid luminance levels
  72239. */
  72240. export class GrainPostProcess extends PostProcess {
  72241. /**
  72242. * The intensity of the grain added (default: 30)
  72243. */
  72244. intensity: number;
  72245. /**
  72246. * If the grain should be randomized on every frame
  72247. */
  72248. animated: boolean;
  72249. /**
  72250. * Creates a new instance of @see GrainPostProcess
  72251. * @param name The name of the effect.
  72252. * @param options The required width/height ratio to downsize to before computing the render pass.
  72253. * @param camera The camera to apply the render pass to.
  72254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72255. * @param engine The engine which the post process will be applied. (default: current engine)
  72256. * @param reusable If the post process can be reused on the same frame. (default: false)
  72257. * @param textureType Type of textures used when performing the post process. (default: 0)
  72258. * @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)
  72259. */
  72260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72261. }
  72262. }
  72263. declare module "babylonjs/Shaders/highlights.fragment" {
  72264. /** @hidden */
  72265. export var highlightsPixelShader: {
  72266. name: string;
  72267. shader: string;
  72268. };
  72269. }
  72270. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72271. import { Nullable } from "babylonjs/types";
  72272. import { Camera } from "babylonjs/Cameras/camera";
  72273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72274. import { Engine } from "babylonjs/Engines/engine";
  72275. import "babylonjs/Shaders/highlights.fragment";
  72276. /**
  72277. * Extracts highlights from the image
  72278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72279. */
  72280. export class HighlightsPostProcess extends PostProcess {
  72281. /**
  72282. * Extracts highlights from the image
  72283. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72284. * @param name The name of the effect.
  72285. * @param options The required width/height ratio to downsize to before computing the render pass.
  72286. * @param camera The camera to apply the render pass to.
  72287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72288. * @param engine The engine which the post process will be applied. (default: current engine)
  72289. * @param reusable If the post process can be reused on the same frame. (default: false)
  72290. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72291. */
  72292. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72293. }
  72294. }
  72295. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72296. /** @hidden */
  72297. export var mrtFragmentDeclaration: {
  72298. name: string;
  72299. shader: string;
  72300. };
  72301. }
  72302. declare module "babylonjs/Shaders/geometry.fragment" {
  72303. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72304. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72305. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72306. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72307. /** @hidden */
  72308. export var geometryPixelShader: {
  72309. name: string;
  72310. shader: string;
  72311. };
  72312. }
  72313. declare module "babylonjs/Shaders/geometry.vertex" {
  72314. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72317. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72319. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72320. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72321. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72322. /** @hidden */
  72323. export var geometryVertexShader: {
  72324. name: string;
  72325. shader: string;
  72326. };
  72327. }
  72328. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72329. import { Matrix } from "babylonjs/Maths/math.vector";
  72330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72331. import { Mesh } from "babylonjs/Meshes/mesh";
  72332. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72333. import { Effect } from "babylonjs/Materials/effect";
  72334. import { Scene } from "babylonjs/scene";
  72335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72336. import "babylonjs/Shaders/geometry.fragment";
  72337. import "babylonjs/Shaders/geometry.vertex";
  72338. /** @hidden */
  72339. interface ISavedTransformationMatrix {
  72340. world: Matrix;
  72341. viewProjection: Matrix;
  72342. }
  72343. /**
  72344. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72345. */
  72346. export class GeometryBufferRenderer {
  72347. /**
  72348. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72349. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72350. */
  72351. static readonly POSITION_TEXTURE_TYPE: number;
  72352. /**
  72353. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72354. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72355. */
  72356. static readonly VELOCITY_TEXTURE_TYPE: number;
  72357. /**
  72358. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72359. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72360. */
  72361. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72362. /**
  72363. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72364. * in order to compute objects velocities when enableVelocity is set to "true"
  72365. * @hidden
  72366. */
  72367. _previousTransformationMatrices: {
  72368. [index: number]: ISavedTransformationMatrix;
  72369. };
  72370. /**
  72371. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72372. * in order to compute objects velocities when enableVelocity is set to "true"
  72373. * @hidden
  72374. */
  72375. _previousBonesTransformationMatrices: {
  72376. [index: number]: Float32Array;
  72377. };
  72378. /**
  72379. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72380. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72381. */
  72382. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72383. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72384. renderTransparentMeshes: boolean;
  72385. private _scene;
  72386. private _multiRenderTarget;
  72387. private _ratio;
  72388. private _enablePosition;
  72389. private _enableVelocity;
  72390. private _enableReflectivity;
  72391. private _positionIndex;
  72392. private _velocityIndex;
  72393. private _reflectivityIndex;
  72394. protected _effect: Effect;
  72395. protected _cachedDefines: string;
  72396. /**
  72397. * Set the render list (meshes to be rendered) used in the G buffer.
  72398. */
  72399. set renderList(meshes: Mesh[]);
  72400. /**
  72401. * Gets wether or not G buffer are supported by the running hardware.
  72402. * This requires draw buffer supports
  72403. */
  72404. get isSupported(): boolean;
  72405. /**
  72406. * Returns the index of the given texture type in the G-Buffer textures array
  72407. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72408. * @returns the index of the given texture type in the G-Buffer textures array
  72409. */
  72410. getTextureIndex(textureType: number): number;
  72411. /**
  72412. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72413. */
  72414. get enablePosition(): boolean;
  72415. /**
  72416. * Sets whether or not objects positions are enabled for the G buffer.
  72417. */
  72418. set enablePosition(enable: boolean);
  72419. /**
  72420. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72421. */
  72422. get enableVelocity(): boolean;
  72423. /**
  72424. * Sets wether or not objects velocities are enabled for the G buffer.
  72425. */
  72426. set enableVelocity(enable: boolean);
  72427. /**
  72428. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72429. */
  72430. get enableReflectivity(): boolean;
  72431. /**
  72432. * Sets wether or not objects roughness are enabled for the G buffer.
  72433. */
  72434. set enableReflectivity(enable: boolean);
  72435. /**
  72436. * Gets the scene associated with the buffer.
  72437. */
  72438. get scene(): Scene;
  72439. /**
  72440. * Gets the ratio used by the buffer during its creation.
  72441. * How big is the buffer related to the main canvas.
  72442. */
  72443. get ratio(): number;
  72444. /** @hidden */
  72445. static _SceneComponentInitialization: (scene: Scene) => void;
  72446. /**
  72447. * Creates a new G Buffer for the scene
  72448. * @param scene The scene the buffer belongs to
  72449. * @param ratio How big is the buffer related to the main canvas.
  72450. */
  72451. constructor(scene: Scene, ratio?: number);
  72452. /**
  72453. * Checks wether everything is ready to render a submesh to the G buffer.
  72454. * @param subMesh the submesh to check readiness for
  72455. * @param useInstances is the mesh drawn using instance or not
  72456. * @returns true if ready otherwise false
  72457. */
  72458. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72459. /**
  72460. * Gets the current underlying G Buffer.
  72461. * @returns the buffer
  72462. */
  72463. getGBuffer(): MultiRenderTarget;
  72464. /**
  72465. * Gets the number of samples used to render the buffer (anti aliasing).
  72466. */
  72467. get samples(): number;
  72468. /**
  72469. * Sets the number of samples used to render the buffer (anti aliasing).
  72470. */
  72471. set samples(value: number);
  72472. /**
  72473. * Disposes the renderer and frees up associated resources.
  72474. */
  72475. dispose(): void;
  72476. protected _createRenderTargets(): void;
  72477. private _copyBonesTransformationMatrices;
  72478. }
  72479. }
  72480. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72481. import { Nullable } from "babylonjs/types";
  72482. import { Scene } from "babylonjs/scene";
  72483. import { ISceneComponent } from "babylonjs/sceneComponent";
  72484. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72485. module "babylonjs/scene" {
  72486. interface Scene {
  72487. /** @hidden (Backing field) */
  72488. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72489. /**
  72490. * Gets or Sets the current geometry buffer associated to the scene.
  72491. */
  72492. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72493. /**
  72494. * Enables a GeometryBufferRender and associates it with the scene
  72495. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72496. * @returns the GeometryBufferRenderer
  72497. */
  72498. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72499. /**
  72500. * Disables the GeometryBufferRender associated with the scene
  72501. */
  72502. disableGeometryBufferRenderer(): void;
  72503. }
  72504. }
  72505. /**
  72506. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72507. * in several rendering techniques.
  72508. */
  72509. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72510. /**
  72511. * The component name helpful to identify the component in the list of scene components.
  72512. */
  72513. readonly name: string;
  72514. /**
  72515. * The scene the component belongs to.
  72516. */
  72517. scene: Scene;
  72518. /**
  72519. * Creates a new instance of the component for the given scene
  72520. * @param scene Defines the scene to register the component in
  72521. */
  72522. constructor(scene: Scene);
  72523. /**
  72524. * Registers the component in a given scene
  72525. */
  72526. register(): void;
  72527. /**
  72528. * Rebuilds the elements related to this component in case of
  72529. * context lost for instance.
  72530. */
  72531. rebuild(): void;
  72532. /**
  72533. * Disposes the component and the associated ressources
  72534. */
  72535. dispose(): void;
  72536. private _gatherRenderTargets;
  72537. }
  72538. }
  72539. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72540. /** @hidden */
  72541. export var motionBlurPixelShader: {
  72542. name: string;
  72543. shader: string;
  72544. };
  72545. }
  72546. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72547. import { Nullable } from "babylonjs/types";
  72548. import { Camera } from "babylonjs/Cameras/camera";
  72549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72550. import { Scene } from "babylonjs/scene";
  72551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72552. import "babylonjs/Animations/animatable";
  72553. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72554. import "babylonjs/Shaders/motionBlur.fragment";
  72555. import { Engine } from "babylonjs/Engines/engine";
  72556. /**
  72557. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72558. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72559. * As an example, all you have to do is to create the post-process:
  72560. * var mb = new BABYLON.MotionBlurPostProcess(
  72561. * 'mb', // The name of the effect.
  72562. * scene, // The scene containing the objects to blur according to their velocity.
  72563. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72564. * camera // The camera to apply the render pass to.
  72565. * );
  72566. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72567. */
  72568. export class MotionBlurPostProcess extends PostProcess {
  72569. /**
  72570. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72571. */
  72572. motionStrength: number;
  72573. /**
  72574. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72575. */
  72576. get motionBlurSamples(): number;
  72577. /**
  72578. * Sets the number of iterations to be used for motion blur quality
  72579. */
  72580. set motionBlurSamples(samples: number);
  72581. private _motionBlurSamples;
  72582. private _geometryBufferRenderer;
  72583. /**
  72584. * Creates a new instance MotionBlurPostProcess
  72585. * @param name The name of the effect.
  72586. * @param scene The scene containing the objects to blur according to their velocity.
  72587. * @param options The required width/height ratio to downsize to before computing the render pass.
  72588. * @param camera The camera to apply the render pass to.
  72589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72590. * @param engine The engine which the post process will be applied. (default: current engine)
  72591. * @param reusable If the post process can be reused on the same frame. (default: false)
  72592. * @param textureType Type of textures used when performing the post process. (default: 0)
  72593. * @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)
  72594. */
  72595. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72596. /**
  72597. * Excludes the given skinned mesh from computing bones velocities.
  72598. * 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.
  72599. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72600. */
  72601. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72602. /**
  72603. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72604. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72605. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72606. */
  72607. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72608. /**
  72609. * Disposes the post process.
  72610. * @param camera The camera to dispose the post process on.
  72611. */
  72612. dispose(camera?: Camera): void;
  72613. }
  72614. }
  72615. declare module "babylonjs/Shaders/refraction.fragment" {
  72616. /** @hidden */
  72617. export var refractionPixelShader: {
  72618. name: string;
  72619. shader: string;
  72620. };
  72621. }
  72622. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72623. import { Color3 } from "babylonjs/Maths/math.color";
  72624. import { Camera } from "babylonjs/Cameras/camera";
  72625. import { Texture } from "babylonjs/Materials/Textures/texture";
  72626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72627. import { Engine } from "babylonjs/Engines/engine";
  72628. import "babylonjs/Shaders/refraction.fragment";
  72629. /**
  72630. * Post process which applies a refractin texture
  72631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72632. */
  72633. export class RefractionPostProcess extends PostProcess {
  72634. /** the base color of the refraction (used to taint the rendering) */
  72635. color: Color3;
  72636. /** simulated refraction depth */
  72637. depth: number;
  72638. /** the coefficient of the base color (0 to remove base color tainting) */
  72639. colorLevel: number;
  72640. private _refTexture;
  72641. private _ownRefractionTexture;
  72642. /**
  72643. * Gets or sets the refraction texture
  72644. * Please note that you are responsible for disposing the texture if you set it manually
  72645. */
  72646. get refractionTexture(): Texture;
  72647. set refractionTexture(value: Texture);
  72648. /**
  72649. * Initializes the RefractionPostProcess
  72650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72651. * @param name The name of the effect.
  72652. * @param refractionTextureUrl Url of the refraction texture to use
  72653. * @param color the base color of the refraction (used to taint the rendering)
  72654. * @param depth simulated refraction depth
  72655. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72656. * @param camera The camera to apply the render pass to.
  72657. * @param options The required width/height ratio to downsize to before computing the render pass.
  72658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72659. * @param engine The engine which the post process will be applied. (default: current engine)
  72660. * @param reusable If the post process can be reused on the same frame. (default: false)
  72661. */
  72662. constructor(name: string, refractionTextureUrl: string,
  72663. /** the base color of the refraction (used to taint the rendering) */
  72664. color: Color3,
  72665. /** simulated refraction depth */
  72666. depth: number,
  72667. /** the coefficient of the base color (0 to remove base color tainting) */
  72668. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72669. /**
  72670. * Disposes of the post process
  72671. * @param camera Camera to dispose post process on
  72672. */
  72673. dispose(camera: Camera): void;
  72674. }
  72675. }
  72676. declare module "babylonjs/Shaders/sharpen.fragment" {
  72677. /** @hidden */
  72678. export var sharpenPixelShader: {
  72679. name: string;
  72680. shader: string;
  72681. };
  72682. }
  72683. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72684. import { Nullable } from "babylonjs/types";
  72685. import { Camera } from "babylonjs/Cameras/camera";
  72686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72687. import "babylonjs/Shaders/sharpen.fragment";
  72688. import { Engine } from "babylonjs/Engines/engine";
  72689. /**
  72690. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72691. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72692. */
  72693. export class SharpenPostProcess extends PostProcess {
  72694. /**
  72695. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72696. */
  72697. colorAmount: number;
  72698. /**
  72699. * How much sharpness should be applied (default: 0.3)
  72700. */
  72701. edgeAmount: number;
  72702. /**
  72703. * Creates a new instance ConvolutionPostProcess
  72704. * @param name The name of the effect.
  72705. * @param options The required width/height ratio to downsize to before computing the render pass.
  72706. * @param camera The camera to apply the render pass to.
  72707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72708. * @param engine The engine which the post process will be applied. (default: current engine)
  72709. * @param reusable If the post process can be reused on the same frame. (default: false)
  72710. * @param textureType Type of textures used when performing the post process. (default: 0)
  72711. * @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)
  72712. */
  72713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72714. }
  72715. }
  72716. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72717. import { Nullable } from "babylonjs/types";
  72718. import { Camera } from "babylonjs/Cameras/camera";
  72719. import { Engine } from "babylonjs/Engines/engine";
  72720. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72721. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72722. /**
  72723. * PostProcessRenderPipeline
  72724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72725. */
  72726. export class PostProcessRenderPipeline {
  72727. private engine;
  72728. private _renderEffects;
  72729. private _renderEffectsForIsolatedPass;
  72730. /**
  72731. * List of inspectable custom properties (used by the Inspector)
  72732. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72733. */
  72734. inspectableCustomProperties: IInspectable[];
  72735. /**
  72736. * @hidden
  72737. */
  72738. protected _cameras: Camera[];
  72739. /** @hidden */
  72740. _name: string;
  72741. /**
  72742. * Gets pipeline name
  72743. */
  72744. get name(): string;
  72745. /** Gets the list of attached cameras */
  72746. get cameras(): Camera[];
  72747. /**
  72748. * Initializes a PostProcessRenderPipeline
  72749. * @param engine engine to add the pipeline to
  72750. * @param name name of the pipeline
  72751. */
  72752. constructor(engine: Engine, name: string);
  72753. /**
  72754. * Gets the class name
  72755. * @returns "PostProcessRenderPipeline"
  72756. */
  72757. getClassName(): string;
  72758. /**
  72759. * If all the render effects in the pipeline are supported
  72760. */
  72761. get isSupported(): boolean;
  72762. /**
  72763. * Adds an effect to the pipeline
  72764. * @param renderEffect the effect to add
  72765. */
  72766. addEffect(renderEffect: PostProcessRenderEffect): void;
  72767. /** @hidden */
  72768. _rebuild(): void;
  72769. /** @hidden */
  72770. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72771. /** @hidden */
  72772. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72773. /** @hidden */
  72774. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72775. /** @hidden */
  72776. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72777. /** @hidden */
  72778. _attachCameras(cameras: Camera, unique: boolean): void;
  72779. /** @hidden */
  72780. _attachCameras(cameras: Camera[], unique: boolean): void;
  72781. /** @hidden */
  72782. _detachCameras(cameras: Camera): void;
  72783. /** @hidden */
  72784. _detachCameras(cameras: Nullable<Camera[]>): void;
  72785. /** @hidden */
  72786. _update(): void;
  72787. /** @hidden */
  72788. _reset(): void;
  72789. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72790. /**
  72791. * Disposes of the pipeline
  72792. */
  72793. dispose(): void;
  72794. }
  72795. }
  72796. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72797. import { Camera } from "babylonjs/Cameras/camera";
  72798. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72799. /**
  72800. * PostProcessRenderPipelineManager class
  72801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72802. */
  72803. export class PostProcessRenderPipelineManager {
  72804. private _renderPipelines;
  72805. /**
  72806. * Initializes a PostProcessRenderPipelineManager
  72807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72808. */
  72809. constructor();
  72810. /**
  72811. * Gets the list of supported render pipelines
  72812. */
  72813. get supportedPipelines(): PostProcessRenderPipeline[];
  72814. /**
  72815. * Adds a pipeline to the manager
  72816. * @param renderPipeline The pipeline to add
  72817. */
  72818. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72819. /**
  72820. * Attaches a camera to the pipeline
  72821. * @param renderPipelineName The name of the pipeline to attach to
  72822. * @param cameras the camera to attach
  72823. * @param unique if the camera can be attached multiple times to the pipeline
  72824. */
  72825. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72826. /**
  72827. * Detaches a camera from the pipeline
  72828. * @param renderPipelineName The name of the pipeline to detach from
  72829. * @param cameras the camera to detach
  72830. */
  72831. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72832. /**
  72833. * Enables an effect by name on a pipeline
  72834. * @param renderPipelineName the name of the pipeline to enable the effect in
  72835. * @param renderEffectName the name of the effect to enable
  72836. * @param cameras the cameras that the effect should be enabled on
  72837. */
  72838. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72839. /**
  72840. * Disables an effect by name on a pipeline
  72841. * @param renderPipelineName the name of the pipeline to disable the effect in
  72842. * @param renderEffectName the name of the effect to disable
  72843. * @param cameras the cameras that the effect should be disabled on
  72844. */
  72845. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72846. /**
  72847. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72848. */
  72849. update(): void;
  72850. /** @hidden */
  72851. _rebuild(): void;
  72852. /**
  72853. * Disposes of the manager and pipelines
  72854. */
  72855. dispose(): void;
  72856. }
  72857. }
  72858. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72859. import { ISceneComponent } from "babylonjs/sceneComponent";
  72860. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72861. import { Scene } from "babylonjs/scene";
  72862. module "babylonjs/scene" {
  72863. interface Scene {
  72864. /** @hidden (Backing field) */
  72865. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72866. /**
  72867. * Gets the postprocess render pipeline manager
  72868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72869. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72870. */
  72871. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72872. }
  72873. }
  72874. /**
  72875. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72876. */
  72877. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72878. /**
  72879. * The component name helpfull to identify the component in the list of scene components.
  72880. */
  72881. readonly name: string;
  72882. /**
  72883. * The scene the component belongs to.
  72884. */
  72885. scene: Scene;
  72886. /**
  72887. * Creates a new instance of the component for the given scene
  72888. * @param scene Defines the scene to register the component in
  72889. */
  72890. constructor(scene: Scene);
  72891. /**
  72892. * Registers the component in a given scene
  72893. */
  72894. register(): void;
  72895. /**
  72896. * Rebuilds the elements related to this component in case of
  72897. * context lost for instance.
  72898. */
  72899. rebuild(): void;
  72900. /**
  72901. * Disposes the component and the associated ressources
  72902. */
  72903. dispose(): void;
  72904. private _gatherRenderTargets;
  72905. }
  72906. }
  72907. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72908. import { Nullable } from "babylonjs/types";
  72909. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72910. import { Camera } from "babylonjs/Cameras/camera";
  72911. import { IDisposable } from "babylonjs/scene";
  72912. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72913. import { Scene } from "babylonjs/scene";
  72914. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72915. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72916. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72917. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72918. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72919. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72920. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72921. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72922. import { Animation } from "babylonjs/Animations/animation";
  72923. /**
  72924. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72925. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72926. */
  72927. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72928. private _scene;
  72929. private _camerasToBeAttached;
  72930. /**
  72931. * ID of the sharpen post process,
  72932. */
  72933. private readonly SharpenPostProcessId;
  72934. /**
  72935. * @ignore
  72936. * ID of the image processing post process;
  72937. */
  72938. readonly ImageProcessingPostProcessId: string;
  72939. /**
  72940. * @ignore
  72941. * ID of the Fast Approximate Anti-Aliasing post process;
  72942. */
  72943. readonly FxaaPostProcessId: string;
  72944. /**
  72945. * ID of the chromatic aberration post process,
  72946. */
  72947. private readonly ChromaticAberrationPostProcessId;
  72948. /**
  72949. * ID of the grain post process
  72950. */
  72951. private readonly GrainPostProcessId;
  72952. /**
  72953. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72954. */
  72955. sharpen: SharpenPostProcess;
  72956. private _sharpenEffect;
  72957. private bloom;
  72958. /**
  72959. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72960. */
  72961. depthOfField: DepthOfFieldEffect;
  72962. /**
  72963. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72964. */
  72965. fxaa: FxaaPostProcess;
  72966. /**
  72967. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72968. */
  72969. imageProcessing: ImageProcessingPostProcess;
  72970. /**
  72971. * Chromatic aberration post process which will shift rgb colors in the image
  72972. */
  72973. chromaticAberration: ChromaticAberrationPostProcess;
  72974. private _chromaticAberrationEffect;
  72975. /**
  72976. * Grain post process which add noise to the image
  72977. */
  72978. grain: GrainPostProcess;
  72979. private _grainEffect;
  72980. /**
  72981. * Glow post process which adds a glow to emissive areas of the image
  72982. */
  72983. private _glowLayer;
  72984. /**
  72985. * Animations which can be used to tweak settings over a period of time
  72986. */
  72987. animations: Animation[];
  72988. private _imageProcessingConfigurationObserver;
  72989. private _sharpenEnabled;
  72990. private _bloomEnabled;
  72991. private _depthOfFieldEnabled;
  72992. private _depthOfFieldBlurLevel;
  72993. private _fxaaEnabled;
  72994. private _imageProcessingEnabled;
  72995. private _defaultPipelineTextureType;
  72996. private _bloomScale;
  72997. private _chromaticAberrationEnabled;
  72998. private _grainEnabled;
  72999. private _buildAllowed;
  73000. /**
  73001. * Gets active scene
  73002. */
  73003. get scene(): Scene;
  73004. /**
  73005. * Enable or disable the sharpen process from the pipeline
  73006. */
  73007. set sharpenEnabled(enabled: boolean);
  73008. get sharpenEnabled(): boolean;
  73009. private _resizeObserver;
  73010. private _hardwareScaleLevel;
  73011. private _bloomKernel;
  73012. /**
  73013. * Specifies the size of the bloom blur kernel, relative to the final output size
  73014. */
  73015. get bloomKernel(): number;
  73016. set bloomKernel(value: number);
  73017. /**
  73018. * Specifies the weight of the bloom in the final rendering
  73019. */
  73020. private _bloomWeight;
  73021. /**
  73022. * Specifies the luma threshold for the area that will be blurred by the bloom
  73023. */
  73024. private _bloomThreshold;
  73025. private _hdr;
  73026. /**
  73027. * The strength of the bloom.
  73028. */
  73029. set bloomWeight(value: number);
  73030. get bloomWeight(): number;
  73031. /**
  73032. * The strength of the bloom.
  73033. */
  73034. set bloomThreshold(value: number);
  73035. get bloomThreshold(): number;
  73036. /**
  73037. * The scale of the bloom, lower value will provide better performance.
  73038. */
  73039. set bloomScale(value: number);
  73040. get bloomScale(): number;
  73041. /**
  73042. * Enable or disable the bloom from the pipeline
  73043. */
  73044. set bloomEnabled(enabled: boolean);
  73045. get bloomEnabled(): boolean;
  73046. private _rebuildBloom;
  73047. /**
  73048. * If the depth of field is enabled.
  73049. */
  73050. get depthOfFieldEnabled(): boolean;
  73051. set depthOfFieldEnabled(enabled: boolean);
  73052. /**
  73053. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73054. */
  73055. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73056. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73057. /**
  73058. * If the anti aliasing is enabled.
  73059. */
  73060. set fxaaEnabled(enabled: boolean);
  73061. get fxaaEnabled(): boolean;
  73062. private _samples;
  73063. /**
  73064. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73065. */
  73066. set samples(sampleCount: number);
  73067. get samples(): number;
  73068. /**
  73069. * If image processing is enabled.
  73070. */
  73071. set imageProcessingEnabled(enabled: boolean);
  73072. get imageProcessingEnabled(): boolean;
  73073. /**
  73074. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73075. */
  73076. set glowLayerEnabled(enabled: boolean);
  73077. get glowLayerEnabled(): boolean;
  73078. /**
  73079. * Gets the glow layer (or null if not defined)
  73080. */
  73081. get glowLayer(): Nullable<GlowLayer>;
  73082. /**
  73083. * Enable or disable the chromaticAberration process from the pipeline
  73084. */
  73085. set chromaticAberrationEnabled(enabled: boolean);
  73086. get chromaticAberrationEnabled(): boolean;
  73087. /**
  73088. * Enable or disable the grain process from the pipeline
  73089. */
  73090. set grainEnabled(enabled: boolean);
  73091. get grainEnabled(): boolean;
  73092. /**
  73093. * @constructor
  73094. * @param name - The rendering pipeline name (default: "")
  73095. * @param hdr - If high dynamic range textures should be used (default: true)
  73096. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73097. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73098. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73099. */
  73100. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73101. /**
  73102. * Get the class name
  73103. * @returns "DefaultRenderingPipeline"
  73104. */
  73105. getClassName(): string;
  73106. /**
  73107. * Force the compilation of the entire pipeline.
  73108. */
  73109. prepare(): void;
  73110. private _hasCleared;
  73111. private _prevPostProcess;
  73112. private _prevPrevPostProcess;
  73113. private _setAutoClearAndTextureSharing;
  73114. private _depthOfFieldSceneObserver;
  73115. private _buildPipeline;
  73116. private _disposePostProcesses;
  73117. /**
  73118. * Adds a camera to the pipeline
  73119. * @param camera the camera to be added
  73120. */
  73121. addCamera(camera: Camera): void;
  73122. /**
  73123. * Removes a camera from the pipeline
  73124. * @param camera the camera to remove
  73125. */
  73126. removeCamera(camera: Camera): void;
  73127. /**
  73128. * Dispose of the pipeline and stop all post processes
  73129. */
  73130. dispose(): void;
  73131. /**
  73132. * Serialize the rendering pipeline (Used when exporting)
  73133. * @returns the serialized object
  73134. */
  73135. serialize(): any;
  73136. /**
  73137. * Parse the serialized pipeline
  73138. * @param source Source pipeline.
  73139. * @param scene The scene to load the pipeline to.
  73140. * @param rootUrl The URL of the serialized pipeline.
  73141. * @returns An instantiated pipeline from the serialized object.
  73142. */
  73143. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73144. }
  73145. }
  73146. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73147. /** @hidden */
  73148. export var lensHighlightsPixelShader: {
  73149. name: string;
  73150. shader: string;
  73151. };
  73152. }
  73153. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73154. /** @hidden */
  73155. export var depthOfFieldPixelShader: {
  73156. name: string;
  73157. shader: string;
  73158. };
  73159. }
  73160. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73161. import { Camera } from "babylonjs/Cameras/camera";
  73162. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73163. import { Scene } from "babylonjs/scene";
  73164. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73165. import "babylonjs/Shaders/chromaticAberration.fragment";
  73166. import "babylonjs/Shaders/lensHighlights.fragment";
  73167. import "babylonjs/Shaders/depthOfField.fragment";
  73168. /**
  73169. * BABYLON.JS Chromatic Aberration GLSL Shader
  73170. * Author: Olivier Guyot
  73171. * Separates very slightly R, G and B colors on the edges of the screen
  73172. * Inspired by Francois Tarlier & Martins Upitis
  73173. */
  73174. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73175. /**
  73176. * @ignore
  73177. * The chromatic aberration PostProcess id in the pipeline
  73178. */
  73179. LensChromaticAberrationEffect: string;
  73180. /**
  73181. * @ignore
  73182. * The highlights enhancing PostProcess id in the pipeline
  73183. */
  73184. HighlightsEnhancingEffect: string;
  73185. /**
  73186. * @ignore
  73187. * The depth-of-field PostProcess id in the pipeline
  73188. */
  73189. LensDepthOfFieldEffect: string;
  73190. private _scene;
  73191. private _depthTexture;
  73192. private _grainTexture;
  73193. private _chromaticAberrationPostProcess;
  73194. private _highlightsPostProcess;
  73195. private _depthOfFieldPostProcess;
  73196. private _edgeBlur;
  73197. private _grainAmount;
  73198. private _chromaticAberration;
  73199. private _distortion;
  73200. private _highlightsGain;
  73201. private _highlightsThreshold;
  73202. private _dofDistance;
  73203. private _dofAperture;
  73204. private _dofDarken;
  73205. private _dofPentagon;
  73206. private _blurNoise;
  73207. /**
  73208. * @constructor
  73209. *
  73210. * Effect parameters are as follow:
  73211. * {
  73212. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73213. * edge_blur: number; // from 0 to x (1 for realism)
  73214. * distortion: number; // from 0 to x (1 for realism)
  73215. * grain_amount: number; // from 0 to 1
  73216. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73217. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73218. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73219. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73220. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73221. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73222. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73223. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73224. * }
  73225. * Note: if an effect parameter is unset, effect is disabled
  73226. *
  73227. * @param name The rendering pipeline name
  73228. * @param parameters - An object containing all parameters (see above)
  73229. * @param scene The scene linked to this pipeline
  73230. * @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)
  73231. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73232. */
  73233. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73234. /**
  73235. * Get the class name
  73236. * @returns "LensRenderingPipeline"
  73237. */
  73238. getClassName(): string;
  73239. /**
  73240. * Gets associated scene
  73241. */
  73242. get scene(): Scene;
  73243. /**
  73244. * Gets or sets the edge blur
  73245. */
  73246. get edgeBlur(): number;
  73247. set edgeBlur(value: number);
  73248. /**
  73249. * Gets or sets the grain amount
  73250. */
  73251. get grainAmount(): number;
  73252. set grainAmount(value: number);
  73253. /**
  73254. * Gets or sets the chromatic aberration amount
  73255. */
  73256. get chromaticAberration(): number;
  73257. set chromaticAberration(value: number);
  73258. /**
  73259. * Gets or sets the depth of field aperture
  73260. */
  73261. get dofAperture(): number;
  73262. set dofAperture(value: number);
  73263. /**
  73264. * Gets or sets the edge distortion
  73265. */
  73266. get edgeDistortion(): number;
  73267. set edgeDistortion(value: number);
  73268. /**
  73269. * Gets or sets the depth of field distortion
  73270. */
  73271. get dofDistortion(): number;
  73272. set dofDistortion(value: number);
  73273. /**
  73274. * Gets or sets the darken out of focus amount
  73275. */
  73276. get darkenOutOfFocus(): number;
  73277. set darkenOutOfFocus(value: number);
  73278. /**
  73279. * Gets or sets a boolean indicating if blur noise is enabled
  73280. */
  73281. get blurNoise(): boolean;
  73282. set blurNoise(value: boolean);
  73283. /**
  73284. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73285. */
  73286. get pentagonBokeh(): boolean;
  73287. set pentagonBokeh(value: boolean);
  73288. /**
  73289. * Gets or sets the highlight grain amount
  73290. */
  73291. get highlightsGain(): number;
  73292. set highlightsGain(value: number);
  73293. /**
  73294. * Gets or sets the highlight threshold
  73295. */
  73296. get highlightsThreshold(): number;
  73297. set highlightsThreshold(value: number);
  73298. /**
  73299. * Sets the amount of blur at the edges
  73300. * @param amount blur amount
  73301. */
  73302. setEdgeBlur(amount: number): void;
  73303. /**
  73304. * Sets edge blur to 0
  73305. */
  73306. disableEdgeBlur(): void;
  73307. /**
  73308. * Sets the amout of grain
  73309. * @param amount Amount of grain
  73310. */
  73311. setGrainAmount(amount: number): void;
  73312. /**
  73313. * Set grain amount to 0
  73314. */
  73315. disableGrain(): void;
  73316. /**
  73317. * Sets the chromatic aberration amount
  73318. * @param amount amount of chromatic aberration
  73319. */
  73320. setChromaticAberration(amount: number): void;
  73321. /**
  73322. * Sets chromatic aberration amount to 0
  73323. */
  73324. disableChromaticAberration(): void;
  73325. /**
  73326. * Sets the EdgeDistortion amount
  73327. * @param amount amount of EdgeDistortion
  73328. */
  73329. setEdgeDistortion(amount: number): void;
  73330. /**
  73331. * Sets edge distortion to 0
  73332. */
  73333. disableEdgeDistortion(): void;
  73334. /**
  73335. * Sets the FocusDistance amount
  73336. * @param amount amount of FocusDistance
  73337. */
  73338. setFocusDistance(amount: number): void;
  73339. /**
  73340. * Disables depth of field
  73341. */
  73342. disableDepthOfField(): void;
  73343. /**
  73344. * Sets the Aperture amount
  73345. * @param amount amount of Aperture
  73346. */
  73347. setAperture(amount: number): void;
  73348. /**
  73349. * Sets the DarkenOutOfFocus amount
  73350. * @param amount amount of DarkenOutOfFocus
  73351. */
  73352. setDarkenOutOfFocus(amount: number): void;
  73353. private _pentagonBokehIsEnabled;
  73354. /**
  73355. * Creates a pentagon bokeh effect
  73356. */
  73357. enablePentagonBokeh(): void;
  73358. /**
  73359. * Disables the pentagon bokeh effect
  73360. */
  73361. disablePentagonBokeh(): void;
  73362. /**
  73363. * Enables noise blur
  73364. */
  73365. enableNoiseBlur(): void;
  73366. /**
  73367. * Disables noise blur
  73368. */
  73369. disableNoiseBlur(): void;
  73370. /**
  73371. * Sets the HighlightsGain amount
  73372. * @param amount amount of HighlightsGain
  73373. */
  73374. setHighlightsGain(amount: number): void;
  73375. /**
  73376. * Sets the HighlightsThreshold amount
  73377. * @param amount amount of HighlightsThreshold
  73378. */
  73379. setHighlightsThreshold(amount: number): void;
  73380. /**
  73381. * Disables highlights
  73382. */
  73383. disableHighlights(): void;
  73384. /**
  73385. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73386. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73387. */
  73388. dispose(disableDepthRender?: boolean): void;
  73389. private _createChromaticAberrationPostProcess;
  73390. private _createHighlightsPostProcess;
  73391. private _createDepthOfFieldPostProcess;
  73392. private _createGrainTexture;
  73393. }
  73394. }
  73395. declare module "babylonjs/Shaders/ssao2.fragment" {
  73396. /** @hidden */
  73397. export var ssao2PixelShader: {
  73398. name: string;
  73399. shader: string;
  73400. };
  73401. }
  73402. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73403. /** @hidden */
  73404. export var ssaoCombinePixelShader: {
  73405. name: string;
  73406. shader: string;
  73407. };
  73408. }
  73409. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73410. import { Camera } from "babylonjs/Cameras/camera";
  73411. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73412. import { Scene } from "babylonjs/scene";
  73413. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73414. import "babylonjs/Shaders/ssao2.fragment";
  73415. import "babylonjs/Shaders/ssaoCombine.fragment";
  73416. /**
  73417. * Render pipeline to produce ssao effect
  73418. */
  73419. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73420. /**
  73421. * @ignore
  73422. * The PassPostProcess id in the pipeline that contains the original scene color
  73423. */
  73424. SSAOOriginalSceneColorEffect: string;
  73425. /**
  73426. * @ignore
  73427. * The SSAO PostProcess id in the pipeline
  73428. */
  73429. SSAORenderEffect: string;
  73430. /**
  73431. * @ignore
  73432. * The horizontal blur PostProcess id in the pipeline
  73433. */
  73434. SSAOBlurHRenderEffect: string;
  73435. /**
  73436. * @ignore
  73437. * The vertical blur PostProcess id in the pipeline
  73438. */
  73439. SSAOBlurVRenderEffect: string;
  73440. /**
  73441. * @ignore
  73442. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73443. */
  73444. SSAOCombineRenderEffect: string;
  73445. /**
  73446. * The output strength of the SSAO post-process. Default value is 1.0.
  73447. */
  73448. totalStrength: number;
  73449. /**
  73450. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73451. */
  73452. maxZ: number;
  73453. /**
  73454. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73455. */
  73456. minZAspect: number;
  73457. private _samples;
  73458. /**
  73459. * Number of samples used for the SSAO calculations. Default value is 8
  73460. */
  73461. set samples(n: number);
  73462. get samples(): number;
  73463. private _textureSamples;
  73464. /**
  73465. * Number of samples to use for antialiasing
  73466. */
  73467. set textureSamples(n: number);
  73468. get textureSamples(): number;
  73469. /**
  73470. * Ratio object used for SSAO ratio and blur ratio
  73471. */
  73472. private _ratio;
  73473. /**
  73474. * Dynamically generated sphere sampler.
  73475. */
  73476. private _sampleSphere;
  73477. /**
  73478. * Blur filter offsets
  73479. */
  73480. private _samplerOffsets;
  73481. private _expensiveBlur;
  73482. /**
  73483. * If bilateral blur should be used
  73484. */
  73485. set expensiveBlur(b: boolean);
  73486. get expensiveBlur(): boolean;
  73487. /**
  73488. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73489. */
  73490. radius: number;
  73491. /**
  73492. * The base color of the SSAO post-process
  73493. * The final result is "base + ssao" between [0, 1]
  73494. */
  73495. base: number;
  73496. /**
  73497. * Support test.
  73498. */
  73499. static get IsSupported(): boolean;
  73500. private _scene;
  73501. private _depthTexture;
  73502. private _normalTexture;
  73503. private _randomTexture;
  73504. private _originalColorPostProcess;
  73505. private _ssaoPostProcess;
  73506. private _blurHPostProcess;
  73507. private _blurVPostProcess;
  73508. private _ssaoCombinePostProcess;
  73509. /**
  73510. * Gets active scene
  73511. */
  73512. get scene(): Scene;
  73513. /**
  73514. * @constructor
  73515. * @param name The rendering pipeline name
  73516. * @param scene The scene linked to this pipeline
  73517. * @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 }
  73518. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73519. */
  73520. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73521. /**
  73522. * Get the class name
  73523. * @returns "SSAO2RenderingPipeline"
  73524. */
  73525. getClassName(): string;
  73526. /**
  73527. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73528. */
  73529. dispose(disableGeometryBufferRenderer?: boolean): void;
  73530. private _createBlurPostProcess;
  73531. /** @hidden */
  73532. _rebuild(): void;
  73533. private _bits;
  73534. private _radicalInverse_VdC;
  73535. private _hammersley;
  73536. private _hemisphereSample_uniform;
  73537. private _generateHemisphere;
  73538. private _createSSAOPostProcess;
  73539. private _createSSAOCombinePostProcess;
  73540. private _createRandomTexture;
  73541. /**
  73542. * Serialize the rendering pipeline (Used when exporting)
  73543. * @returns the serialized object
  73544. */
  73545. serialize(): any;
  73546. /**
  73547. * Parse the serialized pipeline
  73548. * @param source Source pipeline.
  73549. * @param scene The scene to load the pipeline to.
  73550. * @param rootUrl The URL of the serialized pipeline.
  73551. * @returns An instantiated pipeline from the serialized object.
  73552. */
  73553. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73554. }
  73555. }
  73556. declare module "babylonjs/Shaders/ssao.fragment" {
  73557. /** @hidden */
  73558. export var ssaoPixelShader: {
  73559. name: string;
  73560. shader: string;
  73561. };
  73562. }
  73563. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73564. import { Camera } from "babylonjs/Cameras/camera";
  73565. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73566. import { Scene } from "babylonjs/scene";
  73567. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73568. import "babylonjs/Shaders/ssao.fragment";
  73569. import "babylonjs/Shaders/ssaoCombine.fragment";
  73570. /**
  73571. * Render pipeline to produce ssao effect
  73572. */
  73573. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73574. /**
  73575. * @ignore
  73576. * The PassPostProcess id in the pipeline that contains the original scene color
  73577. */
  73578. SSAOOriginalSceneColorEffect: string;
  73579. /**
  73580. * @ignore
  73581. * The SSAO PostProcess id in the pipeline
  73582. */
  73583. SSAORenderEffect: string;
  73584. /**
  73585. * @ignore
  73586. * The horizontal blur PostProcess id in the pipeline
  73587. */
  73588. SSAOBlurHRenderEffect: string;
  73589. /**
  73590. * @ignore
  73591. * The vertical blur PostProcess id in the pipeline
  73592. */
  73593. SSAOBlurVRenderEffect: string;
  73594. /**
  73595. * @ignore
  73596. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73597. */
  73598. SSAOCombineRenderEffect: string;
  73599. /**
  73600. * The output strength of the SSAO post-process. Default value is 1.0.
  73601. */
  73602. totalStrength: number;
  73603. /**
  73604. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73605. */
  73606. radius: number;
  73607. /**
  73608. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73609. * Must not be equal to fallOff and superior to fallOff.
  73610. * Default value is 0.0075
  73611. */
  73612. area: number;
  73613. /**
  73614. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73615. * Must not be equal to area and inferior to area.
  73616. * Default value is 0.000001
  73617. */
  73618. fallOff: number;
  73619. /**
  73620. * The base color of the SSAO post-process
  73621. * The final result is "base + ssao" between [0, 1]
  73622. */
  73623. base: number;
  73624. private _scene;
  73625. private _depthTexture;
  73626. private _randomTexture;
  73627. private _originalColorPostProcess;
  73628. private _ssaoPostProcess;
  73629. private _blurHPostProcess;
  73630. private _blurVPostProcess;
  73631. private _ssaoCombinePostProcess;
  73632. private _firstUpdate;
  73633. /**
  73634. * Gets active scene
  73635. */
  73636. get scene(): Scene;
  73637. /**
  73638. * @constructor
  73639. * @param name - The rendering pipeline name
  73640. * @param scene - The scene linked to this pipeline
  73641. * @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 }
  73642. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73643. */
  73644. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73645. /**
  73646. * Get the class name
  73647. * @returns "SSAORenderingPipeline"
  73648. */
  73649. getClassName(): string;
  73650. /**
  73651. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73652. */
  73653. dispose(disableDepthRender?: boolean): void;
  73654. private _createBlurPostProcess;
  73655. /** @hidden */
  73656. _rebuild(): void;
  73657. private _createSSAOPostProcess;
  73658. private _createSSAOCombinePostProcess;
  73659. private _createRandomTexture;
  73660. }
  73661. }
  73662. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73663. /** @hidden */
  73664. export var screenSpaceReflectionPixelShader: {
  73665. name: string;
  73666. shader: string;
  73667. };
  73668. }
  73669. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73670. import { Nullable } from "babylonjs/types";
  73671. import { Camera } from "babylonjs/Cameras/camera";
  73672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73673. import { Scene } from "babylonjs/scene";
  73674. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73675. import { Engine } from "babylonjs/Engines/engine";
  73676. /**
  73677. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73678. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73679. */
  73680. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73681. /**
  73682. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73683. */
  73684. threshold: number;
  73685. /**
  73686. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73687. */
  73688. strength: number;
  73689. /**
  73690. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73691. */
  73692. reflectionSpecularFalloffExponent: number;
  73693. /**
  73694. * 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]
  73695. */
  73696. step: number;
  73697. /**
  73698. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73699. */
  73700. roughnessFactor: number;
  73701. private _geometryBufferRenderer;
  73702. private _enableSmoothReflections;
  73703. private _reflectionSamples;
  73704. private _smoothSteps;
  73705. /**
  73706. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73707. * @param name The name of the effect.
  73708. * @param scene The scene containing the objects to calculate reflections.
  73709. * @param options The required width/height ratio to downsize to before computing the render pass.
  73710. * @param camera The camera to apply the render pass to.
  73711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73712. * @param engine The engine which the post process will be applied. (default: current engine)
  73713. * @param reusable If the post process can be reused on the same frame. (default: false)
  73714. * @param textureType Type of textures used when performing the post process. (default: 0)
  73715. * @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)
  73716. */
  73717. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73718. /**
  73719. * Gets wether or not smoothing reflections is enabled.
  73720. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73721. */
  73722. get enableSmoothReflections(): boolean;
  73723. /**
  73724. * Sets wether or not smoothing reflections is enabled.
  73725. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73726. */
  73727. set enableSmoothReflections(enabled: boolean);
  73728. /**
  73729. * Gets the number of samples taken while computing reflections. More samples count is high,
  73730. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73731. */
  73732. get reflectionSamples(): number;
  73733. /**
  73734. * Sets the number of samples taken while computing reflections. More samples count is high,
  73735. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73736. */
  73737. set reflectionSamples(samples: number);
  73738. /**
  73739. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73740. * more the post-process will require GPU power and can generate a drop in FPS.
  73741. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73742. */
  73743. get smoothSteps(): number;
  73744. set smoothSteps(steps: number);
  73745. private _updateEffectDefines;
  73746. }
  73747. }
  73748. declare module "babylonjs/Shaders/standard.fragment" {
  73749. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73750. /** @hidden */
  73751. export var standardPixelShader: {
  73752. name: string;
  73753. shader: string;
  73754. };
  73755. }
  73756. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73757. import { Nullable } from "babylonjs/types";
  73758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73759. import { Camera } from "babylonjs/Cameras/camera";
  73760. import { Texture } from "babylonjs/Materials/Textures/texture";
  73761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73762. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73763. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73764. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73765. import { IDisposable } from "babylonjs/scene";
  73766. import { SpotLight } from "babylonjs/Lights/spotLight";
  73767. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73768. import { Scene } from "babylonjs/scene";
  73769. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73770. import { Animation } from "babylonjs/Animations/animation";
  73771. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73772. import "babylonjs/Shaders/standard.fragment";
  73773. /**
  73774. * Standard rendering pipeline
  73775. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73776. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73777. */
  73778. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73779. /**
  73780. * Public members
  73781. */
  73782. /**
  73783. * Post-process which contains the original scene color before the pipeline applies all the effects
  73784. */
  73785. originalPostProcess: Nullable<PostProcess>;
  73786. /**
  73787. * Post-process used to down scale an image x4
  73788. */
  73789. downSampleX4PostProcess: Nullable<PostProcess>;
  73790. /**
  73791. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73792. */
  73793. brightPassPostProcess: Nullable<PostProcess>;
  73794. /**
  73795. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73796. */
  73797. blurHPostProcesses: PostProcess[];
  73798. /**
  73799. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73800. */
  73801. blurVPostProcesses: PostProcess[];
  73802. /**
  73803. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73804. */
  73805. textureAdderPostProcess: Nullable<PostProcess>;
  73806. /**
  73807. * Post-process used to create volumetric lighting effect
  73808. */
  73809. volumetricLightPostProcess: Nullable<PostProcess>;
  73810. /**
  73811. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73812. */
  73813. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73814. /**
  73815. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73816. */
  73817. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73818. /**
  73819. * Post-process used to merge the volumetric light effect and the real scene color
  73820. */
  73821. volumetricLightMergePostProces: Nullable<PostProcess>;
  73822. /**
  73823. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73824. */
  73825. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73826. /**
  73827. * Base post-process used to calculate the average luminance of the final image for HDR
  73828. */
  73829. luminancePostProcess: Nullable<PostProcess>;
  73830. /**
  73831. * Post-processes used to create down sample post-processes in order to get
  73832. * the average luminance of the final image for HDR
  73833. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73834. */
  73835. luminanceDownSamplePostProcesses: PostProcess[];
  73836. /**
  73837. * Post-process used to create a HDR effect (light adaptation)
  73838. */
  73839. hdrPostProcess: Nullable<PostProcess>;
  73840. /**
  73841. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73842. */
  73843. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73844. /**
  73845. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73846. */
  73847. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73848. /**
  73849. * Post-process used to merge the final HDR post-process and the real scene color
  73850. */
  73851. hdrFinalPostProcess: Nullable<PostProcess>;
  73852. /**
  73853. * Post-process used to create a lens flare effect
  73854. */
  73855. lensFlarePostProcess: Nullable<PostProcess>;
  73856. /**
  73857. * Post-process that merges the result of the lens flare post-process and the real scene color
  73858. */
  73859. lensFlareComposePostProcess: Nullable<PostProcess>;
  73860. /**
  73861. * Post-process used to create a motion blur effect
  73862. */
  73863. motionBlurPostProcess: Nullable<PostProcess>;
  73864. /**
  73865. * Post-process used to create a depth of field effect
  73866. */
  73867. depthOfFieldPostProcess: Nullable<PostProcess>;
  73868. /**
  73869. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73870. */
  73871. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73872. /**
  73873. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73874. */
  73875. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73876. /**
  73877. * Represents the brightness threshold in order to configure the illuminated surfaces
  73878. */
  73879. brightThreshold: number;
  73880. /**
  73881. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73882. */
  73883. blurWidth: number;
  73884. /**
  73885. * Sets if the blur for highlighted surfaces must be only horizontal
  73886. */
  73887. horizontalBlur: boolean;
  73888. /**
  73889. * Gets the overall exposure used by the pipeline
  73890. */
  73891. get exposure(): number;
  73892. /**
  73893. * Sets the overall exposure used by the pipeline
  73894. */
  73895. set exposure(value: number);
  73896. /**
  73897. * Texture used typically to simulate "dirty" on camera lens
  73898. */
  73899. lensTexture: Nullable<Texture>;
  73900. /**
  73901. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73902. */
  73903. volumetricLightCoefficient: number;
  73904. /**
  73905. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73906. */
  73907. volumetricLightPower: number;
  73908. /**
  73909. * Used the set the blur intensity to smooth the volumetric lights
  73910. */
  73911. volumetricLightBlurScale: number;
  73912. /**
  73913. * Light (spot or directional) used to generate the volumetric lights rays
  73914. * The source light must have a shadow generate so the pipeline can get its
  73915. * depth map
  73916. */
  73917. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73918. /**
  73919. * For eye adaptation, represents the minimum luminance the eye can see
  73920. */
  73921. hdrMinimumLuminance: number;
  73922. /**
  73923. * For eye adaptation, represents the decrease luminance speed
  73924. */
  73925. hdrDecreaseRate: number;
  73926. /**
  73927. * For eye adaptation, represents the increase luminance speed
  73928. */
  73929. hdrIncreaseRate: number;
  73930. /**
  73931. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73932. */
  73933. get hdrAutoExposure(): boolean;
  73934. /**
  73935. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73936. */
  73937. set hdrAutoExposure(value: boolean);
  73938. /**
  73939. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73940. */
  73941. lensColorTexture: Nullable<Texture>;
  73942. /**
  73943. * The overall strengh for the lens flare effect
  73944. */
  73945. lensFlareStrength: number;
  73946. /**
  73947. * Dispersion coefficient for lens flare ghosts
  73948. */
  73949. lensFlareGhostDispersal: number;
  73950. /**
  73951. * Main lens flare halo width
  73952. */
  73953. lensFlareHaloWidth: number;
  73954. /**
  73955. * Based on the lens distortion effect, defines how much the lens flare result
  73956. * is distorted
  73957. */
  73958. lensFlareDistortionStrength: number;
  73959. /**
  73960. * Configures the blur intensity used for for lens flare (halo)
  73961. */
  73962. lensFlareBlurWidth: number;
  73963. /**
  73964. * Lens star texture must be used to simulate rays on the flares and is available
  73965. * in the documentation
  73966. */
  73967. lensStarTexture: Nullable<Texture>;
  73968. /**
  73969. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73970. * flare effect by taking account of the dirt texture
  73971. */
  73972. lensFlareDirtTexture: Nullable<Texture>;
  73973. /**
  73974. * Represents the focal length for the depth of field effect
  73975. */
  73976. depthOfFieldDistance: number;
  73977. /**
  73978. * Represents the blur intensity for the blurred part of the depth of field effect
  73979. */
  73980. depthOfFieldBlurWidth: number;
  73981. /**
  73982. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73983. */
  73984. get motionStrength(): number;
  73985. /**
  73986. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73987. */
  73988. set motionStrength(strength: number);
  73989. /**
  73990. * Gets wether or not the motion blur post-process is object based or screen based.
  73991. */
  73992. get objectBasedMotionBlur(): boolean;
  73993. /**
  73994. * Sets wether or not the motion blur post-process should be object based or screen based
  73995. */
  73996. set objectBasedMotionBlur(value: boolean);
  73997. /**
  73998. * List of animations for the pipeline (IAnimatable implementation)
  73999. */
  74000. animations: Animation[];
  74001. /**
  74002. * Private members
  74003. */
  74004. private _scene;
  74005. private _currentDepthOfFieldSource;
  74006. private _basePostProcess;
  74007. private _fixedExposure;
  74008. private _currentExposure;
  74009. private _hdrAutoExposure;
  74010. private _hdrCurrentLuminance;
  74011. private _motionStrength;
  74012. private _isObjectBasedMotionBlur;
  74013. private _floatTextureType;
  74014. private _camerasToBeAttached;
  74015. private _ratio;
  74016. private _bloomEnabled;
  74017. private _depthOfFieldEnabled;
  74018. private _vlsEnabled;
  74019. private _lensFlareEnabled;
  74020. private _hdrEnabled;
  74021. private _motionBlurEnabled;
  74022. private _fxaaEnabled;
  74023. private _screenSpaceReflectionsEnabled;
  74024. private _motionBlurSamples;
  74025. private _volumetricLightStepsCount;
  74026. private _samples;
  74027. /**
  74028. * @ignore
  74029. * Specifies if the bloom pipeline is enabled
  74030. */
  74031. get BloomEnabled(): boolean;
  74032. set BloomEnabled(enabled: boolean);
  74033. /**
  74034. * @ignore
  74035. * Specifies if the depth of field pipeline is enabed
  74036. */
  74037. get DepthOfFieldEnabled(): boolean;
  74038. set DepthOfFieldEnabled(enabled: boolean);
  74039. /**
  74040. * @ignore
  74041. * Specifies if the lens flare pipeline is enabed
  74042. */
  74043. get LensFlareEnabled(): boolean;
  74044. set LensFlareEnabled(enabled: boolean);
  74045. /**
  74046. * @ignore
  74047. * Specifies if the HDR pipeline is enabled
  74048. */
  74049. get HDREnabled(): boolean;
  74050. set HDREnabled(enabled: boolean);
  74051. /**
  74052. * @ignore
  74053. * Specifies if the volumetric lights scattering effect is enabled
  74054. */
  74055. get VLSEnabled(): boolean;
  74056. set VLSEnabled(enabled: boolean);
  74057. /**
  74058. * @ignore
  74059. * Specifies if the motion blur effect is enabled
  74060. */
  74061. get MotionBlurEnabled(): boolean;
  74062. set MotionBlurEnabled(enabled: boolean);
  74063. /**
  74064. * Specifies if anti-aliasing is enabled
  74065. */
  74066. get fxaaEnabled(): boolean;
  74067. set fxaaEnabled(enabled: boolean);
  74068. /**
  74069. * Specifies if screen space reflections are enabled.
  74070. */
  74071. get screenSpaceReflectionsEnabled(): boolean;
  74072. set screenSpaceReflectionsEnabled(enabled: boolean);
  74073. /**
  74074. * Specifies the number of steps used to calculate the volumetric lights
  74075. * Typically in interval [50, 200]
  74076. */
  74077. get volumetricLightStepsCount(): number;
  74078. set volumetricLightStepsCount(count: number);
  74079. /**
  74080. * Specifies the number of samples used for the motion blur effect
  74081. * Typically in interval [16, 64]
  74082. */
  74083. get motionBlurSamples(): number;
  74084. set motionBlurSamples(samples: number);
  74085. /**
  74086. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74087. */
  74088. get samples(): number;
  74089. set samples(sampleCount: number);
  74090. /**
  74091. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74092. * @constructor
  74093. * @param name The rendering pipeline name
  74094. * @param scene The scene linked to this pipeline
  74095. * @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)
  74096. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74097. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74098. */
  74099. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74100. private _buildPipeline;
  74101. private _createDownSampleX4PostProcess;
  74102. private _createBrightPassPostProcess;
  74103. private _createBlurPostProcesses;
  74104. private _createTextureAdderPostProcess;
  74105. private _createVolumetricLightPostProcess;
  74106. private _createLuminancePostProcesses;
  74107. private _createHdrPostProcess;
  74108. private _createLensFlarePostProcess;
  74109. private _createDepthOfFieldPostProcess;
  74110. private _createMotionBlurPostProcess;
  74111. private _getDepthTexture;
  74112. private _disposePostProcesses;
  74113. /**
  74114. * Dispose of the pipeline and stop all post processes
  74115. */
  74116. dispose(): void;
  74117. /**
  74118. * Serialize the rendering pipeline (Used when exporting)
  74119. * @returns the serialized object
  74120. */
  74121. serialize(): any;
  74122. /**
  74123. * Parse the serialized pipeline
  74124. * @param source Source pipeline.
  74125. * @param scene The scene to load the pipeline to.
  74126. * @param rootUrl The URL of the serialized pipeline.
  74127. * @returns An instantiated pipeline from the serialized object.
  74128. */
  74129. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74130. /**
  74131. * Luminance steps
  74132. */
  74133. static LuminanceSteps: number;
  74134. }
  74135. }
  74136. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74137. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74138. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74139. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74140. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74141. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74142. }
  74143. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74144. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74145. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74146. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74147. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74148. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74149. }
  74150. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74151. /** @hidden */
  74152. export var stereoscopicInterlacePixelShader: {
  74153. name: string;
  74154. shader: string;
  74155. };
  74156. }
  74157. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74158. import { Camera } from "babylonjs/Cameras/camera";
  74159. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74160. import { Engine } from "babylonjs/Engines/engine";
  74161. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74162. /**
  74163. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74164. */
  74165. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74166. private _stepSize;
  74167. private _passedProcess;
  74168. /**
  74169. * Initializes a StereoscopicInterlacePostProcessI
  74170. * @param name The name of the effect.
  74171. * @param rigCameras The rig cameras to be appled to the post process
  74172. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74173. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74175. * @param engine The engine which the post process will be applied. (default: current engine)
  74176. * @param reusable If the post process can be reused on the same frame. (default: false)
  74177. */
  74178. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74179. }
  74180. /**
  74181. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74182. */
  74183. export class StereoscopicInterlacePostProcess extends PostProcess {
  74184. private _stepSize;
  74185. private _passedProcess;
  74186. /**
  74187. * Initializes a StereoscopicInterlacePostProcess
  74188. * @param name The name of the effect.
  74189. * @param rigCameras The rig cameras to be appled to the post process
  74190. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74192. * @param engine The engine which the post process will be applied. (default: current engine)
  74193. * @param reusable If the post process can be reused on the same frame. (default: false)
  74194. */
  74195. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74196. }
  74197. }
  74198. declare module "babylonjs/Shaders/tonemap.fragment" {
  74199. /** @hidden */
  74200. export var tonemapPixelShader: {
  74201. name: string;
  74202. shader: string;
  74203. };
  74204. }
  74205. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74206. import { Camera } from "babylonjs/Cameras/camera";
  74207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74208. import "babylonjs/Shaders/tonemap.fragment";
  74209. import { Engine } from "babylonjs/Engines/engine";
  74210. /** Defines operator used for tonemapping */
  74211. export enum TonemappingOperator {
  74212. /** Hable */
  74213. Hable = 0,
  74214. /** Reinhard */
  74215. Reinhard = 1,
  74216. /** HejiDawson */
  74217. HejiDawson = 2,
  74218. /** Photographic */
  74219. Photographic = 3
  74220. }
  74221. /**
  74222. * Defines a post process to apply tone mapping
  74223. */
  74224. export class TonemapPostProcess extends PostProcess {
  74225. private _operator;
  74226. /** Defines the required exposure adjustement */
  74227. exposureAdjustment: number;
  74228. /**
  74229. * Creates a new TonemapPostProcess
  74230. * @param name defines the name of the postprocess
  74231. * @param _operator defines the operator to use
  74232. * @param exposureAdjustment defines the required exposure adjustement
  74233. * @param camera defines the camera to use (can be null)
  74234. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74235. * @param engine defines the hosting engine (can be ignore if camera is set)
  74236. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74237. */
  74238. constructor(name: string, _operator: TonemappingOperator,
  74239. /** Defines the required exposure adjustement */
  74240. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74241. }
  74242. }
  74243. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74244. /** @hidden */
  74245. export var volumetricLightScatteringPixelShader: {
  74246. name: string;
  74247. shader: string;
  74248. };
  74249. }
  74250. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74251. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74252. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74253. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74254. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74256. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74257. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74258. /** @hidden */
  74259. export var volumetricLightScatteringPassVertexShader: {
  74260. name: string;
  74261. shader: string;
  74262. };
  74263. }
  74264. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74265. /** @hidden */
  74266. export var volumetricLightScatteringPassPixelShader: {
  74267. name: string;
  74268. shader: string;
  74269. };
  74270. }
  74271. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74272. import { Vector3 } from "babylonjs/Maths/math.vector";
  74273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74274. import { Mesh } from "babylonjs/Meshes/mesh";
  74275. import { Camera } from "babylonjs/Cameras/camera";
  74276. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74278. import { Scene } from "babylonjs/scene";
  74279. import "babylonjs/Meshes/Builders/planeBuilder";
  74280. import "babylonjs/Shaders/depth.vertex";
  74281. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74282. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74283. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74284. import { Engine } from "babylonjs/Engines/engine";
  74285. /**
  74286. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74287. */
  74288. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74289. private _volumetricLightScatteringPass;
  74290. private _volumetricLightScatteringRTT;
  74291. private _viewPort;
  74292. private _screenCoordinates;
  74293. private _cachedDefines;
  74294. /**
  74295. * If not undefined, the mesh position is computed from the attached node position
  74296. */
  74297. attachedNode: {
  74298. position: Vector3;
  74299. };
  74300. /**
  74301. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74302. */
  74303. customMeshPosition: Vector3;
  74304. /**
  74305. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74306. */
  74307. useCustomMeshPosition: boolean;
  74308. /**
  74309. * If the post-process should inverse the light scattering direction
  74310. */
  74311. invert: boolean;
  74312. /**
  74313. * The internal mesh used by the post-process
  74314. */
  74315. mesh: Mesh;
  74316. /**
  74317. * @hidden
  74318. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74319. */
  74320. get useDiffuseColor(): boolean;
  74321. set useDiffuseColor(useDiffuseColor: boolean);
  74322. /**
  74323. * Array containing the excluded meshes not rendered in the internal pass
  74324. */
  74325. excludedMeshes: AbstractMesh[];
  74326. /**
  74327. * Controls the overall intensity of the post-process
  74328. */
  74329. exposure: number;
  74330. /**
  74331. * Dissipates each sample's contribution in range [0, 1]
  74332. */
  74333. decay: number;
  74334. /**
  74335. * Controls the overall intensity of each sample
  74336. */
  74337. weight: number;
  74338. /**
  74339. * Controls the density of each sample
  74340. */
  74341. density: number;
  74342. /**
  74343. * @constructor
  74344. * @param name The post-process name
  74345. * @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)
  74346. * @param camera The camera that the post-process will be attached to
  74347. * @param mesh The mesh used to create the light scattering
  74348. * @param samples The post-process quality, default 100
  74349. * @param samplingModeThe post-process filtering mode
  74350. * @param engine The babylon engine
  74351. * @param reusable If the post-process is reusable
  74352. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74353. */
  74354. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74355. /**
  74356. * Returns the string "VolumetricLightScatteringPostProcess"
  74357. * @returns "VolumetricLightScatteringPostProcess"
  74358. */
  74359. getClassName(): string;
  74360. private _isReady;
  74361. /**
  74362. * Sets the new light position for light scattering effect
  74363. * @param position The new custom light position
  74364. */
  74365. setCustomMeshPosition(position: Vector3): void;
  74366. /**
  74367. * Returns the light position for light scattering effect
  74368. * @return Vector3 The custom light position
  74369. */
  74370. getCustomMeshPosition(): Vector3;
  74371. /**
  74372. * Disposes the internal assets and detaches the post-process from the camera
  74373. */
  74374. dispose(camera: Camera): void;
  74375. /**
  74376. * Returns the render target texture used by the post-process
  74377. * @return the render target texture used by the post-process
  74378. */
  74379. getPass(): RenderTargetTexture;
  74380. private _meshExcluded;
  74381. private _createPass;
  74382. private _updateMeshScreenCoordinates;
  74383. /**
  74384. * Creates a default mesh for the Volumeric Light Scattering post-process
  74385. * @param name The mesh name
  74386. * @param scene The scene where to create the mesh
  74387. * @return the default mesh
  74388. */
  74389. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74390. }
  74391. }
  74392. declare module "babylonjs/PostProcesses/index" {
  74393. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74394. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74395. export * from "babylonjs/PostProcesses/bloomEffect";
  74396. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74397. export * from "babylonjs/PostProcesses/blurPostProcess";
  74398. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74399. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74400. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74401. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74402. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74403. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74404. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74405. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74406. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74407. export * from "babylonjs/PostProcesses/filterPostProcess";
  74408. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74409. export * from "babylonjs/PostProcesses/grainPostProcess";
  74410. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74411. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74412. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74413. export * from "babylonjs/PostProcesses/passPostProcess";
  74414. export * from "babylonjs/PostProcesses/postProcess";
  74415. export * from "babylonjs/PostProcesses/postProcessManager";
  74416. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74417. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74418. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74419. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74420. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74421. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74422. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74423. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74424. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74425. }
  74426. declare module "babylonjs/Probes/index" {
  74427. export * from "babylonjs/Probes/reflectionProbe";
  74428. }
  74429. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74430. import { Scene } from "babylonjs/scene";
  74431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74432. import { SmartArray } from "babylonjs/Misc/smartArray";
  74433. import { ISceneComponent } from "babylonjs/sceneComponent";
  74434. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74435. import "babylonjs/Meshes/Builders/boxBuilder";
  74436. import "babylonjs/Shaders/color.fragment";
  74437. import "babylonjs/Shaders/color.vertex";
  74438. import { Color3 } from "babylonjs/Maths/math.color";
  74439. import { Observable } from "babylonjs/Misc/observable";
  74440. module "babylonjs/scene" {
  74441. interface Scene {
  74442. /** @hidden (Backing field) */
  74443. _boundingBoxRenderer: BoundingBoxRenderer;
  74444. /** @hidden (Backing field) */
  74445. _forceShowBoundingBoxes: boolean;
  74446. /**
  74447. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74448. */
  74449. forceShowBoundingBoxes: boolean;
  74450. /**
  74451. * Gets the bounding box renderer associated with the scene
  74452. * @returns a BoundingBoxRenderer
  74453. */
  74454. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74455. }
  74456. }
  74457. module "babylonjs/Meshes/abstractMesh" {
  74458. interface AbstractMesh {
  74459. /** @hidden (Backing field) */
  74460. _showBoundingBox: boolean;
  74461. /**
  74462. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74463. */
  74464. showBoundingBox: boolean;
  74465. }
  74466. }
  74467. /**
  74468. * Component responsible of rendering the bounding box of the meshes in a scene.
  74469. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74470. */
  74471. export class BoundingBoxRenderer implements ISceneComponent {
  74472. /**
  74473. * The component name helpfull to identify the component in the list of scene components.
  74474. */
  74475. readonly name: string;
  74476. /**
  74477. * The scene the component belongs to.
  74478. */
  74479. scene: Scene;
  74480. /**
  74481. * Color of the bounding box lines placed in front of an object
  74482. */
  74483. frontColor: Color3;
  74484. /**
  74485. * Color of the bounding box lines placed behind an object
  74486. */
  74487. backColor: Color3;
  74488. /**
  74489. * Defines if the renderer should show the back lines or not
  74490. */
  74491. showBackLines: boolean;
  74492. /**
  74493. * Observable raised before rendering a bounding box
  74494. */
  74495. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74496. /**
  74497. * Observable raised after rendering a bounding box
  74498. */
  74499. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74500. /**
  74501. * @hidden
  74502. */
  74503. renderList: SmartArray<BoundingBox>;
  74504. private _colorShader;
  74505. private _vertexBuffers;
  74506. private _indexBuffer;
  74507. private _fillIndexBuffer;
  74508. private _fillIndexData;
  74509. /**
  74510. * Instantiates a new bounding box renderer in a scene.
  74511. * @param scene the scene the renderer renders in
  74512. */
  74513. constructor(scene: Scene);
  74514. /**
  74515. * Registers the component in a given scene
  74516. */
  74517. register(): void;
  74518. private _evaluateSubMesh;
  74519. private _activeMesh;
  74520. private _prepareRessources;
  74521. private _createIndexBuffer;
  74522. /**
  74523. * Rebuilds the elements related to this component in case of
  74524. * context lost for instance.
  74525. */
  74526. rebuild(): void;
  74527. /**
  74528. * @hidden
  74529. */
  74530. reset(): void;
  74531. /**
  74532. * Render the bounding boxes of a specific rendering group
  74533. * @param renderingGroupId defines the rendering group to render
  74534. */
  74535. render(renderingGroupId: number): void;
  74536. /**
  74537. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74538. * @param mesh Define the mesh to render the occlusion bounding box for
  74539. */
  74540. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74541. /**
  74542. * Dispose and release the resources attached to this renderer.
  74543. */
  74544. dispose(): void;
  74545. }
  74546. }
  74547. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74548. import { Nullable } from "babylonjs/types";
  74549. import { Scene } from "babylonjs/scene";
  74550. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74551. import { Camera } from "babylonjs/Cameras/camera";
  74552. import { ISceneComponent } from "babylonjs/sceneComponent";
  74553. module "babylonjs/scene" {
  74554. interface Scene {
  74555. /** @hidden (Backing field) */
  74556. _depthRenderer: {
  74557. [id: string]: DepthRenderer;
  74558. };
  74559. /**
  74560. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74561. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74562. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74563. * @returns the created depth renderer
  74564. */
  74565. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74566. /**
  74567. * Disables a depth renderer for a given camera
  74568. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74569. */
  74570. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74571. }
  74572. }
  74573. /**
  74574. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74575. * in several rendering techniques.
  74576. */
  74577. export class DepthRendererSceneComponent implements ISceneComponent {
  74578. /**
  74579. * The component name helpfull to identify the component in the list of scene components.
  74580. */
  74581. readonly name: string;
  74582. /**
  74583. * The scene the component belongs to.
  74584. */
  74585. scene: Scene;
  74586. /**
  74587. * Creates a new instance of the component for the given scene
  74588. * @param scene Defines the scene to register the component in
  74589. */
  74590. constructor(scene: Scene);
  74591. /**
  74592. * Registers the component in a given scene
  74593. */
  74594. register(): void;
  74595. /**
  74596. * Rebuilds the elements related to this component in case of
  74597. * context lost for instance.
  74598. */
  74599. rebuild(): void;
  74600. /**
  74601. * Disposes the component and the associated ressources
  74602. */
  74603. dispose(): void;
  74604. private _gatherRenderTargets;
  74605. private _gatherActiveCameraRenderTargets;
  74606. }
  74607. }
  74608. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  74609. /** @hidden */
  74610. export var fibonacci: {
  74611. name: string;
  74612. shader: string;
  74613. };
  74614. }
  74615. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  74616. /** @hidden */
  74617. export var diffusionProfile: {
  74618. name: string;
  74619. shader: string;
  74620. };
  74621. }
  74622. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  74623. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  74624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74625. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  74626. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  74627. /** @hidden */
  74628. export var subSurfaceScatteringPixelShader: {
  74629. name: string;
  74630. shader: string;
  74631. };
  74632. }
  74633. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  74634. import { Nullable } from "babylonjs/types";
  74635. import { Camera } from "babylonjs/Cameras/camera";
  74636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74637. import { Engine } from "babylonjs/Engines/engine";
  74638. import { Scene } from "babylonjs/scene";
  74639. import "babylonjs/Shaders/imageProcessing.fragment";
  74640. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  74641. import "babylonjs/Shaders/postprocess.vertex";
  74642. /**
  74643. * Sub surface scattering post process
  74644. */
  74645. export class SubSurfaceScatteringPostProcess extends PostProcess {
  74646. /** @hidden */
  74647. texelWidth: number;
  74648. /** @hidden */
  74649. texelHeight: number;
  74650. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74651. }
  74652. }
  74653. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  74654. import { Color3 } from "babylonjs/Maths/math.color";
  74655. /**
  74656. * Contains all parameters needed for the prepass to perform
  74657. * screen space subsurface scattering
  74658. */
  74659. export class SubSurfaceConfiguration {
  74660. private _ssDiffusionS;
  74661. private _ssFilterRadii;
  74662. private _ssDiffusionD;
  74663. /**
  74664. * Diffusion profile color for subsurface scattering
  74665. */
  74666. get ssDiffusionS(): number[];
  74667. /**
  74668. * Diffusion profile max color channel value for subsurface scattering
  74669. */
  74670. get ssDiffusionD(): number[];
  74671. /**
  74672. * Diffusion profile filter radius for subsurface scattering
  74673. */
  74674. get ssFilterRadii(): number[];
  74675. /**
  74676. * Diffusion profile colors for subsurface scattering
  74677. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  74678. * See ...
  74679. * Note that you can only store up to 5 of them
  74680. */
  74681. ssDiffusionProfileColors: Color3[];
  74682. /**
  74683. * Defines the ratio real world => scene units.
  74684. * Used for subsurface scattering
  74685. */
  74686. metersPerUnit: number;
  74687. /**
  74688. * Builds a subsurface configuration object
  74689. * @param scene The scene
  74690. */
  74691. constructor();
  74692. /**
  74693. * Adds a new diffusion profile.
  74694. * Useful for more realistic subsurface scattering on diverse materials.
  74695. * @param color The color of the diffusion profile. Should be the average color of the material.
  74696. * @return The index of the diffusion profile for the material subsurface configuration
  74697. */
  74698. addDiffusionProfile(color: Color3): number;
  74699. /**
  74700. * Deletes all diffusion profiles.
  74701. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  74702. */
  74703. clearAllDiffusionProfiles(): void;
  74704. /**
  74705. * Disposes this object
  74706. */
  74707. dispose(): void;
  74708. /**
  74709. * @hidden
  74710. * https://zero-radiance.github.io/post/sampling-diffusion/
  74711. *
  74712. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  74713. * ------------------------------------------------------------------------------------
  74714. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  74715. * PDF[r, phi, s] = r * R[r, phi, s]
  74716. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  74717. * ------------------------------------------------------------------------------------
  74718. * We importance sample the color channel with the widest scattering distance.
  74719. */
  74720. getDiffusionProfileParameters(color: Color3): number;
  74721. /**
  74722. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  74723. * 'u' is the random number (the value of the CDF): [0, 1).
  74724. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  74725. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  74726. */
  74727. private _sampleBurleyDiffusionProfile;
  74728. }
  74729. }
  74730. declare module "babylonjs/Rendering/prePassRenderer" {
  74731. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  74732. import { Scene } from "babylonjs/scene";
  74733. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74734. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  74735. import { Effect } from "babylonjs/Materials/effect";
  74736. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  74737. /**
  74738. * Renders a pre pass of the scene
  74739. * This means every mesh in the scene will be rendered to a render target texture
  74740. * And then this texture will be composited to the rendering canvas with post processes
  74741. * It is necessary for effects like subsurface scattering or deferred shading
  74742. */
  74743. export class PrePassRenderer {
  74744. /** @hidden */
  74745. static _SceneComponentInitialization: (scene: Scene) => void;
  74746. private _scene;
  74747. private _engine;
  74748. private _isDirty;
  74749. /**
  74750. * Number of textures in the multi render target texture where the scene is directly rendered
  74751. */
  74752. readonly mrtCount: number;
  74753. /**
  74754. * The render target where the scene is directly rendered
  74755. */
  74756. prePassRT: MultiRenderTarget;
  74757. private _mrtTypes;
  74758. private _multiRenderAttachments;
  74759. private _defaultAttachments;
  74760. private _clearAttachments;
  74761. private readonly _clearColor;
  74762. /**
  74763. * Image processing post process for composition
  74764. */
  74765. imageProcessingPostProcess: ImageProcessingPostProcess;
  74766. /**
  74767. * Post process for subsurface scattering
  74768. */
  74769. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  74770. /**
  74771. * Configuration for sub surface scattering post process
  74772. */
  74773. subSurfaceConfiguration: SubSurfaceConfiguration;
  74774. private _enabled;
  74775. /**
  74776. * Indicates if the prepass is enabled
  74777. */
  74778. get enabled(): boolean;
  74779. /**
  74780. * How many samples are used for MSAA of the scene render target
  74781. */
  74782. get samples(): number;
  74783. set samples(n: number);
  74784. /**
  74785. * Instanciates a prepass renderer
  74786. * @param scene The scene
  74787. */
  74788. constructor(scene: Scene);
  74789. private _initializeAttachments;
  74790. private _createEffects;
  74791. /**
  74792. * Indicates if rendering a prepass is supported
  74793. */
  74794. get isSupported(): boolean;
  74795. /**
  74796. * Sets the proper output textures to draw in the engine.
  74797. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  74798. */
  74799. bindAttachmentsForEffect(effect: Effect): void;
  74800. /**
  74801. * @hidden
  74802. */
  74803. _beforeCameraDraw(): void;
  74804. /**
  74805. * @hidden
  74806. */
  74807. _afterCameraDraw(): void;
  74808. private _checkRTSize;
  74809. private _bindFrameBuffer;
  74810. /**
  74811. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  74812. */
  74813. clear(): void;
  74814. private _setState;
  74815. private _enable;
  74816. private _disable;
  74817. /**
  74818. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  74819. */
  74820. markAsDirty(): void;
  74821. private _update;
  74822. /**
  74823. * Disposes the prepass renderer.
  74824. */
  74825. dispose(): void;
  74826. }
  74827. }
  74828. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74829. import { Nullable } from "babylonjs/types";
  74830. import { Scene } from "babylonjs/scene";
  74831. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74832. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74833. import { AbstractScene } from "babylonjs/abstractScene";
  74834. module "babylonjs/abstractScene" {
  74835. interface AbstractScene {
  74836. /** @hidden (Backing field) */
  74837. _prePassRenderer: Nullable<PrePassRenderer>;
  74838. /**
  74839. * Gets or Sets the current prepass renderer associated to the scene.
  74840. */
  74841. prePassRenderer: Nullable<PrePassRenderer>;
  74842. /**
  74843. * Enables the prepass and associates it with the scene
  74844. * @returns the PrePassRenderer
  74845. */
  74846. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74847. /**
  74848. * Disables the prepass associated with the scene
  74849. */
  74850. disablePrePassRenderer(): void;
  74851. }
  74852. }
  74853. /**
  74854. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74855. * in several rendering techniques.
  74856. */
  74857. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74858. /**
  74859. * The component name helpful to identify the component in the list of scene components.
  74860. */
  74861. readonly name: string;
  74862. /**
  74863. * The scene the component belongs to.
  74864. */
  74865. scene: Scene;
  74866. /**
  74867. * Creates a new instance of the component for the given scene
  74868. * @param scene Defines the scene to register the component in
  74869. */
  74870. constructor(scene: Scene);
  74871. /**
  74872. * Registers the component in a given scene
  74873. */
  74874. register(): void;
  74875. private _beforeCameraDraw;
  74876. private _afterCameraDraw;
  74877. private _beforeClearStage;
  74878. /**
  74879. * Serializes the component data to the specified json object
  74880. * @param serializationObject The object to serialize to
  74881. */
  74882. serialize(serializationObject: any): void;
  74883. /**
  74884. * Adds all the elements from the container to the scene
  74885. * @param container the container holding the elements
  74886. */
  74887. addFromContainer(container: AbstractScene): void;
  74888. /**
  74889. * Removes all the elements in the container from the scene
  74890. * @param container contains the elements to remove
  74891. * @param dispose if the removed element should be disposed (default: false)
  74892. */
  74893. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74894. /**
  74895. * Rebuilds the elements related to this component in case of
  74896. * context lost for instance.
  74897. */
  74898. rebuild(): void;
  74899. /**
  74900. * Disposes the component and the associated ressources
  74901. */
  74902. dispose(): void;
  74903. }
  74904. }
  74905. declare module "babylonjs/Shaders/outline.fragment" {
  74906. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74907. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74908. /** @hidden */
  74909. export var outlinePixelShader: {
  74910. name: string;
  74911. shader: string;
  74912. };
  74913. }
  74914. declare module "babylonjs/Shaders/outline.vertex" {
  74915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74921. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74922. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74923. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74924. /** @hidden */
  74925. export var outlineVertexShader: {
  74926. name: string;
  74927. shader: string;
  74928. };
  74929. }
  74930. declare module "babylonjs/Rendering/outlineRenderer" {
  74931. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74932. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74933. import { Scene } from "babylonjs/scene";
  74934. import { ISceneComponent } from "babylonjs/sceneComponent";
  74935. import "babylonjs/Shaders/outline.fragment";
  74936. import "babylonjs/Shaders/outline.vertex";
  74937. module "babylonjs/scene" {
  74938. interface Scene {
  74939. /** @hidden */
  74940. _outlineRenderer: OutlineRenderer;
  74941. /**
  74942. * Gets the outline renderer associated with the scene
  74943. * @returns a OutlineRenderer
  74944. */
  74945. getOutlineRenderer(): OutlineRenderer;
  74946. }
  74947. }
  74948. module "babylonjs/Meshes/abstractMesh" {
  74949. interface AbstractMesh {
  74950. /** @hidden (Backing field) */
  74951. _renderOutline: boolean;
  74952. /**
  74953. * Gets or sets a boolean indicating if the outline must be rendered as well
  74954. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74955. */
  74956. renderOutline: boolean;
  74957. /** @hidden (Backing field) */
  74958. _renderOverlay: boolean;
  74959. /**
  74960. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74961. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74962. */
  74963. renderOverlay: boolean;
  74964. }
  74965. }
  74966. /**
  74967. * This class is responsible to draw bothe outline/overlay of meshes.
  74968. * It should not be used directly but through the available method on mesh.
  74969. */
  74970. export class OutlineRenderer implements ISceneComponent {
  74971. /**
  74972. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74973. */
  74974. private static _StencilReference;
  74975. /**
  74976. * The name of the component. Each component must have a unique name.
  74977. */
  74978. name: string;
  74979. /**
  74980. * The scene the component belongs to.
  74981. */
  74982. scene: Scene;
  74983. /**
  74984. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74985. */
  74986. zOffset: number;
  74987. private _engine;
  74988. private _effect;
  74989. private _cachedDefines;
  74990. private _savedDepthWrite;
  74991. /**
  74992. * Instantiates a new outline renderer. (There could be only one per scene).
  74993. * @param scene Defines the scene it belongs to
  74994. */
  74995. constructor(scene: Scene);
  74996. /**
  74997. * Register the component to one instance of a scene.
  74998. */
  74999. register(): void;
  75000. /**
  75001. * Rebuilds the elements related to this component in case of
  75002. * context lost for instance.
  75003. */
  75004. rebuild(): void;
  75005. /**
  75006. * Disposes the component and the associated ressources.
  75007. */
  75008. dispose(): void;
  75009. /**
  75010. * Renders the outline in the canvas.
  75011. * @param subMesh Defines the sumesh to render
  75012. * @param batch Defines the batch of meshes in case of instances
  75013. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75014. */
  75015. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75016. /**
  75017. * Returns whether or not the outline renderer is ready for a given submesh.
  75018. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75019. * @param subMesh Defines the submesh to check readyness for
  75020. * @param useInstances Defines wheter wee are trying to render instances or not
  75021. * @returns true if ready otherwise false
  75022. */
  75023. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75024. private _beforeRenderingMesh;
  75025. private _afterRenderingMesh;
  75026. }
  75027. }
  75028. declare module "babylonjs/Rendering/index" {
  75029. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75030. export * from "babylonjs/Rendering/depthRenderer";
  75031. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75032. export * from "babylonjs/Rendering/edgesRenderer";
  75033. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75034. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75035. export * from "babylonjs/Rendering/prePassRenderer";
  75036. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75037. export * from "babylonjs/Rendering/outlineRenderer";
  75038. export * from "babylonjs/Rendering/renderingGroup";
  75039. export * from "babylonjs/Rendering/renderingManager";
  75040. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75041. }
  75042. declare module "babylonjs/Sprites/ISprites" {
  75043. /**
  75044. * Defines the basic options interface of a Sprite Frame Source Size.
  75045. */
  75046. export interface ISpriteJSONSpriteSourceSize {
  75047. /**
  75048. * number of the original width of the Frame
  75049. */
  75050. w: number;
  75051. /**
  75052. * number of the original height of the Frame
  75053. */
  75054. h: number;
  75055. }
  75056. /**
  75057. * Defines the basic options interface of a Sprite Frame Data.
  75058. */
  75059. export interface ISpriteJSONSpriteFrameData {
  75060. /**
  75061. * number of the x offset of the Frame
  75062. */
  75063. x: number;
  75064. /**
  75065. * number of the y offset of the Frame
  75066. */
  75067. y: number;
  75068. /**
  75069. * number of the width of the Frame
  75070. */
  75071. w: number;
  75072. /**
  75073. * number of the height of the Frame
  75074. */
  75075. h: number;
  75076. }
  75077. /**
  75078. * Defines the basic options interface of a JSON Sprite.
  75079. */
  75080. export interface ISpriteJSONSprite {
  75081. /**
  75082. * string name of the Frame
  75083. */
  75084. filename: string;
  75085. /**
  75086. * ISpriteJSONSpriteFrame basic object of the frame data
  75087. */
  75088. frame: ISpriteJSONSpriteFrameData;
  75089. /**
  75090. * boolean to flag is the frame was rotated.
  75091. */
  75092. rotated: boolean;
  75093. /**
  75094. * boolean to flag is the frame was trimmed.
  75095. */
  75096. trimmed: boolean;
  75097. /**
  75098. * ISpriteJSONSpriteFrame basic object of the source data
  75099. */
  75100. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75101. /**
  75102. * ISpriteJSONSpriteFrame basic object of the source data
  75103. */
  75104. sourceSize: ISpriteJSONSpriteSourceSize;
  75105. }
  75106. /**
  75107. * Defines the basic options interface of a JSON atlas.
  75108. */
  75109. export interface ISpriteJSONAtlas {
  75110. /**
  75111. * Array of objects that contain the frame data.
  75112. */
  75113. frames: Array<ISpriteJSONSprite>;
  75114. /**
  75115. * object basic object containing the sprite meta data.
  75116. */
  75117. meta?: object;
  75118. }
  75119. }
  75120. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75121. /** @hidden */
  75122. export var spriteMapPixelShader: {
  75123. name: string;
  75124. shader: string;
  75125. };
  75126. }
  75127. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75128. /** @hidden */
  75129. export var spriteMapVertexShader: {
  75130. name: string;
  75131. shader: string;
  75132. };
  75133. }
  75134. declare module "babylonjs/Sprites/spriteMap" {
  75135. import { IDisposable, Scene } from "babylonjs/scene";
  75136. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75137. import { Texture } from "babylonjs/Materials/Textures/texture";
  75138. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75139. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75140. import "babylonjs/Meshes/Builders/planeBuilder";
  75141. import "babylonjs/Shaders/spriteMap.fragment";
  75142. import "babylonjs/Shaders/spriteMap.vertex";
  75143. /**
  75144. * Defines the basic options interface of a SpriteMap
  75145. */
  75146. export interface ISpriteMapOptions {
  75147. /**
  75148. * Vector2 of the number of cells in the grid.
  75149. */
  75150. stageSize?: Vector2;
  75151. /**
  75152. * Vector2 of the size of the output plane in World Units.
  75153. */
  75154. outputSize?: Vector2;
  75155. /**
  75156. * Vector3 of the position of the output plane in World Units.
  75157. */
  75158. outputPosition?: Vector3;
  75159. /**
  75160. * Vector3 of the rotation of the output plane.
  75161. */
  75162. outputRotation?: Vector3;
  75163. /**
  75164. * number of layers that the system will reserve in resources.
  75165. */
  75166. layerCount?: number;
  75167. /**
  75168. * number of max animation frames a single cell will reserve in resources.
  75169. */
  75170. maxAnimationFrames?: number;
  75171. /**
  75172. * number cell index of the base tile when the system compiles.
  75173. */
  75174. baseTile?: number;
  75175. /**
  75176. * boolean flip the sprite after its been repositioned by the framing data.
  75177. */
  75178. flipU?: boolean;
  75179. /**
  75180. * Vector3 scalar of the global RGB values of the SpriteMap.
  75181. */
  75182. colorMultiply?: Vector3;
  75183. }
  75184. /**
  75185. * Defines the IDisposable interface in order to be cleanable from resources.
  75186. */
  75187. export interface ISpriteMap extends IDisposable {
  75188. /**
  75189. * String name of the SpriteMap.
  75190. */
  75191. name: string;
  75192. /**
  75193. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75194. */
  75195. atlasJSON: ISpriteJSONAtlas;
  75196. /**
  75197. * Texture of the SpriteMap.
  75198. */
  75199. spriteSheet: Texture;
  75200. /**
  75201. * The parameters to initialize the SpriteMap with.
  75202. */
  75203. options: ISpriteMapOptions;
  75204. }
  75205. /**
  75206. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75207. */
  75208. export class SpriteMap implements ISpriteMap {
  75209. /** The Name of the spriteMap */
  75210. name: string;
  75211. /** The JSON file with the frame and meta data */
  75212. atlasJSON: ISpriteJSONAtlas;
  75213. /** The systems Sprite Sheet Texture */
  75214. spriteSheet: Texture;
  75215. /** Arguments passed with the Constructor */
  75216. options: ISpriteMapOptions;
  75217. /** Public Sprite Storage array, parsed from atlasJSON */
  75218. sprites: Array<ISpriteJSONSprite>;
  75219. /** Returns the Number of Sprites in the System */
  75220. get spriteCount(): number;
  75221. /** Returns the Position of Output Plane*/
  75222. get position(): Vector3;
  75223. /** Returns the Position of Output Plane*/
  75224. set position(v: Vector3);
  75225. /** Returns the Rotation of Output Plane*/
  75226. get rotation(): Vector3;
  75227. /** Returns the Rotation of Output Plane*/
  75228. set rotation(v: Vector3);
  75229. /** Sets the AnimationMap*/
  75230. get animationMap(): RawTexture;
  75231. /** Sets the AnimationMap*/
  75232. set animationMap(v: RawTexture);
  75233. /** Scene that the SpriteMap was created in */
  75234. private _scene;
  75235. /** Texture Buffer of Float32 that holds tile frame data*/
  75236. private _frameMap;
  75237. /** Texture Buffers of Float32 that holds tileMap data*/
  75238. private _tileMaps;
  75239. /** Texture Buffer of Float32 that holds Animation Data*/
  75240. private _animationMap;
  75241. /** Custom ShaderMaterial Central to the System*/
  75242. private _material;
  75243. /** Custom ShaderMaterial Central to the System*/
  75244. private _output;
  75245. /** Systems Time Ticker*/
  75246. private _time;
  75247. /**
  75248. * Creates a new SpriteMap
  75249. * @param name defines the SpriteMaps Name
  75250. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75251. * @param spriteSheet is the Texture that the Sprites are on.
  75252. * @param options a basic deployment configuration
  75253. * @param scene The Scene that the map is deployed on
  75254. */
  75255. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75256. /**
  75257. * Returns tileID location
  75258. * @returns Vector2 the cell position ID
  75259. */
  75260. getTileID(): Vector2;
  75261. /**
  75262. * Gets the UV location of the mouse over the SpriteMap.
  75263. * @returns Vector2 the UV position of the mouse interaction
  75264. */
  75265. getMousePosition(): Vector2;
  75266. /**
  75267. * Creates the "frame" texture Buffer
  75268. * -------------------------------------
  75269. * Structure of frames
  75270. * "filename": "Falling-Water-2.png",
  75271. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75272. * "rotated": true,
  75273. * "trimmed": true,
  75274. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75275. * "sourceSize": {"w":32,"h":32}
  75276. * @returns RawTexture of the frameMap
  75277. */
  75278. private _createFrameBuffer;
  75279. /**
  75280. * Creates the tileMap texture Buffer
  75281. * @param buffer normally and array of numbers, or a false to generate from scratch
  75282. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75283. * @returns RawTexture of the tileMap
  75284. */
  75285. private _createTileBuffer;
  75286. /**
  75287. * Modifies the data of the tileMaps
  75288. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75289. * @param pos is the iVector2 Coordinates of the Tile
  75290. * @param tile The SpriteIndex of the new Tile
  75291. */
  75292. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75293. /**
  75294. * Creates the animationMap texture Buffer
  75295. * @param buffer normally and array of numbers, or a false to generate from scratch
  75296. * @returns RawTexture of the animationMap
  75297. */
  75298. private _createTileAnimationBuffer;
  75299. /**
  75300. * Modifies the data of the animationMap
  75301. * @param cellID is the Index of the Sprite
  75302. * @param _frame is the target Animation frame
  75303. * @param toCell is the Target Index of the next frame of the animation
  75304. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75305. * @param speed is a global scalar of the time variable on the map.
  75306. */
  75307. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75308. /**
  75309. * Exports the .tilemaps file
  75310. */
  75311. saveTileMaps(): void;
  75312. /**
  75313. * Imports the .tilemaps file
  75314. * @param url of the .tilemaps file
  75315. */
  75316. loadTileMaps(url: string): void;
  75317. /**
  75318. * Release associated resources
  75319. */
  75320. dispose(): void;
  75321. }
  75322. }
  75323. declare module "babylonjs/Sprites/spritePackedManager" {
  75324. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75325. import { Scene } from "babylonjs/scene";
  75326. /**
  75327. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75328. * @see https://doc.babylonjs.com/babylon101/sprites
  75329. */
  75330. export class SpritePackedManager extends SpriteManager {
  75331. /** defines the packed manager's name */
  75332. name: string;
  75333. /**
  75334. * Creates a new sprite manager from a packed sprite sheet
  75335. * @param name defines the manager's name
  75336. * @param imgUrl defines the sprite sheet url
  75337. * @param capacity defines the maximum allowed number of sprites
  75338. * @param scene defines the hosting scene
  75339. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75340. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75341. * @param samplingMode defines the smapling mode to use with spritesheet
  75342. * @param fromPacked set to true; do not alter
  75343. */
  75344. constructor(
  75345. /** defines the packed manager's name */
  75346. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75347. }
  75348. }
  75349. declare module "babylonjs/Sprites/index" {
  75350. export * from "babylonjs/Sprites/sprite";
  75351. export * from "babylonjs/Sprites/ISprites";
  75352. export * from "babylonjs/Sprites/spriteManager";
  75353. export * from "babylonjs/Sprites/spriteMap";
  75354. export * from "babylonjs/Sprites/spritePackedManager";
  75355. export * from "babylonjs/Sprites/spriteSceneComponent";
  75356. }
  75357. declare module "babylonjs/States/index" {
  75358. export * from "babylonjs/States/alphaCullingState";
  75359. export * from "babylonjs/States/depthCullingState";
  75360. export * from "babylonjs/States/stencilState";
  75361. }
  75362. declare module "babylonjs/Misc/assetsManager" {
  75363. import { Scene } from "babylonjs/scene";
  75364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75365. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75366. import { Skeleton } from "babylonjs/Bones/skeleton";
  75367. import { Observable } from "babylonjs/Misc/observable";
  75368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75369. import { Texture } from "babylonjs/Materials/Textures/texture";
  75370. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75371. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75372. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75373. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75374. /**
  75375. * Defines the list of states available for a task inside a AssetsManager
  75376. */
  75377. export enum AssetTaskState {
  75378. /**
  75379. * Initialization
  75380. */
  75381. INIT = 0,
  75382. /**
  75383. * Running
  75384. */
  75385. RUNNING = 1,
  75386. /**
  75387. * Done
  75388. */
  75389. DONE = 2,
  75390. /**
  75391. * Error
  75392. */
  75393. ERROR = 3
  75394. }
  75395. /**
  75396. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75397. */
  75398. export abstract class AbstractAssetTask {
  75399. /**
  75400. * Task name
  75401. */ name: string;
  75402. /**
  75403. * Callback called when the task is successful
  75404. */
  75405. onSuccess: (task: any) => void;
  75406. /**
  75407. * Callback called when the task is not successful
  75408. */
  75409. onError: (task: any, message?: string, exception?: any) => void;
  75410. /**
  75411. * Creates a new AssetsManager
  75412. * @param name defines the name of the task
  75413. */
  75414. constructor(
  75415. /**
  75416. * Task name
  75417. */ name: string);
  75418. private _isCompleted;
  75419. private _taskState;
  75420. private _errorObject;
  75421. /**
  75422. * Get if the task is completed
  75423. */
  75424. get isCompleted(): boolean;
  75425. /**
  75426. * Gets the current state of the task
  75427. */
  75428. get taskState(): AssetTaskState;
  75429. /**
  75430. * Gets the current error object (if task is in error)
  75431. */
  75432. get errorObject(): {
  75433. message?: string;
  75434. exception?: any;
  75435. };
  75436. /**
  75437. * Internal only
  75438. * @hidden
  75439. */
  75440. _setErrorObject(message?: string, exception?: any): void;
  75441. /**
  75442. * Execute the current task
  75443. * @param scene defines the scene where you want your assets to be loaded
  75444. * @param onSuccess is a callback called when the task is successfully executed
  75445. * @param onError is a callback called if an error occurs
  75446. */
  75447. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75448. /**
  75449. * Execute the current task
  75450. * @param scene defines the scene where you want your assets to be loaded
  75451. * @param onSuccess is a callback called when the task is successfully executed
  75452. * @param onError is a callback called if an error occurs
  75453. */
  75454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75455. /**
  75456. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75457. * This can be used with failed tasks that have the reason for failure fixed.
  75458. */
  75459. reset(): void;
  75460. private onErrorCallback;
  75461. private onDoneCallback;
  75462. }
  75463. /**
  75464. * Define the interface used by progress events raised during assets loading
  75465. */
  75466. export interface IAssetsProgressEvent {
  75467. /**
  75468. * Defines the number of remaining tasks to process
  75469. */
  75470. remainingCount: number;
  75471. /**
  75472. * Defines the total number of tasks
  75473. */
  75474. totalCount: number;
  75475. /**
  75476. * Defines the task that was just processed
  75477. */
  75478. task: AbstractAssetTask;
  75479. }
  75480. /**
  75481. * Class used to share progress information about assets loading
  75482. */
  75483. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75484. /**
  75485. * Defines the number of remaining tasks to process
  75486. */
  75487. remainingCount: number;
  75488. /**
  75489. * Defines the total number of tasks
  75490. */
  75491. totalCount: number;
  75492. /**
  75493. * Defines the task that was just processed
  75494. */
  75495. task: AbstractAssetTask;
  75496. /**
  75497. * Creates a AssetsProgressEvent
  75498. * @param remainingCount defines the number of remaining tasks to process
  75499. * @param totalCount defines the total number of tasks
  75500. * @param task defines the task that was just processed
  75501. */
  75502. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75503. }
  75504. /**
  75505. * Define a task used by AssetsManager to load meshes
  75506. */
  75507. export class MeshAssetTask extends AbstractAssetTask {
  75508. /**
  75509. * Defines the name of the task
  75510. */
  75511. name: string;
  75512. /**
  75513. * Defines the list of mesh's names you want to load
  75514. */
  75515. meshesNames: any;
  75516. /**
  75517. * Defines the root url to use as a base to load your meshes and associated resources
  75518. */
  75519. rootUrl: string;
  75520. /**
  75521. * Defines the filename or File of the scene to load from
  75522. */
  75523. sceneFilename: string | File;
  75524. /**
  75525. * Gets the list of loaded meshes
  75526. */
  75527. loadedMeshes: Array<AbstractMesh>;
  75528. /**
  75529. * Gets the list of loaded particle systems
  75530. */
  75531. loadedParticleSystems: Array<IParticleSystem>;
  75532. /**
  75533. * Gets the list of loaded skeletons
  75534. */
  75535. loadedSkeletons: Array<Skeleton>;
  75536. /**
  75537. * Gets the list of loaded animation groups
  75538. */
  75539. loadedAnimationGroups: Array<AnimationGroup>;
  75540. /**
  75541. * Callback called when the task is successful
  75542. */
  75543. onSuccess: (task: MeshAssetTask) => void;
  75544. /**
  75545. * Callback called when the task is successful
  75546. */
  75547. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75548. /**
  75549. * Creates a new MeshAssetTask
  75550. * @param name defines the name of the task
  75551. * @param meshesNames defines the list of mesh's names you want to load
  75552. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75553. * @param sceneFilename defines the filename or File of the scene to load from
  75554. */
  75555. constructor(
  75556. /**
  75557. * Defines the name of the task
  75558. */
  75559. name: string,
  75560. /**
  75561. * Defines the list of mesh's names you want to load
  75562. */
  75563. meshesNames: any,
  75564. /**
  75565. * Defines the root url to use as a base to load your meshes and associated resources
  75566. */
  75567. rootUrl: string,
  75568. /**
  75569. * Defines the filename or File of the scene to load from
  75570. */
  75571. sceneFilename: string | File);
  75572. /**
  75573. * Execute the current task
  75574. * @param scene defines the scene where you want your assets to be loaded
  75575. * @param onSuccess is a callback called when the task is successfully executed
  75576. * @param onError is a callback called if an error occurs
  75577. */
  75578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75579. }
  75580. /**
  75581. * Define a task used by AssetsManager to load text content
  75582. */
  75583. export class TextFileAssetTask extends AbstractAssetTask {
  75584. /**
  75585. * Defines the name of the task
  75586. */
  75587. name: string;
  75588. /**
  75589. * Defines the location of the file to load
  75590. */
  75591. url: string;
  75592. /**
  75593. * Gets the loaded text string
  75594. */
  75595. text: string;
  75596. /**
  75597. * Callback called when the task is successful
  75598. */
  75599. onSuccess: (task: TextFileAssetTask) => void;
  75600. /**
  75601. * Callback called when the task is successful
  75602. */
  75603. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75604. /**
  75605. * Creates a new TextFileAssetTask object
  75606. * @param name defines the name of the task
  75607. * @param url defines the location of the file to load
  75608. */
  75609. constructor(
  75610. /**
  75611. * Defines the name of the task
  75612. */
  75613. name: string,
  75614. /**
  75615. * Defines the location of the file to load
  75616. */
  75617. url: string);
  75618. /**
  75619. * Execute the current task
  75620. * @param scene defines the scene where you want your assets to be loaded
  75621. * @param onSuccess is a callback called when the task is successfully executed
  75622. * @param onError is a callback called if an error occurs
  75623. */
  75624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75625. }
  75626. /**
  75627. * Define a task used by AssetsManager to load binary data
  75628. */
  75629. export class BinaryFileAssetTask extends AbstractAssetTask {
  75630. /**
  75631. * Defines the name of the task
  75632. */
  75633. name: string;
  75634. /**
  75635. * Defines the location of the file to load
  75636. */
  75637. url: string;
  75638. /**
  75639. * Gets the lodaded data (as an array buffer)
  75640. */
  75641. data: ArrayBuffer;
  75642. /**
  75643. * Callback called when the task is successful
  75644. */
  75645. onSuccess: (task: BinaryFileAssetTask) => void;
  75646. /**
  75647. * Callback called when the task is successful
  75648. */
  75649. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75650. /**
  75651. * Creates a new BinaryFileAssetTask object
  75652. * @param name defines the name of the new task
  75653. * @param url defines the location of the file to load
  75654. */
  75655. constructor(
  75656. /**
  75657. * Defines the name of the task
  75658. */
  75659. name: string,
  75660. /**
  75661. * Defines the location of the file to load
  75662. */
  75663. url: string);
  75664. /**
  75665. * Execute the current task
  75666. * @param scene defines the scene where you want your assets to be loaded
  75667. * @param onSuccess is a callback called when the task is successfully executed
  75668. * @param onError is a callback called if an error occurs
  75669. */
  75670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75671. }
  75672. /**
  75673. * Define a task used by AssetsManager to load images
  75674. */
  75675. export class ImageAssetTask extends AbstractAssetTask {
  75676. /**
  75677. * Defines the name of the task
  75678. */
  75679. name: string;
  75680. /**
  75681. * Defines the location of the image to load
  75682. */
  75683. url: string;
  75684. /**
  75685. * Gets the loaded images
  75686. */
  75687. image: HTMLImageElement;
  75688. /**
  75689. * Callback called when the task is successful
  75690. */
  75691. onSuccess: (task: ImageAssetTask) => void;
  75692. /**
  75693. * Callback called when the task is successful
  75694. */
  75695. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75696. /**
  75697. * Creates a new ImageAssetTask
  75698. * @param name defines the name of the task
  75699. * @param url defines the location of the image to load
  75700. */
  75701. constructor(
  75702. /**
  75703. * Defines the name of the task
  75704. */
  75705. name: string,
  75706. /**
  75707. * Defines the location of the image to load
  75708. */
  75709. url: string);
  75710. /**
  75711. * Execute the current task
  75712. * @param scene defines the scene where you want your assets to be loaded
  75713. * @param onSuccess is a callback called when the task is successfully executed
  75714. * @param onError is a callback called if an error occurs
  75715. */
  75716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75717. }
  75718. /**
  75719. * Defines the interface used by texture loading tasks
  75720. */
  75721. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75722. /**
  75723. * Gets the loaded texture
  75724. */
  75725. texture: TEX;
  75726. }
  75727. /**
  75728. * Define a task used by AssetsManager to load 2D textures
  75729. */
  75730. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75731. /**
  75732. * Defines the name of the task
  75733. */
  75734. name: string;
  75735. /**
  75736. * Defines the location of the file to load
  75737. */
  75738. url: string;
  75739. /**
  75740. * Defines if mipmap should not be generated (default is false)
  75741. */
  75742. noMipmap?: boolean | undefined;
  75743. /**
  75744. * Defines if texture must be inverted on Y axis (default is true)
  75745. */
  75746. invertY: boolean;
  75747. /**
  75748. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75749. */
  75750. samplingMode: number;
  75751. /**
  75752. * Gets the loaded texture
  75753. */
  75754. texture: Texture;
  75755. /**
  75756. * Callback called when the task is successful
  75757. */
  75758. onSuccess: (task: TextureAssetTask) => void;
  75759. /**
  75760. * Callback called when the task is successful
  75761. */
  75762. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75763. /**
  75764. * Creates a new TextureAssetTask object
  75765. * @param name defines the name of the task
  75766. * @param url defines the location of the file to load
  75767. * @param noMipmap defines if mipmap should not be generated (default is false)
  75768. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75769. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75770. */
  75771. constructor(
  75772. /**
  75773. * Defines the name of the task
  75774. */
  75775. name: string,
  75776. /**
  75777. * Defines the location of the file to load
  75778. */
  75779. url: string,
  75780. /**
  75781. * Defines if mipmap should not be generated (default is false)
  75782. */
  75783. noMipmap?: boolean | undefined,
  75784. /**
  75785. * Defines if texture must be inverted on Y axis (default is true)
  75786. */
  75787. invertY?: boolean,
  75788. /**
  75789. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75790. */
  75791. samplingMode?: number);
  75792. /**
  75793. * Execute the current task
  75794. * @param scene defines the scene where you want your assets to be loaded
  75795. * @param onSuccess is a callback called when the task is successfully executed
  75796. * @param onError is a callback called if an error occurs
  75797. */
  75798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75799. }
  75800. /**
  75801. * Define a task used by AssetsManager to load cube textures
  75802. */
  75803. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75804. /**
  75805. * Defines the name of the task
  75806. */
  75807. name: string;
  75808. /**
  75809. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75810. */
  75811. url: string;
  75812. /**
  75813. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75814. */
  75815. extensions?: string[] | undefined;
  75816. /**
  75817. * Defines if mipmaps should not be generated (default is false)
  75818. */
  75819. noMipmap?: boolean | undefined;
  75820. /**
  75821. * Defines the explicit list of files (undefined by default)
  75822. */
  75823. files?: string[] | undefined;
  75824. /**
  75825. * Gets the loaded texture
  75826. */
  75827. texture: CubeTexture;
  75828. /**
  75829. * Callback called when the task is successful
  75830. */
  75831. onSuccess: (task: CubeTextureAssetTask) => void;
  75832. /**
  75833. * Callback called when the task is successful
  75834. */
  75835. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75836. /**
  75837. * Creates a new CubeTextureAssetTask
  75838. * @param name defines the name of the task
  75839. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75840. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75841. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75842. * @param files defines the explicit list of files (undefined by default)
  75843. */
  75844. constructor(
  75845. /**
  75846. * Defines the name of the task
  75847. */
  75848. name: string,
  75849. /**
  75850. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75851. */
  75852. url: string,
  75853. /**
  75854. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75855. */
  75856. extensions?: string[] | undefined,
  75857. /**
  75858. * Defines if mipmaps should not be generated (default is false)
  75859. */
  75860. noMipmap?: boolean | undefined,
  75861. /**
  75862. * Defines the explicit list of files (undefined by default)
  75863. */
  75864. files?: string[] | undefined);
  75865. /**
  75866. * Execute the current task
  75867. * @param scene defines the scene where you want your assets to be loaded
  75868. * @param onSuccess is a callback called when the task is successfully executed
  75869. * @param onError is a callback called if an error occurs
  75870. */
  75871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75872. }
  75873. /**
  75874. * Define a task used by AssetsManager to load HDR cube textures
  75875. */
  75876. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75877. /**
  75878. * Defines the name of the task
  75879. */
  75880. name: string;
  75881. /**
  75882. * Defines the location of the file to load
  75883. */
  75884. url: string;
  75885. /**
  75886. * Defines the desired size (the more it increases the longer the generation will be)
  75887. */
  75888. size: number;
  75889. /**
  75890. * Defines if mipmaps should not be generated (default is false)
  75891. */
  75892. noMipmap: boolean;
  75893. /**
  75894. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75895. */
  75896. generateHarmonics: boolean;
  75897. /**
  75898. * 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)
  75899. */
  75900. gammaSpace: boolean;
  75901. /**
  75902. * Internal Use Only
  75903. */
  75904. reserved: boolean;
  75905. /**
  75906. * Gets the loaded texture
  75907. */
  75908. texture: HDRCubeTexture;
  75909. /**
  75910. * Callback called when the task is successful
  75911. */
  75912. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75913. /**
  75914. * Callback called when the task is successful
  75915. */
  75916. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75917. /**
  75918. * Creates a new HDRCubeTextureAssetTask object
  75919. * @param name defines the name of the task
  75920. * @param url defines the location of the file to load
  75921. * @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.
  75922. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75923. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75924. * @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)
  75925. * @param reserved Internal use only
  75926. */
  75927. constructor(
  75928. /**
  75929. * Defines the name of the task
  75930. */
  75931. name: string,
  75932. /**
  75933. * Defines the location of the file to load
  75934. */
  75935. url: string,
  75936. /**
  75937. * Defines the desired size (the more it increases the longer the generation will be)
  75938. */
  75939. size: number,
  75940. /**
  75941. * Defines if mipmaps should not be generated (default is false)
  75942. */
  75943. noMipmap?: boolean,
  75944. /**
  75945. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75946. */
  75947. generateHarmonics?: boolean,
  75948. /**
  75949. * 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)
  75950. */
  75951. gammaSpace?: boolean,
  75952. /**
  75953. * Internal Use Only
  75954. */
  75955. reserved?: boolean);
  75956. /**
  75957. * Execute the current task
  75958. * @param scene defines the scene where you want your assets to be loaded
  75959. * @param onSuccess is a callback called when the task is successfully executed
  75960. * @param onError is a callback called if an error occurs
  75961. */
  75962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75963. }
  75964. /**
  75965. * Define a task used by AssetsManager to load Equirectangular cube textures
  75966. */
  75967. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75968. /**
  75969. * Defines the name of the task
  75970. */
  75971. name: string;
  75972. /**
  75973. * Defines the location of the file to load
  75974. */
  75975. url: string;
  75976. /**
  75977. * Defines the desired size (the more it increases the longer the generation will be)
  75978. */
  75979. size: number;
  75980. /**
  75981. * Defines if mipmaps should not be generated (default is false)
  75982. */
  75983. noMipmap: boolean;
  75984. /**
  75985. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75986. * but the standard material would require them in Gamma space) (default is true)
  75987. */
  75988. gammaSpace: boolean;
  75989. /**
  75990. * Gets the loaded texture
  75991. */
  75992. texture: EquiRectangularCubeTexture;
  75993. /**
  75994. * Callback called when the task is successful
  75995. */
  75996. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75997. /**
  75998. * Callback called when the task is successful
  75999. */
  76000. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76001. /**
  76002. * Creates a new EquiRectangularCubeTextureAssetTask object
  76003. * @param name defines the name of the task
  76004. * @param url defines the location of the file to load
  76005. * @param size defines the desired size (the more it increases the longer the generation will be)
  76006. * If the size is omitted this implies you are using a preprocessed cubemap.
  76007. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76008. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76009. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76010. * (default is true)
  76011. */
  76012. constructor(
  76013. /**
  76014. * Defines the name of the task
  76015. */
  76016. name: string,
  76017. /**
  76018. * Defines the location of the file to load
  76019. */
  76020. url: string,
  76021. /**
  76022. * Defines the desired size (the more it increases the longer the generation will be)
  76023. */
  76024. size: number,
  76025. /**
  76026. * Defines if mipmaps should not be generated (default is false)
  76027. */
  76028. noMipmap?: boolean,
  76029. /**
  76030. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76031. * but the standard material would require them in Gamma space) (default is true)
  76032. */
  76033. gammaSpace?: boolean);
  76034. /**
  76035. * Execute the current task
  76036. * @param scene defines the scene where you want your assets to be loaded
  76037. * @param onSuccess is a callback called when the task is successfully executed
  76038. * @param onError is a callback called if an error occurs
  76039. */
  76040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76041. }
  76042. /**
  76043. * This class can be used to easily import assets into a scene
  76044. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76045. */
  76046. export class AssetsManager {
  76047. private _scene;
  76048. private _isLoading;
  76049. protected _tasks: AbstractAssetTask[];
  76050. protected _waitingTasksCount: number;
  76051. protected _totalTasksCount: number;
  76052. /**
  76053. * Callback called when all tasks are processed
  76054. */
  76055. onFinish: (tasks: AbstractAssetTask[]) => void;
  76056. /**
  76057. * Callback called when a task is successful
  76058. */
  76059. onTaskSuccess: (task: AbstractAssetTask) => void;
  76060. /**
  76061. * Callback called when a task had an error
  76062. */
  76063. onTaskError: (task: AbstractAssetTask) => void;
  76064. /**
  76065. * Callback called when a task is done (whatever the result is)
  76066. */
  76067. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76068. /**
  76069. * Observable called when all tasks are processed
  76070. */
  76071. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76072. /**
  76073. * Observable called when a task had an error
  76074. */
  76075. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76076. /**
  76077. * Observable called when all tasks were executed
  76078. */
  76079. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76080. /**
  76081. * Observable called when a task is done (whatever the result is)
  76082. */
  76083. onProgressObservable: Observable<IAssetsProgressEvent>;
  76084. /**
  76085. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76086. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76087. */
  76088. useDefaultLoadingScreen: boolean;
  76089. /**
  76090. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76091. * when all assets have been downloaded.
  76092. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76093. */
  76094. autoHideLoadingUI: boolean;
  76095. /**
  76096. * Creates a new AssetsManager
  76097. * @param scene defines the scene to work on
  76098. */
  76099. constructor(scene: Scene);
  76100. /**
  76101. * Add a MeshAssetTask to the list of active tasks
  76102. * @param taskName defines the name of the new task
  76103. * @param meshesNames defines the name of meshes to load
  76104. * @param rootUrl defines the root url to use to locate files
  76105. * @param sceneFilename defines the filename of the scene file
  76106. * @returns a new MeshAssetTask object
  76107. */
  76108. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76109. /**
  76110. * Add a TextFileAssetTask to the list of active tasks
  76111. * @param taskName defines the name of the new task
  76112. * @param url defines the url of the file to load
  76113. * @returns a new TextFileAssetTask object
  76114. */
  76115. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76116. /**
  76117. * Add a BinaryFileAssetTask to the list of active tasks
  76118. * @param taskName defines the name of the new task
  76119. * @param url defines the url of the file to load
  76120. * @returns a new BinaryFileAssetTask object
  76121. */
  76122. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76123. /**
  76124. * Add a ImageAssetTask to the list of active tasks
  76125. * @param taskName defines the name of the new task
  76126. * @param url defines the url of the file to load
  76127. * @returns a new ImageAssetTask object
  76128. */
  76129. addImageTask(taskName: string, url: string): ImageAssetTask;
  76130. /**
  76131. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  76135. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76136. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76137. * @returns a new TextureAssetTask object
  76138. */
  76139. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76140. /**
  76141. * Add a CubeTextureAssetTask to the list of active tasks
  76142. * @param taskName defines the name of the new task
  76143. * @param url defines the url of the file to load
  76144. * @param extensions defines the extension to use to load the cube map (can be null)
  76145. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76146. * @param files defines the list of files to load (can be null)
  76147. * @returns a new CubeTextureAssetTask object
  76148. */
  76149. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76150. /**
  76151. *
  76152. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76153. * @param taskName defines the name of the new task
  76154. * @param url defines the url of the file to load
  76155. * @param size defines the size you want for the cubemap (can be null)
  76156. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76157. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76158. * @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)
  76159. * @param reserved Internal use only
  76160. * @returns a new HDRCubeTextureAssetTask object
  76161. */
  76162. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76163. /**
  76164. *
  76165. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76166. * @param taskName defines the name of the new task
  76167. * @param url defines the url of the file to load
  76168. * @param size defines the size you want for the cubemap (can be null)
  76169. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76170. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76171. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76172. * @returns a new EquiRectangularCubeTextureAssetTask object
  76173. */
  76174. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76175. /**
  76176. * Remove a task from the assets manager.
  76177. * @param task the task to remove
  76178. */
  76179. removeTask(task: AbstractAssetTask): void;
  76180. private _decreaseWaitingTasksCount;
  76181. private _runTask;
  76182. /**
  76183. * Reset the AssetsManager and remove all tasks
  76184. * @return the current instance of the AssetsManager
  76185. */
  76186. reset(): AssetsManager;
  76187. /**
  76188. * Start the loading process
  76189. * @return the current instance of the AssetsManager
  76190. */
  76191. load(): AssetsManager;
  76192. /**
  76193. * Start the loading process as an async operation
  76194. * @return a promise returning the list of failed tasks
  76195. */
  76196. loadAsync(): Promise<void>;
  76197. }
  76198. }
  76199. declare module "babylonjs/Misc/deferred" {
  76200. /**
  76201. * Wrapper class for promise with external resolve and reject.
  76202. */
  76203. export class Deferred<T> {
  76204. /**
  76205. * The promise associated with this deferred object.
  76206. */
  76207. readonly promise: Promise<T>;
  76208. private _resolve;
  76209. private _reject;
  76210. /**
  76211. * The resolve method of the promise associated with this deferred object.
  76212. */
  76213. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76214. /**
  76215. * The reject method of the promise associated with this deferred object.
  76216. */
  76217. get reject(): (reason?: any) => void;
  76218. /**
  76219. * Constructor for this deferred object.
  76220. */
  76221. constructor();
  76222. }
  76223. }
  76224. declare module "babylonjs/Misc/meshExploder" {
  76225. import { Mesh } from "babylonjs/Meshes/mesh";
  76226. /**
  76227. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76228. */
  76229. export class MeshExploder {
  76230. private _centerMesh;
  76231. private _meshes;
  76232. private _meshesOrigins;
  76233. private _toCenterVectors;
  76234. private _scaledDirection;
  76235. private _newPosition;
  76236. private _centerPosition;
  76237. /**
  76238. * Explodes meshes from a center mesh.
  76239. * @param meshes The meshes to explode.
  76240. * @param centerMesh The mesh to be center of explosion.
  76241. */
  76242. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76243. private _setCenterMesh;
  76244. /**
  76245. * Get class name
  76246. * @returns "MeshExploder"
  76247. */
  76248. getClassName(): string;
  76249. /**
  76250. * "Exploded meshes"
  76251. * @returns Array of meshes with the centerMesh at index 0.
  76252. */
  76253. getMeshes(): Array<Mesh>;
  76254. /**
  76255. * Explodes meshes giving a specific direction
  76256. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76257. */
  76258. explode(direction?: number): void;
  76259. }
  76260. }
  76261. declare module "babylonjs/Misc/filesInput" {
  76262. import { Engine } from "babylonjs/Engines/engine";
  76263. import { Scene } from "babylonjs/scene";
  76264. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76265. import { Nullable } from "babylonjs/types";
  76266. /**
  76267. * Class used to help managing file picking and drag'n'drop
  76268. */
  76269. export class FilesInput {
  76270. /**
  76271. * List of files ready to be loaded
  76272. */
  76273. static get FilesToLoad(): {
  76274. [key: string]: File;
  76275. };
  76276. /**
  76277. * Callback called when a file is processed
  76278. */
  76279. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76280. private _engine;
  76281. private _currentScene;
  76282. private _sceneLoadedCallback;
  76283. private _progressCallback;
  76284. private _additionalRenderLoopLogicCallback;
  76285. private _textureLoadingCallback;
  76286. private _startingProcessingFilesCallback;
  76287. private _onReloadCallback;
  76288. private _errorCallback;
  76289. private _elementToMonitor;
  76290. private _sceneFileToLoad;
  76291. private _filesToLoad;
  76292. /**
  76293. * Creates a new FilesInput
  76294. * @param engine defines the rendering engine
  76295. * @param scene defines the hosting scene
  76296. * @param sceneLoadedCallback callback called when scene is loaded
  76297. * @param progressCallback callback called to track progress
  76298. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76299. * @param textureLoadingCallback callback called when a texture is loading
  76300. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76301. * @param onReloadCallback callback called when a reload is requested
  76302. * @param errorCallback callback call if an error occurs
  76303. */
  76304. 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>);
  76305. private _dragEnterHandler;
  76306. private _dragOverHandler;
  76307. private _dropHandler;
  76308. /**
  76309. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76310. * @param elementToMonitor defines the DOM element to track
  76311. */
  76312. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76313. /** Gets the current list of files to load */
  76314. get filesToLoad(): File[];
  76315. /**
  76316. * Release all associated resources
  76317. */
  76318. dispose(): void;
  76319. private renderFunction;
  76320. private drag;
  76321. private drop;
  76322. private _traverseFolder;
  76323. private _processFiles;
  76324. /**
  76325. * Load files from a drop event
  76326. * @param event defines the drop event to use as source
  76327. */
  76328. loadFiles(event: any): void;
  76329. private _processReload;
  76330. /**
  76331. * Reload the current scene from the loaded files
  76332. */
  76333. reload(): void;
  76334. }
  76335. }
  76336. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76337. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76338. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76339. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76340. }
  76341. declare module "babylonjs/Misc/sceneOptimizer" {
  76342. import { Scene, IDisposable } from "babylonjs/scene";
  76343. import { Observable } from "babylonjs/Misc/observable";
  76344. /**
  76345. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76346. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76347. */
  76348. export class SceneOptimization {
  76349. /**
  76350. * Defines the priority of this optimization (0 by default which means first in the list)
  76351. */
  76352. priority: number;
  76353. /**
  76354. * Gets a string describing the action executed by the current optimization
  76355. * @returns description string
  76356. */
  76357. getDescription(): string;
  76358. /**
  76359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76360. * @param scene defines the current scene where to apply this optimization
  76361. * @param optimizer defines the current optimizer
  76362. * @returns true if everything that can be done was applied
  76363. */
  76364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76365. /**
  76366. * Creates the SceneOptimization object
  76367. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76368. * @param desc defines the description associated with the optimization
  76369. */
  76370. constructor(
  76371. /**
  76372. * Defines the priority of this optimization (0 by default which means first in the list)
  76373. */
  76374. priority?: number);
  76375. }
  76376. /**
  76377. * Defines an optimization used to reduce the size of render target textures
  76378. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76379. */
  76380. export class TextureOptimization extends SceneOptimization {
  76381. /**
  76382. * Defines the priority of this optimization (0 by default which means first in the list)
  76383. */
  76384. priority: number;
  76385. /**
  76386. * 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
  76387. */
  76388. maximumSize: number;
  76389. /**
  76390. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76391. */
  76392. step: number;
  76393. /**
  76394. * Gets a string describing the action executed by the current optimization
  76395. * @returns description string
  76396. */
  76397. getDescription(): string;
  76398. /**
  76399. * Creates the TextureOptimization object
  76400. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76401. * @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
  76402. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76403. */
  76404. constructor(
  76405. /**
  76406. * Defines the priority of this optimization (0 by default which means first in the list)
  76407. */
  76408. priority?: number,
  76409. /**
  76410. * 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
  76411. */
  76412. maximumSize?: number,
  76413. /**
  76414. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76415. */
  76416. step?: number);
  76417. /**
  76418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76419. * @param scene defines the current scene where to apply this optimization
  76420. * @param optimizer defines the current optimizer
  76421. * @returns true if everything that can be done was applied
  76422. */
  76423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76424. }
  76425. /**
  76426. * Defines an optimization used to increase or decrease the rendering resolution
  76427. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76428. */
  76429. export class HardwareScalingOptimization extends SceneOptimization {
  76430. /**
  76431. * Defines the priority of this optimization (0 by default which means first in the list)
  76432. */
  76433. priority: number;
  76434. /**
  76435. * Defines the maximum scale to use (2 by default)
  76436. */
  76437. maximumScale: number;
  76438. /**
  76439. * Defines the step to use between two passes (0.5 by default)
  76440. */
  76441. step: number;
  76442. private _currentScale;
  76443. private _directionOffset;
  76444. /**
  76445. * Gets a string describing the action executed by the current optimization
  76446. * @return description string
  76447. */
  76448. getDescription(): string;
  76449. /**
  76450. * Creates the HardwareScalingOptimization object
  76451. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76452. * @param maximumScale defines the maximum scale to use (2 by default)
  76453. * @param step defines the step to use between two passes (0.5 by default)
  76454. */
  76455. constructor(
  76456. /**
  76457. * Defines the priority of this optimization (0 by default which means first in the list)
  76458. */
  76459. priority?: number,
  76460. /**
  76461. * Defines the maximum scale to use (2 by default)
  76462. */
  76463. maximumScale?: number,
  76464. /**
  76465. * Defines the step to use between two passes (0.5 by default)
  76466. */
  76467. step?: number);
  76468. /**
  76469. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76470. * @param scene defines the current scene where to apply this optimization
  76471. * @param optimizer defines the current optimizer
  76472. * @returns true if everything that can be done was applied
  76473. */
  76474. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76475. }
  76476. /**
  76477. * Defines an optimization used to remove shadows
  76478. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76479. */
  76480. export class ShadowsOptimization extends SceneOptimization {
  76481. /**
  76482. * Gets a string describing the action executed by the current optimization
  76483. * @return description string
  76484. */
  76485. getDescription(): string;
  76486. /**
  76487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76488. * @param scene defines the current scene where to apply this optimization
  76489. * @param optimizer defines the current optimizer
  76490. * @returns true if everything that can be done was applied
  76491. */
  76492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76493. }
  76494. /**
  76495. * Defines an optimization used to turn post-processes off
  76496. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76497. */
  76498. export class PostProcessesOptimization extends SceneOptimization {
  76499. /**
  76500. * Gets a string describing the action executed by the current optimization
  76501. * @return description string
  76502. */
  76503. getDescription(): string;
  76504. /**
  76505. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76506. * @param scene defines the current scene where to apply this optimization
  76507. * @param optimizer defines the current optimizer
  76508. * @returns true if everything that can be done was applied
  76509. */
  76510. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76511. }
  76512. /**
  76513. * Defines an optimization used to turn lens flares off
  76514. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76515. */
  76516. export class LensFlaresOptimization extends SceneOptimization {
  76517. /**
  76518. * Gets a string describing the action executed by the current optimization
  76519. * @return description string
  76520. */
  76521. getDescription(): string;
  76522. /**
  76523. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76524. * @param scene defines the current scene where to apply this optimization
  76525. * @param optimizer defines the current optimizer
  76526. * @returns true if everything that can be done was applied
  76527. */
  76528. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76529. }
  76530. /**
  76531. * Defines an optimization based on user defined callback.
  76532. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76533. */
  76534. export class CustomOptimization extends SceneOptimization {
  76535. /**
  76536. * Callback called to apply the custom optimization.
  76537. */
  76538. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76539. /**
  76540. * Callback called to get custom description
  76541. */
  76542. onGetDescription: () => string;
  76543. /**
  76544. * Gets a string describing the action executed by the current optimization
  76545. * @returns description string
  76546. */
  76547. getDescription(): string;
  76548. /**
  76549. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76550. * @param scene defines the current scene where to apply this optimization
  76551. * @param optimizer defines the current optimizer
  76552. * @returns true if everything that can be done was applied
  76553. */
  76554. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76555. }
  76556. /**
  76557. * Defines an optimization used to turn particles off
  76558. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76559. */
  76560. export class ParticlesOptimization extends SceneOptimization {
  76561. /**
  76562. * Gets a string describing the action executed by the current optimization
  76563. * @return description string
  76564. */
  76565. getDescription(): string;
  76566. /**
  76567. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76568. * @param scene defines the current scene where to apply this optimization
  76569. * @param optimizer defines the current optimizer
  76570. * @returns true if everything that can be done was applied
  76571. */
  76572. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76573. }
  76574. /**
  76575. * Defines an optimization used to turn render targets off
  76576. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76577. */
  76578. export class RenderTargetsOptimization extends SceneOptimization {
  76579. /**
  76580. * Gets a string describing the action executed by the current optimization
  76581. * @return description string
  76582. */
  76583. getDescription(): string;
  76584. /**
  76585. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76586. * @param scene defines the current scene where to apply this optimization
  76587. * @param optimizer defines the current optimizer
  76588. * @returns true if everything that can be done was applied
  76589. */
  76590. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76591. }
  76592. /**
  76593. * Defines an optimization used to merge meshes with compatible materials
  76594. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76595. */
  76596. export class MergeMeshesOptimization extends SceneOptimization {
  76597. private static _UpdateSelectionTree;
  76598. /**
  76599. * Gets or sets a boolean which defines if optimization octree has to be updated
  76600. */
  76601. static get UpdateSelectionTree(): boolean;
  76602. /**
  76603. * Gets or sets a boolean which defines if optimization octree has to be updated
  76604. */
  76605. static set UpdateSelectionTree(value: boolean);
  76606. /**
  76607. * Gets a string describing the action executed by the current optimization
  76608. * @return description string
  76609. */
  76610. getDescription(): string;
  76611. private _canBeMerged;
  76612. /**
  76613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76614. * @param scene defines the current scene where to apply this optimization
  76615. * @param optimizer defines the current optimizer
  76616. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76617. * @returns true if everything that can be done was applied
  76618. */
  76619. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76620. }
  76621. /**
  76622. * Defines a list of options used by SceneOptimizer
  76623. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76624. */
  76625. export class SceneOptimizerOptions {
  76626. /**
  76627. * Defines the target frame rate to reach (60 by default)
  76628. */
  76629. targetFrameRate: number;
  76630. /**
  76631. * Defines the interval between two checkes (2000ms by default)
  76632. */
  76633. trackerDuration: number;
  76634. /**
  76635. * Gets the list of optimizations to apply
  76636. */
  76637. optimizations: SceneOptimization[];
  76638. /**
  76639. * Creates a new list of options used by SceneOptimizer
  76640. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76641. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76642. */
  76643. constructor(
  76644. /**
  76645. * Defines the target frame rate to reach (60 by default)
  76646. */
  76647. targetFrameRate?: number,
  76648. /**
  76649. * Defines the interval between two checkes (2000ms by default)
  76650. */
  76651. trackerDuration?: number);
  76652. /**
  76653. * Add a new optimization
  76654. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76655. * @returns the current SceneOptimizerOptions
  76656. */
  76657. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76658. /**
  76659. * Add a new custom optimization
  76660. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76661. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76662. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76663. * @returns the current SceneOptimizerOptions
  76664. */
  76665. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76666. /**
  76667. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76668. * @param targetFrameRate defines the target frame rate (60 by default)
  76669. * @returns a SceneOptimizerOptions object
  76670. */
  76671. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76672. /**
  76673. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76674. * @param targetFrameRate defines the target frame rate (60 by default)
  76675. * @returns a SceneOptimizerOptions object
  76676. */
  76677. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76678. /**
  76679. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76680. * @param targetFrameRate defines the target frame rate (60 by default)
  76681. * @returns a SceneOptimizerOptions object
  76682. */
  76683. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76684. }
  76685. /**
  76686. * Class used to run optimizations in order to reach a target frame rate
  76687. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76688. */
  76689. export class SceneOptimizer implements IDisposable {
  76690. private _isRunning;
  76691. private _options;
  76692. private _scene;
  76693. private _currentPriorityLevel;
  76694. private _targetFrameRate;
  76695. private _trackerDuration;
  76696. private _currentFrameRate;
  76697. private _sceneDisposeObserver;
  76698. private _improvementMode;
  76699. /**
  76700. * Defines an observable called when the optimizer reaches the target frame rate
  76701. */
  76702. onSuccessObservable: Observable<SceneOptimizer>;
  76703. /**
  76704. * Defines an observable called when the optimizer enables an optimization
  76705. */
  76706. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76707. /**
  76708. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76709. */
  76710. onFailureObservable: Observable<SceneOptimizer>;
  76711. /**
  76712. * Gets a boolean indicating if the optimizer is in improvement mode
  76713. */
  76714. get isInImprovementMode(): boolean;
  76715. /**
  76716. * Gets the current priority level (0 at start)
  76717. */
  76718. get currentPriorityLevel(): number;
  76719. /**
  76720. * Gets the current frame rate checked by the SceneOptimizer
  76721. */
  76722. get currentFrameRate(): number;
  76723. /**
  76724. * Gets or sets the current target frame rate (60 by default)
  76725. */
  76726. get targetFrameRate(): number;
  76727. /**
  76728. * Gets or sets the current target frame rate (60 by default)
  76729. */
  76730. set targetFrameRate(value: number);
  76731. /**
  76732. * Gets or sets the current interval between two checks (every 2000ms by default)
  76733. */
  76734. get trackerDuration(): number;
  76735. /**
  76736. * Gets or sets the current interval between two checks (every 2000ms by default)
  76737. */
  76738. set trackerDuration(value: number);
  76739. /**
  76740. * Gets the list of active optimizations
  76741. */
  76742. get optimizations(): SceneOptimization[];
  76743. /**
  76744. * Creates a new SceneOptimizer
  76745. * @param scene defines the scene to work on
  76746. * @param options defines the options to use with the SceneOptimizer
  76747. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76748. * @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)
  76749. */
  76750. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76751. /**
  76752. * Stops the current optimizer
  76753. */
  76754. stop(): void;
  76755. /**
  76756. * Reset the optimizer to initial step (current priority level = 0)
  76757. */
  76758. reset(): void;
  76759. /**
  76760. * Start the optimizer. By default it will try to reach a specific framerate
  76761. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76762. */
  76763. start(): void;
  76764. private _checkCurrentState;
  76765. /**
  76766. * Release all resources
  76767. */
  76768. dispose(): void;
  76769. /**
  76770. * Helper function to create a SceneOptimizer with one single line of code
  76771. * @param scene defines the scene to work on
  76772. * @param options defines the options to use with the SceneOptimizer
  76773. * @param onSuccess defines a callback to call on success
  76774. * @param onFailure defines a callback to call on failure
  76775. * @returns the new SceneOptimizer object
  76776. */
  76777. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76778. }
  76779. }
  76780. declare module "babylonjs/Misc/sceneSerializer" {
  76781. import { Scene } from "babylonjs/scene";
  76782. /**
  76783. * Class used to serialize a scene into a string
  76784. */
  76785. export class SceneSerializer {
  76786. /**
  76787. * Clear cache used by a previous serialization
  76788. */
  76789. static ClearCache(): void;
  76790. /**
  76791. * Serialize a scene into a JSON compatible object
  76792. * @param scene defines the scene to serialize
  76793. * @returns a JSON compatible object
  76794. */
  76795. static Serialize(scene: Scene): any;
  76796. /**
  76797. * Serialize a mesh into a JSON compatible object
  76798. * @param toSerialize defines the mesh to serialize
  76799. * @param withParents defines if parents must be serialized as well
  76800. * @param withChildren defines if children must be serialized as well
  76801. * @returns a JSON compatible object
  76802. */
  76803. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76804. }
  76805. }
  76806. declare module "babylonjs/Misc/textureTools" {
  76807. import { Texture } from "babylonjs/Materials/Textures/texture";
  76808. /**
  76809. * Class used to host texture specific utilities
  76810. */
  76811. export class TextureTools {
  76812. /**
  76813. * Uses the GPU to create a copy texture rescaled at a given size
  76814. * @param texture Texture to copy from
  76815. * @param width defines the desired width
  76816. * @param height defines the desired height
  76817. * @param useBilinearMode defines if bilinear mode has to be used
  76818. * @return the generated texture
  76819. */
  76820. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76821. }
  76822. }
  76823. declare module "babylonjs/Misc/videoRecorder" {
  76824. import { Nullable } from "babylonjs/types";
  76825. import { Engine } from "babylonjs/Engines/engine";
  76826. /**
  76827. * This represents the different options available for the video capture.
  76828. */
  76829. export interface VideoRecorderOptions {
  76830. /** Defines the mime type of the video. */
  76831. mimeType: string;
  76832. /** Defines the FPS the video should be recorded at. */
  76833. fps: number;
  76834. /** Defines the chunk size for the recording data. */
  76835. recordChunckSize: number;
  76836. /** The audio tracks to attach to the recording. */
  76837. audioTracks?: MediaStreamTrack[];
  76838. }
  76839. /**
  76840. * This can help with recording videos from BabylonJS.
  76841. * This is based on the available WebRTC functionalities of the browser.
  76842. *
  76843. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76844. */
  76845. export class VideoRecorder {
  76846. private static readonly _defaultOptions;
  76847. /**
  76848. * Returns whether or not the VideoRecorder is available in your browser.
  76849. * @param engine Defines the Babylon Engine.
  76850. * @returns true if supported otherwise false.
  76851. */
  76852. static IsSupported(engine: Engine): boolean;
  76853. private readonly _options;
  76854. private _canvas;
  76855. private _mediaRecorder;
  76856. private _recordedChunks;
  76857. private _fileName;
  76858. private _resolve;
  76859. private _reject;
  76860. /**
  76861. * True when a recording is already in progress.
  76862. */
  76863. get isRecording(): boolean;
  76864. /**
  76865. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76866. * @param engine Defines the BabylonJS Engine you wish to record.
  76867. * @param options Defines options that can be used to customize the capture.
  76868. */
  76869. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76870. /**
  76871. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76872. */
  76873. stopRecording(): void;
  76874. /**
  76875. * Starts recording the canvas for a max duration specified in parameters.
  76876. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76877. * If null no automatic download will start and you can rely on the promise to get the data back.
  76878. * @param maxDuration Defines the maximum recording time in seconds.
  76879. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76880. * @return A promise callback at the end of the recording with the video data in Blob.
  76881. */
  76882. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76883. /**
  76884. * Releases internal resources used during the recording.
  76885. */
  76886. dispose(): void;
  76887. private _handleDataAvailable;
  76888. private _handleError;
  76889. private _handleStop;
  76890. }
  76891. }
  76892. declare module "babylonjs/Misc/screenshotTools" {
  76893. import { Camera } from "babylonjs/Cameras/camera";
  76894. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76895. import { Engine } from "babylonjs/Engines/engine";
  76896. /**
  76897. * Class containing a set of static utilities functions for screenshots
  76898. */
  76899. export class ScreenshotTools {
  76900. /**
  76901. * Captures a screenshot of the current rendering
  76902. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76903. * @param engine defines the rendering engine
  76904. * @param camera defines the source camera
  76905. * @param size This parameter can be set to a single number or to an object with the
  76906. * following (optional) properties: precision, width, height. If a single number is passed,
  76907. * it will be used for both width and height. If an object is passed, the screenshot size
  76908. * will be derived from the parameters. The precision property is a multiplier allowing
  76909. * rendering at a higher or lower resolution
  76910. * @param successCallback defines the callback receives a single parameter which contains the
  76911. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76912. * src parameter of an <img> to display it
  76913. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76914. * Check your browser for supported MIME types
  76915. */
  76916. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76917. /**
  76918. * Captures a screenshot of the current rendering
  76919. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76920. * @param engine defines the rendering engine
  76921. * @param camera defines the source camera
  76922. * @param size This parameter can be set to a single number or to an object with the
  76923. * following (optional) properties: precision, width, height. If a single number is passed,
  76924. * it will be used for both width and height. If an object is passed, the screenshot size
  76925. * will be derived from the parameters. The precision property is a multiplier allowing
  76926. * rendering at a higher or lower resolution
  76927. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76928. * Check your browser for supported MIME types
  76929. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76930. * to the src parameter of an <img> to display it
  76931. */
  76932. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76933. /**
  76934. * Generates an image screenshot from the specified camera.
  76935. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76936. * @param engine The engine to use for rendering
  76937. * @param camera The camera to use for rendering
  76938. * @param size This parameter can be set to a single number or to an object with the
  76939. * following (optional) properties: precision, width, height. If a single number is passed,
  76940. * it will be used for both width and height. If an object is passed, the screenshot size
  76941. * will be derived from the parameters. The precision property is a multiplier allowing
  76942. * rendering at a higher or lower resolution
  76943. * @param successCallback The callback receives a single parameter which contains the
  76944. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76945. * src parameter of an <img> to display it
  76946. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76947. * Check your browser for supported MIME types
  76948. * @param samples Texture samples (default: 1)
  76949. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76950. * @param fileName A name for for the downloaded file.
  76951. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76952. */
  76953. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76954. /**
  76955. * Generates an image screenshot from the specified camera.
  76956. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  76957. * @param engine The engine to use for rendering
  76958. * @param camera The camera to use for rendering
  76959. * @param size This parameter can be set to a single number or to an object with the
  76960. * following (optional) properties: precision, width, height. If a single number is passed,
  76961. * it will be used for both width and height. If an object is passed, the screenshot size
  76962. * will be derived from the parameters. The precision property is a multiplier allowing
  76963. * rendering at a higher or lower resolution
  76964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76965. * Check your browser for supported MIME types
  76966. * @param samples Texture samples (default: 1)
  76967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76968. * @param fileName A name for for the downloaded file.
  76969. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76970. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76971. * to the src parameter of an <img> to display it
  76972. */
  76973. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76974. /**
  76975. * Gets height and width for screenshot size
  76976. * @private
  76977. */
  76978. private static _getScreenshotSize;
  76979. }
  76980. }
  76981. declare module "babylonjs/Misc/dataReader" {
  76982. /**
  76983. * Interface for a data buffer
  76984. */
  76985. export interface IDataBuffer {
  76986. /**
  76987. * Reads bytes from the data buffer.
  76988. * @param byteOffset The byte offset to read
  76989. * @param byteLength The byte length to read
  76990. * @returns A promise that resolves when the bytes are read
  76991. */
  76992. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76993. /**
  76994. * The byte length of the buffer.
  76995. */
  76996. readonly byteLength: number;
  76997. }
  76998. /**
  76999. * Utility class for reading from a data buffer
  77000. */
  77001. export class DataReader {
  77002. /**
  77003. * The data buffer associated with this data reader.
  77004. */
  77005. readonly buffer: IDataBuffer;
  77006. /**
  77007. * The current byte offset from the beginning of the data buffer.
  77008. */
  77009. byteOffset: number;
  77010. private _dataView;
  77011. private _dataByteOffset;
  77012. /**
  77013. * Constructor
  77014. * @param buffer The buffer to read
  77015. */
  77016. constructor(buffer: IDataBuffer);
  77017. /**
  77018. * Loads the given byte length.
  77019. * @param byteLength The byte length to load
  77020. * @returns A promise that resolves when the load is complete
  77021. */
  77022. loadAsync(byteLength: number): Promise<void>;
  77023. /**
  77024. * Read a unsigned 32-bit integer from the currently loaded data range.
  77025. * @returns The 32-bit integer read
  77026. */
  77027. readUint32(): number;
  77028. /**
  77029. * Read a byte array from the currently loaded data range.
  77030. * @param byteLength The byte length to read
  77031. * @returns The byte array read
  77032. */
  77033. readUint8Array(byteLength: number): Uint8Array;
  77034. /**
  77035. * Read a string from the currently loaded data range.
  77036. * @param byteLength The byte length to read
  77037. * @returns The string read
  77038. */
  77039. readString(byteLength: number): string;
  77040. /**
  77041. * Skips the given byte length the currently loaded data range.
  77042. * @param byteLength The byte length to skip
  77043. */
  77044. skipBytes(byteLength: number): void;
  77045. }
  77046. }
  77047. declare module "babylonjs/Misc/dataStorage" {
  77048. /**
  77049. * Class for storing data to local storage if available or in-memory storage otherwise
  77050. */
  77051. export class DataStorage {
  77052. private static _Storage;
  77053. private static _GetStorage;
  77054. /**
  77055. * Reads a string from the data storage
  77056. * @param key The key to read
  77057. * @param defaultValue The value if the key doesn't exist
  77058. * @returns The string value
  77059. */
  77060. static ReadString(key: string, defaultValue: string): string;
  77061. /**
  77062. * Writes a string to the data storage
  77063. * @param key The key to write
  77064. * @param value The value to write
  77065. */
  77066. static WriteString(key: string, value: string): void;
  77067. /**
  77068. * Reads a boolean from the data storage
  77069. * @param key The key to read
  77070. * @param defaultValue The value if the key doesn't exist
  77071. * @returns The boolean value
  77072. */
  77073. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77074. /**
  77075. * Writes a boolean to the data storage
  77076. * @param key The key to write
  77077. * @param value The value to write
  77078. */
  77079. static WriteBoolean(key: string, value: boolean): void;
  77080. /**
  77081. * Reads a number from the data storage
  77082. * @param key The key to read
  77083. * @param defaultValue The value if the key doesn't exist
  77084. * @returns The number value
  77085. */
  77086. static ReadNumber(key: string, defaultValue: number): number;
  77087. /**
  77088. * Writes a number to the data storage
  77089. * @param key The key to write
  77090. * @param value The value to write
  77091. */
  77092. static WriteNumber(key: string, value: number): void;
  77093. }
  77094. }
  77095. declare module "babylonjs/Misc/index" {
  77096. export * from "babylonjs/Misc/andOrNotEvaluator";
  77097. export * from "babylonjs/Misc/assetsManager";
  77098. export * from "babylonjs/Misc/basis";
  77099. export * from "babylonjs/Misc/dds";
  77100. export * from "babylonjs/Misc/decorators";
  77101. export * from "babylonjs/Misc/deferred";
  77102. export * from "babylonjs/Misc/environmentTextureTools";
  77103. export * from "babylonjs/Misc/meshExploder";
  77104. export * from "babylonjs/Misc/filesInput";
  77105. export * from "babylonjs/Misc/HighDynamicRange/index";
  77106. export * from "babylonjs/Misc/khronosTextureContainer";
  77107. export * from "babylonjs/Misc/observable";
  77108. export * from "babylonjs/Misc/performanceMonitor";
  77109. export * from "babylonjs/Misc/promise";
  77110. export * from "babylonjs/Misc/sceneOptimizer";
  77111. export * from "babylonjs/Misc/sceneSerializer";
  77112. export * from "babylonjs/Misc/smartArray";
  77113. export * from "babylonjs/Misc/stringDictionary";
  77114. export * from "babylonjs/Misc/tags";
  77115. export * from "babylonjs/Misc/textureTools";
  77116. export * from "babylonjs/Misc/tga";
  77117. export * from "babylonjs/Misc/tools";
  77118. export * from "babylonjs/Misc/videoRecorder";
  77119. export * from "babylonjs/Misc/virtualJoystick";
  77120. export * from "babylonjs/Misc/workerPool";
  77121. export * from "babylonjs/Misc/logger";
  77122. export * from "babylonjs/Misc/typeStore";
  77123. export * from "babylonjs/Misc/filesInputStore";
  77124. export * from "babylonjs/Misc/deepCopier";
  77125. export * from "babylonjs/Misc/pivotTools";
  77126. export * from "babylonjs/Misc/precisionDate";
  77127. export * from "babylonjs/Misc/screenshotTools";
  77128. export * from "babylonjs/Misc/typeStore";
  77129. export * from "babylonjs/Misc/webRequest";
  77130. export * from "babylonjs/Misc/iInspectable";
  77131. export * from "babylonjs/Misc/brdfTextureTools";
  77132. export * from "babylonjs/Misc/rgbdTextureTools";
  77133. export * from "babylonjs/Misc/gradients";
  77134. export * from "babylonjs/Misc/perfCounter";
  77135. export * from "babylonjs/Misc/fileRequest";
  77136. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77137. export * from "babylonjs/Misc/retryStrategy";
  77138. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77139. export * from "babylonjs/Misc/canvasGenerator";
  77140. export * from "babylonjs/Misc/fileTools";
  77141. export * from "babylonjs/Misc/stringTools";
  77142. export * from "babylonjs/Misc/dataReader";
  77143. export * from "babylonjs/Misc/minMaxReducer";
  77144. export * from "babylonjs/Misc/depthReducer";
  77145. export * from "babylonjs/Misc/dataStorage";
  77146. }
  77147. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77148. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77149. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77150. import { Observable } from "babylonjs/Misc/observable";
  77151. import { Matrix } from "babylonjs/Maths/math.vector";
  77152. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77153. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77154. /**
  77155. * An interface for all Hit test features
  77156. */
  77157. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77158. /**
  77159. * Triggered when new babylon (transformed) hit test results are available
  77160. */
  77161. onHitTestResultObservable: Observable<T[]>;
  77162. }
  77163. /**
  77164. * Options used for hit testing
  77165. */
  77166. export interface IWebXRLegacyHitTestOptions {
  77167. /**
  77168. * Only test when user interacted with the scene. Default - hit test every frame
  77169. */
  77170. testOnPointerDownOnly?: boolean;
  77171. /**
  77172. * The node to use to transform the local results to world coordinates
  77173. */
  77174. worldParentNode?: TransformNode;
  77175. }
  77176. /**
  77177. * Interface defining the babylon result of raycasting/hit-test
  77178. */
  77179. export interface IWebXRLegacyHitResult {
  77180. /**
  77181. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77182. */
  77183. transformationMatrix: Matrix;
  77184. /**
  77185. * The native hit test result
  77186. */
  77187. xrHitResult: XRHitResult | XRHitTestResult;
  77188. }
  77189. /**
  77190. * The currently-working hit-test module.
  77191. * Hit test (or Ray-casting) is used to interact with the real world.
  77192. * For further information read here - https://github.com/immersive-web/hit-test
  77193. */
  77194. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77195. /**
  77196. * options to use when constructing this feature
  77197. */
  77198. readonly options: IWebXRLegacyHitTestOptions;
  77199. private _direction;
  77200. private _mat;
  77201. private _onSelectEnabled;
  77202. private _origin;
  77203. /**
  77204. * The module's name
  77205. */
  77206. static readonly Name: string;
  77207. /**
  77208. * The (Babylon) version of this module.
  77209. * This is an integer representing the implementation version.
  77210. * This number does not correspond to the WebXR specs version
  77211. */
  77212. static readonly Version: number;
  77213. /**
  77214. * Populated with the last native XR Hit Results
  77215. */
  77216. lastNativeXRHitResults: XRHitResult[];
  77217. /**
  77218. * Triggered when new babylon (transformed) hit test results are available
  77219. */
  77220. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77221. /**
  77222. * Creates a new instance of the (legacy version) hit test feature
  77223. * @param _xrSessionManager an instance of WebXRSessionManager
  77224. * @param options options to use when constructing this feature
  77225. */
  77226. constructor(_xrSessionManager: WebXRSessionManager,
  77227. /**
  77228. * options to use when constructing this feature
  77229. */
  77230. options?: IWebXRLegacyHitTestOptions);
  77231. /**
  77232. * execute a hit test with an XR Ray
  77233. *
  77234. * @param xrSession a native xrSession that will execute this hit test
  77235. * @param xrRay the ray (position and direction) to use for ray-casting
  77236. * @param referenceSpace native XR reference space to use for the hit-test
  77237. * @param filter filter function that will filter the results
  77238. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77239. */
  77240. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77241. /**
  77242. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77243. * @param event the (select) event to use to select with
  77244. * @param referenceSpace the reference space to use for this hit test
  77245. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77246. */
  77247. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77248. /**
  77249. * attach this feature
  77250. * Will usually be called by the features manager
  77251. *
  77252. * @returns true if successful.
  77253. */
  77254. attach(): boolean;
  77255. /**
  77256. * detach this feature.
  77257. * Will usually be called by the features manager
  77258. *
  77259. * @returns true if successful.
  77260. */
  77261. detach(): boolean;
  77262. /**
  77263. * Dispose this feature and all of the resources attached
  77264. */
  77265. dispose(): void;
  77266. protected _onXRFrame(frame: XRFrame): void;
  77267. private _onHitTestResults;
  77268. private _onSelect;
  77269. }
  77270. }
  77271. declare module "babylonjs/XR/features/WebXRHitTest" {
  77272. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77273. import { Observable } from "babylonjs/Misc/observable";
  77274. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77275. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77276. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77277. /**
  77278. * Options used for hit testing (version 2)
  77279. */
  77280. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77281. /**
  77282. * Do not create a permanent hit test. Will usually be used when only
  77283. * transient inputs are needed.
  77284. */
  77285. disablePermanentHitTest?: boolean;
  77286. /**
  77287. * Enable transient (for example touch-based) hit test inspections
  77288. */
  77289. enableTransientHitTest?: boolean;
  77290. /**
  77291. * Offset ray for the permanent hit test
  77292. */
  77293. offsetRay?: Vector3;
  77294. /**
  77295. * Offset ray for the transient hit test
  77296. */
  77297. transientOffsetRay?: Vector3;
  77298. /**
  77299. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77300. */
  77301. useReferenceSpace?: boolean;
  77302. }
  77303. /**
  77304. * Interface defining the babylon result of hit-test
  77305. */
  77306. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77307. /**
  77308. * The input source that generated this hit test (if transient)
  77309. */
  77310. inputSource?: XRInputSource;
  77311. /**
  77312. * Is this a transient hit test
  77313. */
  77314. isTransient?: boolean;
  77315. /**
  77316. * Position of the hit test result
  77317. */
  77318. position: Vector3;
  77319. /**
  77320. * Rotation of the hit test result
  77321. */
  77322. rotationQuaternion: Quaternion;
  77323. /**
  77324. * The native hit test result
  77325. */
  77326. xrHitResult: XRHitTestResult;
  77327. }
  77328. /**
  77329. * The currently-working hit-test module.
  77330. * Hit test (or Ray-casting) is used to interact with the real world.
  77331. * For further information read here - https://github.com/immersive-web/hit-test
  77332. *
  77333. * Tested on chrome (mobile) 80.
  77334. */
  77335. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77336. /**
  77337. * options to use when constructing this feature
  77338. */
  77339. readonly options: IWebXRHitTestOptions;
  77340. private _tmpMat;
  77341. private _tmpPos;
  77342. private _tmpQuat;
  77343. private _transientXrHitTestSource;
  77344. private _xrHitTestSource;
  77345. private initHitTestSource;
  77346. /**
  77347. * The module's name
  77348. */
  77349. static readonly Name: string;
  77350. /**
  77351. * The (Babylon) version of this module.
  77352. * This is an integer representing the implementation version.
  77353. * This number does not correspond to the WebXR specs version
  77354. */
  77355. static readonly Version: number;
  77356. /**
  77357. * When set to true, each hit test will have its own position/rotation objects
  77358. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77359. * the developers will clone them or copy them as they see fit.
  77360. */
  77361. autoCloneTransformation: boolean;
  77362. /**
  77363. * Triggered when new babylon (transformed) hit test results are available
  77364. */
  77365. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77366. /**
  77367. * Use this to temporarily pause hit test checks.
  77368. */
  77369. paused: boolean;
  77370. /**
  77371. * Creates a new instance of the hit test feature
  77372. * @param _xrSessionManager an instance of WebXRSessionManager
  77373. * @param options options to use when constructing this feature
  77374. */
  77375. constructor(_xrSessionManager: WebXRSessionManager,
  77376. /**
  77377. * options to use when constructing this feature
  77378. */
  77379. options?: IWebXRHitTestOptions);
  77380. /**
  77381. * attach this feature
  77382. * Will usually be called by the features manager
  77383. *
  77384. * @returns true if successful.
  77385. */
  77386. attach(): boolean;
  77387. /**
  77388. * detach this feature.
  77389. * Will usually be called by the features manager
  77390. *
  77391. * @returns true if successful.
  77392. */
  77393. detach(): boolean;
  77394. /**
  77395. * Dispose this feature and all of the resources attached
  77396. */
  77397. dispose(): void;
  77398. protected _onXRFrame(frame: XRFrame): void;
  77399. private _processWebXRHitTestResult;
  77400. }
  77401. }
  77402. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77403. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77404. import { Observable } from "babylonjs/Misc/observable";
  77405. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77407. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77408. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77409. /**
  77410. * Configuration options of the anchor system
  77411. */
  77412. export interface IWebXRAnchorSystemOptions {
  77413. /**
  77414. * a node that will be used to convert local to world coordinates
  77415. */
  77416. worldParentNode?: TransformNode;
  77417. /**
  77418. * If set to true a reference of the created anchors will be kept until the next session starts
  77419. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77420. */
  77421. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77422. }
  77423. /**
  77424. * A babylon container for an XR Anchor
  77425. */
  77426. export interface IWebXRAnchor {
  77427. /**
  77428. * A babylon-assigned ID for this anchor
  77429. */
  77430. id: number;
  77431. /**
  77432. * Transformation matrix to apply to an object attached to this anchor
  77433. */
  77434. transformationMatrix: Matrix;
  77435. /**
  77436. * The native anchor object
  77437. */
  77438. xrAnchor: XRAnchor;
  77439. /**
  77440. * if defined, this object will be constantly updated by the anchor's position and rotation
  77441. */
  77442. attachedNode?: TransformNode;
  77443. }
  77444. /**
  77445. * An implementation of the anchor system for WebXR.
  77446. * For further information see https://github.com/immersive-web/anchors/
  77447. */
  77448. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77449. private _options;
  77450. private _lastFrameDetected;
  77451. private _trackedAnchors;
  77452. private _referenceSpaceForFrameAnchors;
  77453. private _futureAnchors;
  77454. /**
  77455. * The module's name
  77456. */
  77457. static readonly Name: string;
  77458. /**
  77459. * The (Babylon) version of this module.
  77460. * This is an integer representing the implementation version.
  77461. * This number does not correspond to the WebXR specs version
  77462. */
  77463. static readonly Version: number;
  77464. /**
  77465. * Observers registered here will be executed when a new anchor was added to the session
  77466. */
  77467. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77468. /**
  77469. * Observers registered here will be executed when an anchor was removed from the session
  77470. */
  77471. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77472. /**
  77473. * Observers registered here will be executed when an existing anchor updates
  77474. * This can execute N times every frame
  77475. */
  77476. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77477. /**
  77478. * Set the reference space to use for anchor creation, when not using a hit test.
  77479. * Will default to the session's reference space if not defined
  77480. */
  77481. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77482. /**
  77483. * constructs a new anchor system
  77484. * @param _xrSessionManager an instance of WebXRSessionManager
  77485. * @param _options configuration object for this feature
  77486. */
  77487. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77488. private _tmpVector;
  77489. private _tmpQuaternion;
  77490. private _populateTmpTransformation;
  77491. /**
  77492. * Create a new anchor point using a hit test result at a specific point in the scene
  77493. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77494. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77495. *
  77496. * @param hitTestResult The hit test result to use for this anchor creation
  77497. * @param position an optional position offset for this anchor
  77498. * @param rotationQuaternion an optional rotation offset for this anchor
  77499. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77500. */
  77501. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77502. /**
  77503. * Add a new anchor at a specific position and rotation
  77504. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77505. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77506. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77507. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77508. *
  77509. * @param position the position in which to add an anchor
  77510. * @param rotationQuaternion an optional rotation for the anchor transformation
  77511. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77512. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77513. */
  77514. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77515. /**
  77516. * detach this feature.
  77517. * Will usually be called by the features manager
  77518. *
  77519. * @returns true if successful.
  77520. */
  77521. detach(): boolean;
  77522. /**
  77523. * Dispose this feature and all of the resources attached
  77524. */
  77525. dispose(): void;
  77526. protected _onXRFrame(frame: XRFrame): void;
  77527. /**
  77528. * avoiding using Array.find for global support.
  77529. * @param xrAnchor the plane to find in the array
  77530. */
  77531. private _findIndexInAnchorArray;
  77532. private _updateAnchorWithXRFrame;
  77533. private _createAnchorAtTransformation;
  77534. }
  77535. }
  77536. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77537. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77538. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77539. import { Observable } from "babylonjs/Misc/observable";
  77540. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77541. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77542. /**
  77543. * Options used in the plane detector module
  77544. */
  77545. export interface IWebXRPlaneDetectorOptions {
  77546. /**
  77547. * The node to use to transform the local results to world coordinates
  77548. */
  77549. worldParentNode?: TransformNode;
  77550. /**
  77551. * If set to true a reference of the created planes will be kept until the next session starts
  77552. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77553. */
  77554. doNotRemovePlanesOnSessionEnded?: boolean;
  77555. }
  77556. /**
  77557. * A babylon interface for a WebXR plane.
  77558. * A Plane is actually a polygon, built from N points in space
  77559. *
  77560. * Supported in chrome 79, not supported in canary 81 ATM
  77561. */
  77562. export interface IWebXRPlane {
  77563. /**
  77564. * a babylon-assigned ID for this polygon
  77565. */
  77566. id: number;
  77567. /**
  77568. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77569. */
  77570. polygonDefinition: Array<Vector3>;
  77571. /**
  77572. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77573. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77574. */
  77575. transformationMatrix: Matrix;
  77576. /**
  77577. * the native xr-plane object
  77578. */
  77579. xrPlane: XRPlane;
  77580. }
  77581. /**
  77582. * The plane detector is used to detect planes in the real world when in AR
  77583. * For more information see https://github.com/immersive-web/real-world-geometry/
  77584. */
  77585. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77586. private _options;
  77587. private _detectedPlanes;
  77588. private _enabled;
  77589. private _lastFrameDetected;
  77590. /**
  77591. * The module's name
  77592. */
  77593. static readonly Name: string;
  77594. /**
  77595. * The (Babylon) version of this module.
  77596. * This is an integer representing the implementation version.
  77597. * This number does not correspond to the WebXR specs version
  77598. */
  77599. static readonly Version: number;
  77600. /**
  77601. * Observers registered here will be executed when a new plane was added to the session
  77602. */
  77603. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77604. /**
  77605. * Observers registered here will be executed when a plane is no longer detected in the session
  77606. */
  77607. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77608. /**
  77609. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77610. * This can execute N times every frame
  77611. */
  77612. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77613. /**
  77614. * construct a new Plane Detector
  77615. * @param _xrSessionManager an instance of xr Session manager
  77616. * @param _options configuration to use when constructing this feature
  77617. */
  77618. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77619. /**
  77620. * detach this feature.
  77621. * Will usually be called by the features manager
  77622. *
  77623. * @returns true if successful.
  77624. */
  77625. detach(): boolean;
  77626. /**
  77627. * Dispose this feature and all of the resources attached
  77628. */
  77629. dispose(): void;
  77630. protected _onXRFrame(frame: XRFrame): void;
  77631. private _init;
  77632. private _updatePlaneWithXRPlane;
  77633. /**
  77634. * avoiding using Array.find for global support.
  77635. * @param xrPlane the plane to find in the array
  77636. */
  77637. private findIndexInPlaneArray;
  77638. }
  77639. }
  77640. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77641. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77643. import { Observable } from "babylonjs/Misc/observable";
  77644. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77645. /**
  77646. * Options interface for the background remover plugin
  77647. */
  77648. export interface IWebXRBackgroundRemoverOptions {
  77649. /**
  77650. * Further background meshes to disable when entering AR
  77651. */
  77652. backgroundMeshes?: AbstractMesh[];
  77653. /**
  77654. * flags to configure the removal of the environment helper.
  77655. * If not set, the entire background will be removed. If set, flags should be set as well.
  77656. */
  77657. environmentHelperRemovalFlags?: {
  77658. /**
  77659. * Should the skybox be removed (default false)
  77660. */
  77661. skyBox?: boolean;
  77662. /**
  77663. * Should the ground be removed (default false)
  77664. */
  77665. ground?: boolean;
  77666. };
  77667. /**
  77668. * don't disable the environment helper
  77669. */
  77670. ignoreEnvironmentHelper?: boolean;
  77671. }
  77672. /**
  77673. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77674. */
  77675. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77676. /**
  77677. * read-only options to be used in this module
  77678. */
  77679. readonly options: IWebXRBackgroundRemoverOptions;
  77680. /**
  77681. * The module's name
  77682. */
  77683. static readonly Name: string;
  77684. /**
  77685. * The (Babylon) version of this module.
  77686. * This is an integer representing the implementation version.
  77687. * This number does not correspond to the WebXR specs version
  77688. */
  77689. static readonly Version: number;
  77690. /**
  77691. * registered observers will be triggered when the background state changes
  77692. */
  77693. onBackgroundStateChangedObservable: Observable<boolean>;
  77694. /**
  77695. * constructs a new background remover module
  77696. * @param _xrSessionManager the session manager for this module
  77697. * @param options read-only options to be used in this module
  77698. */
  77699. constructor(_xrSessionManager: WebXRSessionManager,
  77700. /**
  77701. * read-only options to be used in this module
  77702. */
  77703. options?: IWebXRBackgroundRemoverOptions);
  77704. /**
  77705. * attach this feature
  77706. * Will usually be called by the features manager
  77707. *
  77708. * @returns true if successful.
  77709. */
  77710. attach(): boolean;
  77711. /**
  77712. * detach this feature.
  77713. * Will usually be called by the features manager
  77714. *
  77715. * @returns true if successful.
  77716. */
  77717. detach(): boolean;
  77718. /**
  77719. * Dispose this feature and all of the resources attached
  77720. */
  77721. dispose(): void;
  77722. protected _onXRFrame(_xrFrame: XRFrame): void;
  77723. private _setBackgroundState;
  77724. }
  77725. }
  77726. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77727. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77728. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77729. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77730. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77731. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77732. import { Nullable } from "babylonjs/types";
  77733. /**
  77734. * Options for the controller physics feature
  77735. */
  77736. export class IWebXRControllerPhysicsOptions {
  77737. /**
  77738. * Should the headset get its own impostor
  77739. */
  77740. enableHeadsetImpostor?: boolean;
  77741. /**
  77742. * Optional parameters for the headset impostor
  77743. */
  77744. headsetImpostorParams?: {
  77745. /**
  77746. * The type of impostor to create. Default is sphere
  77747. */
  77748. impostorType: number;
  77749. /**
  77750. * the size of the impostor. Defaults to 10cm
  77751. */
  77752. impostorSize?: number | {
  77753. width: number;
  77754. height: number;
  77755. depth: number;
  77756. };
  77757. /**
  77758. * Friction definitions
  77759. */
  77760. friction?: number;
  77761. /**
  77762. * Restitution
  77763. */
  77764. restitution?: number;
  77765. };
  77766. /**
  77767. * The physics properties of the future impostors
  77768. */
  77769. physicsProperties?: {
  77770. /**
  77771. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77772. * Note that this requires a physics engine that supports mesh impostors!
  77773. */
  77774. useControllerMesh?: boolean;
  77775. /**
  77776. * The type of impostor to create. Default is sphere
  77777. */
  77778. impostorType?: number;
  77779. /**
  77780. * the size of the impostor. Defaults to 10cm
  77781. */
  77782. impostorSize?: number | {
  77783. width: number;
  77784. height: number;
  77785. depth: number;
  77786. };
  77787. /**
  77788. * Friction definitions
  77789. */
  77790. friction?: number;
  77791. /**
  77792. * Restitution
  77793. */
  77794. restitution?: number;
  77795. };
  77796. /**
  77797. * the xr input to use with this pointer selection
  77798. */
  77799. xrInput: WebXRInput;
  77800. }
  77801. /**
  77802. * Add physics impostor to your webxr controllers,
  77803. * including naive calculation of their linear and angular velocity
  77804. */
  77805. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77806. private readonly _options;
  77807. private _attachController;
  77808. private _controllers;
  77809. private _debugMode;
  77810. private _delta;
  77811. private _headsetImpostor?;
  77812. private _headsetMesh?;
  77813. private _lastTimestamp;
  77814. private _tmpQuaternion;
  77815. private _tmpVector;
  77816. /**
  77817. * The module's name
  77818. */
  77819. static readonly Name: string;
  77820. /**
  77821. * The (Babylon) version of this module.
  77822. * This is an integer representing the implementation version.
  77823. * This number does not correspond to the webxr specs version
  77824. */
  77825. static readonly Version: number;
  77826. /**
  77827. * Construct a new Controller Physics Feature
  77828. * @param _xrSessionManager the corresponding xr session manager
  77829. * @param _options options to create this feature with
  77830. */
  77831. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77832. /**
  77833. * @hidden
  77834. * enable debugging - will show console outputs and the impostor mesh
  77835. */
  77836. _enablePhysicsDebug(): void;
  77837. /**
  77838. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77839. * @param xrController the controller to add
  77840. */
  77841. addController(xrController: WebXRInputSource): void;
  77842. /**
  77843. * attach this feature
  77844. * Will usually be called by the features manager
  77845. *
  77846. * @returns true if successful.
  77847. */
  77848. attach(): boolean;
  77849. /**
  77850. * detach this feature.
  77851. * Will usually be called by the features manager
  77852. *
  77853. * @returns true if successful.
  77854. */
  77855. detach(): boolean;
  77856. /**
  77857. * Get the headset impostor, if enabled
  77858. * @returns the impostor
  77859. */
  77860. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77861. /**
  77862. * Get the physics impostor of a specific controller.
  77863. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77864. * @param controller the controller or the controller id of which to get the impostor
  77865. * @returns the impostor or null
  77866. */
  77867. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77868. /**
  77869. * Update the physics properties provided in the constructor
  77870. * @param newProperties the new properties object
  77871. */
  77872. setPhysicsProperties(newProperties: {
  77873. impostorType?: number;
  77874. impostorSize?: number | {
  77875. width: number;
  77876. height: number;
  77877. depth: number;
  77878. };
  77879. friction?: number;
  77880. restitution?: number;
  77881. }): void;
  77882. protected _onXRFrame(_xrFrame: any): void;
  77883. private _detachController;
  77884. }
  77885. }
  77886. declare module "babylonjs/XR/features/index" {
  77887. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77888. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77889. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77890. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77891. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77892. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77893. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77894. export * from "babylonjs/XR/features/WebXRHitTest";
  77895. }
  77896. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77897. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77899. import { Scene } from "babylonjs/scene";
  77900. /**
  77901. * The motion controller class for all microsoft mixed reality controllers
  77902. */
  77903. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77904. protected readonly _mapping: {
  77905. defaultButton: {
  77906. valueNodeName: string;
  77907. unpressedNodeName: string;
  77908. pressedNodeName: string;
  77909. };
  77910. defaultAxis: {
  77911. valueNodeName: string;
  77912. minNodeName: string;
  77913. maxNodeName: string;
  77914. };
  77915. buttons: {
  77916. "xr-standard-trigger": {
  77917. rootNodeName: string;
  77918. componentProperty: string;
  77919. states: string[];
  77920. };
  77921. "xr-standard-squeeze": {
  77922. rootNodeName: string;
  77923. componentProperty: string;
  77924. states: string[];
  77925. };
  77926. "xr-standard-touchpad": {
  77927. rootNodeName: string;
  77928. labelAnchorNodeName: string;
  77929. touchPointNodeName: string;
  77930. };
  77931. "xr-standard-thumbstick": {
  77932. rootNodeName: string;
  77933. componentProperty: string;
  77934. states: string[];
  77935. };
  77936. };
  77937. axes: {
  77938. "xr-standard-touchpad": {
  77939. "x-axis": {
  77940. rootNodeName: string;
  77941. };
  77942. "y-axis": {
  77943. rootNodeName: string;
  77944. };
  77945. };
  77946. "xr-standard-thumbstick": {
  77947. "x-axis": {
  77948. rootNodeName: string;
  77949. };
  77950. "y-axis": {
  77951. rootNodeName: string;
  77952. };
  77953. };
  77954. };
  77955. };
  77956. /**
  77957. * The base url used to load the left and right controller models
  77958. */
  77959. static MODEL_BASE_URL: string;
  77960. /**
  77961. * The name of the left controller model file
  77962. */
  77963. static MODEL_LEFT_FILENAME: string;
  77964. /**
  77965. * The name of the right controller model file
  77966. */
  77967. static MODEL_RIGHT_FILENAME: string;
  77968. profileId: string;
  77969. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77970. protected _getFilenameAndPath(): {
  77971. filename: string;
  77972. path: string;
  77973. };
  77974. protected _getModelLoadingConstraints(): boolean;
  77975. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77976. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77977. protected _updateModel(): void;
  77978. }
  77979. }
  77980. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77981. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77983. import { Scene } from "babylonjs/scene";
  77984. /**
  77985. * The motion controller class for oculus touch (quest, rift).
  77986. * This class supports legacy mapping as well the standard xr mapping
  77987. */
  77988. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77989. private _forceLegacyControllers;
  77990. private _modelRootNode;
  77991. /**
  77992. * The base url used to load the left and right controller models
  77993. */
  77994. static MODEL_BASE_URL: string;
  77995. /**
  77996. * The name of the left controller model file
  77997. */
  77998. static MODEL_LEFT_FILENAME: string;
  77999. /**
  78000. * The name of the right controller model file
  78001. */
  78002. static MODEL_RIGHT_FILENAME: string;
  78003. /**
  78004. * Base Url for the Quest controller model.
  78005. */
  78006. static QUEST_MODEL_BASE_URL: string;
  78007. profileId: string;
  78008. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78009. protected _getFilenameAndPath(): {
  78010. filename: string;
  78011. path: string;
  78012. };
  78013. protected _getModelLoadingConstraints(): boolean;
  78014. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78015. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78016. protected _updateModel(): void;
  78017. /**
  78018. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78019. * between the touch and touch 2.
  78020. */
  78021. private _isQuest;
  78022. }
  78023. }
  78024. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78025. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78026. import { Scene } from "babylonjs/scene";
  78027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78028. /**
  78029. * The motion controller class for the standard HTC-Vive controllers
  78030. */
  78031. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78032. private _modelRootNode;
  78033. /**
  78034. * The base url used to load the left and right controller models
  78035. */
  78036. static MODEL_BASE_URL: string;
  78037. /**
  78038. * File name for the controller model.
  78039. */
  78040. static MODEL_FILENAME: string;
  78041. profileId: string;
  78042. /**
  78043. * Create a new Vive motion controller object
  78044. * @param scene the scene to use to create this controller
  78045. * @param gamepadObject the corresponding gamepad object
  78046. * @param handedness the handedness of the controller
  78047. */
  78048. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78049. protected _getFilenameAndPath(): {
  78050. filename: string;
  78051. path: string;
  78052. };
  78053. protected _getModelLoadingConstraints(): boolean;
  78054. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78055. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78056. protected _updateModel(): void;
  78057. }
  78058. }
  78059. declare module "babylonjs/XR/motionController/index" {
  78060. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78061. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78062. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78063. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78064. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78065. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78066. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78067. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78068. }
  78069. declare module "babylonjs/XR/index" {
  78070. export * from "babylonjs/XR/webXRCamera";
  78071. export * from "babylonjs/XR/webXREnterExitUI";
  78072. export * from "babylonjs/XR/webXRExperienceHelper";
  78073. export * from "babylonjs/XR/webXRInput";
  78074. export * from "babylonjs/XR/webXRInputSource";
  78075. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78076. export * from "babylonjs/XR/webXRTypes";
  78077. export * from "babylonjs/XR/webXRSessionManager";
  78078. export * from "babylonjs/XR/webXRDefaultExperience";
  78079. export * from "babylonjs/XR/webXRFeaturesManager";
  78080. export * from "babylonjs/XR/features/index";
  78081. export * from "babylonjs/XR/motionController/index";
  78082. }
  78083. declare module "babylonjs/index" {
  78084. export * from "babylonjs/abstractScene";
  78085. export * from "babylonjs/Actions/index";
  78086. export * from "babylonjs/Animations/index";
  78087. export * from "babylonjs/assetContainer";
  78088. export * from "babylonjs/Audio/index";
  78089. export * from "babylonjs/Behaviors/index";
  78090. export * from "babylonjs/Bones/index";
  78091. export * from "babylonjs/Cameras/index";
  78092. export * from "babylonjs/Collisions/index";
  78093. export * from "babylonjs/Culling/index";
  78094. export * from "babylonjs/Debug/index";
  78095. export * from "babylonjs/DeviceInput/index";
  78096. export * from "babylonjs/Engines/index";
  78097. export * from "babylonjs/Events/index";
  78098. export * from "babylonjs/Gamepads/index";
  78099. export * from "babylonjs/Gizmos/index";
  78100. export * from "babylonjs/Helpers/index";
  78101. export * from "babylonjs/Instrumentation/index";
  78102. export * from "babylonjs/Layers/index";
  78103. export * from "babylonjs/LensFlares/index";
  78104. export * from "babylonjs/Lights/index";
  78105. export * from "babylonjs/Loading/index";
  78106. export * from "babylonjs/Materials/index";
  78107. export * from "babylonjs/Maths/index";
  78108. export * from "babylonjs/Meshes/index";
  78109. export * from "babylonjs/Morph/index";
  78110. export * from "babylonjs/Navigation/index";
  78111. export * from "babylonjs/node";
  78112. export * from "babylonjs/Offline/index";
  78113. export * from "babylonjs/Particles/index";
  78114. export * from "babylonjs/Physics/index";
  78115. export * from "babylonjs/PostProcesses/index";
  78116. export * from "babylonjs/Probes/index";
  78117. export * from "babylonjs/Rendering/index";
  78118. export * from "babylonjs/scene";
  78119. export * from "babylonjs/sceneComponent";
  78120. export * from "babylonjs/Sprites/index";
  78121. export * from "babylonjs/States/index";
  78122. export * from "babylonjs/Misc/index";
  78123. export * from "babylonjs/XR/index";
  78124. export * from "babylonjs/types";
  78125. }
  78126. declare module "babylonjs/Animations/pathCursor" {
  78127. import { Vector3 } from "babylonjs/Maths/math.vector";
  78128. import { Path2 } from "babylonjs/Maths/math.path";
  78129. /**
  78130. * A cursor which tracks a point on a path
  78131. */
  78132. export class PathCursor {
  78133. private path;
  78134. /**
  78135. * Stores path cursor callbacks for when an onchange event is triggered
  78136. */
  78137. private _onchange;
  78138. /**
  78139. * The value of the path cursor
  78140. */
  78141. value: number;
  78142. /**
  78143. * The animation array of the path cursor
  78144. */
  78145. animations: Animation[];
  78146. /**
  78147. * Initializes the path cursor
  78148. * @param path The path to track
  78149. */
  78150. constructor(path: Path2);
  78151. /**
  78152. * Gets the cursor point on the path
  78153. * @returns A point on the path cursor at the cursor location
  78154. */
  78155. getPoint(): Vector3;
  78156. /**
  78157. * Moves the cursor ahead by the step amount
  78158. * @param step The amount to move the cursor forward
  78159. * @returns This path cursor
  78160. */
  78161. moveAhead(step?: number): PathCursor;
  78162. /**
  78163. * Moves the cursor behind by the step amount
  78164. * @param step The amount to move the cursor back
  78165. * @returns This path cursor
  78166. */
  78167. moveBack(step?: number): PathCursor;
  78168. /**
  78169. * Moves the cursor by the step amount
  78170. * If the step amount is greater than one, an exception is thrown
  78171. * @param step The amount to move the cursor
  78172. * @returns This path cursor
  78173. */
  78174. move(step: number): PathCursor;
  78175. /**
  78176. * Ensures that the value is limited between zero and one
  78177. * @returns This path cursor
  78178. */
  78179. private ensureLimits;
  78180. /**
  78181. * Runs onchange callbacks on change (used by the animation engine)
  78182. * @returns This path cursor
  78183. */
  78184. private raiseOnChange;
  78185. /**
  78186. * Executes a function on change
  78187. * @param f A path cursor onchange callback
  78188. * @returns This path cursor
  78189. */
  78190. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78191. }
  78192. }
  78193. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78194. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78195. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78196. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78197. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78198. }
  78199. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78200. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78201. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78202. }
  78203. declare module "babylonjs/Engines/Processors/index" {
  78204. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78205. export * from "babylonjs/Engines/Processors/Expressions/index";
  78206. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78207. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78208. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78209. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78210. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78211. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78212. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78213. }
  78214. declare module "babylonjs/Legacy/legacy" {
  78215. import * as Babylon from "babylonjs/index";
  78216. export * from "babylonjs/index";
  78217. }
  78218. declare module "babylonjs/Shaders/blur.fragment" {
  78219. /** @hidden */
  78220. export var blurPixelShader: {
  78221. name: string;
  78222. shader: string;
  78223. };
  78224. }
  78225. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78226. /** @hidden */
  78227. export var pointCloudVertexDeclaration: {
  78228. name: string;
  78229. shader: string;
  78230. };
  78231. }
  78232. declare module "babylonjs" {
  78233. export * from "babylonjs/Legacy/legacy";
  78234. }
  78235. declare module BABYLON {
  78236. /** Alias type for value that can be null */
  78237. export type Nullable<T> = T | null;
  78238. /**
  78239. * Alias type for number that are floats
  78240. * @ignorenaming
  78241. */
  78242. export type float = number;
  78243. /**
  78244. * Alias type for number that are doubles.
  78245. * @ignorenaming
  78246. */
  78247. export type double = number;
  78248. /**
  78249. * Alias type for number that are integer
  78250. * @ignorenaming
  78251. */
  78252. export type int = number;
  78253. /** Alias type for number array or Float32Array */
  78254. export type FloatArray = number[] | Float32Array;
  78255. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78256. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78257. /**
  78258. * Alias for types that can be used by a Buffer or VertexBuffer.
  78259. */
  78260. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78261. /**
  78262. * Alias type for primitive types
  78263. * @ignorenaming
  78264. */
  78265. type Primitive = undefined | null | boolean | string | number | Function;
  78266. /**
  78267. * Type modifier to make all the properties of an object Readonly
  78268. */
  78269. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78270. /**
  78271. * Type modifier to make all the properties of an object Readonly recursively
  78272. */
  78273. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78274. /**
  78275. * Type modifier to make object properties readonly.
  78276. */
  78277. export type DeepImmutableObject<T> = {
  78278. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78279. };
  78280. /** @hidden */
  78281. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78282. }
  78283. }
  78284. declare module BABYLON {
  78285. /**
  78286. * A class serves as a medium between the observable and its observers
  78287. */
  78288. export class EventState {
  78289. /**
  78290. * Create a new EventState
  78291. * @param mask defines the mask associated with this state
  78292. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78293. * @param target defines the original target of the state
  78294. * @param currentTarget defines the current target of the state
  78295. */
  78296. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78297. /**
  78298. * Initialize the current event state
  78299. * @param mask defines the mask associated with this state
  78300. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78301. * @param target defines the original target of the state
  78302. * @param currentTarget defines the current target of the state
  78303. * @returns the current event state
  78304. */
  78305. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78306. /**
  78307. * An Observer can set this property to true to prevent subsequent observers of being notified
  78308. */
  78309. skipNextObservers: boolean;
  78310. /**
  78311. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78312. */
  78313. mask: number;
  78314. /**
  78315. * The object that originally notified the event
  78316. */
  78317. target?: any;
  78318. /**
  78319. * The current object in the bubbling phase
  78320. */
  78321. currentTarget?: any;
  78322. /**
  78323. * This will be populated with the return value of the last function that was executed.
  78324. * If it is the first function in the callback chain it will be the event data.
  78325. */
  78326. lastReturnValue?: any;
  78327. }
  78328. /**
  78329. * Represent an Observer registered to a given Observable object.
  78330. */
  78331. export class Observer<T> {
  78332. /**
  78333. * Defines the callback to call when the observer is notified
  78334. */
  78335. callback: (eventData: T, eventState: EventState) => void;
  78336. /**
  78337. * Defines the mask of the observer (used to filter notifications)
  78338. */
  78339. mask: number;
  78340. /**
  78341. * Defines the current scope used to restore the JS context
  78342. */
  78343. scope: any;
  78344. /** @hidden */
  78345. _willBeUnregistered: boolean;
  78346. /**
  78347. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78348. */
  78349. unregisterOnNextCall: boolean;
  78350. /**
  78351. * Creates a new observer
  78352. * @param callback defines the callback to call when the observer is notified
  78353. * @param mask defines the mask of the observer (used to filter notifications)
  78354. * @param scope defines the current scope used to restore the JS context
  78355. */
  78356. constructor(
  78357. /**
  78358. * Defines the callback to call when the observer is notified
  78359. */
  78360. callback: (eventData: T, eventState: EventState) => void,
  78361. /**
  78362. * Defines the mask of the observer (used to filter notifications)
  78363. */
  78364. mask: number,
  78365. /**
  78366. * Defines the current scope used to restore the JS context
  78367. */
  78368. scope?: any);
  78369. }
  78370. /**
  78371. * Represent a list of observers registered to multiple Observables object.
  78372. */
  78373. export class MultiObserver<T> {
  78374. private _observers;
  78375. private _observables;
  78376. /**
  78377. * Release associated resources
  78378. */
  78379. dispose(): void;
  78380. /**
  78381. * Raise a callback when one of the observable will notify
  78382. * @param observables defines a list of observables to watch
  78383. * @param callback defines the callback to call on notification
  78384. * @param mask defines the mask used to filter notifications
  78385. * @param scope defines the current scope used to restore the JS context
  78386. * @returns the new MultiObserver
  78387. */
  78388. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78389. }
  78390. /**
  78391. * The Observable class is a simple implementation of the Observable pattern.
  78392. *
  78393. * 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.
  78394. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78395. * 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).
  78396. * 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.
  78397. */
  78398. export class Observable<T> {
  78399. private _observers;
  78400. private _eventState;
  78401. private _onObserverAdded;
  78402. /**
  78403. * Gets the list of observers
  78404. */
  78405. get observers(): Array<Observer<T>>;
  78406. /**
  78407. * Creates a new observable
  78408. * @param onObserverAdded defines a callback to call when a new observer is added
  78409. */
  78410. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78411. /**
  78412. * Create a new Observer with the specified callback
  78413. * @param callback the callback that will be executed for that Observer
  78414. * @param mask the mask used to filter observers
  78415. * @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.
  78416. * @param scope optional scope for the callback to be called from
  78417. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78418. * @returns the new observer created for the callback
  78419. */
  78420. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78421. /**
  78422. * Create a new Observer with the specified callback and unregisters after the next notification
  78423. * @param callback the callback that will be executed for that Observer
  78424. * @returns the new observer created for the callback
  78425. */
  78426. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78427. /**
  78428. * Remove an Observer from the Observable object
  78429. * @param observer the instance of the Observer to remove
  78430. * @returns false if it doesn't belong to this Observable
  78431. */
  78432. remove(observer: Nullable<Observer<T>>): boolean;
  78433. /**
  78434. * Remove a callback from the Observable object
  78435. * @param callback the callback to remove
  78436. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78437. * @returns false if it doesn't belong to this Observable
  78438. */
  78439. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78440. private _deferUnregister;
  78441. private _remove;
  78442. /**
  78443. * Moves the observable to the top of the observer list making it get called first when notified
  78444. * @param observer the observer to move
  78445. */
  78446. makeObserverTopPriority(observer: Observer<T>): void;
  78447. /**
  78448. * Moves the observable to the bottom of the observer list making it get called last when notified
  78449. * @param observer the observer to move
  78450. */
  78451. makeObserverBottomPriority(observer: Observer<T>): void;
  78452. /**
  78453. * Notify all Observers by calling their respective callback with the given data
  78454. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78455. * @param eventData defines the data to send to all observers
  78456. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78457. * @param target defines the original target of the state
  78458. * @param currentTarget defines the current target of the state
  78459. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78460. */
  78461. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78462. /**
  78463. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78464. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78465. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78466. * and it is crucial that all callbacks will be executed.
  78467. * The order of the callbacks is kept, callbacks are not executed parallel.
  78468. *
  78469. * @param eventData The data to be sent to each callback
  78470. * @param mask is used to filter observers defaults to -1
  78471. * @param target defines the callback target (see EventState)
  78472. * @param currentTarget defines he current object in the bubbling phase
  78473. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78474. */
  78475. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78476. /**
  78477. * Notify a specific observer
  78478. * @param observer defines the observer to notify
  78479. * @param eventData defines the data to be sent to each callback
  78480. * @param mask is used to filter observers defaults to -1
  78481. */
  78482. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78483. /**
  78484. * Gets a boolean indicating if the observable has at least one observer
  78485. * @returns true is the Observable has at least one Observer registered
  78486. */
  78487. hasObservers(): boolean;
  78488. /**
  78489. * Clear the list of observers
  78490. */
  78491. clear(): void;
  78492. /**
  78493. * Clone the current observable
  78494. * @returns a new observable
  78495. */
  78496. clone(): Observable<T>;
  78497. /**
  78498. * Does this observable handles observer registered with a given mask
  78499. * @param mask defines the mask to be tested
  78500. * @return whether or not one observer registered with the given mask is handeled
  78501. **/
  78502. hasSpecificMask(mask?: number): boolean;
  78503. }
  78504. }
  78505. declare module BABYLON {
  78506. /**
  78507. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78508. * Babylon.js
  78509. */
  78510. export class DomManagement {
  78511. /**
  78512. * Checks if the window object exists
  78513. * @returns true if the window object exists
  78514. */
  78515. static IsWindowObjectExist(): boolean;
  78516. /**
  78517. * Checks if the navigator object exists
  78518. * @returns true if the navigator object exists
  78519. */
  78520. static IsNavigatorAvailable(): boolean;
  78521. /**
  78522. * Check if the document object exists
  78523. * @returns true if the document object exists
  78524. */
  78525. static IsDocumentAvailable(): boolean;
  78526. /**
  78527. * Extracts text content from a DOM element hierarchy
  78528. * @param element defines the root element
  78529. * @returns a string
  78530. */
  78531. static GetDOMTextContent(element: HTMLElement): string;
  78532. }
  78533. }
  78534. declare module BABYLON {
  78535. /**
  78536. * Logger used througouht the application to allow configuration of
  78537. * the log level required for the messages.
  78538. */
  78539. export class Logger {
  78540. /**
  78541. * No log
  78542. */
  78543. static readonly NoneLogLevel: number;
  78544. /**
  78545. * Only message logs
  78546. */
  78547. static readonly MessageLogLevel: number;
  78548. /**
  78549. * Only warning logs
  78550. */
  78551. static readonly WarningLogLevel: number;
  78552. /**
  78553. * Only error logs
  78554. */
  78555. static readonly ErrorLogLevel: number;
  78556. /**
  78557. * All logs
  78558. */
  78559. static readonly AllLogLevel: number;
  78560. private static _LogCache;
  78561. /**
  78562. * Gets a value indicating the number of loading errors
  78563. * @ignorenaming
  78564. */
  78565. static errorsCount: number;
  78566. /**
  78567. * Callback called when a new log is added
  78568. */
  78569. static OnNewCacheEntry: (entry: string) => void;
  78570. private static _AddLogEntry;
  78571. private static _FormatMessage;
  78572. private static _LogDisabled;
  78573. private static _LogEnabled;
  78574. private static _WarnDisabled;
  78575. private static _WarnEnabled;
  78576. private static _ErrorDisabled;
  78577. private static _ErrorEnabled;
  78578. /**
  78579. * Log a message to the console
  78580. */
  78581. static Log: (message: string) => void;
  78582. /**
  78583. * Write a warning message to the console
  78584. */
  78585. static Warn: (message: string) => void;
  78586. /**
  78587. * Write an error message to the console
  78588. */
  78589. static Error: (message: string) => void;
  78590. /**
  78591. * Gets current log cache (list of logs)
  78592. */
  78593. static get LogCache(): string;
  78594. /**
  78595. * Clears the log cache
  78596. */
  78597. static ClearLogCache(): void;
  78598. /**
  78599. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78600. */
  78601. static set LogLevels(level: number);
  78602. }
  78603. }
  78604. declare module BABYLON {
  78605. /** @hidden */
  78606. export class _TypeStore {
  78607. /** @hidden */
  78608. static RegisteredTypes: {
  78609. [key: string]: Object;
  78610. };
  78611. /** @hidden */
  78612. static GetClass(fqdn: string): any;
  78613. }
  78614. }
  78615. declare module BABYLON {
  78616. /**
  78617. * Helper to manipulate strings
  78618. */
  78619. export class StringTools {
  78620. /**
  78621. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78622. * @param str Source string
  78623. * @param suffix Suffix to search for in the source string
  78624. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78625. */
  78626. static EndsWith(str: string, suffix: string): boolean;
  78627. /**
  78628. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78629. * @param str Source string
  78630. * @param suffix Suffix to search for in the source string
  78631. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78632. */
  78633. static StartsWith(str: string, suffix: string): boolean;
  78634. /**
  78635. * Decodes a buffer into a string
  78636. * @param buffer The buffer to decode
  78637. * @returns The decoded string
  78638. */
  78639. static Decode(buffer: Uint8Array | Uint16Array): string;
  78640. /**
  78641. * Encode a buffer to a base64 string
  78642. * @param buffer defines the buffer to encode
  78643. * @returns the encoded string
  78644. */
  78645. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78646. /**
  78647. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78648. * @param num the number to convert and pad
  78649. * @param length the expected length of the string
  78650. * @returns the padded string
  78651. */
  78652. static PadNumber(num: number, length: number): string;
  78653. }
  78654. }
  78655. declare module BABYLON {
  78656. /**
  78657. * Class containing a set of static utilities functions for deep copy.
  78658. */
  78659. export class DeepCopier {
  78660. /**
  78661. * Tries to copy an object by duplicating every property
  78662. * @param source defines the source object
  78663. * @param destination defines the target object
  78664. * @param doNotCopyList defines a list of properties to avoid
  78665. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78666. */
  78667. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78668. }
  78669. }
  78670. declare module BABYLON {
  78671. /**
  78672. * Class containing a set of static utilities functions for precision date
  78673. */
  78674. export class PrecisionDate {
  78675. /**
  78676. * Gets either window.performance.now() if supported or Date.now() else
  78677. */
  78678. static get Now(): number;
  78679. }
  78680. }
  78681. declare module BABYLON {
  78682. /** @hidden */
  78683. export class _DevTools {
  78684. static WarnImport(name: string): string;
  78685. }
  78686. }
  78687. declare module BABYLON {
  78688. /**
  78689. * Interface used to define the mechanism to get data from the network
  78690. */
  78691. export interface IWebRequest {
  78692. /**
  78693. * Returns client's response url
  78694. */
  78695. responseURL: string;
  78696. /**
  78697. * Returns client's status
  78698. */
  78699. status: number;
  78700. /**
  78701. * Returns client's status as a text
  78702. */
  78703. statusText: string;
  78704. }
  78705. }
  78706. declare module BABYLON {
  78707. /**
  78708. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78709. */
  78710. export class WebRequest implements IWebRequest {
  78711. private _xhr;
  78712. /**
  78713. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78714. * i.e. when loading files, where the server/service expects an Authorization header
  78715. */
  78716. static CustomRequestHeaders: {
  78717. [key: string]: string;
  78718. };
  78719. /**
  78720. * Add callback functions in this array to update all the requests before they get sent to the network
  78721. */
  78722. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78723. private _injectCustomRequestHeaders;
  78724. /**
  78725. * Gets or sets a function to be called when loading progress changes
  78726. */
  78727. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78728. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78729. /**
  78730. * Returns client's state
  78731. */
  78732. get readyState(): number;
  78733. /**
  78734. * Returns client's status
  78735. */
  78736. get status(): number;
  78737. /**
  78738. * Returns client's status as a text
  78739. */
  78740. get statusText(): string;
  78741. /**
  78742. * Returns client's response
  78743. */
  78744. get response(): any;
  78745. /**
  78746. * Returns client's response url
  78747. */
  78748. get responseURL(): string;
  78749. /**
  78750. * Returns client's response as text
  78751. */
  78752. get responseText(): string;
  78753. /**
  78754. * Gets or sets the expected response type
  78755. */
  78756. get responseType(): XMLHttpRequestResponseType;
  78757. set responseType(value: XMLHttpRequestResponseType);
  78758. /** @hidden */
  78759. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78760. /** @hidden */
  78761. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78762. /**
  78763. * Cancels any network activity
  78764. */
  78765. abort(): void;
  78766. /**
  78767. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78768. * @param body defines an optional request body
  78769. */
  78770. send(body?: Document | BodyInit | null): void;
  78771. /**
  78772. * Sets the request method, request URL
  78773. * @param method defines the method to use (GET, POST, etc..)
  78774. * @param url defines the url to connect with
  78775. */
  78776. open(method: string, url: string): void;
  78777. /**
  78778. * Sets the value of a request header.
  78779. * @param name The name of the header whose value is to be set
  78780. * @param value The value to set as the body of the header
  78781. */
  78782. setRequestHeader(name: string, value: string): void;
  78783. /**
  78784. * Get the string containing the text of a particular header's value.
  78785. * @param name The name of the header
  78786. * @returns The string containing the text of the given header name
  78787. */
  78788. getResponseHeader(name: string): Nullable<string>;
  78789. }
  78790. }
  78791. declare module BABYLON {
  78792. /**
  78793. * File request interface
  78794. */
  78795. export interface IFileRequest {
  78796. /**
  78797. * Raised when the request is complete (success or error).
  78798. */
  78799. onCompleteObservable: Observable<IFileRequest>;
  78800. /**
  78801. * Aborts the request for a file.
  78802. */
  78803. abort: () => void;
  78804. }
  78805. }
  78806. declare module BABYLON {
  78807. /**
  78808. * Define options used to create a render target texture
  78809. */
  78810. export class RenderTargetCreationOptions {
  78811. /**
  78812. * Specifies is mipmaps must be generated
  78813. */
  78814. generateMipMaps?: boolean;
  78815. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78816. generateDepthBuffer?: boolean;
  78817. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78818. generateStencilBuffer?: boolean;
  78819. /** Defines texture type (int by default) */
  78820. type?: number;
  78821. /** Defines sampling mode (trilinear by default) */
  78822. samplingMode?: number;
  78823. /** Defines format (RGBA by default) */
  78824. format?: number;
  78825. }
  78826. }
  78827. declare module BABYLON {
  78828. /** Defines the cross module used constants to avoid circular dependncies */
  78829. export class Constants {
  78830. /** Defines that alpha blending is disabled */
  78831. static readonly ALPHA_DISABLE: number;
  78832. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78833. static readonly ALPHA_ADD: number;
  78834. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78835. static readonly ALPHA_COMBINE: number;
  78836. /** Defines that alpha blending is DEST - SRC * DEST */
  78837. static readonly ALPHA_SUBTRACT: number;
  78838. /** Defines that alpha blending is SRC * DEST */
  78839. static readonly ALPHA_MULTIPLY: number;
  78840. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78841. static readonly ALPHA_MAXIMIZED: number;
  78842. /** Defines that alpha blending is SRC + DEST */
  78843. static readonly ALPHA_ONEONE: number;
  78844. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78845. static readonly ALPHA_PREMULTIPLIED: number;
  78846. /**
  78847. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78848. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78849. */
  78850. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78851. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78852. static readonly ALPHA_INTERPOLATE: number;
  78853. /**
  78854. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78855. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78856. */
  78857. static readonly ALPHA_SCREENMODE: number;
  78858. /**
  78859. * Defines that alpha blending is SRC + DST
  78860. * Alpha will be set to SRC ALPHA + DST ALPHA
  78861. */
  78862. static readonly ALPHA_ONEONE_ONEONE: number;
  78863. /**
  78864. * Defines that alpha blending is SRC * DST ALPHA + DST
  78865. * Alpha will be set to 0
  78866. */
  78867. static readonly ALPHA_ALPHATOCOLOR: number;
  78868. /**
  78869. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78870. */
  78871. static readonly ALPHA_REVERSEONEMINUS: number;
  78872. /**
  78873. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78874. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78875. */
  78876. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78877. /**
  78878. * Defines that alpha blending is SRC + DST
  78879. * Alpha will be set to SRC ALPHA
  78880. */
  78881. static readonly ALPHA_ONEONE_ONEZERO: number;
  78882. /**
  78883. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78884. * Alpha will be set to DST ALPHA
  78885. */
  78886. static readonly ALPHA_EXCLUSION: number;
  78887. /** Defines that alpha blending equation a SUM */
  78888. static readonly ALPHA_EQUATION_ADD: number;
  78889. /** Defines that alpha blending equation a SUBSTRACTION */
  78890. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78891. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78892. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78893. /** Defines that alpha blending equation a MAX operation */
  78894. static readonly ALPHA_EQUATION_MAX: number;
  78895. /** Defines that alpha blending equation a MIN operation */
  78896. static readonly ALPHA_EQUATION_MIN: number;
  78897. /**
  78898. * Defines that alpha blending equation a DARKEN operation:
  78899. * It takes the min of the src and sums the alpha channels.
  78900. */
  78901. static readonly ALPHA_EQUATION_DARKEN: number;
  78902. /** Defines that the ressource is not delayed*/
  78903. static readonly DELAYLOADSTATE_NONE: number;
  78904. /** Defines that the ressource was successfully delay loaded */
  78905. static readonly DELAYLOADSTATE_LOADED: number;
  78906. /** Defines that the ressource is currently delay loading */
  78907. static readonly DELAYLOADSTATE_LOADING: number;
  78908. /** Defines that the ressource is delayed and has not started loading */
  78909. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78911. static readonly NEVER: number;
  78912. /** 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 */
  78913. static readonly ALWAYS: number;
  78914. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78915. static readonly LESS: number;
  78916. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78917. static readonly EQUAL: number;
  78918. /** 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 */
  78919. static readonly LEQUAL: number;
  78920. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78921. static readonly GREATER: number;
  78922. /** 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 */
  78923. static readonly GEQUAL: number;
  78924. /** 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 */
  78925. static readonly NOTEQUAL: number;
  78926. /** Passed to stencilOperation to specify that stencil value must be kept */
  78927. static readonly KEEP: number;
  78928. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78929. static readonly REPLACE: number;
  78930. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78931. static readonly INCR: number;
  78932. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78933. static readonly DECR: number;
  78934. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78935. static readonly INVERT: number;
  78936. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78937. static readonly INCR_WRAP: number;
  78938. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78939. static readonly DECR_WRAP: number;
  78940. /** Texture is not repeating outside of 0..1 UVs */
  78941. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78942. /** Texture is repeating outside of 0..1 UVs */
  78943. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78944. /** Texture is repeating and mirrored */
  78945. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78946. /** ALPHA */
  78947. static readonly TEXTUREFORMAT_ALPHA: number;
  78948. /** LUMINANCE */
  78949. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78950. /** LUMINANCE_ALPHA */
  78951. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78952. /** RGB */
  78953. static readonly TEXTUREFORMAT_RGB: number;
  78954. /** RGBA */
  78955. static readonly TEXTUREFORMAT_RGBA: number;
  78956. /** RED */
  78957. static readonly TEXTUREFORMAT_RED: number;
  78958. /** RED (2nd reference) */
  78959. static readonly TEXTUREFORMAT_R: number;
  78960. /** RG */
  78961. static readonly TEXTUREFORMAT_RG: number;
  78962. /** RED_INTEGER */
  78963. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78964. /** RED_INTEGER (2nd reference) */
  78965. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78966. /** RG_INTEGER */
  78967. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78968. /** RGB_INTEGER */
  78969. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78970. /** RGBA_INTEGER */
  78971. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78972. /** UNSIGNED_BYTE */
  78973. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78974. /** UNSIGNED_BYTE (2nd reference) */
  78975. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78976. /** FLOAT */
  78977. static readonly TEXTURETYPE_FLOAT: number;
  78978. /** HALF_FLOAT */
  78979. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78980. /** BYTE */
  78981. static readonly TEXTURETYPE_BYTE: number;
  78982. /** SHORT */
  78983. static readonly TEXTURETYPE_SHORT: number;
  78984. /** UNSIGNED_SHORT */
  78985. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78986. /** INT */
  78987. static readonly TEXTURETYPE_INT: number;
  78988. /** UNSIGNED_INT */
  78989. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78990. /** UNSIGNED_SHORT_4_4_4_4 */
  78991. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78992. /** UNSIGNED_SHORT_5_5_5_1 */
  78993. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78994. /** UNSIGNED_SHORT_5_6_5 */
  78995. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78996. /** UNSIGNED_INT_2_10_10_10_REV */
  78997. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78998. /** UNSIGNED_INT_24_8 */
  78999. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79000. /** UNSIGNED_INT_10F_11F_11F_REV */
  79001. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79002. /** UNSIGNED_INT_5_9_9_9_REV */
  79003. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79004. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79005. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79006. /** nearest is mag = nearest and min = nearest and no mip */
  79007. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79008. /** mag = nearest and min = nearest and mip = none */
  79009. static readonly TEXTURE_NEAREST_NEAREST: number;
  79010. /** Bilinear is mag = linear and min = linear and no mip */
  79011. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79012. /** mag = linear and min = linear and mip = none */
  79013. static readonly TEXTURE_LINEAR_LINEAR: number;
  79014. /** Trilinear is mag = linear and min = linear and mip = linear */
  79015. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79016. /** Trilinear is mag = linear and min = linear and mip = linear */
  79017. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79018. /** mag = nearest and min = nearest and mip = nearest */
  79019. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79020. /** mag = nearest and min = linear and mip = nearest */
  79021. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79022. /** mag = nearest and min = linear and mip = linear */
  79023. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79024. /** mag = nearest and min = linear and mip = none */
  79025. static readonly TEXTURE_NEAREST_LINEAR: number;
  79026. /** nearest is mag = nearest and min = nearest and mip = linear */
  79027. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79028. /** mag = linear and min = nearest and mip = nearest */
  79029. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79030. /** mag = linear and min = nearest and mip = linear */
  79031. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79032. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79033. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79034. /** mag = linear and min = nearest and mip = none */
  79035. static readonly TEXTURE_LINEAR_NEAREST: number;
  79036. /** Explicit coordinates mode */
  79037. static readonly TEXTURE_EXPLICIT_MODE: number;
  79038. /** Spherical coordinates mode */
  79039. static readonly TEXTURE_SPHERICAL_MODE: number;
  79040. /** Planar coordinates mode */
  79041. static readonly TEXTURE_PLANAR_MODE: number;
  79042. /** Cubic coordinates mode */
  79043. static readonly TEXTURE_CUBIC_MODE: number;
  79044. /** Projection coordinates mode */
  79045. static readonly TEXTURE_PROJECTION_MODE: number;
  79046. /** Skybox coordinates mode */
  79047. static readonly TEXTURE_SKYBOX_MODE: number;
  79048. /** Inverse Cubic coordinates mode */
  79049. static readonly TEXTURE_INVCUBIC_MODE: number;
  79050. /** Equirectangular coordinates mode */
  79051. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79052. /** Equirectangular Fixed coordinates mode */
  79053. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79054. /** Equirectangular Fixed Mirrored coordinates mode */
  79055. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79056. /** Offline (baking) quality for texture filtering */
  79057. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79058. /** High quality for texture filtering */
  79059. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79060. /** Medium quality for texture filtering */
  79061. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79062. /** Low quality for texture filtering */
  79063. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79064. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79065. static readonly SCALEMODE_FLOOR: number;
  79066. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79067. static readonly SCALEMODE_NEAREST: number;
  79068. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79069. static readonly SCALEMODE_CEILING: number;
  79070. /**
  79071. * The dirty texture flag value
  79072. */
  79073. static readonly MATERIAL_TextureDirtyFlag: number;
  79074. /**
  79075. * The dirty light flag value
  79076. */
  79077. static readonly MATERIAL_LightDirtyFlag: number;
  79078. /**
  79079. * The dirty fresnel flag value
  79080. */
  79081. static readonly MATERIAL_FresnelDirtyFlag: number;
  79082. /**
  79083. * The dirty attribute flag value
  79084. */
  79085. static readonly MATERIAL_AttributesDirtyFlag: number;
  79086. /**
  79087. * The dirty misc flag value
  79088. */
  79089. static readonly MATERIAL_MiscDirtyFlag: number;
  79090. /**
  79091. * The all dirty flag value
  79092. */
  79093. static readonly MATERIAL_AllDirtyFlag: number;
  79094. /**
  79095. * Returns the triangle fill mode
  79096. */
  79097. static readonly MATERIAL_TriangleFillMode: number;
  79098. /**
  79099. * Returns the wireframe mode
  79100. */
  79101. static readonly MATERIAL_WireFrameFillMode: number;
  79102. /**
  79103. * Returns the point fill mode
  79104. */
  79105. static readonly MATERIAL_PointFillMode: number;
  79106. /**
  79107. * Returns the point list draw mode
  79108. */
  79109. static readonly MATERIAL_PointListDrawMode: number;
  79110. /**
  79111. * Returns the line list draw mode
  79112. */
  79113. static readonly MATERIAL_LineListDrawMode: number;
  79114. /**
  79115. * Returns the line loop draw mode
  79116. */
  79117. static readonly MATERIAL_LineLoopDrawMode: number;
  79118. /**
  79119. * Returns the line strip draw mode
  79120. */
  79121. static readonly MATERIAL_LineStripDrawMode: number;
  79122. /**
  79123. * Returns the triangle strip draw mode
  79124. */
  79125. static readonly MATERIAL_TriangleStripDrawMode: number;
  79126. /**
  79127. * Returns the triangle fan draw mode
  79128. */
  79129. static readonly MATERIAL_TriangleFanDrawMode: number;
  79130. /**
  79131. * Stores the clock-wise side orientation
  79132. */
  79133. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79134. /**
  79135. * Stores the counter clock-wise side orientation
  79136. */
  79137. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79138. /**
  79139. * Nothing
  79140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79141. */
  79142. static readonly ACTION_NothingTrigger: number;
  79143. /**
  79144. * On pick
  79145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79146. */
  79147. static readonly ACTION_OnPickTrigger: number;
  79148. /**
  79149. * On left pick
  79150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79151. */
  79152. static readonly ACTION_OnLeftPickTrigger: number;
  79153. /**
  79154. * On right pick
  79155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79156. */
  79157. static readonly ACTION_OnRightPickTrigger: number;
  79158. /**
  79159. * On center pick
  79160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79161. */
  79162. static readonly ACTION_OnCenterPickTrigger: number;
  79163. /**
  79164. * On pick down
  79165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79166. */
  79167. static readonly ACTION_OnPickDownTrigger: number;
  79168. /**
  79169. * On double pick
  79170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79171. */
  79172. static readonly ACTION_OnDoublePickTrigger: number;
  79173. /**
  79174. * On pick up
  79175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79176. */
  79177. static readonly ACTION_OnPickUpTrigger: number;
  79178. /**
  79179. * On pick out.
  79180. * This trigger will only be raised if you also declared a OnPickDown
  79181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79182. */
  79183. static readonly ACTION_OnPickOutTrigger: number;
  79184. /**
  79185. * On long press
  79186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79187. */
  79188. static readonly ACTION_OnLongPressTrigger: number;
  79189. /**
  79190. * On pointer over
  79191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79192. */
  79193. static readonly ACTION_OnPointerOverTrigger: number;
  79194. /**
  79195. * On pointer out
  79196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79197. */
  79198. static readonly ACTION_OnPointerOutTrigger: number;
  79199. /**
  79200. * On every frame
  79201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79202. */
  79203. static readonly ACTION_OnEveryFrameTrigger: number;
  79204. /**
  79205. * On intersection enter
  79206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79207. */
  79208. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79209. /**
  79210. * On intersection exit
  79211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79212. */
  79213. static readonly ACTION_OnIntersectionExitTrigger: number;
  79214. /**
  79215. * On key down
  79216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79217. */
  79218. static readonly ACTION_OnKeyDownTrigger: number;
  79219. /**
  79220. * On key up
  79221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79222. */
  79223. static readonly ACTION_OnKeyUpTrigger: number;
  79224. /**
  79225. * Billboard mode will only apply to Y axis
  79226. */
  79227. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79228. /**
  79229. * Billboard mode will apply to all axes
  79230. */
  79231. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79232. /**
  79233. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79234. */
  79235. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79236. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79237. * Test order :
  79238. * Is the bounding sphere outside the frustum ?
  79239. * If not, are the bounding box vertices outside the frustum ?
  79240. * It not, then the cullable object is in the frustum.
  79241. */
  79242. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79243. /** Culling strategy : Bounding Sphere Only.
  79244. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79245. * It's also less accurate than the standard because some not visible objects can still be selected.
  79246. * Test : is the bounding sphere outside the frustum ?
  79247. * If not, then the cullable object is in the frustum.
  79248. */
  79249. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79250. /** Culling strategy : Optimistic Inclusion.
  79251. * This in an inclusion test first, then the standard exclusion test.
  79252. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79253. * 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.
  79254. * Anyway, it's as accurate as the standard strategy.
  79255. * Test :
  79256. * Is the cullable object bounding sphere center in the frustum ?
  79257. * If not, apply the default culling strategy.
  79258. */
  79259. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79260. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79261. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79262. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79263. * 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.
  79264. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79265. * Test :
  79266. * Is the cullable object bounding sphere center in the frustum ?
  79267. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79268. */
  79269. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79270. /**
  79271. * No logging while loading
  79272. */
  79273. static readonly SCENELOADER_NO_LOGGING: number;
  79274. /**
  79275. * Minimal logging while loading
  79276. */
  79277. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79278. /**
  79279. * Summary logging while loading
  79280. */
  79281. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79282. /**
  79283. * Detailled logging while loading
  79284. */
  79285. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79286. }
  79287. }
  79288. declare module BABYLON {
  79289. /**
  79290. * This represents the required contract to create a new type of texture loader.
  79291. */
  79292. export interface IInternalTextureLoader {
  79293. /**
  79294. * Defines wether the loader supports cascade loading the different faces.
  79295. */
  79296. supportCascades: boolean;
  79297. /**
  79298. * This returns if the loader support the current file information.
  79299. * @param extension defines the file extension of the file being loaded
  79300. * @param mimeType defines the optional mime type of the file being loaded
  79301. * @returns true if the loader can load the specified file
  79302. */
  79303. canLoad(extension: string, mimeType?: string): boolean;
  79304. /**
  79305. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79306. * @param data contains the texture data
  79307. * @param texture defines the BabylonJS internal texture
  79308. * @param createPolynomials will be true if polynomials have been requested
  79309. * @param onLoad defines the callback to trigger once the texture is ready
  79310. * @param onError defines the callback to trigger in case of error
  79311. */
  79312. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79313. /**
  79314. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79315. * @param data contains the texture data
  79316. * @param texture defines the BabylonJS internal texture
  79317. * @param callback defines the method to call once ready to upload
  79318. */
  79319. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79320. }
  79321. }
  79322. declare module BABYLON {
  79323. /**
  79324. * Class used to store and describe the pipeline context associated with an effect
  79325. */
  79326. export interface IPipelineContext {
  79327. /**
  79328. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79329. */
  79330. isAsync: boolean;
  79331. /**
  79332. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79333. */
  79334. isReady: boolean;
  79335. /** @hidden */
  79336. _getVertexShaderCode(): string | null;
  79337. /** @hidden */
  79338. _getFragmentShaderCode(): string | null;
  79339. /** @hidden */
  79340. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79341. }
  79342. }
  79343. declare module BABYLON {
  79344. /**
  79345. * Class used to store gfx data (like WebGLBuffer)
  79346. */
  79347. export class DataBuffer {
  79348. /**
  79349. * Gets or sets the number of objects referencing this buffer
  79350. */
  79351. references: number;
  79352. /** Gets or sets the size of the underlying buffer */
  79353. capacity: number;
  79354. /**
  79355. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79356. */
  79357. is32Bits: boolean;
  79358. /**
  79359. * Gets the underlying buffer
  79360. */
  79361. get underlyingResource(): any;
  79362. }
  79363. }
  79364. declare module BABYLON {
  79365. /** @hidden */
  79366. export interface IShaderProcessor {
  79367. attributeProcessor?: (attribute: string) => string;
  79368. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79369. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79370. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79371. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79372. lineProcessor?: (line: string, isFragment: boolean) => string;
  79373. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79374. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79375. }
  79376. }
  79377. declare module BABYLON {
  79378. /** @hidden */
  79379. export interface ProcessingOptions {
  79380. defines: string[];
  79381. indexParameters: any;
  79382. isFragment: boolean;
  79383. shouldUseHighPrecisionShader: boolean;
  79384. supportsUniformBuffers: boolean;
  79385. shadersRepository: string;
  79386. includesShadersStore: {
  79387. [key: string]: string;
  79388. };
  79389. processor?: IShaderProcessor;
  79390. version: string;
  79391. platformName: string;
  79392. lookForClosingBracketForUniformBuffer?: boolean;
  79393. }
  79394. }
  79395. declare module BABYLON {
  79396. /** @hidden */
  79397. export class ShaderCodeNode {
  79398. line: string;
  79399. children: ShaderCodeNode[];
  79400. additionalDefineKey?: string;
  79401. additionalDefineValue?: string;
  79402. isValid(preprocessors: {
  79403. [key: string]: string;
  79404. }): boolean;
  79405. process(preprocessors: {
  79406. [key: string]: string;
  79407. }, options: ProcessingOptions): string;
  79408. }
  79409. }
  79410. declare module BABYLON {
  79411. /** @hidden */
  79412. export class ShaderCodeCursor {
  79413. private _lines;
  79414. lineIndex: number;
  79415. get currentLine(): string;
  79416. get canRead(): boolean;
  79417. set lines(value: string[]);
  79418. }
  79419. }
  79420. declare module BABYLON {
  79421. /** @hidden */
  79422. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79423. process(preprocessors: {
  79424. [key: string]: string;
  79425. }, options: ProcessingOptions): string;
  79426. }
  79427. }
  79428. declare module BABYLON {
  79429. /** @hidden */
  79430. export class ShaderDefineExpression {
  79431. isTrue(preprocessors: {
  79432. [key: string]: string;
  79433. }): boolean;
  79434. private static _OperatorPriority;
  79435. private static _Stack;
  79436. static postfixToInfix(postfix: string[]): string;
  79437. static infixToPostfix(infix: string): string[];
  79438. }
  79439. }
  79440. declare module BABYLON {
  79441. /** @hidden */
  79442. export class ShaderCodeTestNode extends ShaderCodeNode {
  79443. testExpression: ShaderDefineExpression;
  79444. isValid(preprocessors: {
  79445. [key: string]: string;
  79446. }): boolean;
  79447. }
  79448. }
  79449. declare module BABYLON {
  79450. /** @hidden */
  79451. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79452. define: string;
  79453. not: boolean;
  79454. constructor(define: string, not?: boolean);
  79455. isTrue(preprocessors: {
  79456. [key: string]: string;
  79457. }): boolean;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /** @hidden */
  79462. export class ShaderDefineOrOperator 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 ShaderDefineAndOperator extends ShaderDefineExpression {
  79473. leftOperand: ShaderDefineExpression;
  79474. rightOperand: ShaderDefineExpression;
  79475. isTrue(preprocessors: {
  79476. [key: string]: string;
  79477. }): boolean;
  79478. }
  79479. }
  79480. declare module BABYLON {
  79481. /** @hidden */
  79482. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79483. define: string;
  79484. operand: string;
  79485. testValue: string;
  79486. constructor(define: string, operand: string, testValue: string);
  79487. isTrue(preprocessors: {
  79488. [key: string]: string;
  79489. }): boolean;
  79490. }
  79491. }
  79492. declare module BABYLON {
  79493. /**
  79494. * Class used to enable access to offline support
  79495. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79496. */
  79497. export interface IOfflineProvider {
  79498. /**
  79499. * Gets a boolean indicating if scene must be saved in the database
  79500. */
  79501. enableSceneOffline: boolean;
  79502. /**
  79503. * Gets a boolean indicating if textures must be saved in the database
  79504. */
  79505. enableTexturesOffline: boolean;
  79506. /**
  79507. * Open the offline support and make it available
  79508. * @param successCallback defines the callback to call on success
  79509. * @param errorCallback defines the callback to call on error
  79510. */
  79511. open(successCallback: () => void, errorCallback: () => void): void;
  79512. /**
  79513. * Loads an image from the offline support
  79514. * @param url defines the url to load from
  79515. * @param image defines the target DOM image
  79516. */
  79517. loadImage(url: string, image: HTMLImageElement): void;
  79518. /**
  79519. * Loads a file from offline support
  79520. * @param url defines the URL to load from
  79521. * @param sceneLoaded defines a callback to call on success
  79522. * @param progressCallBack defines a callback to call when progress changed
  79523. * @param errorCallback defines a callback to call on error
  79524. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79525. */
  79526. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79527. }
  79528. }
  79529. declare module BABYLON {
  79530. /**
  79531. * Class used to help managing file picking and drag'n'drop
  79532. * File Storage
  79533. */
  79534. export class FilesInputStore {
  79535. /**
  79536. * List of files ready to be loaded
  79537. */
  79538. static FilesToLoad: {
  79539. [key: string]: File;
  79540. };
  79541. }
  79542. }
  79543. declare module BABYLON {
  79544. /**
  79545. * Class used to define a retry strategy when error happens while loading assets
  79546. */
  79547. export class RetryStrategy {
  79548. /**
  79549. * Function used to defines an exponential back off strategy
  79550. * @param maxRetries defines the maximum number of retries (3 by default)
  79551. * @param baseInterval defines the interval between retries
  79552. * @returns the strategy function to use
  79553. */
  79554. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79555. }
  79556. }
  79557. declare module BABYLON {
  79558. /**
  79559. * @ignore
  79560. * Application error to support additional information when loading a file
  79561. */
  79562. export abstract class BaseError extends Error {
  79563. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79564. }
  79565. }
  79566. declare module BABYLON {
  79567. /** @ignore */
  79568. export class LoadFileError extends BaseError {
  79569. request?: WebRequest;
  79570. file?: File;
  79571. /**
  79572. * Creates a new LoadFileError
  79573. * @param message defines the message of the error
  79574. * @param request defines the optional web request
  79575. * @param file defines the optional file
  79576. */
  79577. constructor(message: string, object?: WebRequest | File);
  79578. }
  79579. /** @ignore */
  79580. export class RequestFileError extends BaseError {
  79581. request: WebRequest;
  79582. /**
  79583. * Creates a new LoadFileError
  79584. * @param message defines the message of the error
  79585. * @param request defines the optional web request
  79586. */
  79587. constructor(message: string, request: WebRequest);
  79588. }
  79589. /** @ignore */
  79590. export class ReadFileError extends BaseError {
  79591. file: File;
  79592. /**
  79593. * Creates a new ReadFileError
  79594. * @param message defines the message of the error
  79595. * @param file defines the optional file
  79596. */
  79597. constructor(message: string, file: File);
  79598. }
  79599. /**
  79600. * @hidden
  79601. */
  79602. export class FileTools {
  79603. /**
  79604. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79605. */
  79606. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79607. /**
  79608. * Gets or sets the base URL to use to load assets
  79609. */
  79610. static BaseUrl: string;
  79611. /**
  79612. * Default behaviour for cors in the application.
  79613. * It can be a string if the expected behavior is identical in the entire app.
  79614. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79615. */
  79616. static CorsBehavior: string | ((url: string | string[]) => string);
  79617. /**
  79618. * Gets or sets a function used to pre-process url before using them to load assets
  79619. */
  79620. static PreprocessUrl: (url: string) => string;
  79621. /**
  79622. * Removes unwanted characters from an url
  79623. * @param url defines the url to clean
  79624. * @returns the cleaned url
  79625. */
  79626. private static _CleanUrl;
  79627. /**
  79628. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79629. * @param url define the url we are trying
  79630. * @param element define the dom element where to configure the cors policy
  79631. */
  79632. static SetCorsBehavior(url: string | string[], element: {
  79633. crossOrigin: string | null;
  79634. }): void;
  79635. /**
  79636. * Loads an image as an HTMLImageElement.
  79637. * @param input url string, ArrayBuffer, or Blob to load
  79638. * @param onLoad callback called when the image successfully loads
  79639. * @param onError callback called when the image fails to load
  79640. * @param offlineProvider offline provider for caching
  79641. * @param mimeType optional mime type
  79642. * @returns the HTMLImageElement of the loaded image
  79643. */
  79644. 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>;
  79645. /**
  79646. * Reads a file from a File object
  79647. * @param file defines the file to load
  79648. * @param onSuccess defines the callback to call when data is loaded
  79649. * @param onProgress defines the callback to call during loading process
  79650. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79651. * @param onError defines the callback to call when an error occurs
  79652. * @returns a file request object
  79653. */
  79654. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79655. /**
  79656. * Loads a file from a url
  79657. * @param url url to load
  79658. * @param onSuccess callback called when the file successfully loads
  79659. * @param onProgress callback called while file is loading (if the server supports this mode)
  79660. * @param offlineProvider defines the offline provider for caching
  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. * @returns a file request object
  79664. */
  79665. 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;
  79666. /**
  79667. * Loads a file
  79668. * @param url url to load
  79669. * @param onSuccess callback called when the file successfully loads
  79670. * @param onProgress callback called while file is loading (if the server supports this mode)
  79671. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79672. * @param onError callback called when the file fails to load
  79673. * @param onOpened callback called when the web request is opened
  79674. * @returns a file request object
  79675. */
  79676. 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;
  79677. /**
  79678. * Checks if the loaded document was accessed via `file:`-Protocol.
  79679. * @returns boolean
  79680. */
  79681. static IsFileURL(): boolean;
  79682. }
  79683. }
  79684. declare module BABYLON {
  79685. /** @hidden */
  79686. export class ShaderProcessor {
  79687. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79688. private static _ProcessPrecision;
  79689. private static _ExtractOperation;
  79690. private static _BuildSubExpression;
  79691. private static _BuildExpression;
  79692. private static _MoveCursorWithinIf;
  79693. private static _MoveCursor;
  79694. private static _EvaluatePreProcessors;
  79695. private static _PreparePreProcessors;
  79696. private static _ProcessShaderConversion;
  79697. private static _ProcessIncludes;
  79698. /**
  79699. * Loads a file from a url
  79700. * @param url url to load
  79701. * @param onSuccess callback called when the file successfully loads
  79702. * @param onProgress callback called while file is loading (if the server supports this mode)
  79703. * @param offlineProvider defines the offline provider for caching
  79704. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79705. * @param onError callback called when the file fails to load
  79706. * @returns a file request object
  79707. * @hidden
  79708. */
  79709. 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;
  79710. }
  79711. }
  79712. declare module BABYLON {
  79713. /**
  79714. * @hidden
  79715. */
  79716. export interface IColor4Like {
  79717. r: float;
  79718. g: float;
  79719. b: float;
  79720. a: float;
  79721. }
  79722. /**
  79723. * @hidden
  79724. */
  79725. export interface IColor3Like {
  79726. r: float;
  79727. g: float;
  79728. b: float;
  79729. }
  79730. /**
  79731. * @hidden
  79732. */
  79733. export interface IVector4Like {
  79734. x: float;
  79735. y: float;
  79736. z: float;
  79737. w: float;
  79738. }
  79739. /**
  79740. * @hidden
  79741. */
  79742. export interface IVector3Like {
  79743. x: float;
  79744. y: float;
  79745. z: float;
  79746. }
  79747. /**
  79748. * @hidden
  79749. */
  79750. export interface IVector2Like {
  79751. x: float;
  79752. y: float;
  79753. }
  79754. /**
  79755. * @hidden
  79756. */
  79757. export interface IMatrixLike {
  79758. toArray(): DeepImmutable<Float32Array>;
  79759. updateFlag: int;
  79760. }
  79761. /**
  79762. * @hidden
  79763. */
  79764. export interface IViewportLike {
  79765. x: float;
  79766. y: float;
  79767. width: float;
  79768. height: float;
  79769. }
  79770. /**
  79771. * @hidden
  79772. */
  79773. export interface IPlaneLike {
  79774. normal: IVector3Like;
  79775. d: float;
  79776. normalize(): void;
  79777. }
  79778. }
  79779. declare module BABYLON {
  79780. /**
  79781. * Interface used to define common properties for effect fallbacks
  79782. */
  79783. export interface IEffectFallbacks {
  79784. /**
  79785. * Removes the defines that should be removed when falling back.
  79786. * @param currentDefines defines the current define statements for the shader.
  79787. * @param effect defines the current effect we try to compile
  79788. * @returns The resulting defines with defines of the current rank removed.
  79789. */
  79790. reduce(currentDefines: string, effect: Effect): string;
  79791. /**
  79792. * Removes the fallback from the bound mesh.
  79793. */
  79794. unBindMesh(): void;
  79795. /**
  79796. * Checks to see if more fallbacks are still availible.
  79797. */
  79798. hasMoreFallbacks: boolean;
  79799. }
  79800. }
  79801. declare module BABYLON {
  79802. /**
  79803. * Class used to evalaute queries containing `and` and `or` operators
  79804. */
  79805. export class AndOrNotEvaluator {
  79806. /**
  79807. * Evaluate a query
  79808. * @param query defines the query to evaluate
  79809. * @param evaluateCallback defines the callback used to filter result
  79810. * @returns true if the query matches
  79811. */
  79812. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79813. private static _HandleParenthesisContent;
  79814. private static _SimplifyNegation;
  79815. }
  79816. }
  79817. declare module BABYLON {
  79818. /**
  79819. * Class used to store custom tags
  79820. */
  79821. export class Tags {
  79822. /**
  79823. * Adds support for tags on the given object
  79824. * @param obj defines the object to use
  79825. */
  79826. static EnableFor(obj: any): void;
  79827. /**
  79828. * Removes tags support
  79829. * @param obj defines the object to use
  79830. */
  79831. static DisableFor(obj: any): void;
  79832. /**
  79833. * Gets a boolean indicating if the given object has tags
  79834. * @param obj defines the object to use
  79835. * @returns a boolean
  79836. */
  79837. static HasTags(obj: any): boolean;
  79838. /**
  79839. * Gets the tags available on a given object
  79840. * @param obj defines the object to use
  79841. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79842. * @returns the tags
  79843. */
  79844. static GetTags(obj: any, asString?: boolean): any;
  79845. /**
  79846. * Adds tags to an object
  79847. * @param obj defines the object to use
  79848. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79849. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79850. */
  79851. static AddTagsTo(obj: any, tagsString: string): void;
  79852. /**
  79853. * @hidden
  79854. */
  79855. static _AddTagTo(obj: any, tag: string): void;
  79856. /**
  79857. * Removes specific tags from a specific object
  79858. * @param obj defines the object to use
  79859. * @param tagsString defines the tags to remove
  79860. */
  79861. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79862. /**
  79863. * @hidden
  79864. */
  79865. static _RemoveTagFrom(obj: any, tag: string): void;
  79866. /**
  79867. * Defines if tags hosted on an object match a given query
  79868. * @param obj defines the object to use
  79869. * @param tagsQuery defines the tag query
  79870. * @returns a boolean
  79871. */
  79872. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79873. }
  79874. }
  79875. declare module BABYLON {
  79876. /**
  79877. * Scalar computation library
  79878. */
  79879. export class Scalar {
  79880. /**
  79881. * Two pi constants convenient for computation.
  79882. */
  79883. static TwoPi: number;
  79884. /**
  79885. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79886. * @param a number
  79887. * @param b number
  79888. * @param epsilon (default = 1.401298E-45)
  79889. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79890. */
  79891. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79892. /**
  79893. * Returns a string : the upper case translation of the number i to hexadecimal.
  79894. * @param i number
  79895. * @returns the upper case translation of the number i to hexadecimal.
  79896. */
  79897. static ToHex(i: number): string;
  79898. /**
  79899. * Returns -1 if value is negative and +1 is value is positive.
  79900. * @param value the value
  79901. * @returns the value itself if it's equal to zero.
  79902. */
  79903. static Sign(value: number): number;
  79904. /**
  79905. * Returns the value itself if it's between min and max.
  79906. * Returns min if the value is lower than min.
  79907. * Returns max if the value is greater than max.
  79908. * @param value the value to clmap
  79909. * @param min the min value to clamp to (default: 0)
  79910. * @param max the max value to clamp to (default: 1)
  79911. * @returns the clamped value
  79912. */
  79913. static Clamp(value: number, min?: number, max?: number): number;
  79914. /**
  79915. * the log2 of value.
  79916. * @param value the value to compute log2 of
  79917. * @returns the log2 of value.
  79918. */
  79919. static Log2(value: number): number;
  79920. /**
  79921. * Loops the value, so that it is never larger than length and never smaller than 0.
  79922. *
  79923. * This is similar to the modulo operator but it works with floating point numbers.
  79924. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79925. * With t = 5 and length = 2.5, the result would be 0.0.
  79926. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79927. * @param value the value
  79928. * @param length the length
  79929. * @returns the looped value
  79930. */
  79931. static Repeat(value: number, length: number): number;
  79932. /**
  79933. * Normalize the value between 0.0 and 1.0 using min and max values
  79934. * @param value value to normalize
  79935. * @param min max to normalize between
  79936. * @param max min to normalize between
  79937. * @returns the normalized value
  79938. */
  79939. static Normalize(value: number, min: number, max: number): number;
  79940. /**
  79941. * Denormalize the value from 0.0 and 1.0 using min and max values
  79942. * @param normalized value to denormalize
  79943. * @param min max to denormalize between
  79944. * @param max min to denormalize between
  79945. * @returns the denormalized value
  79946. */
  79947. static Denormalize(normalized: number, min: number, max: number): number;
  79948. /**
  79949. * Calculates the shortest difference between two given angles given in degrees.
  79950. * @param current current angle in degrees
  79951. * @param target target angle in degrees
  79952. * @returns the delta
  79953. */
  79954. static DeltaAngle(current: number, target: number): number;
  79955. /**
  79956. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79957. * @param tx value
  79958. * @param length length
  79959. * @returns The returned value will move back and forth between 0 and length
  79960. */
  79961. static PingPong(tx: number, length: number): number;
  79962. /**
  79963. * Interpolates between min and max with smoothing at the limits.
  79964. *
  79965. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79966. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79967. * @param from from
  79968. * @param to to
  79969. * @param tx value
  79970. * @returns the smooth stepped value
  79971. */
  79972. static SmoothStep(from: number, to: number, tx: number): number;
  79973. /**
  79974. * Moves a value current towards target.
  79975. *
  79976. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79977. * Negative values of maxDelta pushes the value away from target.
  79978. * @param current current value
  79979. * @param target target value
  79980. * @param maxDelta max distance to move
  79981. * @returns resulting value
  79982. */
  79983. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79984. /**
  79985. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79986. *
  79987. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79988. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79989. * @param current current value
  79990. * @param target target value
  79991. * @param maxDelta max distance to move
  79992. * @returns resulting angle
  79993. */
  79994. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79995. /**
  79996. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79997. * @param start start value
  79998. * @param end target value
  79999. * @param amount amount to lerp between
  80000. * @returns the lerped value
  80001. */
  80002. static Lerp(start: number, end: number, amount: number): number;
  80003. /**
  80004. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80005. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80006. * @param start start value
  80007. * @param end target value
  80008. * @param amount amount to lerp between
  80009. * @returns the lerped value
  80010. */
  80011. static LerpAngle(start: number, end: number, amount: number): number;
  80012. /**
  80013. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80014. * @param a start value
  80015. * @param b target value
  80016. * @param value value between a and b
  80017. * @returns the inverseLerp value
  80018. */
  80019. static InverseLerp(a: number, b: number, value: number): number;
  80020. /**
  80021. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80022. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80023. * @param value1 spline value
  80024. * @param tangent1 spline value
  80025. * @param value2 spline value
  80026. * @param tangent2 spline value
  80027. * @param amount input value
  80028. * @returns hermite result
  80029. */
  80030. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80031. /**
  80032. * Returns a random float number between and min and max values
  80033. * @param min min value of random
  80034. * @param max max value of random
  80035. * @returns random value
  80036. */
  80037. static RandomRange(min: number, max: number): number;
  80038. /**
  80039. * This function returns percentage of a number in a given range.
  80040. *
  80041. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80042. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80043. * @param number to convert to percentage
  80044. * @param min min range
  80045. * @param max max range
  80046. * @returns the percentage
  80047. */
  80048. static RangeToPercent(number: number, min: number, max: number): number;
  80049. /**
  80050. * This function returns number that corresponds to the percentage in a given range.
  80051. *
  80052. * PercentToRange(0.34,0,100) will return 34.
  80053. * @param percent to convert to number
  80054. * @param min min range
  80055. * @param max max range
  80056. * @returns the number
  80057. */
  80058. static PercentToRange(percent: number, min: number, max: number): number;
  80059. /**
  80060. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80061. * @param angle The angle to normalize in radian.
  80062. * @return The converted angle.
  80063. */
  80064. static NormalizeRadians(angle: number): number;
  80065. }
  80066. }
  80067. declare module BABYLON {
  80068. /**
  80069. * Constant used to convert a value to gamma space
  80070. * @ignorenaming
  80071. */
  80072. export const ToGammaSpace: number;
  80073. /**
  80074. * Constant used to convert a value to linear space
  80075. * @ignorenaming
  80076. */
  80077. export const ToLinearSpace = 2.2;
  80078. /**
  80079. * Constant used to define the minimal number value in Babylon.js
  80080. * @ignorenaming
  80081. */
  80082. let Epsilon: number;
  80083. }
  80084. declare module BABYLON {
  80085. /**
  80086. * Class used to represent a viewport on screen
  80087. */
  80088. export class Viewport {
  80089. /** viewport left coordinate */
  80090. x: number;
  80091. /** viewport top coordinate */
  80092. y: number;
  80093. /**viewport width */
  80094. width: number;
  80095. /** viewport height */
  80096. height: number;
  80097. /**
  80098. * Creates a Viewport object located at (x, y) and sized (width, height)
  80099. * @param x defines viewport left coordinate
  80100. * @param y defines viewport top coordinate
  80101. * @param width defines the viewport width
  80102. * @param height defines the viewport height
  80103. */
  80104. constructor(
  80105. /** viewport left coordinate */
  80106. x: number,
  80107. /** viewport top coordinate */
  80108. y: number,
  80109. /**viewport width */
  80110. width: number,
  80111. /** viewport height */
  80112. height: number);
  80113. /**
  80114. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80115. * @param renderWidth defines the rendering width
  80116. * @param renderHeight defines the rendering height
  80117. * @returns a new Viewport
  80118. */
  80119. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80120. /**
  80121. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80122. * @param renderWidth defines the rendering width
  80123. * @param renderHeight defines the rendering height
  80124. * @param ref defines the target viewport
  80125. * @returns the current viewport
  80126. */
  80127. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80128. /**
  80129. * Returns a new Viewport copied from the current one
  80130. * @returns a new Viewport
  80131. */
  80132. clone(): Viewport;
  80133. }
  80134. }
  80135. declare module BABYLON {
  80136. /**
  80137. * Class containing a set of static utilities functions for arrays.
  80138. */
  80139. export class ArrayTools {
  80140. /**
  80141. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80142. * @param size the number of element to construct and put in the array
  80143. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80144. * @returns a new array filled with new objects
  80145. */
  80146. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80147. }
  80148. }
  80149. declare module BABYLON {
  80150. /**
  80151. * Represents a plane by the equation ax + by + cz + d = 0
  80152. */
  80153. export class Plane {
  80154. private static _TmpMatrix;
  80155. /**
  80156. * Normal of the plane (a,b,c)
  80157. */
  80158. normal: Vector3;
  80159. /**
  80160. * d component of the plane
  80161. */
  80162. d: number;
  80163. /**
  80164. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80165. * @param a a component of the plane
  80166. * @param b b component of the plane
  80167. * @param c c component of the plane
  80168. * @param d d component of the plane
  80169. */
  80170. constructor(a: number, b: number, c: number, d: number);
  80171. /**
  80172. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80173. */
  80174. asArray(): number[];
  80175. /**
  80176. * @returns a new plane copied from the current Plane.
  80177. */
  80178. clone(): Plane;
  80179. /**
  80180. * @returns the string "Plane".
  80181. */
  80182. getClassName(): string;
  80183. /**
  80184. * @returns the Plane hash code.
  80185. */
  80186. getHashCode(): number;
  80187. /**
  80188. * Normalize the current Plane in place.
  80189. * @returns the updated Plane.
  80190. */
  80191. normalize(): Plane;
  80192. /**
  80193. * Applies a transformation the plane and returns the result
  80194. * @param transformation the transformation matrix to be applied to the plane
  80195. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80196. */
  80197. transform(transformation: DeepImmutable<Matrix>): Plane;
  80198. /**
  80199. * Compute the dot product between the point and the plane normal
  80200. * @param point point to calculate the dot product with
  80201. * @returns the dot product (float) of the point coordinates and the plane normal.
  80202. */
  80203. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80204. /**
  80205. * Updates the current Plane from the plane defined by the three given points.
  80206. * @param point1 one of the points used to contruct the plane
  80207. * @param point2 one of the points used to contruct the plane
  80208. * @param point3 one of the points used to contruct the plane
  80209. * @returns the updated Plane.
  80210. */
  80211. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80212. /**
  80213. * Checks if the plane is facing a given direction
  80214. * @param direction the direction to check if the plane is facing
  80215. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80216. * @returns True is the vector "direction" is the same side than the plane normal.
  80217. */
  80218. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80219. /**
  80220. * Calculates the distance to a point
  80221. * @param point point to calculate distance to
  80222. * @returns the signed distance (float) from the given point to the Plane.
  80223. */
  80224. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80225. /**
  80226. * Creates a plane from an array
  80227. * @param array the array to create a plane from
  80228. * @returns a new Plane from the given array.
  80229. */
  80230. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80231. /**
  80232. * Creates a plane from three points
  80233. * @param point1 point used to create the plane
  80234. * @param point2 point used to create the plane
  80235. * @param point3 point used to create the plane
  80236. * @returns a new Plane defined by the three given points.
  80237. */
  80238. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80239. /**
  80240. * Creates a plane from an origin point and a normal
  80241. * @param origin origin of the plane to be constructed
  80242. * @param normal normal of the plane to be constructed
  80243. * @returns a new Plane the normal vector to this plane at the given origin point.
  80244. * Note : the vector "normal" is updated because normalized.
  80245. */
  80246. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80247. /**
  80248. * Calculates the distance from a plane and a point
  80249. * @param origin origin of the plane to be constructed
  80250. * @param normal normal of the plane to be constructed
  80251. * @param point point to calculate distance to
  80252. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80253. */
  80254. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80255. }
  80256. }
  80257. declare module BABYLON {
  80258. /**
  80259. * Class representing a vector containing 2 coordinates
  80260. */
  80261. export class Vector2 {
  80262. /** defines the first coordinate */
  80263. x: number;
  80264. /** defines the second coordinate */
  80265. y: number;
  80266. /**
  80267. * Creates a new Vector2 from the given x and y coordinates
  80268. * @param x defines the first coordinate
  80269. * @param y defines the second coordinate
  80270. */
  80271. constructor(
  80272. /** defines the first coordinate */
  80273. x?: number,
  80274. /** defines the second coordinate */
  80275. y?: number);
  80276. /**
  80277. * Gets a string with the Vector2 coordinates
  80278. * @returns a string with the Vector2 coordinates
  80279. */
  80280. toString(): string;
  80281. /**
  80282. * Gets class name
  80283. * @returns the string "Vector2"
  80284. */
  80285. getClassName(): string;
  80286. /**
  80287. * Gets current vector hash code
  80288. * @returns the Vector2 hash code as a number
  80289. */
  80290. getHashCode(): number;
  80291. /**
  80292. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80293. * @param array defines the source array
  80294. * @param index defines the offset in source array
  80295. * @returns the current Vector2
  80296. */
  80297. toArray(array: FloatArray, index?: number): Vector2;
  80298. /**
  80299. * Copy the current vector to an array
  80300. * @returns a new array with 2 elements: the Vector2 coordinates.
  80301. */
  80302. asArray(): number[];
  80303. /**
  80304. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80305. * @param source defines the source Vector2
  80306. * @returns the current updated Vector2
  80307. */
  80308. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80309. /**
  80310. * Sets the Vector2 coordinates with the given floats
  80311. * @param x defines the first coordinate
  80312. * @param y defines the second coordinate
  80313. * @returns the current updated Vector2
  80314. */
  80315. copyFromFloats(x: number, y: number): Vector2;
  80316. /**
  80317. * Sets the Vector2 coordinates with the given floats
  80318. * @param x defines the first coordinate
  80319. * @param y defines the second coordinate
  80320. * @returns the current updated Vector2
  80321. */
  80322. set(x: number, y: number): Vector2;
  80323. /**
  80324. * Add another vector with the current one
  80325. * @param otherVector defines the other vector
  80326. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80327. */
  80328. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80329. /**
  80330. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80331. * @param otherVector defines the other vector
  80332. * @param result defines the target vector
  80333. * @returns the unmodified current Vector2
  80334. */
  80335. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80336. /**
  80337. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80338. * @param otherVector defines the other vector
  80339. * @returns the current updated Vector2
  80340. */
  80341. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80342. /**
  80343. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80344. * @param otherVector defines the other vector
  80345. * @returns a new Vector2
  80346. */
  80347. addVector3(otherVector: Vector3): Vector2;
  80348. /**
  80349. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80350. * @param otherVector defines the other vector
  80351. * @returns a new Vector2
  80352. */
  80353. subtract(otherVector: Vector2): Vector2;
  80354. /**
  80355. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80356. * @param otherVector defines the other vector
  80357. * @param result defines the target vector
  80358. * @returns the unmodified current Vector2
  80359. */
  80360. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80361. /**
  80362. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80363. * @param otherVector defines the other vector
  80364. * @returns the current updated Vector2
  80365. */
  80366. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80367. /**
  80368. * Multiplies in place the current Vector2 coordinates by the given ones
  80369. * @param otherVector defines the other vector
  80370. * @returns the current updated Vector2
  80371. */
  80372. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80373. /**
  80374. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80375. * @param otherVector defines the other vector
  80376. * @returns a new Vector2
  80377. */
  80378. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80379. /**
  80380. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80381. * @param otherVector defines the other vector
  80382. * @param result defines the target vector
  80383. * @returns the unmodified current Vector2
  80384. */
  80385. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80386. /**
  80387. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80388. * @param x defines the first coordinate
  80389. * @param y defines the second coordinate
  80390. * @returns a new Vector2
  80391. */
  80392. multiplyByFloats(x: number, y: number): Vector2;
  80393. /**
  80394. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80395. * @param otherVector defines the other vector
  80396. * @returns a new Vector2
  80397. */
  80398. divide(otherVector: Vector2): Vector2;
  80399. /**
  80400. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80401. * @param otherVector defines the other vector
  80402. * @param result defines the target vector
  80403. * @returns the unmodified current Vector2
  80404. */
  80405. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80406. /**
  80407. * Divides the current Vector2 coordinates by the given ones
  80408. * @param otherVector defines the other vector
  80409. * @returns the current updated Vector2
  80410. */
  80411. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80412. /**
  80413. * Gets a new Vector2 with current Vector2 negated coordinates
  80414. * @returns a new Vector2
  80415. */
  80416. negate(): Vector2;
  80417. /**
  80418. * Negate this vector in place
  80419. * @returns this
  80420. */
  80421. negateInPlace(): Vector2;
  80422. /**
  80423. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80424. * @param result defines the Vector3 object where to store the result
  80425. * @returns the current Vector2
  80426. */
  80427. negateToRef(result: Vector2): Vector2;
  80428. /**
  80429. * Multiply the Vector2 coordinates by scale
  80430. * @param scale defines the scaling factor
  80431. * @returns the current updated Vector2
  80432. */
  80433. scaleInPlace(scale: number): Vector2;
  80434. /**
  80435. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80436. * @param scale defines the scaling factor
  80437. * @returns a new Vector2
  80438. */
  80439. scale(scale: number): Vector2;
  80440. /**
  80441. * Scale the current Vector2 values by a factor to a given Vector2
  80442. * @param scale defines the scale factor
  80443. * @param result defines the Vector2 object where to store the result
  80444. * @returns the unmodified current Vector2
  80445. */
  80446. scaleToRef(scale: number, result: Vector2): Vector2;
  80447. /**
  80448. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80449. * @param scale defines the scale factor
  80450. * @param result defines the Vector2 object where to store the result
  80451. * @returns the unmodified current Vector2
  80452. */
  80453. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80454. /**
  80455. * Gets a boolean if two vectors are equals
  80456. * @param otherVector defines the other vector
  80457. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80458. */
  80459. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80460. /**
  80461. * Gets a boolean if two vectors are equals (using an epsilon value)
  80462. * @param otherVector defines the other vector
  80463. * @param epsilon defines the minimal distance to consider equality
  80464. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80465. */
  80466. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80467. /**
  80468. * Gets a new Vector2 from current Vector2 floored values
  80469. * @returns a new Vector2
  80470. */
  80471. floor(): Vector2;
  80472. /**
  80473. * Gets a new Vector2 from current Vector2 floored values
  80474. * @returns a new Vector2
  80475. */
  80476. fract(): Vector2;
  80477. /**
  80478. * Gets the length of the vector
  80479. * @returns the vector length (float)
  80480. */
  80481. length(): number;
  80482. /**
  80483. * Gets the vector squared length
  80484. * @returns the vector squared length (float)
  80485. */
  80486. lengthSquared(): number;
  80487. /**
  80488. * Normalize the vector
  80489. * @returns the current updated Vector2
  80490. */
  80491. normalize(): Vector2;
  80492. /**
  80493. * Gets a new Vector2 copied from the Vector2
  80494. * @returns a new Vector2
  80495. */
  80496. clone(): Vector2;
  80497. /**
  80498. * Gets a new Vector2(0, 0)
  80499. * @returns a new Vector2
  80500. */
  80501. static Zero(): Vector2;
  80502. /**
  80503. * Gets a new Vector2(1, 1)
  80504. * @returns a new Vector2
  80505. */
  80506. static One(): Vector2;
  80507. /**
  80508. * Gets a new Vector2 set from the given index element of the given array
  80509. * @param array defines the data source
  80510. * @param offset defines the offset in the data source
  80511. * @returns a new Vector2
  80512. */
  80513. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80514. /**
  80515. * Sets "result" from the given index element of the given array
  80516. * @param array defines the data source
  80517. * @param offset defines the offset in the data source
  80518. * @param result defines the target vector
  80519. */
  80520. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80521. /**
  80522. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80523. * @param value1 defines 1st point of control
  80524. * @param value2 defines 2nd point of control
  80525. * @param value3 defines 3rd point of control
  80526. * @param value4 defines 4th point of control
  80527. * @param amount defines the interpolation factor
  80528. * @returns a new Vector2
  80529. */
  80530. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80531. /**
  80532. * 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".
  80533. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80534. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80535. * @param value defines the value to clamp
  80536. * @param min defines the lower limit
  80537. * @param max defines the upper limit
  80538. * @returns a new Vector2
  80539. */
  80540. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80541. /**
  80542. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80543. * @param value1 defines the 1st control point
  80544. * @param tangent1 defines the outgoing tangent
  80545. * @param value2 defines the 2nd control point
  80546. * @param tangent2 defines the incoming tangent
  80547. * @param amount defines the interpolation factor
  80548. * @returns a new Vector2
  80549. */
  80550. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80551. /**
  80552. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80553. * @param start defines the start vector
  80554. * @param end defines the end vector
  80555. * @param amount defines the interpolation factor
  80556. * @returns a new Vector2
  80557. */
  80558. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80559. /**
  80560. * Gets the dot product of the vector "left" and the vector "right"
  80561. * @param left defines first vector
  80562. * @param right defines second vector
  80563. * @returns the dot product (float)
  80564. */
  80565. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80566. /**
  80567. * Returns a new Vector2 equal to the normalized given vector
  80568. * @param vector defines the vector to normalize
  80569. * @returns a new Vector2
  80570. */
  80571. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80572. /**
  80573. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80574. * @param left defines 1st vector
  80575. * @param right defines 2nd vector
  80576. * @returns a new Vector2
  80577. */
  80578. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80579. /**
  80580. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80581. * @param left defines 1st vector
  80582. * @param right defines 2nd vector
  80583. * @returns a new Vector2
  80584. */
  80585. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80586. /**
  80587. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80588. * @param vector defines the vector to transform
  80589. * @param transformation defines the matrix to apply
  80590. * @returns a new Vector2
  80591. */
  80592. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80593. /**
  80594. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80595. * @param vector defines the vector to transform
  80596. * @param transformation defines the matrix to apply
  80597. * @param result defines the target vector
  80598. */
  80599. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80600. /**
  80601. * Determines if a given vector is included in a triangle
  80602. * @param p defines the vector to test
  80603. * @param p0 defines 1st triangle point
  80604. * @param p1 defines 2nd triangle point
  80605. * @param p2 defines 3rd triangle point
  80606. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80607. */
  80608. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80609. /**
  80610. * Gets the distance between the vectors "value1" and "value2"
  80611. * @param value1 defines first vector
  80612. * @param value2 defines second vector
  80613. * @returns the distance between vectors
  80614. */
  80615. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80616. /**
  80617. * Returns the squared distance between the vectors "value1" and "value2"
  80618. * @param value1 defines first vector
  80619. * @param value2 defines second vector
  80620. * @returns the squared distance between vectors
  80621. */
  80622. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80623. /**
  80624. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80625. * @param value1 defines first vector
  80626. * @param value2 defines second vector
  80627. * @returns a new Vector2
  80628. */
  80629. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80630. /**
  80631. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80632. * @param p defines the middle point
  80633. * @param segA defines one point of the segment
  80634. * @param segB defines the other point of the segment
  80635. * @returns the shortest distance
  80636. */
  80637. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80638. }
  80639. /**
  80640. * Class used to store (x,y,z) vector representation
  80641. * A Vector3 is the main object used in 3D geometry
  80642. * It can represent etiher the coordinates of a point the space, either a direction
  80643. * Reminder: js uses a left handed forward facing system
  80644. */
  80645. export class Vector3 {
  80646. private static _UpReadOnly;
  80647. private static _ZeroReadOnly;
  80648. /** @hidden */
  80649. _x: number;
  80650. /** @hidden */
  80651. _y: number;
  80652. /** @hidden */
  80653. _z: number;
  80654. /** @hidden */
  80655. _isDirty: boolean;
  80656. /** Gets or sets the x coordinate */
  80657. get x(): number;
  80658. set x(value: number);
  80659. /** Gets or sets the y coordinate */
  80660. get y(): number;
  80661. set y(value: number);
  80662. /** Gets or sets the z coordinate */
  80663. get z(): number;
  80664. set z(value: number);
  80665. /**
  80666. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80667. * @param x defines the first coordinates (on X axis)
  80668. * @param y defines the second coordinates (on Y axis)
  80669. * @param z defines the third coordinates (on Z axis)
  80670. */
  80671. constructor(x?: number, y?: number, z?: number);
  80672. /**
  80673. * Creates a string representation of the Vector3
  80674. * @returns a string with the Vector3 coordinates.
  80675. */
  80676. toString(): string;
  80677. /**
  80678. * Gets the class name
  80679. * @returns the string "Vector3"
  80680. */
  80681. getClassName(): string;
  80682. /**
  80683. * Creates the Vector3 hash code
  80684. * @returns a number which tends to be unique between Vector3 instances
  80685. */
  80686. getHashCode(): number;
  80687. /**
  80688. * Creates an array containing three elements : the coordinates of the Vector3
  80689. * @returns a new array of numbers
  80690. */
  80691. asArray(): number[];
  80692. /**
  80693. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80694. * @param array defines the destination array
  80695. * @param index defines the offset in the destination array
  80696. * @returns the current Vector3
  80697. */
  80698. toArray(array: FloatArray, index?: number): Vector3;
  80699. /**
  80700. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80701. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80702. */
  80703. toQuaternion(): Quaternion;
  80704. /**
  80705. * Adds the given vector to the current Vector3
  80706. * @param otherVector defines the second operand
  80707. * @returns the current updated Vector3
  80708. */
  80709. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80710. /**
  80711. * Adds the given coordinates to the current Vector3
  80712. * @param x defines the x coordinate of the operand
  80713. * @param y defines the y coordinate of the operand
  80714. * @param z defines the z coordinate of the operand
  80715. * @returns the current updated Vector3
  80716. */
  80717. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80718. /**
  80719. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80720. * @param otherVector defines the second operand
  80721. * @returns the resulting Vector3
  80722. */
  80723. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80724. /**
  80725. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80726. * @param otherVector defines the second operand
  80727. * @param result defines the Vector3 object where to store the result
  80728. * @returns the current Vector3
  80729. */
  80730. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80731. /**
  80732. * Subtract the given vector from the current Vector3
  80733. * @param otherVector defines the second operand
  80734. * @returns the current updated Vector3
  80735. */
  80736. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80737. /**
  80738. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80739. * @param otherVector defines the second operand
  80740. * @returns the resulting Vector3
  80741. */
  80742. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80743. /**
  80744. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80745. * @param otherVector defines the second operand
  80746. * @param result defines the Vector3 object where to store the result
  80747. * @returns the current Vector3
  80748. */
  80749. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80750. /**
  80751. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80752. * @param x defines the x coordinate of the operand
  80753. * @param y defines the y coordinate of the operand
  80754. * @param z defines the z coordinate of the operand
  80755. * @returns the resulting Vector3
  80756. */
  80757. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80758. /**
  80759. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80760. * @param x defines the x coordinate of the operand
  80761. * @param y defines the y coordinate of the operand
  80762. * @param z defines the z coordinate of the operand
  80763. * @param result defines the Vector3 object where to store the result
  80764. * @returns the current Vector3
  80765. */
  80766. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80767. /**
  80768. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80769. * @returns a new Vector3
  80770. */
  80771. negate(): Vector3;
  80772. /**
  80773. * Negate this vector in place
  80774. * @returns this
  80775. */
  80776. negateInPlace(): Vector3;
  80777. /**
  80778. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80779. * @param result defines the Vector3 object where to store the result
  80780. * @returns the current Vector3
  80781. */
  80782. negateToRef(result: Vector3): Vector3;
  80783. /**
  80784. * Multiplies the Vector3 coordinates by the float "scale"
  80785. * @param scale defines the multiplier factor
  80786. * @returns the current updated Vector3
  80787. */
  80788. scaleInPlace(scale: number): Vector3;
  80789. /**
  80790. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80791. * @param scale defines the multiplier factor
  80792. * @returns a new Vector3
  80793. */
  80794. scale(scale: number): Vector3;
  80795. /**
  80796. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80797. * @param scale defines the multiplier factor
  80798. * @param result defines the Vector3 object where to store the result
  80799. * @returns the current Vector3
  80800. */
  80801. scaleToRef(scale: number, result: Vector3): Vector3;
  80802. /**
  80803. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80804. * @param scale defines the scale factor
  80805. * @param result defines the Vector3 object where to store the result
  80806. * @returns the unmodified current Vector3
  80807. */
  80808. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80809. /**
  80810. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80811. * @param origin defines the origin of the projection ray
  80812. * @param plane defines the plane to project to
  80813. * @returns the projected vector3
  80814. */
  80815. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80816. /**
  80817. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80818. * @param origin defines the origin of the projection ray
  80819. * @param plane defines the plane to project to
  80820. * @param result defines the Vector3 where to store the result
  80821. */
  80822. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80823. /**
  80824. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80825. * @param otherVector defines the second operand
  80826. * @returns true if both vectors are equals
  80827. */
  80828. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80829. /**
  80830. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80831. * @param otherVector defines the second operand
  80832. * @param epsilon defines the minimal distance to define values as equals
  80833. * @returns true if both vectors are distant less than epsilon
  80834. */
  80835. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80836. /**
  80837. * Returns true if the current Vector3 coordinates equals the given floats
  80838. * @param x defines the x coordinate of the operand
  80839. * @param y defines the y coordinate of the operand
  80840. * @param z defines the z coordinate of the operand
  80841. * @returns true if both vectors are equals
  80842. */
  80843. equalsToFloats(x: number, y: number, z: number): boolean;
  80844. /**
  80845. * Multiplies the current Vector3 coordinates by the given ones
  80846. * @param otherVector defines the second operand
  80847. * @returns the current updated Vector3
  80848. */
  80849. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80850. /**
  80851. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80852. * @param otherVector defines the second operand
  80853. * @returns the new Vector3
  80854. */
  80855. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80856. /**
  80857. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80858. * @param otherVector defines the second operand
  80859. * @param result defines the Vector3 object where to store the result
  80860. * @returns the current Vector3
  80861. */
  80862. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80863. /**
  80864. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80865. * @param x defines the x coordinate of the operand
  80866. * @param y defines the y coordinate of the operand
  80867. * @param z defines the z coordinate of the operand
  80868. * @returns the new Vector3
  80869. */
  80870. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80871. /**
  80872. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80873. * @param otherVector defines the second operand
  80874. * @returns the new Vector3
  80875. */
  80876. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80877. /**
  80878. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80879. * @param otherVector defines the second operand
  80880. * @param result defines the Vector3 object where to store the result
  80881. * @returns the current Vector3
  80882. */
  80883. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80884. /**
  80885. * Divides the current Vector3 coordinates by the given ones.
  80886. * @param otherVector defines the second operand
  80887. * @returns the current updated Vector3
  80888. */
  80889. divideInPlace(otherVector: Vector3): Vector3;
  80890. /**
  80891. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80892. * @param other defines the second operand
  80893. * @returns the current updated Vector3
  80894. */
  80895. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80896. /**
  80897. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80898. * @param other defines the second operand
  80899. * @returns the current updated Vector3
  80900. */
  80901. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80902. /**
  80903. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80904. * @param x defines the x coordinate of the operand
  80905. * @param y defines the y coordinate of the operand
  80906. * @param z defines the z coordinate of the operand
  80907. * @returns the current updated Vector3
  80908. */
  80909. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80910. /**
  80911. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80912. * @param x defines the x coordinate of the operand
  80913. * @param y defines the y coordinate of the operand
  80914. * @param z defines the z coordinate of the operand
  80915. * @returns the current updated Vector3
  80916. */
  80917. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80918. /**
  80919. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80920. * Check if is non uniform within a certain amount of decimal places to account for this
  80921. * @param epsilon the amount the values can differ
  80922. * @returns if the the vector is non uniform to a certain number of decimal places
  80923. */
  80924. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80925. /**
  80926. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80927. */
  80928. get isNonUniform(): boolean;
  80929. /**
  80930. * Gets a new Vector3 from current Vector3 floored values
  80931. * @returns a new Vector3
  80932. */
  80933. floor(): Vector3;
  80934. /**
  80935. * Gets a new Vector3 from current Vector3 floored values
  80936. * @returns a new Vector3
  80937. */
  80938. fract(): Vector3;
  80939. /**
  80940. * Gets the length of the Vector3
  80941. * @returns the length of the Vector3
  80942. */
  80943. length(): number;
  80944. /**
  80945. * Gets the squared length of the Vector3
  80946. * @returns squared length of the Vector3
  80947. */
  80948. lengthSquared(): number;
  80949. /**
  80950. * Normalize the current Vector3.
  80951. * Please note that this is an in place operation.
  80952. * @returns the current updated Vector3
  80953. */
  80954. normalize(): Vector3;
  80955. /**
  80956. * Reorders the x y z properties of the vector in place
  80957. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80958. * @returns the current updated vector
  80959. */
  80960. reorderInPlace(order: string): this;
  80961. /**
  80962. * Rotates the vector around 0,0,0 by a quaternion
  80963. * @param quaternion the rotation quaternion
  80964. * @param result vector to store the result
  80965. * @returns the resulting vector
  80966. */
  80967. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80968. /**
  80969. * Rotates a vector around a given point
  80970. * @param quaternion the rotation quaternion
  80971. * @param point the point to rotate around
  80972. * @param result vector to store the result
  80973. * @returns the resulting vector
  80974. */
  80975. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80976. /**
  80977. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80978. * The cross product is then orthogonal to both current and "other"
  80979. * @param other defines the right operand
  80980. * @returns the cross product
  80981. */
  80982. cross(other: Vector3): Vector3;
  80983. /**
  80984. * Normalize the current Vector3 with the given input length.
  80985. * Please note that this is an in place operation.
  80986. * @param len the length of the vector
  80987. * @returns the current updated Vector3
  80988. */
  80989. normalizeFromLength(len: number): Vector3;
  80990. /**
  80991. * Normalize the current Vector3 to a new vector
  80992. * @returns the new Vector3
  80993. */
  80994. normalizeToNew(): Vector3;
  80995. /**
  80996. * Normalize the current Vector3 to the reference
  80997. * @param reference define the Vector3 to update
  80998. * @returns the updated Vector3
  80999. */
  81000. normalizeToRef(reference: Vector3): Vector3;
  81001. /**
  81002. * Creates a new Vector3 copied from the current Vector3
  81003. * @returns the new Vector3
  81004. */
  81005. clone(): Vector3;
  81006. /**
  81007. * Copies the given vector coordinates to the current Vector3 ones
  81008. * @param source defines the source Vector3
  81009. * @returns the current updated Vector3
  81010. */
  81011. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81012. /**
  81013. * Copies the given floats to the current Vector3 coordinates
  81014. * @param x defines the x coordinate of the operand
  81015. * @param y defines the y coordinate of the operand
  81016. * @param z defines the z coordinate of the operand
  81017. * @returns the current updated Vector3
  81018. */
  81019. copyFromFloats(x: number, y: number, z: number): Vector3;
  81020. /**
  81021. * Copies the given floats to the current Vector3 coordinates
  81022. * @param x defines the x coordinate of the operand
  81023. * @param y defines the y coordinate of the operand
  81024. * @param z defines the z coordinate of the operand
  81025. * @returns the current updated Vector3
  81026. */
  81027. set(x: number, y: number, z: number): Vector3;
  81028. /**
  81029. * Copies the given float to the current Vector3 coordinates
  81030. * @param v defines the x, y and z coordinates of the operand
  81031. * @returns the current updated Vector3
  81032. */
  81033. setAll(v: number): Vector3;
  81034. /**
  81035. * Get the clip factor between two vectors
  81036. * @param vector0 defines the first operand
  81037. * @param vector1 defines the second operand
  81038. * @param axis defines the axis to use
  81039. * @param size defines the size along the axis
  81040. * @returns the clip factor
  81041. */
  81042. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81043. /**
  81044. * Get angle between two vectors
  81045. * @param vector0 angle between vector0 and vector1
  81046. * @param vector1 angle between vector0 and vector1
  81047. * @param normal direction of the normal
  81048. * @return the angle between vector0 and vector1
  81049. */
  81050. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81051. /**
  81052. * Returns a new Vector3 set from the index "offset" of the given array
  81053. * @param array defines the source array
  81054. * @param offset defines the offset in the source array
  81055. * @returns the new Vector3
  81056. */
  81057. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81058. /**
  81059. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81060. * @param array defines the source array
  81061. * @param offset defines the offset in the source array
  81062. * @returns the new Vector3
  81063. * @deprecated Please use FromArray instead.
  81064. */
  81065. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81066. /**
  81067. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81068. * @param array defines the source array
  81069. * @param offset defines the offset in the source array
  81070. * @param result defines the Vector3 where to store the result
  81071. */
  81072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81073. /**
  81074. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81075. * @param array defines the source array
  81076. * @param offset defines the offset in the source array
  81077. * @param result defines the Vector3 where to store the result
  81078. * @deprecated Please use FromArrayToRef instead.
  81079. */
  81080. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81081. /**
  81082. * Sets the given vector "result" with the given floats.
  81083. * @param x defines the x coordinate of the source
  81084. * @param y defines the y coordinate of the source
  81085. * @param z defines the z coordinate of the source
  81086. * @param result defines the Vector3 where to store the result
  81087. */
  81088. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81089. /**
  81090. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81091. * @returns a new empty Vector3
  81092. */
  81093. static Zero(): Vector3;
  81094. /**
  81095. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81096. * @returns a new unit Vector3
  81097. */
  81098. static One(): Vector3;
  81099. /**
  81100. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81101. * @returns a new up Vector3
  81102. */
  81103. static Up(): Vector3;
  81104. /**
  81105. * Gets a up Vector3 that must not be updated
  81106. */
  81107. static get UpReadOnly(): DeepImmutable<Vector3>;
  81108. /**
  81109. * Gets a zero Vector3 that must not be updated
  81110. */
  81111. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81112. /**
  81113. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81114. * @returns a new down Vector3
  81115. */
  81116. static Down(): Vector3;
  81117. /**
  81118. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81119. * @param rightHandedSystem is the scene right-handed (negative z)
  81120. * @returns a new forward Vector3
  81121. */
  81122. static Forward(rightHandedSystem?: boolean): Vector3;
  81123. /**
  81124. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81125. * @param rightHandedSystem is the scene right-handed (negative-z)
  81126. * @returns a new forward Vector3
  81127. */
  81128. static Backward(rightHandedSystem?: boolean): Vector3;
  81129. /**
  81130. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81131. * @returns a new right Vector3
  81132. */
  81133. static Right(): Vector3;
  81134. /**
  81135. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81136. * @returns a new left Vector3
  81137. */
  81138. static Left(): Vector3;
  81139. /**
  81140. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81141. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81142. * @param vector defines the Vector3 to transform
  81143. * @param transformation defines the transformation matrix
  81144. * @returns the transformed Vector3
  81145. */
  81146. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81147. /**
  81148. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81149. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81150. * @param vector defines the Vector3 to transform
  81151. * @param transformation defines the transformation matrix
  81152. * @param result defines the Vector3 where to store the result
  81153. */
  81154. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81155. /**
  81156. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81157. * This method computes tranformed coordinates only, not transformed direction vectors
  81158. * @param x define the x coordinate of the source vector
  81159. * @param y define the y coordinate of the source vector
  81160. * @param z define the z coordinate of the source vector
  81161. * @param transformation defines the transformation matrix
  81162. * @param result defines the Vector3 where to store the result
  81163. */
  81164. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81165. /**
  81166. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81167. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81168. * @param vector defines the Vector3 to transform
  81169. * @param transformation defines the transformation matrix
  81170. * @returns the new Vector3
  81171. */
  81172. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81173. /**
  81174. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81175. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81176. * @param vector defines the Vector3 to transform
  81177. * @param transformation defines the transformation matrix
  81178. * @param result defines the Vector3 where to store the result
  81179. */
  81180. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81181. /**
  81182. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81183. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81184. * @param x define the x coordinate of the source vector
  81185. * @param y define the y coordinate of the source vector
  81186. * @param z define the z coordinate of the source vector
  81187. * @param transformation defines the transformation matrix
  81188. * @param result defines the Vector3 where to store the result
  81189. */
  81190. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81191. /**
  81192. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81193. * @param value1 defines the first control point
  81194. * @param value2 defines the second control point
  81195. * @param value3 defines the third control point
  81196. * @param value4 defines the fourth control point
  81197. * @param amount defines the amount on the spline to use
  81198. * @returns the new Vector3
  81199. */
  81200. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81201. /**
  81202. * 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"
  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. * @returns the new Vector3
  81209. */
  81210. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81211. /**
  81212. * 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"
  81213. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81214. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81215. * @param value defines the current value
  81216. * @param min defines the lower range value
  81217. * @param max defines the upper range value
  81218. * @param result defines the Vector3 where to store the result
  81219. */
  81220. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81221. /**
  81222. * Checks if a given vector is inside a specific range
  81223. * @param v defines the vector to test
  81224. * @param min defines the minimum range
  81225. * @param max defines the maximum range
  81226. */
  81227. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81228. /**
  81229. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81230. * @param value1 defines the first control point
  81231. * @param tangent1 defines the first tangent vector
  81232. * @param value2 defines the second control point
  81233. * @param tangent2 defines the second tangent vector
  81234. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81235. * @returns the new Vector3
  81236. */
  81237. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81238. /**
  81239. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81240. * @param start defines the start value
  81241. * @param end defines the end value
  81242. * @param amount max defines amount between both (between 0 and 1)
  81243. * @returns the new Vector3
  81244. */
  81245. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81246. /**
  81247. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81248. * @param start defines the start value
  81249. * @param end defines the end value
  81250. * @param amount max defines amount between both (between 0 and 1)
  81251. * @param result defines the Vector3 where to store the result
  81252. */
  81253. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81254. /**
  81255. * Returns the dot product (float) between the vectors "left" and "right"
  81256. * @param left defines the left operand
  81257. * @param right defines the right operand
  81258. * @returns the dot product
  81259. */
  81260. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81261. /**
  81262. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81263. * The cross product is then orthogonal to both "left" and "right"
  81264. * @param left defines the left operand
  81265. * @param right defines the right operand
  81266. * @returns the cross product
  81267. */
  81268. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81269. /**
  81270. * Sets the given vector "result" with the cross product of "left" and "right"
  81271. * The cross product is then orthogonal to both "left" and "right"
  81272. * @param left defines the left operand
  81273. * @param right defines the right operand
  81274. * @param result defines the Vector3 where to store the result
  81275. */
  81276. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81277. /**
  81278. * Returns a new Vector3 as the normalization of the given vector
  81279. * @param vector defines the Vector3 to normalize
  81280. * @returns the new Vector3
  81281. */
  81282. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81283. /**
  81284. * Sets the given vector "result" with the normalization of the given first vector
  81285. * @param vector defines the Vector3 to normalize
  81286. * @param result defines the Vector3 where to store the result
  81287. */
  81288. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81289. /**
  81290. * Project a Vector3 onto screen space
  81291. * @param vector defines the Vector3 to project
  81292. * @param world defines the world matrix to use
  81293. * @param transform defines the transform (view x projection) matrix to use
  81294. * @param viewport defines the screen viewport to use
  81295. * @returns the new Vector3
  81296. */
  81297. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81298. /** @hidden */
  81299. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  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 transform defines the transform (view x projection) matrix to use
  81307. * @returns the new Vector3
  81308. */
  81309. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81310. /**
  81311. * Unproject from screen space to object space
  81312. * @param source defines the screen space Vector3 to use
  81313. * @param viewportWidth defines the current width of the viewport
  81314. * @param viewportHeight defines the current height of the viewport
  81315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81316. * @param view defines the view matrix to use
  81317. * @param projection defines the projection matrix to use
  81318. * @returns the new Vector3
  81319. */
  81320. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81321. /**
  81322. * Unproject from screen space to object space
  81323. * @param source defines the screen space Vector3 to use
  81324. * @param viewportWidth defines the current width of the viewport
  81325. * @param viewportHeight defines the current height of the viewport
  81326. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81327. * @param view defines the view matrix to use
  81328. * @param projection defines the projection matrix to use
  81329. * @param result defines the Vector3 where to store the result
  81330. */
  81331. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81332. /**
  81333. * Unproject from screen space to object space
  81334. * @param sourceX defines the screen space x coordinate to use
  81335. * @param sourceY defines the screen space y coordinate to use
  81336. * @param sourceZ defines the screen space z coordinate to use
  81337. * @param viewportWidth defines the current width of the viewport
  81338. * @param viewportHeight defines the current height of the viewport
  81339. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81340. * @param view defines the view matrix to use
  81341. * @param projection defines the projection matrix to use
  81342. * @param result defines the Vector3 where to store the result
  81343. */
  81344. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81345. /**
  81346. * Gets the minimal coordinate values between two Vector3
  81347. * @param left defines the first operand
  81348. * @param right defines the second operand
  81349. * @returns the new Vector3
  81350. */
  81351. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81352. /**
  81353. * Gets the maximal coordinate values between two Vector3
  81354. * @param left defines the first operand
  81355. * @param right defines the second operand
  81356. * @returns the new Vector3
  81357. */
  81358. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81359. /**
  81360. * Returns the distance between the vectors "value1" and "value2"
  81361. * @param value1 defines the first operand
  81362. * @param value2 defines the second operand
  81363. * @returns the distance
  81364. */
  81365. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81366. /**
  81367. * Returns the squared distance between the vectors "value1" and "value2"
  81368. * @param value1 defines the first operand
  81369. * @param value2 defines the second operand
  81370. * @returns the squared distance
  81371. */
  81372. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81373. /**
  81374. * Returns a new Vector3 located at the center between "value1" and "value2"
  81375. * @param value1 defines the first operand
  81376. * @param value2 defines the second operand
  81377. * @returns the new Vector3
  81378. */
  81379. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81380. /**
  81381. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81382. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81383. * to something in order to rotate it from its local system to the given target system
  81384. * Note: axis1, axis2 and axis3 are normalized during this operation
  81385. * @param axis1 defines the first axis
  81386. * @param axis2 defines the second axis
  81387. * @param axis3 defines the third axis
  81388. * @returns a new Vector3
  81389. */
  81390. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81391. /**
  81392. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81393. * @param axis1 defines the first axis
  81394. * @param axis2 defines the second axis
  81395. * @param axis3 defines the third axis
  81396. * @param ref defines the Vector3 where to store the result
  81397. */
  81398. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81399. }
  81400. /**
  81401. * Vector4 class created for EulerAngle class conversion to Quaternion
  81402. */
  81403. export class Vector4 {
  81404. /** x value of the vector */
  81405. x: number;
  81406. /** y value of the vector */
  81407. y: number;
  81408. /** z value of the vector */
  81409. z: number;
  81410. /** w value of the vector */
  81411. w: number;
  81412. /**
  81413. * Creates a Vector4 object from the given floats.
  81414. * @param x x value of the vector
  81415. * @param y y value of the vector
  81416. * @param z z value of the vector
  81417. * @param w w value of the vector
  81418. */
  81419. constructor(
  81420. /** x value of the vector */
  81421. x: number,
  81422. /** y value of the vector */
  81423. y: number,
  81424. /** z value of the vector */
  81425. z: number,
  81426. /** w value of the vector */
  81427. w: number);
  81428. /**
  81429. * Returns the string with the Vector4 coordinates.
  81430. * @returns a string containing all the vector values
  81431. */
  81432. toString(): string;
  81433. /**
  81434. * Returns the string "Vector4".
  81435. * @returns "Vector4"
  81436. */
  81437. getClassName(): string;
  81438. /**
  81439. * Returns the Vector4 hash code.
  81440. * @returns a unique hash code
  81441. */
  81442. getHashCode(): number;
  81443. /**
  81444. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81445. * @returns the resulting array
  81446. */
  81447. asArray(): number[];
  81448. /**
  81449. * Populates the given array from the given index with the Vector4 coordinates.
  81450. * @param array array to populate
  81451. * @param index index of the array to start at (default: 0)
  81452. * @returns the Vector4.
  81453. */
  81454. toArray(array: FloatArray, index?: number): Vector4;
  81455. /**
  81456. * Adds the given vector to the current Vector4.
  81457. * @param otherVector the vector to add
  81458. * @returns the updated Vector4.
  81459. */
  81460. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81461. /**
  81462. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81463. * @param otherVector the vector to add
  81464. * @returns the resulting vector
  81465. */
  81466. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81467. /**
  81468. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81469. * @param otherVector the vector to add
  81470. * @param result the vector to store the result
  81471. * @returns the current Vector4.
  81472. */
  81473. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81474. /**
  81475. * Subtract in place the given vector from the current Vector4.
  81476. * @param otherVector the vector to subtract
  81477. * @returns the updated Vector4.
  81478. */
  81479. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81480. /**
  81481. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81482. * @param otherVector the vector to add
  81483. * @returns the new vector with the result
  81484. */
  81485. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81486. /**
  81487. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81488. * @param otherVector the vector to subtract
  81489. * @param result the vector to store the result
  81490. * @returns the current Vector4.
  81491. */
  81492. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81493. /**
  81494. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81495. */
  81496. /**
  81497. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81498. * @param x value to subtract
  81499. * @param y value to subtract
  81500. * @param z value to subtract
  81501. * @param w value to subtract
  81502. * @returns new vector containing the result
  81503. */
  81504. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81505. /**
  81506. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81507. * @param x value to subtract
  81508. * @param y value to subtract
  81509. * @param z value to subtract
  81510. * @param w value to subtract
  81511. * @param result the vector to store the result in
  81512. * @returns the current Vector4.
  81513. */
  81514. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81515. /**
  81516. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81517. * @returns a new vector with the negated values
  81518. */
  81519. negate(): Vector4;
  81520. /**
  81521. * Negate this vector in place
  81522. * @returns this
  81523. */
  81524. negateInPlace(): Vector4;
  81525. /**
  81526. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81527. * @param result defines the Vector3 object where to store the result
  81528. * @returns the current Vector4
  81529. */
  81530. negateToRef(result: Vector4): Vector4;
  81531. /**
  81532. * Multiplies the current Vector4 coordinates by scale (float).
  81533. * @param scale the number to scale with
  81534. * @returns the updated Vector4.
  81535. */
  81536. scaleInPlace(scale: number): Vector4;
  81537. /**
  81538. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81539. * @param scale the number to scale with
  81540. * @returns a new vector with the result
  81541. */
  81542. scale(scale: number): Vector4;
  81543. /**
  81544. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81545. * @param scale the number to scale with
  81546. * @param result a vector to store the result in
  81547. * @returns the current Vector4.
  81548. */
  81549. scaleToRef(scale: number, result: Vector4): Vector4;
  81550. /**
  81551. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81552. * @param scale defines the scale factor
  81553. * @param result defines the Vector4 object where to store the result
  81554. * @returns the unmodified current Vector4
  81555. */
  81556. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81557. /**
  81558. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81559. * @param otherVector the vector to compare against
  81560. * @returns true if they are equal
  81561. */
  81562. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81563. /**
  81564. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81565. * @param otherVector vector to compare against
  81566. * @param epsilon (Default: very small number)
  81567. * @returns true if they are equal
  81568. */
  81569. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81570. /**
  81571. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81572. * @param x x value to compare against
  81573. * @param y y value to compare against
  81574. * @param z z value to compare against
  81575. * @param w w value to compare against
  81576. * @returns true if equal
  81577. */
  81578. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81579. /**
  81580. * Multiplies in place the current Vector4 by the given one.
  81581. * @param otherVector vector to multiple with
  81582. * @returns the updated Vector4.
  81583. */
  81584. multiplyInPlace(otherVector: Vector4): Vector4;
  81585. /**
  81586. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81587. * @param otherVector vector to multiple with
  81588. * @returns resulting new vector
  81589. */
  81590. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81591. /**
  81592. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81593. * @param otherVector vector to multiple with
  81594. * @param result vector to store the result
  81595. * @returns the current Vector4.
  81596. */
  81597. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81598. /**
  81599. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81600. * @param x x value multiply with
  81601. * @param y y value multiply with
  81602. * @param z z value multiply with
  81603. * @param w w value multiply with
  81604. * @returns resulting new vector
  81605. */
  81606. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81607. /**
  81608. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81609. * @param otherVector vector to devide with
  81610. * @returns resulting new vector
  81611. */
  81612. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81613. /**
  81614. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81615. * @param otherVector vector to devide with
  81616. * @param result vector to store the result
  81617. * @returns the current Vector4.
  81618. */
  81619. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81620. /**
  81621. * Divides the current Vector3 coordinates by the given ones.
  81622. * @param otherVector vector to devide with
  81623. * @returns the updated Vector3.
  81624. */
  81625. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81626. /**
  81627. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81628. * @param other defines the second operand
  81629. * @returns the current updated Vector4
  81630. */
  81631. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81632. /**
  81633. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81634. * @param other defines the second operand
  81635. * @returns the current updated Vector4
  81636. */
  81637. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81638. /**
  81639. * Gets a new Vector4 from current Vector4 floored values
  81640. * @returns a new Vector4
  81641. */
  81642. floor(): Vector4;
  81643. /**
  81644. * Gets a new Vector4 from current Vector3 floored values
  81645. * @returns a new Vector4
  81646. */
  81647. fract(): Vector4;
  81648. /**
  81649. * Returns the Vector4 length (float).
  81650. * @returns the length
  81651. */
  81652. length(): number;
  81653. /**
  81654. * Returns the Vector4 squared length (float).
  81655. * @returns the length squared
  81656. */
  81657. lengthSquared(): number;
  81658. /**
  81659. * Normalizes in place the Vector4.
  81660. * @returns the updated Vector4.
  81661. */
  81662. normalize(): Vector4;
  81663. /**
  81664. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81665. * @returns this converted to a new vector3
  81666. */
  81667. toVector3(): Vector3;
  81668. /**
  81669. * Returns a new Vector4 copied from the current one.
  81670. * @returns the new cloned vector
  81671. */
  81672. clone(): Vector4;
  81673. /**
  81674. * Updates the current Vector4 with the given one coordinates.
  81675. * @param source the source vector to copy from
  81676. * @returns the updated Vector4.
  81677. */
  81678. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81679. /**
  81680. * Updates the current Vector4 coordinates with the given floats.
  81681. * @param x float to copy from
  81682. * @param y float to copy from
  81683. * @param z float to copy from
  81684. * @param w float to copy from
  81685. * @returns the updated Vector4.
  81686. */
  81687. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81688. /**
  81689. * Updates the current Vector4 coordinates with the given floats.
  81690. * @param x float to set from
  81691. * @param y float to set from
  81692. * @param z float to set from
  81693. * @param w float to set from
  81694. * @returns the updated Vector4.
  81695. */
  81696. set(x: number, y: number, z: number, w: number): Vector4;
  81697. /**
  81698. * Copies the given float to the current Vector3 coordinates
  81699. * @param v defines the x, y, z and w coordinates of the operand
  81700. * @returns the current updated Vector3
  81701. */
  81702. setAll(v: number): Vector4;
  81703. /**
  81704. * Returns a new Vector4 set from the starting index of the given array.
  81705. * @param array the array to pull values from
  81706. * @param offset the offset into the array to start at
  81707. * @returns the new vector
  81708. */
  81709. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81710. /**
  81711. * Updates the given vector "result" from the starting index of the given array.
  81712. * @param array the array to pull values from
  81713. * @param offset the offset into the array to start at
  81714. * @param result the vector to store the result in
  81715. */
  81716. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81717. /**
  81718. * Updates the given vector "result" from the starting index of the given Float32Array.
  81719. * @param array the array to pull values from
  81720. * @param offset the offset into the array to start at
  81721. * @param result the vector to store the result in
  81722. */
  81723. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81724. /**
  81725. * Updates the given vector "result" coordinates from the given floats.
  81726. * @param x float to set from
  81727. * @param y float to set from
  81728. * @param z float to set from
  81729. * @param w float to set from
  81730. * @param result the vector to the floats in
  81731. */
  81732. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81733. /**
  81734. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81735. * @returns the new vector
  81736. */
  81737. static Zero(): Vector4;
  81738. /**
  81739. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81740. * @returns the new vector
  81741. */
  81742. static One(): Vector4;
  81743. /**
  81744. * Returns a new normalized Vector4 from the given one.
  81745. * @param vector the vector to normalize
  81746. * @returns the vector
  81747. */
  81748. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81749. /**
  81750. * Updates the given vector "result" from the normalization of the given one.
  81751. * @param vector the vector to normalize
  81752. * @param result the vector to store the result in
  81753. */
  81754. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81755. /**
  81756. * Returns a vector with the minimum values from the left and right vectors
  81757. * @param left left vector to minimize
  81758. * @param right right vector to minimize
  81759. * @returns a new vector with the minimum of the left and right vector values
  81760. */
  81761. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81762. /**
  81763. * Returns a vector with the maximum values from the left and right vectors
  81764. * @param left left vector to maximize
  81765. * @param right right vector to maximize
  81766. * @returns a new vector with the maximum of the left and right vector values
  81767. */
  81768. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81769. /**
  81770. * Returns the distance (float) between the vectors "value1" and "value2".
  81771. * @param value1 value to calulate the distance between
  81772. * @param value2 value to calulate the distance between
  81773. * @return the distance between the two vectors
  81774. */
  81775. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81776. /**
  81777. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81778. * @param value1 value to calulate the distance between
  81779. * @param value2 value to calulate the distance between
  81780. * @return the distance between the two vectors squared
  81781. */
  81782. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81783. /**
  81784. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81785. * @param value1 value to calulate the center between
  81786. * @param value2 value to calulate the center between
  81787. * @return the center between the two vectors
  81788. */
  81789. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81790. /**
  81791. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81792. * This methods computes transformed normalized direction vectors only.
  81793. * @param vector the vector to transform
  81794. * @param transformation the transformation matrix to apply
  81795. * @returns the new vector
  81796. */
  81797. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81798. /**
  81799. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81800. * This methods computes transformed normalized direction vectors only.
  81801. * @param vector the vector to transform
  81802. * @param transformation the transformation matrix to apply
  81803. * @param result the vector to store the result in
  81804. */
  81805. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81806. /**
  81807. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81808. * This methods computes transformed normalized direction vectors only.
  81809. * @param x value to transform
  81810. * @param y value to transform
  81811. * @param z value to transform
  81812. * @param w value to transform
  81813. * @param transformation the transformation matrix to apply
  81814. * @param result the vector to store the results in
  81815. */
  81816. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81817. /**
  81818. * Creates a new Vector4 from a Vector3
  81819. * @param source defines the source data
  81820. * @param w defines the 4th component (default is 0)
  81821. * @returns a new Vector4
  81822. */
  81823. static FromVector3(source: Vector3, w?: number): Vector4;
  81824. }
  81825. /**
  81826. * Class used to store quaternion data
  81827. * @see https://en.wikipedia.org/wiki/Quaternion
  81828. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81829. */
  81830. export class Quaternion {
  81831. /** @hidden */
  81832. _x: number;
  81833. /** @hidden */
  81834. _y: number;
  81835. /** @hidden */
  81836. _z: number;
  81837. /** @hidden */
  81838. _w: number;
  81839. /** @hidden */
  81840. _isDirty: boolean;
  81841. /** Gets or sets the x coordinate */
  81842. get x(): number;
  81843. set x(value: number);
  81844. /** Gets or sets the y coordinate */
  81845. get y(): number;
  81846. set y(value: number);
  81847. /** Gets or sets the z coordinate */
  81848. get z(): number;
  81849. set z(value: number);
  81850. /** Gets or sets the w coordinate */
  81851. get w(): number;
  81852. set w(value: number);
  81853. /**
  81854. * Creates a new Quaternion from the given floats
  81855. * @param x defines the first component (0 by default)
  81856. * @param y defines the second component (0 by default)
  81857. * @param z defines the third component (0 by default)
  81858. * @param w defines the fourth component (1.0 by default)
  81859. */
  81860. constructor(x?: number, y?: number, z?: number, w?: number);
  81861. /**
  81862. * Gets a string representation for the current quaternion
  81863. * @returns a string with the Quaternion coordinates
  81864. */
  81865. toString(): string;
  81866. /**
  81867. * Gets the class name of the quaternion
  81868. * @returns the string "Quaternion"
  81869. */
  81870. getClassName(): string;
  81871. /**
  81872. * Gets a hash code for this quaternion
  81873. * @returns the quaternion hash code
  81874. */
  81875. getHashCode(): number;
  81876. /**
  81877. * Copy the quaternion to an array
  81878. * @returns a new array populated with 4 elements from the quaternion coordinates
  81879. */
  81880. asArray(): number[];
  81881. /**
  81882. * Check if two quaternions are equals
  81883. * @param otherQuaternion defines the second operand
  81884. * @return true if the current quaternion and the given one coordinates are strictly equals
  81885. */
  81886. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81887. /**
  81888. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81889. * @param otherQuaternion defines the other quaternion
  81890. * @param epsilon defines the minimal distance to consider equality
  81891. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81892. */
  81893. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81894. /**
  81895. * Clone the current quaternion
  81896. * @returns a new quaternion copied from the current one
  81897. */
  81898. clone(): Quaternion;
  81899. /**
  81900. * Copy a quaternion to the current one
  81901. * @param other defines the other quaternion
  81902. * @returns the updated current quaternion
  81903. */
  81904. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81905. /**
  81906. * Updates the current quaternion with the given float coordinates
  81907. * @param x defines the x coordinate
  81908. * @param y defines the y coordinate
  81909. * @param z defines the z coordinate
  81910. * @param w defines the w coordinate
  81911. * @returns the updated current quaternion
  81912. */
  81913. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81914. /**
  81915. * Updates the current quaternion from the given float coordinates
  81916. * @param x defines the x coordinate
  81917. * @param y defines the y coordinate
  81918. * @param z defines the z coordinate
  81919. * @param w defines the w coordinate
  81920. * @returns the updated current quaternion
  81921. */
  81922. set(x: number, y: number, z: number, w: number): Quaternion;
  81923. /**
  81924. * Adds two quaternions
  81925. * @param other defines the second operand
  81926. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81927. */
  81928. add(other: DeepImmutable<Quaternion>): Quaternion;
  81929. /**
  81930. * Add a quaternion to the current one
  81931. * @param other defines the quaternion to add
  81932. * @returns the current quaternion
  81933. */
  81934. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81935. /**
  81936. * Subtract two quaternions
  81937. * @param other defines the second operand
  81938. * @returns a new quaternion as the subtraction result of the given one from the current one
  81939. */
  81940. subtract(other: Quaternion): Quaternion;
  81941. /**
  81942. * Multiplies the current quaternion by a scale factor
  81943. * @param value defines the scale factor
  81944. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81945. */
  81946. scale(value: number): Quaternion;
  81947. /**
  81948. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81949. * @param scale defines the scale factor
  81950. * @param result defines the Quaternion object where to store the result
  81951. * @returns the unmodified current quaternion
  81952. */
  81953. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81954. /**
  81955. * Multiplies in place the current quaternion by a scale factor
  81956. * @param value defines the scale factor
  81957. * @returns the current modified quaternion
  81958. */
  81959. scaleInPlace(value: number): Quaternion;
  81960. /**
  81961. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81962. * @param scale defines the scale factor
  81963. * @param result defines the Quaternion object where to store the result
  81964. * @returns the unmodified current quaternion
  81965. */
  81966. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81967. /**
  81968. * Multiplies two quaternions
  81969. * @param q1 defines the second operand
  81970. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81971. */
  81972. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81973. /**
  81974. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81975. * @param q1 defines the second operand
  81976. * @param result defines the target quaternion
  81977. * @returns the current quaternion
  81978. */
  81979. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81980. /**
  81981. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81982. * @param q1 defines the second operand
  81983. * @returns the currentupdated quaternion
  81984. */
  81985. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81986. /**
  81987. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81988. * @param ref defines the target quaternion
  81989. * @returns the current quaternion
  81990. */
  81991. conjugateToRef(ref: Quaternion): Quaternion;
  81992. /**
  81993. * Conjugates in place (1-q) the current quaternion
  81994. * @returns the current updated quaternion
  81995. */
  81996. conjugateInPlace(): Quaternion;
  81997. /**
  81998. * Conjugates in place (1-q) the current quaternion
  81999. * @returns a new quaternion
  82000. */
  82001. conjugate(): Quaternion;
  82002. /**
  82003. * Gets length of current quaternion
  82004. * @returns the quaternion length (float)
  82005. */
  82006. length(): number;
  82007. /**
  82008. * Normalize in place the current quaternion
  82009. * @returns the current updated quaternion
  82010. */
  82011. normalize(): Quaternion;
  82012. /**
  82013. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82014. * @param order is a reserved parameter and is ignore for now
  82015. * @returns a new Vector3 containing the Euler angles
  82016. */
  82017. toEulerAngles(order?: string): Vector3;
  82018. /**
  82019. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82020. * @param result defines the vector which will be filled with the Euler angles
  82021. * @param order is a reserved parameter and is ignore for now
  82022. * @returns the current unchanged quaternion
  82023. */
  82024. toEulerAnglesToRef(result: Vector3): Quaternion;
  82025. /**
  82026. * Updates the given rotation matrix with the current quaternion values
  82027. * @param result defines the target matrix
  82028. * @returns the current unchanged quaternion
  82029. */
  82030. toRotationMatrix(result: Matrix): Quaternion;
  82031. /**
  82032. * Updates the current quaternion from the given rotation matrix values
  82033. * @param matrix defines the source matrix
  82034. * @returns the current updated quaternion
  82035. */
  82036. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82037. /**
  82038. * Creates a new quaternion from a rotation matrix
  82039. * @param matrix defines the source matrix
  82040. * @returns a new quaternion created from the given rotation matrix values
  82041. */
  82042. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82043. /**
  82044. * Updates the given quaternion with the given rotation matrix values
  82045. * @param matrix defines the source matrix
  82046. * @param result defines the target quaternion
  82047. */
  82048. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82049. /**
  82050. * Returns the dot product (float) between the quaternions "left" and "right"
  82051. * @param left defines the left operand
  82052. * @param right defines the right operand
  82053. * @returns the dot product
  82054. */
  82055. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82056. /**
  82057. * Checks if the two quaternions are close to each other
  82058. * @param quat0 defines the first quaternion to check
  82059. * @param quat1 defines the second quaternion to check
  82060. * @returns true if the two quaternions are close to each other
  82061. */
  82062. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82063. /**
  82064. * Creates an empty quaternion
  82065. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82066. */
  82067. static Zero(): Quaternion;
  82068. /**
  82069. * Inverse a given quaternion
  82070. * @param q defines the source quaternion
  82071. * @returns a new quaternion as the inverted current quaternion
  82072. */
  82073. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82074. /**
  82075. * Inverse a given quaternion
  82076. * @param q defines the source quaternion
  82077. * @param result the quaternion the result will be stored in
  82078. * @returns the result quaternion
  82079. */
  82080. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82081. /**
  82082. * Creates an identity quaternion
  82083. * @returns the identity quaternion
  82084. */
  82085. static Identity(): Quaternion;
  82086. /**
  82087. * Gets a boolean indicating if the given quaternion is identity
  82088. * @param quaternion defines the quaternion to check
  82089. * @returns true if the quaternion is identity
  82090. */
  82091. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82092. /**
  82093. * Creates a quaternion from a rotation around an axis
  82094. * @param axis defines the axis to use
  82095. * @param angle defines the angle to use
  82096. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82097. */
  82098. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82099. /**
  82100. * Creates a rotation around an axis and stores it into the given quaternion
  82101. * @param axis defines the axis to use
  82102. * @param angle defines the angle to use
  82103. * @param result defines the target quaternion
  82104. * @returns the target quaternion
  82105. */
  82106. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82107. /**
  82108. * Creates a new quaternion from data stored into an array
  82109. * @param array defines the data source
  82110. * @param offset defines the offset in the source array where the data starts
  82111. * @returns a new quaternion
  82112. */
  82113. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82114. /**
  82115. * Updates the given quaternion "result" from the starting index of the given array.
  82116. * @param array the array to pull values from
  82117. * @param offset the offset into the array to start at
  82118. * @param result the quaternion to store the result in
  82119. */
  82120. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82121. /**
  82122. * Create a quaternion from Euler rotation angles
  82123. * @param x Pitch
  82124. * @param y Yaw
  82125. * @param z Roll
  82126. * @returns the new Quaternion
  82127. */
  82128. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82129. /**
  82130. * Updates a quaternion from Euler rotation angles
  82131. * @param x Pitch
  82132. * @param y Yaw
  82133. * @param z Roll
  82134. * @param result the quaternion to store the result
  82135. * @returns the updated quaternion
  82136. */
  82137. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82138. /**
  82139. * Create a quaternion from Euler rotation vector
  82140. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82141. * @returns the new Quaternion
  82142. */
  82143. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82144. /**
  82145. * Updates a quaternion from Euler rotation vector
  82146. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82147. * @param result the quaternion to store the result
  82148. * @returns the updated quaternion
  82149. */
  82150. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82151. /**
  82152. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82153. * @param yaw defines the rotation around Y axis
  82154. * @param pitch defines the rotation around X axis
  82155. * @param roll defines the rotation around Z axis
  82156. * @returns the new quaternion
  82157. */
  82158. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82159. /**
  82160. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82161. * @param yaw defines the rotation around Y axis
  82162. * @param pitch defines the rotation around X axis
  82163. * @param roll defines the rotation around Z axis
  82164. * @param result defines the target quaternion
  82165. */
  82166. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82167. /**
  82168. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82169. * @param alpha defines the rotation around first axis
  82170. * @param beta defines the rotation around second axis
  82171. * @param gamma defines the rotation around third axis
  82172. * @returns the new quaternion
  82173. */
  82174. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82175. /**
  82176. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82177. * @param alpha defines the rotation around first axis
  82178. * @param beta defines the rotation around second axis
  82179. * @param gamma defines the rotation around third axis
  82180. * @param result defines the target quaternion
  82181. */
  82182. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82183. /**
  82184. * 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)
  82185. * @param axis1 defines the first axis
  82186. * @param axis2 defines the second axis
  82187. * @param axis3 defines the third axis
  82188. * @returns the new quaternion
  82189. */
  82190. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82191. /**
  82192. * 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
  82193. * @param axis1 defines the first axis
  82194. * @param axis2 defines the second axis
  82195. * @param axis3 defines the third axis
  82196. * @param ref defines the target quaternion
  82197. */
  82198. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82199. /**
  82200. * Interpolates between two quaternions
  82201. * @param left defines first quaternion
  82202. * @param right defines second quaternion
  82203. * @param amount defines the gradient to use
  82204. * @returns the new interpolated quaternion
  82205. */
  82206. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82207. /**
  82208. * Interpolates between two quaternions and stores it into a target quaternion
  82209. * @param left defines first quaternion
  82210. * @param right defines second quaternion
  82211. * @param amount defines the gradient to use
  82212. * @param result defines the target quaternion
  82213. */
  82214. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82215. /**
  82216. * Interpolate between two quaternions using Hermite interpolation
  82217. * @param value1 defines first quaternion
  82218. * @param tangent1 defines the incoming tangent
  82219. * @param value2 defines second quaternion
  82220. * @param tangent2 defines the outgoing tangent
  82221. * @param amount defines the target quaternion
  82222. * @returns the new interpolated quaternion
  82223. */
  82224. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82225. }
  82226. /**
  82227. * Class used to store matrix data (4x4)
  82228. */
  82229. export class Matrix {
  82230. private static _updateFlagSeed;
  82231. private static _identityReadOnly;
  82232. private _isIdentity;
  82233. private _isIdentityDirty;
  82234. private _isIdentity3x2;
  82235. private _isIdentity3x2Dirty;
  82236. /**
  82237. * Gets the update flag of the matrix which is an unique number for the matrix.
  82238. * It will be incremented every time the matrix data change.
  82239. * You can use it to speed the comparison between two versions of the same matrix.
  82240. */
  82241. updateFlag: number;
  82242. private readonly _m;
  82243. /**
  82244. * Gets the internal data of the matrix
  82245. */
  82246. get m(): DeepImmutable<Float32Array>;
  82247. /** @hidden */
  82248. _markAsUpdated(): void;
  82249. /** @hidden */
  82250. private _updateIdentityStatus;
  82251. /**
  82252. * Creates an empty matrix (filled with zeros)
  82253. */
  82254. constructor();
  82255. /**
  82256. * Check if the current matrix is identity
  82257. * @returns true is the matrix is the identity matrix
  82258. */
  82259. isIdentity(): boolean;
  82260. /**
  82261. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82262. * @returns true is the matrix is the identity matrix
  82263. */
  82264. isIdentityAs3x2(): boolean;
  82265. /**
  82266. * Gets the determinant of the matrix
  82267. * @returns the matrix determinant
  82268. */
  82269. determinant(): number;
  82270. /**
  82271. * Returns the matrix as a Float32Array
  82272. * @returns the matrix underlying array
  82273. */
  82274. toArray(): DeepImmutable<Float32Array>;
  82275. /**
  82276. * Returns the matrix as a Float32Array
  82277. * @returns the matrix underlying array.
  82278. */
  82279. asArray(): DeepImmutable<Float32Array>;
  82280. /**
  82281. * Inverts the current matrix in place
  82282. * @returns the current inverted matrix
  82283. */
  82284. invert(): Matrix;
  82285. /**
  82286. * Sets all the matrix elements to zero
  82287. * @returns the current matrix
  82288. */
  82289. reset(): Matrix;
  82290. /**
  82291. * Adds the current matrix with a second one
  82292. * @param other defines the matrix to add
  82293. * @returns a new matrix as the addition of the current matrix and the given one
  82294. */
  82295. add(other: DeepImmutable<Matrix>): Matrix;
  82296. /**
  82297. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82298. * @param other defines the matrix to add
  82299. * @param result defines the target matrix
  82300. * @returns the current matrix
  82301. */
  82302. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82303. /**
  82304. * Adds in place the given matrix to the current matrix
  82305. * @param other defines the second operand
  82306. * @returns the current updated matrix
  82307. */
  82308. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82309. /**
  82310. * Sets the given matrix to the current inverted Matrix
  82311. * @param other defines the target matrix
  82312. * @returns the unmodified current matrix
  82313. */
  82314. invertToRef(other: Matrix): Matrix;
  82315. /**
  82316. * add a value at the specified position in the current Matrix
  82317. * @param index the index of the value within the matrix. between 0 and 15.
  82318. * @param value the value to be added
  82319. * @returns the current updated matrix
  82320. */
  82321. addAtIndex(index: number, value: number): Matrix;
  82322. /**
  82323. * mutiply the specified position in the current Matrix by a value
  82324. * @param index the index of the value within the matrix. between 0 and 15.
  82325. * @param value the value to be added
  82326. * @returns the current updated matrix
  82327. */
  82328. multiplyAtIndex(index: number, value: number): Matrix;
  82329. /**
  82330. * Inserts the translation vector (using 3 floats) in the current matrix
  82331. * @param x defines the 1st component of the translation
  82332. * @param y defines the 2nd component of the translation
  82333. * @param z defines the 3rd component of the translation
  82334. * @returns the current updated matrix
  82335. */
  82336. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82337. /**
  82338. * Adds the translation vector (using 3 floats) in the current matrix
  82339. * @param x defines the 1st component of the translation
  82340. * @param y defines the 2nd component of the translation
  82341. * @param z defines the 3rd component of the translation
  82342. * @returns the current updated matrix
  82343. */
  82344. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82345. /**
  82346. * Inserts the translation vector in the current matrix
  82347. * @param vector3 defines the translation to insert
  82348. * @returns the current updated matrix
  82349. */
  82350. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82351. /**
  82352. * Gets the translation value of the current matrix
  82353. * @returns a new Vector3 as the extracted translation from the matrix
  82354. */
  82355. getTranslation(): Vector3;
  82356. /**
  82357. * Fill a Vector3 with the extracted translation from the matrix
  82358. * @param result defines the Vector3 where to store the translation
  82359. * @returns the current matrix
  82360. */
  82361. getTranslationToRef(result: Vector3): Matrix;
  82362. /**
  82363. * Remove rotation and scaling part from the matrix
  82364. * @returns the updated matrix
  82365. */
  82366. removeRotationAndScaling(): Matrix;
  82367. /**
  82368. * Multiply two matrices
  82369. * @param other defines the second operand
  82370. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82371. */
  82372. multiply(other: DeepImmutable<Matrix>): Matrix;
  82373. /**
  82374. * Copy the current matrix from the given one
  82375. * @param other defines the source matrix
  82376. * @returns the current updated matrix
  82377. */
  82378. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82379. /**
  82380. * Populates the given array from the starting index with the current matrix values
  82381. * @param array defines the target array
  82382. * @param offset defines the offset in the target array where to start storing values
  82383. * @returns the current matrix
  82384. */
  82385. copyToArray(array: Float32Array, offset?: number): Matrix;
  82386. /**
  82387. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82388. * @param other defines the second operand
  82389. * @param result defines the matrix where to store the multiplication
  82390. * @returns the current matrix
  82391. */
  82392. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82393. /**
  82394. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82395. * @param other defines the second operand
  82396. * @param result defines the array where to store the multiplication
  82397. * @param offset defines the offset in the target array where to start storing values
  82398. * @returns the current matrix
  82399. */
  82400. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82401. /**
  82402. * Check equality between this matrix and a second one
  82403. * @param value defines the second matrix to compare
  82404. * @returns true is the current matrix and the given one values are strictly equal
  82405. */
  82406. equals(value: DeepImmutable<Matrix>): boolean;
  82407. /**
  82408. * Clone the current matrix
  82409. * @returns a new matrix from the current matrix
  82410. */
  82411. clone(): Matrix;
  82412. /**
  82413. * Returns the name of the current matrix class
  82414. * @returns the string "Matrix"
  82415. */
  82416. getClassName(): string;
  82417. /**
  82418. * Gets the hash code of the current matrix
  82419. * @returns the hash code
  82420. */
  82421. getHashCode(): number;
  82422. /**
  82423. * Decomposes the current Matrix into a translation, rotation and scaling components
  82424. * @param scale defines the scale vector3 given as a reference to update
  82425. * @param rotation defines the rotation quaternion given as a reference to update
  82426. * @param translation defines the translation vector3 given as a reference to update
  82427. * @returns true if operation was successful
  82428. */
  82429. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82430. /**
  82431. * Gets specific row of the matrix
  82432. * @param index defines the number of the row to get
  82433. * @returns the index-th row of the current matrix as a new Vector4
  82434. */
  82435. getRow(index: number): Nullable<Vector4>;
  82436. /**
  82437. * Sets the index-th row of the current matrix to the vector4 values
  82438. * @param index defines the number of the row to set
  82439. * @param row defines the target vector4
  82440. * @returns the updated current matrix
  82441. */
  82442. setRow(index: number, row: Vector4): Matrix;
  82443. /**
  82444. * Compute the transpose of the matrix
  82445. * @returns the new transposed matrix
  82446. */
  82447. transpose(): Matrix;
  82448. /**
  82449. * Compute the transpose of the matrix and store it in a given matrix
  82450. * @param result defines the target matrix
  82451. * @returns the current matrix
  82452. */
  82453. transposeToRef(result: Matrix): Matrix;
  82454. /**
  82455. * Sets the index-th row of the current matrix with the given 4 x float values
  82456. * @param index defines the row index
  82457. * @param x defines the x component to set
  82458. * @param y defines the y component to set
  82459. * @param z defines the z component to set
  82460. * @param w defines the w component to set
  82461. * @returns the updated current matrix
  82462. */
  82463. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82464. /**
  82465. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82466. * @param scale defines the scale factor
  82467. * @returns a new matrix
  82468. */
  82469. scale(scale: number): Matrix;
  82470. /**
  82471. * Scale the current matrix values by a factor to a given result matrix
  82472. * @param scale defines the scale factor
  82473. * @param result defines the matrix to store the result
  82474. * @returns the current matrix
  82475. */
  82476. scaleToRef(scale: number, result: Matrix): Matrix;
  82477. /**
  82478. * Scale the current matrix values by a factor and add the result to a given matrix
  82479. * @param scale defines the scale factor
  82480. * @param result defines the Matrix to store the result
  82481. * @returns the current matrix
  82482. */
  82483. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82484. /**
  82485. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82486. * @param ref matrix to store the result
  82487. */
  82488. toNormalMatrix(ref: Matrix): void;
  82489. /**
  82490. * Gets only rotation part of the current matrix
  82491. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82492. */
  82493. getRotationMatrix(): Matrix;
  82494. /**
  82495. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82496. * @param result defines the target matrix to store data to
  82497. * @returns the current matrix
  82498. */
  82499. getRotationMatrixToRef(result: Matrix): Matrix;
  82500. /**
  82501. * Toggles model matrix from being right handed to left handed in place and vice versa
  82502. */
  82503. toggleModelMatrixHandInPlace(): void;
  82504. /**
  82505. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82506. */
  82507. toggleProjectionMatrixHandInPlace(): void;
  82508. /**
  82509. * Creates a matrix from an array
  82510. * @param array defines the source array
  82511. * @param offset defines an offset in the source array
  82512. * @returns a new Matrix set from the starting index of the given array
  82513. */
  82514. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82515. /**
  82516. * Copy the content of an array into a given matrix
  82517. * @param array defines the source array
  82518. * @param offset defines an offset in the source array
  82519. * @param result defines the target matrix
  82520. */
  82521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82522. /**
  82523. * Stores an array into a matrix after having multiplied each component by a given factor
  82524. * @param array defines the source array
  82525. * @param offset defines the offset in the source array
  82526. * @param scale defines the scaling factor
  82527. * @param result defines the target matrix
  82528. */
  82529. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82530. /**
  82531. * Gets an identity matrix that must not be updated
  82532. */
  82533. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82534. /**
  82535. * Stores a list of values (16) inside a given matrix
  82536. * @param initialM11 defines 1st value of 1st row
  82537. * @param initialM12 defines 2nd value of 1st row
  82538. * @param initialM13 defines 3rd value of 1st row
  82539. * @param initialM14 defines 4th value of 1st row
  82540. * @param initialM21 defines 1st value of 2nd row
  82541. * @param initialM22 defines 2nd value of 2nd row
  82542. * @param initialM23 defines 3rd value of 2nd row
  82543. * @param initialM24 defines 4th value of 2nd row
  82544. * @param initialM31 defines 1st value of 3rd row
  82545. * @param initialM32 defines 2nd value of 3rd row
  82546. * @param initialM33 defines 3rd value of 3rd row
  82547. * @param initialM34 defines 4th value of 3rd row
  82548. * @param initialM41 defines 1st value of 4th row
  82549. * @param initialM42 defines 2nd value of 4th row
  82550. * @param initialM43 defines 3rd value of 4th row
  82551. * @param initialM44 defines 4th value of 4th row
  82552. * @param result defines the target matrix
  82553. */
  82554. 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;
  82555. /**
  82556. * Creates new matrix from a list of values (16)
  82557. * @param initialM11 defines 1st value of 1st row
  82558. * @param initialM12 defines 2nd value of 1st row
  82559. * @param initialM13 defines 3rd value of 1st row
  82560. * @param initialM14 defines 4th value of 1st row
  82561. * @param initialM21 defines 1st value of 2nd row
  82562. * @param initialM22 defines 2nd value of 2nd row
  82563. * @param initialM23 defines 3rd value of 2nd row
  82564. * @param initialM24 defines 4th value of 2nd row
  82565. * @param initialM31 defines 1st value of 3rd row
  82566. * @param initialM32 defines 2nd value of 3rd row
  82567. * @param initialM33 defines 3rd value of 3rd row
  82568. * @param initialM34 defines 4th value of 3rd row
  82569. * @param initialM41 defines 1st value of 4th row
  82570. * @param initialM42 defines 2nd value of 4th row
  82571. * @param initialM43 defines 3rd value of 4th row
  82572. * @param initialM44 defines 4th value of 4th row
  82573. * @returns the new matrix
  82574. */
  82575. 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;
  82576. /**
  82577. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82578. * @param scale defines the scale vector3
  82579. * @param rotation defines the rotation quaternion
  82580. * @param translation defines the translation vector3
  82581. * @returns a new matrix
  82582. */
  82583. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82584. /**
  82585. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82586. * @param scale defines the scale vector3
  82587. * @param rotation defines the rotation quaternion
  82588. * @param translation defines the translation vector3
  82589. * @param result defines the target matrix
  82590. */
  82591. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82592. /**
  82593. * Creates a new identity matrix
  82594. * @returns a new identity matrix
  82595. */
  82596. static Identity(): Matrix;
  82597. /**
  82598. * Creates a new identity matrix and stores the result in a given matrix
  82599. * @param result defines the target matrix
  82600. */
  82601. static IdentityToRef(result: Matrix): void;
  82602. /**
  82603. * Creates a new zero matrix
  82604. * @returns a new zero matrix
  82605. */
  82606. static Zero(): Matrix;
  82607. /**
  82608. * Creates a new rotation matrix for "angle" radians around the X axis
  82609. * @param angle defines the angle (in radians) to use
  82610. * @return the new matrix
  82611. */
  82612. static RotationX(angle: number): Matrix;
  82613. /**
  82614. * Creates a new matrix as the invert of a given matrix
  82615. * @param source defines the source matrix
  82616. * @returns the new matrix
  82617. */
  82618. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82619. /**
  82620. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82621. * @param angle defines the angle (in radians) to use
  82622. * @param result defines the target matrix
  82623. */
  82624. static RotationXToRef(angle: number, result: Matrix): void;
  82625. /**
  82626. * Creates a new rotation matrix for "angle" radians around the Y axis
  82627. * @param angle defines the angle (in radians) to use
  82628. * @return the new matrix
  82629. */
  82630. static RotationY(angle: number): Matrix;
  82631. /**
  82632. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82633. * @param angle defines the angle (in radians) to use
  82634. * @param result defines the target matrix
  82635. */
  82636. static RotationYToRef(angle: number, result: Matrix): void;
  82637. /**
  82638. * Creates a new rotation matrix for "angle" radians around the Z axis
  82639. * @param angle defines the angle (in radians) to use
  82640. * @return the new matrix
  82641. */
  82642. static RotationZ(angle: number): Matrix;
  82643. /**
  82644. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82645. * @param angle defines the angle (in radians) to use
  82646. * @param result defines the target matrix
  82647. */
  82648. static RotationZToRef(angle: number, result: Matrix): void;
  82649. /**
  82650. * Creates a new rotation matrix for "angle" radians around the given axis
  82651. * @param axis defines the axis to use
  82652. * @param angle defines the angle (in radians) to use
  82653. * @return the new matrix
  82654. */
  82655. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82656. /**
  82657. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82658. * @param axis defines the axis to use
  82659. * @param angle defines the angle (in radians) to use
  82660. * @param result defines the target matrix
  82661. */
  82662. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82663. /**
  82664. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82665. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82666. * @param from defines the vector to align
  82667. * @param to defines the vector to align to
  82668. * @param result defines the target matrix
  82669. */
  82670. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82671. /**
  82672. * Creates a rotation matrix
  82673. * @param yaw defines the yaw angle in radians (Y axis)
  82674. * @param pitch defines the pitch angle in radians (X axis)
  82675. * @param roll defines the roll angle in radians (X axis)
  82676. * @returns the new rotation matrix
  82677. */
  82678. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82679. /**
  82680. * Creates a rotation matrix and stores it in a given matrix
  82681. * @param yaw defines the yaw angle in radians (Y axis)
  82682. * @param pitch defines the pitch angle in radians (X axis)
  82683. * @param roll defines the roll angle in radians (X axis)
  82684. * @param result defines the target matrix
  82685. */
  82686. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82687. /**
  82688. * Creates a scaling matrix
  82689. * @param x defines the scale factor on X axis
  82690. * @param y defines the scale factor on Y axis
  82691. * @param z defines the scale factor on Z axis
  82692. * @returns the new matrix
  82693. */
  82694. static Scaling(x: number, y: number, z: number): Matrix;
  82695. /**
  82696. * Creates a scaling matrix and stores it in a given matrix
  82697. * @param x defines the scale factor on X axis
  82698. * @param y defines the scale factor on Y axis
  82699. * @param z defines the scale factor on Z axis
  82700. * @param result defines the target matrix
  82701. */
  82702. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82703. /**
  82704. * Creates a translation matrix
  82705. * @param x defines the translation on X axis
  82706. * @param y defines the translation on Y axis
  82707. * @param z defines the translationon Z axis
  82708. * @returns the new matrix
  82709. */
  82710. static Translation(x: number, y: number, z: number): Matrix;
  82711. /**
  82712. * Creates a translation matrix and stores it in a given matrix
  82713. * @param x defines the translation on X axis
  82714. * @param y defines the translation on Y axis
  82715. * @param z defines the translationon Z axis
  82716. * @param result defines the target matrix
  82717. */
  82718. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82719. /**
  82720. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82721. * @param startValue defines the start value
  82722. * @param endValue defines the end value
  82723. * @param gradient defines the gradient factor
  82724. * @returns the new matrix
  82725. */
  82726. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82727. /**
  82728. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82729. * @param startValue defines the start value
  82730. * @param endValue defines the end value
  82731. * @param gradient defines the gradient factor
  82732. * @param result defines the Matrix object where to store data
  82733. */
  82734. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82735. /**
  82736. * Builds a new matrix whose values are computed by:
  82737. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82738. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82739. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82740. * @param startValue defines the first matrix
  82741. * @param endValue defines the second matrix
  82742. * @param gradient defines the gradient between the two matrices
  82743. * @returns the new matrix
  82744. */
  82745. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82746. /**
  82747. * Update a matrix to values which are computed by:
  82748. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82749. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82750. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82751. * @param startValue defines the first matrix
  82752. * @param endValue defines the second matrix
  82753. * @param gradient defines the gradient between the two matrices
  82754. * @param result defines the target matrix
  82755. */
  82756. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82757. /**
  82758. * 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"
  82759. * This function works in left handed mode
  82760. * @param eye defines the final position of the entity
  82761. * @param target defines where the entity should look at
  82762. * @param up defines the up vector for the entity
  82763. * @returns the new matrix
  82764. */
  82765. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82766. /**
  82767. * 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".
  82768. * This function works in left handed mode
  82769. * @param eye defines the final position of the entity
  82770. * @param target defines where the entity should look at
  82771. * @param up defines the up vector for the entity
  82772. * @param result defines the target matrix
  82773. */
  82774. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82775. /**
  82776. * 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"
  82777. * This function works in right handed mode
  82778. * @param eye defines the final position of the entity
  82779. * @param target defines where the entity should look at
  82780. * @param up defines the up vector for the entity
  82781. * @returns the new matrix
  82782. */
  82783. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82784. /**
  82785. * 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".
  82786. * This function works in right handed mode
  82787. * @param eye defines the final position of the entity
  82788. * @param target defines where the entity should look at
  82789. * @param up defines the up vector for the entity
  82790. * @param result defines the target matrix
  82791. */
  82792. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82793. /**
  82794. * Create a left-handed orthographic projection matrix
  82795. * @param width defines the viewport width
  82796. * @param height defines the viewport height
  82797. * @param znear defines the near clip plane
  82798. * @param zfar defines the far clip plane
  82799. * @returns a new matrix as a left-handed orthographic projection matrix
  82800. */
  82801. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82802. /**
  82803. * Store a left-handed orthographic projection to a given matrix
  82804. * @param width defines the viewport width
  82805. * @param height defines the viewport height
  82806. * @param znear defines the near clip plane
  82807. * @param zfar defines the far clip plane
  82808. * @param result defines the target matrix
  82809. */
  82810. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82811. /**
  82812. * Create a left-handed orthographic projection matrix
  82813. * @param left defines the viewport left coordinate
  82814. * @param right defines the viewport right coordinate
  82815. * @param bottom defines the viewport bottom coordinate
  82816. * @param top defines the viewport top coordinate
  82817. * @param znear defines the near clip plane
  82818. * @param zfar defines the far clip plane
  82819. * @returns a new matrix as a left-handed orthographic projection matrix
  82820. */
  82821. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82822. /**
  82823. * Stores a left-handed orthographic projection into a given matrix
  82824. * @param left defines the viewport left coordinate
  82825. * @param right defines the viewport right coordinate
  82826. * @param bottom defines the viewport bottom coordinate
  82827. * @param top defines the viewport top coordinate
  82828. * @param znear defines the near clip plane
  82829. * @param zfar defines the far clip plane
  82830. * @param result defines the target matrix
  82831. */
  82832. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82833. /**
  82834. * Creates a right-handed orthographic projection matrix
  82835. * @param left defines the viewport left coordinate
  82836. * @param right defines the viewport right coordinate
  82837. * @param bottom defines the viewport bottom coordinate
  82838. * @param top defines the viewport top coordinate
  82839. * @param znear defines the near clip plane
  82840. * @param zfar defines the far clip plane
  82841. * @returns a new matrix as a right-handed orthographic projection matrix
  82842. */
  82843. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82844. /**
  82845. * Stores a right-handed orthographic projection into a given matrix
  82846. * @param left defines the viewport left coordinate
  82847. * @param right defines the viewport right coordinate
  82848. * @param bottom defines the viewport bottom coordinate
  82849. * @param top defines the viewport top coordinate
  82850. * @param znear defines the near clip plane
  82851. * @param zfar defines the far clip plane
  82852. * @param result defines the target matrix
  82853. */
  82854. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82855. /**
  82856. * Creates a left-handed perspective projection matrix
  82857. * @param width defines the viewport width
  82858. * @param height defines the viewport height
  82859. * @param znear defines the near clip plane
  82860. * @param zfar defines the far clip plane
  82861. * @returns a new matrix as a left-handed perspective projection matrix
  82862. */
  82863. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82864. /**
  82865. * Creates a left-handed perspective projection matrix
  82866. * @param fov defines the horizontal field of view
  82867. * @param aspect defines the aspect ratio
  82868. * @param znear defines the near clip plane
  82869. * @param zfar defines the far clip plane
  82870. * @returns a new matrix as a left-handed perspective projection matrix
  82871. */
  82872. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82873. /**
  82874. * Stores a left-handed perspective projection into a given matrix
  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 defines the far clip plane
  82879. * @param result defines the target matrix
  82880. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82881. */
  82882. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82883. /**
  82884. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  82889. * @param result defines the target matrix
  82890. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82891. */
  82892. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82893. /**
  82894. * Creates a right-handed perspective projection matrix
  82895. * @param fov defines the horizontal field of view
  82896. * @param aspect defines the aspect ratio
  82897. * @param znear defines the near clip plane
  82898. * @param zfar defines the far clip plane
  82899. * @returns a new matrix as a right-handed perspective projection matrix
  82900. */
  82901. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  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 defines the far clip plane
  82908. * @param result defines the target matrix
  82909. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82910. */
  82911. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82912. /**
  82913. * Stores a right-handed perspective projection into a given matrix
  82914. * @param fov defines the horizontal field of view
  82915. * @param aspect defines the aspect ratio
  82916. * @param znear defines the near clip plane
  82917. * @param zfar not used as infinity is used as far clip
  82918. * @param result defines the target matrix
  82919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82920. */
  82921. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82922. /**
  82923. * Stores a perspective projection for WebVR info a given matrix
  82924. * @param fov defines the field of view
  82925. * @param znear defines the near clip plane
  82926. * @param zfar defines the far clip plane
  82927. * @param result defines the target matrix
  82928. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82929. */
  82930. static PerspectiveFovWebVRToRef(fov: {
  82931. upDegrees: number;
  82932. downDegrees: number;
  82933. leftDegrees: number;
  82934. rightDegrees: number;
  82935. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82936. /**
  82937. * Computes a complete transformation matrix
  82938. * @param viewport defines the viewport to use
  82939. * @param world defines the world matrix
  82940. * @param view defines the view matrix
  82941. * @param projection defines the projection matrix
  82942. * @param zmin defines the near clip plane
  82943. * @param zmax defines the far clip plane
  82944. * @returns the transformation matrix
  82945. */
  82946. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82947. /**
  82948. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82949. * @param matrix defines the matrix to use
  82950. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82951. */
  82952. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82953. /**
  82954. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82955. * @param matrix defines the matrix to use
  82956. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82957. */
  82958. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82959. /**
  82960. * Compute the transpose of a given matrix
  82961. * @param matrix defines the matrix to transpose
  82962. * @returns the new matrix
  82963. */
  82964. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82965. /**
  82966. * Compute the transpose of a matrix and store it in a target matrix
  82967. * @param matrix defines the matrix to transpose
  82968. * @param result defines the target matrix
  82969. */
  82970. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82971. /**
  82972. * Computes a reflection matrix from a plane
  82973. * @param plane defines the reflection plane
  82974. * @returns a new matrix
  82975. */
  82976. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82977. /**
  82978. * Computes a reflection matrix from a plane
  82979. * @param plane defines the reflection plane
  82980. * @param result defines the target matrix
  82981. */
  82982. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82983. /**
  82984. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82985. * @param xaxis defines the value of the 1st axis
  82986. * @param yaxis defines the value of the 2nd axis
  82987. * @param zaxis defines the value of the 3rd axis
  82988. * @param result defines the target matrix
  82989. */
  82990. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82991. /**
  82992. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82993. * @param quat defines the quaternion to use
  82994. * @param result defines the target matrix
  82995. */
  82996. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82997. }
  82998. /**
  82999. * @hidden
  83000. */
  83001. export class TmpVectors {
  83002. static Vector2: Vector2[];
  83003. static Vector3: Vector3[];
  83004. static Vector4: Vector4[];
  83005. static Quaternion: Quaternion[];
  83006. static Matrix: Matrix[];
  83007. }
  83008. }
  83009. declare module BABYLON {
  83010. /**
  83011. * Defines potential orientation for back face culling
  83012. */
  83013. export enum Orientation {
  83014. /**
  83015. * Clockwise
  83016. */
  83017. CW = 0,
  83018. /** Counter clockwise */
  83019. CCW = 1
  83020. }
  83021. /** Class used to represent a Bezier curve */
  83022. export class BezierCurve {
  83023. /**
  83024. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83025. * @param t defines the time
  83026. * @param x1 defines the left coordinate on X axis
  83027. * @param y1 defines the left coordinate on Y axis
  83028. * @param x2 defines the right coordinate on X axis
  83029. * @param y2 defines the right coordinate on Y axis
  83030. * @returns the interpolated value
  83031. */
  83032. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83033. }
  83034. /**
  83035. * Defines angle representation
  83036. */
  83037. export class Angle {
  83038. private _radians;
  83039. /**
  83040. * Creates an Angle object of "radians" radians (float).
  83041. * @param radians the angle in radians
  83042. */
  83043. constructor(radians: number);
  83044. /**
  83045. * Get value in degrees
  83046. * @returns the Angle value in degrees (float)
  83047. */
  83048. degrees(): number;
  83049. /**
  83050. * Get value in radians
  83051. * @returns the Angle value in radians (float)
  83052. */
  83053. radians(): number;
  83054. /**
  83055. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  83056. * @param a defines first vector
  83057. * @param b defines second vector
  83058. * @returns a new Angle
  83059. */
  83060. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83061. /**
  83062. * Gets a new Angle object from the given float in radians
  83063. * @param radians defines the angle value in radians
  83064. * @returns a new Angle
  83065. */
  83066. static FromRadians(radians: number): Angle;
  83067. /**
  83068. * Gets a new Angle object from the given float in degrees
  83069. * @param degrees defines the angle value in degrees
  83070. * @returns a new Angle
  83071. */
  83072. static FromDegrees(degrees: number): Angle;
  83073. }
  83074. /**
  83075. * This represents an arc in a 2d space.
  83076. */
  83077. export class Arc2 {
  83078. /** Defines the start point of the arc */
  83079. startPoint: Vector2;
  83080. /** Defines the mid point of the arc */
  83081. midPoint: Vector2;
  83082. /** Defines the end point of the arc */
  83083. endPoint: Vector2;
  83084. /**
  83085. * Defines the center point of the arc.
  83086. */
  83087. centerPoint: Vector2;
  83088. /**
  83089. * Defines the radius of the arc.
  83090. */
  83091. radius: number;
  83092. /**
  83093. * Defines the angle of the arc (from mid point to end point).
  83094. */
  83095. angle: Angle;
  83096. /**
  83097. * Defines the start angle of the arc (from start point to middle point).
  83098. */
  83099. startAngle: Angle;
  83100. /**
  83101. * Defines the orientation of the arc (clock wise/counter clock wise).
  83102. */
  83103. orientation: Orientation;
  83104. /**
  83105. * Creates an Arc object from the three given points : start, middle and end.
  83106. * @param startPoint Defines the start point of the arc
  83107. * @param midPoint Defines the midlle point of the arc
  83108. * @param endPoint Defines the end point of the arc
  83109. */
  83110. constructor(
  83111. /** Defines the start point of the arc */
  83112. startPoint: Vector2,
  83113. /** Defines the mid point of the arc */
  83114. midPoint: Vector2,
  83115. /** Defines the end point of the arc */
  83116. endPoint: Vector2);
  83117. }
  83118. /**
  83119. * Represents a 2D path made up of multiple 2D points
  83120. */
  83121. export class Path2 {
  83122. private _points;
  83123. private _length;
  83124. /**
  83125. * If the path start and end point are the same
  83126. */
  83127. closed: boolean;
  83128. /**
  83129. * Creates a Path2 object from the starting 2D coordinates x and y.
  83130. * @param x the starting points x value
  83131. * @param y the starting points y value
  83132. */
  83133. constructor(x: number, y: number);
  83134. /**
  83135. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83136. * @param x the added points x value
  83137. * @param y the added points y value
  83138. * @returns the updated Path2.
  83139. */
  83140. addLineTo(x: number, y: number): Path2;
  83141. /**
  83142. * 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.
  83143. * @param midX middle point x value
  83144. * @param midY middle point y value
  83145. * @param endX end point x value
  83146. * @param endY end point y value
  83147. * @param numberOfSegments (default: 36)
  83148. * @returns the updated Path2.
  83149. */
  83150. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83151. /**
  83152. * Closes the Path2.
  83153. * @returns the Path2.
  83154. */
  83155. close(): Path2;
  83156. /**
  83157. * Gets the sum of the distance between each sequential point in the path
  83158. * @returns the Path2 total length (float).
  83159. */
  83160. length(): number;
  83161. /**
  83162. * Gets the points which construct the path
  83163. * @returns the Path2 internal array of points.
  83164. */
  83165. getPoints(): Vector2[];
  83166. /**
  83167. * Retreives the point at the distance aways from the starting point
  83168. * @param normalizedLengthPosition the length along the path to retreive the point from
  83169. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83170. */
  83171. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83172. /**
  83173. * Creates a new path starting from an x and y position
  83174. * @param x starting x value
  83175. * @param y starting y value
  83176. * @returns a new Path2 starting at the coordinates (x, y).
  83177. */
  83178. static StartingAt(x: number, y: number): Path2;
  83179. }
  83180. /**
  83181. * Represents a 3D path made up of multiple 3D points
  83182. */
  83183. export class Path3D {
  83184. /**
  83185. * an array of Vector3, the curve axis of the Path3D
  83186. */
  83187. path: Vector3[];
  83188. private _curve;
  83189. private _distances;
  83190. private _tangents;
  83191. private _normals;
  83192. private _binormals;
  83193. private _raw;
  83194. private _alignTangentsWithPath;
  83195. private readonly _pointAtData;
  83196. /**
  83197. * new Path3D(path, normal, raw)
  83198. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83199. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83200. * @param path an array of Vector3, the curve axis of the Path3D
  83201. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83202. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83203. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83204. */
  83205. constructor(
  83206. /**
  83207. * an array of Vector3, the curve axis of the Path3D
  83208. */
  83209. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83210. /**
  83211. * Returns the Path3D array of successive Vector3 designing its curve.
  83212. * @returns the Path3D array of successive Vector3 designing its curve.
  83213. */
  83214. getCurve(): Vector3[];
  83215. /**
  83216. * Returns the Path3D array of successive Vector3 designing its curve.
  83217. * @returns the Path3D array of successive Vector3 designing its curve.
  83218. */
  83219. getPoints(): Vector3[];
  83220. /**
  83221. * @returns the computed length (float) of the path.
  83222. */
  83223. length(): number;
  83224. /**
  83225. * Returns an array populated with tangent vectors on each Path3D curve point.
  83226. * @returns an array populated with tangent vectors on each Path3D curve point.
  83227. */
  83228. getTangents(): Vector3[];
  83229. /**
  83230. * Returns an array populated with normal vectors on each Path3D curve point.
  83231. * @returns an array populated with normal vectors on each Path3D curve point.
  83232. */
  83233. getNormals(): Vector3[];
  83234. /**
  83235. * Returns an array populated with binormal vectors on each Path3D curve point.
  83236. * @returns an array populated with binormal vectors on each Path3D curve point.
  83237. */
  83238. getBinormals(): Vector3[];
  83239. /**
  83240. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83241. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83242. */
  83243. getDistances(): number[];
  83244. /**
  83245. * Returns an interpolated point along this path
  83246. * @param position the position of the point along this path, from 0.0 to 1.0
  83247. * @returns a new Vector3 as the point
  83248. */
  83249. getPointAt(position: number): Vector3;
  83250. /**
  83251. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83252. * @param position the position of the point along this path, from 0.0 to 1.0
  83253. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83254. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83255. */
  83256. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83257. /**
  83258. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83259. * @param position the position of the point along this path, from 0.0 to 1.0
  83260. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83261. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83262. */
  83263. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83264. /**
  83265. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83266. * @param position the position of the point along this path, from 0.0 to 1.0
  83267. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83268. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83269. */
  83270. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83271. /**
  83272. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83273. * @param position the position of the point along this path, from 0.0 to 1.0
  83274. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83275. */
  83276. getDistanceAt(position: number): number;
  83277. /**
  83278. * Returns the array index of the previous point of an interpolated point along this path
  83279. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83280. * @returns the array index
  83281. */
  83282. getPreviousPointIndexAt(position: number): number;
  83283. /**
  83284. * 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)
  83285. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83286. * @returns the sub position
  83287. */
  83288. getSubPositionAt(position: number): number;
  83289. /**
  83290. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83291. * @param target the vector of which to get the closest position to
  83292. * @returns the position of the closest virtual point on this path to the target vector
  83293. */
  83294. getClosestPositionTo(target: Vector3): number;
  83295. /**
  83296. * Returns a sub path (slice) of this path
  83297. * @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
  83298. * @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
  83299. * @returns a sub path (slice) of this path
  83300. */
  83301. slice(start?: number, end?: number): Path3D;
  83302. /**
  83303. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83304. * @param path path which all values are copied into the curves points
  83305. * @param firstNormal which should be projected onto the curve
  83306. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83307. * @returns the same object updated.
  83308. */
  83309. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83310. private _compute;
  83311. private _getFirstNonNullVector;
  83312. private _getLastNonNullVector;
  83313. private _normalVector;
  83314. /**
  83315. * Updates the point at data for an interpolated point along this curve
  83316. * @param position the position of the point along this curve, from 0.0 to 1.0
  83317. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83318. * @returns the (updated) point at data
  83319. */
  83320. private _updatePointAtData;
  83321. /**
  83322. * Updates the point at data from the specified parameters
  83323. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83324. * @param point the interpolated point
  83325. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83326. */
  83327. private _setPointAtData;
  83328. /**
  83329. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83330. */
  83331. private _updateInterpolationMatrix;
  83332. }
  83333. /**
  83334. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83335. * A Curve3 is designed from a series of successive Vector3.
  83336. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83337. */
  83338. export class Curve3 {
  83339. private _points;
  83340. private _length;
  83341. /**
  83342. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83343. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83344. * @param v1 (Vector3) the control point
  83345. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83346. * @param nbPoints (integer) the wanted number of points in the curve
  83347. * @returns the created Curve3
  83348. */
  83349. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83350. /**
  83351. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83352. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83353. * @param v1 (Vector3) the first control point
  83354. * @param v2 (Vector3) the second control point
  83355. * @param v3 (Vector3) the end point of the Cubic Bezier
  83356. * @param nbPoints (integer) the wanted number of points in the curve
  83357. * @returns the created Curve3
  83358. */
  83359. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83360. /**
  83361. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83362. * @param p1 (Vector3) the origin point of the Hermite Spline
  83363. * @param t1 (Vector3) the tangent vector at the origin point
  83364. * @param p2 (Vector3) the end point of the Hermite Spline
  83365. * @param t2 (Vector3) the tangent vector at the end point
  83366. * @param nbPoints (integer) the wanted number of points in the curve
  83367. * @returns the created Curve3
  83368. */
  83369. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83370. /**
  83371. * Returns a Curve3 object along a CatmullRom Spline curve :
  83372. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83373. * @param nbPoints (integer) the wanted number of points between each curve control points
  83374. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83375. * @returns the created Curve3
  83376. */
  83377. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83378. /**
  83379. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83380. * A Curve3 is designed from a series of successive Vector3.
  83381. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83382. * @param points points which make up the curve
  83383. */
  83384. constructor(points: Vector3[]);
  83385. /**
  83386. * @returns the Curve3 stored array of successive Vector3
  83387. */
  83388. getPoints(): Vector3[];
  83389. /**
  83390. * @returns the computed length (float) of the curve.
  83391. */
  83392. length(): number;
  83393. /**
  83394. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83395. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83396. * curveA and curveB keep unchanged.
  83397. * @param curve the curve to continue from this curve
  83398. * @returns the newly constructed curve
  83399. */
  83400. continue(curve: DeepImmutable<Curve3>): Curve3;
  83401. private _computeLength;
  83402. }
  83403. }
  83404. declare module BABYLON {
  83405. /**
  83406. * This represents the main contract an easing function should follow.
  83407. * Easing functions are used throughout the animation system.
  83408. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83409. */
  83410. export interface IEasingFunction {
  83411. /**
  83412. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83413. * of the easing function.
  83414. * The link below provides some of the most common examples of easing functions.
  83415. * @see https://easings.net/
  83416. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83417. * @returns the corresponding value on the curve defined by the easing function
  83418. */
  83419. ease(gradient: number): number;
  83420. }
  83421. /**
  83422. * Base class used for every default easing function.
  83423. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83424. */
  83425. export class EasingFunction implements IEasingFunction {
  83426. /**
  83427. * Interpolation follows the mathematical formula associated with the easing function.
  83428. */
  83429. static readonly EASINGMODE_EASEIN: number;
  83430. /**
  83431. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83432. */
  83433. static readonly EASINGMODE_EASEOUT: number;
  83434. /**
  83435. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83436. */
  83437. static readonly EASINGMODE_EASEINOUT: number;
  83438. private _easingMode;
  83439. /**
  83440. * Sets the easing mode of the current function.
  83441. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83442. */
  83443. setEasingMode(easingMode: number): void;
  83444. /**
  83445. * Gets the current easing mode.
  83446. * @returns the easing mode
  83447. */
  83448. getEasingMode(): number;
  83449. /**
  83450. * @hidden
  83451. */
  83452. easeInCore(gradient: number): number;
  83453. /**
  83454. * Given an input gradient between 0 and 1, this returns the corresponding value
  83455. * of the easing function.
  83456. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83457. * @returns the corresponding value on the curve defined by the easing function
  83458. */
  83459. ease(gradient: number): number;
  83460. }
  83461. /**
  83462. * Easing function with a circle shape (see link below).
  83463. * @see https://easings.net/#easeInCirc
  83464. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83465. */
  83466. export class CircleEase extends EasingFunction implements IEasingFunction {
  83467. /** @hidden */
  83468. easeInCore(gradient: number): number;
  83469. }
  83470. /**
  83471. * Easing function with a ease back shape (see link below).
  83472. * @see https://easings.net/#easeInBack
  83473. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83474. */
  83475. export class BackEase extends EasingFunction implements IEasingFunction {
  83476. /** Defines the amplitude of the function */
  83477. amplitude: number;
  83478. /**
  83479. * Instantiates a back ease easing
  83480. * @see https://easings.net/#easeInBack
  83481. * @param amplitude Defines the amplitude of the function
  83482. */
  83483. constructor(
  83484. /** Defines the amplitude of the function */
  83485. amplitude?: number);
  83486. /** @hidden */
  83487. easeInCore(gradient: number): number;
  83488. }
  83489. /**
  83490. * Easing function with a bouncing shape (see link below).
  83491. * @see https://easings.net/#easeInBounce
  83492. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83493. */
  83494. export class BounceEase extends EasingFunction implements IEasingFunction {
  83495. /** Defines the number of bounces */
  83496. bounces: number;
  83497. /** Defines the amplitude of the bounce */
  83498. bounciness: number;
  83499. /**
  83500. * Instantiates a bounce easing
  83501. * @see https://easings.net/#easeInBounce
  83502. * @param bounces Defines the number of bounces
  83503. * @param bounciness Defines the amplitude of the bounce
  83504. */
  83505. constructor(
  83506. /** Defines the number of bounces */
  83507. bounces?: number,
  83508. /** Defines the amplitude of the bounce */
  83509. bounciness?: number);
  83510. /** @hidden */
  83511. easeInCore(gradient: number): number;
  83512. }
  83513. /**
  83514. * Easing function with a power of 3 shape (see link below).
  83515. * @see https://easings.net/#easeInCubic
  83516. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83517. */
  83518. export class CubicEase extends EasingFunction implements IEasingFunction {
  83519. /** @hidden */
  83520. easeInCore(gradient: number): number;
  83521. }
  83522. /**
  83523. * Easing function with an elastic shape (see link below).
  83524. * @see https://easings.net/#easeInElastic
  83525. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83526. */
  83527. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83528. /** Defines the number of oscillations*/
  83529. oscillations: number;
  83530. /** Defines the amplitude of the oscillations*/
  83531. springiness: number;
  83532. /**
  83533. * Instantiates an elastic easing function
  83534. * @see https://easings.net/#easeInElastic
  83535. * @param oscillations Defines the number of oscillations
  83536. * @param springiness Defines the amplitude of the oscillations
  83537. */
  83538. constructor(
  83539. /** Defines the number of oscillations*/
  83540. oscillations?: number,
  83541. /** Defines the amplitude of the oscillations*/
  83542. springiness?: number);
  83543. /** @hidden */
  83544. easeInCore(gradient: number): number;
  83545. }
  83546. /**
  83547. * Easing function with an exponential shape (see link below).
  83548. * @see https://easings.net/#easeInExpo
  83549. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83550. */
  83551. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83552. /** Defines the exponent of the function */
  83553. exponent: number;
  83554. /**
  83555. * Instantiates an exponential easing function
  83556. * @see https://easings.net/#easeInExpo
  83557. * @param exponent Defines the exponent of the function
  83558. */
  83559. constructor(
  83560. /** Defines the exponent of the function */
  83561. exponent?: number);
  83562. /** @hidden */
  83563. easeInCore(gradient: number): number;
  83564. }
  83565. /**
  83566. * Easing function with a power shape (see link below).
  83567. * @see https://easings.net/#easeInQuad
  83568. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83569. */
  83570. export class PowerEase extends EasingFunction implements IEasingFunction {
  83571. /** Defines the power of the function */
  83572. power: number;
  83573. /**
  83574. * Instantiates an power base easing function
  83575. * @see https://easings.net/#easeInQuad
  83576. * @param power Defines the power of the function
  83577. */
  83578. constructor(
  83579. /** Defines the power of the function */
  83580. power?: number);
  83581. /** @hidden */
  83582. easeInCore(gradient: number): number;
  83583. }
  83584. /**
  83585. * Easing function with a power of 2 shape (see link below).
  83586. * @see https://easings.net/#easeInQuad
  83587. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83588. */
  83589. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83590. /** @hidden */
  83591. easeInCore(gradient: number): number;
  83592. }
  83593. /**
  83594. * Easing function with a power of 4 shape (see link below).
  83595. * @see https://easings.net/#easeInQuart
  83596. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83597. */
  83598. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83599. /** @hidden */
  83600. easeInCore(gradient: number): number;
  83601. }
  83602. /**
  83603. * Easing function with a power of 5 shape (see link below).
  83604. * @see https://easings.net/#easeInQuint
  83605. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83606. */
  83607. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83608. /** @hidden */
  83609. easeInCore(gradient: number): number;
  83610. }
  83611. /**
  83612. * Easing function with a sin shape (see link below).
  83613. * @see https://easings.net/#easeInSine
  83614. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83615. */
  83616. export class SineEase extends EasingFunction implements IEasingFunction {
  83617. /** @hidden */
  83618. easeInCore(gradient: number): number;
  83619. }
  83620. /**
  83621. * Easing function with a bezier shape (see link below).
  83622. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83623. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83624. */
  83625. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83626. /** Defines the x component of the start tangent in the bezier curve */
  83627. x1: number;
  83628. /** Defines the y component of the start tangent in the bezier curve */
  83629. y1: number;
  83630. /** Defines the x component of the end tangent in the bezier curve */
  83631. x2: number;
  83632. /** Defines the y component of the end tangent in the bezier curve */
  83633. y2: number;
  83634. /**
  83635. * Instantiates a bezier function
  83636. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83637. * @param x1 Defines the x component of the start tangent in the bezier curve
  83638. * @param y1 Defines the y component of the start tangent in the bezier curve
  83639. * @param x2 Defines the x component of the end tangent in the bezier curve
  83640. * @param y2 Defines the y component of the end tangent in the bezier curve
  83641. */
  83642. constructor(
  83643. /** Defines the x component of the start tangent in the bezier curve */
  83644. x1?: number,
  83645. /** Defines the y component of the start tangent in the bezier curve */
  83646. y1?: number,
  83647. /** Defines the x component of the end tangent in the bezier curve */
  83648. x2?: number,
  83649. /** Defines the y component of the end tangent in the bezier curve */
  83650. y2?: number);
  83651. /** @hidden */
  83652. easeInCore(gradient: number): number;
  83653. }
  83654. }
  83655. declare module BABYLON {
  83656. /**
  83657. * Class used to hold a RBG color
  83658. */
  83659. export class Color3 {
  83660. /**
  83661. * Defines the red component (between 0 and 1, default is 0)
  83662. */
  83663. r: number;
  83664. /**
  83665. * Defines the green component (between 0 and 1, default is 0)
  83666. */
  83667. g: number;
  83668. /**
  83669. * Defines the blue component (between 0 and 1, default is 0)
  83670. */
  83671. b: number;
  83672. /**
  83673. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83674. * @param r defines the red component (between 0 and 1, default is 0)
  83675. * @param g defines the green component (between 0 and 1, default is 0)
  83676. * @param b defines the blue component (between 0 and 1, default is 0)
  83677. */
  83678. constructor(
  83679. /**
  83680. * Defines the red component (between 0 and 1, default is 0)
  83681. */
  83682. r?: number,
  83683. /**
  83684. * Defines the green component (between 0 and 1, default is 0)
  83685. */
  83686. g?: number,
  83687. /**
  83688. * Defines the blue component (between 0 and 1, default is 0)
  83689. */
  83690. b?: number);
  83691. /**
  83692. * Creates a string with the Color3 current values
  83693. * @returns the string representation of the Color3 object
  83694. */
  83695. toString(): string;
  83696. /**
  83697. * Returns the string "Color3"
  83698. * @returns "Color3"
  83699. */
  83700. getClassName(): string;
  83701. /**
  83702. * Compute the Color3 hash code
  83703. * @returns an unique number that can be used to hash Color3 objects
  83704. */
  83705. getHashCode(): number;
  83706. /**
  83707. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83708. * @param array defines the array where to store the r,g,b components
  83709. * @param index defines an optional index in the target array to define where to start storing values
  83710. * @returns the current Color3 object
  83711. */
  83712. toArray(array: FloatArray, index?: number): Color3;
  83713. /**
  83714. * Returns a new Color4 object from the current Color3 and the given alpha
  83715. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83716. * @returns a new Color4 object
  83717. */
  83718. toColor4(alpha?: number): Color4;
  83719. /**
  83720. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83721. * @returns the new array
  83722. */
  83723. asArray(): number[];
  83724. /**
  83725. * Returns the luminance value
  83726. * @returns a float value
  83727. */
  83728. toLuminance(): number;
  83729. /**
  83730. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83731. * @param otherColor defines the second operand
  83732. * @returns the new Color3 object
  83733. */
  83734. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83735. /**
  83736. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83737. * @param otherColor defines the second operand
  83738. * @param result defines the Color3 object where to store the result
  83739. * @returns the current Color3
  83740. */
  83741. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83742. /**
  83743. * Determines equality between Color3 objects
  83744. * @param otherColor defines the second operand
  83745. * @returns true if the rgb values are equal to the given ones
  83746. */
  83747. equals(otherColor: DeepImmutable<Color3>): boolean;
  83748. /**
  83749. * Determines equality between the current Color3 object and a set of r,b,g values
  83750. * @param r defines the red component to check
  83751. * @param g defines the green component to check
  83752. * @param b defines the blue component to check
  83753. * @returns true if the rgb values are equal to the given ones
  83754. */
  83755. equalsFloats(r: number, g: number, b: number): boolean;
  83756. /**
  83757. * Multiplies in place each rgb value by scale
  83758. * @param scale defines the scaling factor
  83759. * @returns the updated Color3
  83760. */
  83761. scale(scale: number): Color3;
  83762. /**
  83763. * Multiplies the rgb values by scale and stores the result into "result"
  83764. * @param scale defines the scaling factor
  83765. * @param result defines the Color3 object where to store the result
  83766. * @returns the unmodified current Color3
  83767. */
  83768. scaleToRef(scale: number, result: Color3): Color3;
  83769. /**
  83770. * Scale the current Color3 values by a factor and add the result to a given Color3
  83771. * @param scale defines the scale factor
  83772. * @param result defines color to store the result into
  83773. * @returns the unmodified current Color3
  83774. */
  83775. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83776. /**
  83777. * Clamps the rgb values by the min and max values and stores the result into "result"
  83778. * @param min defines minimum clamping value (default is 0)
  83779. * @param max defines maximum clamping value (default is 1)
  83780. * @param result defines color to store the result into
  83781. * @returns the original Color3
  83782. */
  83783. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83784. /**
  83785. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83786. * @param otherColor defines the second operand
  83787. * @returns the new Color3
  83788. */
  83789. add(otherColor: DeepImmutable<Color3>): Color3;
  83790. /**
  83791. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83792. * @param otherColor defines the second operand
  83793. * @param result defines Color3 object to store the result into
  83794. * @returns the unmodified current Color3
  83795. */
  83796. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83797. /**
  83798. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83799. * @param otherColor defines the second operand
  83800. * @returns the new Color3
  83801. */
  83802. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83803. /**
  83804. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83805. * @param otherColor defines the second operand
  83806. * @param result defines Color3 object to store the result into
  83807. * @returns the unmodified current Color3
  83808. */
  83809. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83810. /**
  83811. * Copy the current object
  83812. * @returns a new Color3 copied the current one
  83813. */
  83814. clone(): Color3;
  83815. /**
  83816. * Copies the rgb values from the source in the current Color3
  83817. * @param source defines the source Color3 object
  83818. * @returns the updated Color3 object
  83819. */
  83820. copyFrom(source: DeepImmutable<Color3>): Color3;
  83821. /**
  83822. * Updates the Color3 rgb values from the given floats
  83823. * @param r defines the red component to read from
  83824. * @param g defines the green component to read from
  83825. * @param b defines the blue component to read from
  83826. * @returns the current Color3 object
  83827. */
  83828. copyFromFloats(r: number, g: number, b: number): Color3;
  83829. /**
  83830. * Updates the Color3 rgb values from the given floats
  83831. * @param r defines the red component to read from
  83832. * @param g defines the green component to read from
  83833. * @param b defines the blue component to read from
  83834. * @returns the current Color3 object
  83835. */
  83836. set(r: number, g: number, b: number): Color3;
  83837. /**
  83838. * Compute the Color3 hexadecimal code as a string
  83839. * @returns a string containing the hexadecimal representation of the Color3 object
  83840. */
  83841. toHexString(): string;
  83842. /**
  83843. * Computes a new Color3 converted from the current one to linear space
  83844. * @returns a new Color3 object
  83845. */
  83846. toLinearSpace(): Color3;
  83847. /**
  83848. * Converts current color in rgb space to HSV values
  83849. * @returns a new color3 representing the HSV values
  83850. */
  83851. toHSV(): Color3;
  83852. /**
  83853. * Converts current color in rgb space to HSV values
  83854. * @param result defines the Color3 where to store the HSV values
  83855. */
  83856. toHSVToRef(result: Color3): void;
  83857. /**
  83858. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83859. * @param convertedColor defines the Color3 object where to store the linear space version
  83860. * @returns the unmodified Color3
  83861. */
  83862. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83863. /**
  83864. * Computes a new Color3 converted from the current one to gamma space
  83865. * @returns a new Color3 object
  83866. */
  83867. toGammaSpace(): Color3;
  83868. /**
  83869. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83870. * @param convertedColor defines the Color3 object where to store the gamma space version
  83871. * @returns the unmodified Color3
  83872. */
  83873. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83874. private static _BlackReadOnly;
  83875. /**
  83876. * Convert Hue, saturation and value to a Color3 (RGB)
  83877. * @param hue defines the hue
  83878. * @param saturation defines the saturation
  83879. * @param value defines the value
  83880. * @param result defines the Color3 where to store the RGB values
  83881. */
  83882. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83883. /**
  83884. * Creates a new Color3 from the string containing valid hexadecimal values
  83885. * @param hex defines a string containing valid hexadecimal values
  83886. * @returns a new Color3 object
  83887. */
  83888. static FromHexString(hex: string): Color3;
  83889. /**
  83890. * Creates a new Color3 from the starting index of the given array
  83891. * @param array defines the source array
  83892. * @param offset defines an offset in the source array
  83893. * @returns a new Color3 object
  83894. */
  83895. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83896. /**
  83897. * Creates a new Color3 from integer values (< 256)
  83898. * @param r defines the red component to read from (value between 0 and 255)
  83899. * @param g defines the green component to read from (value between 0 and 255)
  83900. * @param b defines the blue component to read from (value between 0 and 255)
  83901. * @returns a new Color3 object
  83902. */
  83903. static FromInts(r: number, g: number, b: number): Color3;
  83904. /**
  83905. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83906. * @param start defines the start Color3 value
  83907. * @param end defines the end Color3 value
  83908. * @param amount defines the gradient value between start and end
  83909. * @returns a new Color3 object
  83910. */
  83911. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83912. /**
  83913. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83914. * @param left defines the start value
  83915. * @param right defines the end value
  83916. * @param amount defines the gradient factor
  83917. * @param result defines the Color3 object where to store the result
  83918. */
  83919. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83920. /**
  83921. * Returns a Color3 value containing a red color
  83922. * @returns a new Color3 object
  83923. */
  83924. static Red(): Color3;
  83925. /**
  83926. * Returns a Color3 value containing a green color
  83927. * @returns a new Color3 object
  83928. */
  83929. static Green(): Color3;
  83930. /**
  83931. * Returns a Color3 value containing a blue color
  83932. * @returns a new Color3 object
  83933. */
  83934. static Blue(): Color3;
  83935. /**
  83936. * Returns a Color3 value containing a black color
  83937. * @returns a new Color3 object
  83938. */
  83939. static Black(): Color3;
  83940. /**
  83941. * Gets a Color3 value containing a black color that must not be updated
  83942. */
  83943. static get BlackReadOnly(): DeepImmutable<Color3>;
  83944. /**
  83945. * Returns a Color3 value containing a white color
  83946. * @returns a new Color3 object
  83947. */
  83948. static White(): Color3;
  83949. /**
  83950. * Returns a Color3 value containing a purple color
  83951. * @returns a new Color3 object
  83952. */
  83953. static Purple(): Color3;
  83954. /**
  83955. * Returns a Color3 value containing a magenta color
  83956. * @returns a new Color3 object
  83957. */
  83958. static Magenta(): Color3;
  83959. /**
  83960. * Returns a Color3 value containing a yellow color
  83961. * @returns a new Color3 object
  83962. */
  83963. static Yellow(): Color3;
  83964. /**
  83965. * Returns a Color3 value containing a gray color
  83966. * @returns a new Color3 object
  83967. */
  83968. static Gray(): Color3;
  83969. /**
  83970. * Returns a Color3 value containing a teal color
  83971. * @returns a new Color3 object
  83972. */
  83973. static Teal(): Color3;
  83974. /**
  83975. * Returns a Color3 value containing a random color
  83976. * @returns a new Color3 object
  83977. */
  83978. static Random(): Color3;
  83979. }
  83980. /**
  83981. * Class used to hold a RBGA color
  83982. */
  83983. export class Color4 {
  83984. /**
  83985. * Defines the red component (between 0 and 1, default is 0)
  83986. */
  83987. r: number;
  83988. /**
  83989. * Defines the green component (between 0 and 1, default is 0)
  83990. */
  83991. g: number;
  83992. /**
  83993. * Defines the blue component (between 0 and 1, default is 0)
  83994. */
  83995. b: number;
  83996. /**
  83997. * Defines the alpha component (between 0 and 1, default is 1)
  83998. */
  83999. a: number;
  84000. /**
  84001. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84002. * @param r defines the red component (between 0 and 1, default is 0)
  84003. * @param g defines the green component (between 0 and 1, default is 0)
  84004. * @param b defines the blue component (between 0 and 1, default is 0)
  84005. * @param a defines the alpha component (between 0 and 1, default is 1)
  84006. */
  84007. constructor(
  84008. /**
  84009. * Defines the red component (between 0 and 1, default is 0)
  84010. */
  84011. r?: number,
  84012. /**
  84013. * Defines the green component (between 0 and 1, default is 0)
  84014. */
  84015. g?: number,
  84016. /**
  84017. * Defines the blue component (between 0 and 1, default is 0)
  84018. */
  84019. b?: number,
  84020. /**
  84021. * Defines the alpha component (between 0 and 1, default is 1)
  84022. */
  84023. a?: number);
  84024. /**
  84025. * Adds in place the given Color4 values to the current Color4 object
  84026. * @param right defines the second operand
  84027. * @returns the current updated Color4 object
  84028. */
  84029. addInPlace(right: DeepImmutable<Color4>): Color4;
  84030. /**
  84031. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84032. * @returns the new array
  84033. */
  84034. asArray(): number[];
  84035. /**
  84036. * Stores from the starting index in the given array the Color4 successive values
  84037. * @param array defines the array where to store the r,g,b components
  84038. * @param index defines an optional index in the target array to define where to start storing values
  84039. * @returns the current Color4 object
  84040. */
  84041. toArray(array: number[], index?: number): Color4;
  84042. /**
  84043. * Determines equality between Color4 objects
  84044. * @param otherColor defines the second operand
  84045. * @returns true if the rgba values are equal to the given ones
  84046. */
  84047. equals(otherColor: DeepImmutable<Color4>): boolean;
  84048. /**
  84049. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84050. * @param right defines the second operand
  84051. * @returns a new Color4 object
  84052. */
  84053. add(right: DeepImmutable<Color4>): Color4;
  84054. /**
  84055. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84056. * @param right defines the second operand
  84057. * @returns a new Color4 object
  84058. */
  84059. subtract(right: DeepImmutable<Color4>): Color4;
  84060. /**
  84061. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84062. * @param right defines the second operand
  84063. * @param result defines the Color4 object where to store the result
  84064. * @returns the current Color4 object
  84065. */
  84066. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84067. /**
  84068. * Creates a new Color4 with the current Color4 values multiplied by scale
  84069. * @param scale defines the scaling factor to apply
  84070. * @returns a new Color4 object
  84071. */
  84072. scale(scale: number): Color4;
  84073. /**
  84074. * Multiplies the current Color4 values by scale and stores the result in "result"
  84075. * @param scale defines the scaling factor to apply
  84076. * @param result defines the Color4 object where to store the result
  84077. * @returns the current unmodified Color4
  84078. */
  84079. scaleToRef(scale: number, result: Color4): Color4;
  84080. /**
  84081. * Scale the current Color4 values by a factor and add the result to a given Color4
  84082. * @param scale defines the scale factor
  84083. * @param result defines the Color4 object where to store the result
  84084. * @returns the unmodified current Color4
  84085. */
  84086. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84087. /**
  84088. * Clamps the rgb values by the min and max values and stores the result into "result"
  84089. * @param min defines minimum clamping value (default is 0)
  84090. * @param max defines maximum clamping value (default is 1)
  84091. * @param result defines color to store the result into.
  84092. * @returns the cuurent Color4
  84093. */
  84094. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84095. /**
  84096. * Multipy an Color4 value by another and return a new Color4 object
  84097. * @param color defines the Color4 value to multiply by
  84098. * @returns a new Color4 object
  84099. */
  84100. multiply(color: Color4): Color4;
  84101. /**
  84102. * Multipy a Color4 value by another and push the result in a reference value
  84103. * @param color defines the Color4 value to multiply by
  84104. * @param result defines the Color4 to fill the result in
  84105. * @returns the result Color4
  84106. */
  84107. multiplyToRef(color: Color4, result: Color4): Color4;
  84108. /**
  84109. * Creates a string with the Color4 current values
  84110. * @returns the string representation of the Color4 object
  84111. */
  84112. toString(): string;
  84113. /**
  84114. * Returns the string "Color4"
  84115. * @returns "Color4"
  84116. */
  84117. getClassName(): string;
  84118. /**
  84119. * Compute the Color4 hash code
  84120. * @returns an unique number that can be used to hash Color4 objects
  84121. */
  84122. getHashCode(): number;
  84123. /**
  84124. * Creates a new Color4 copied from the current one
  84125. * @returns a new Color4 object
  84126. */
  84127. clone(): Color4;
  84128. /**
  84129. * Copies the given Color4 values into the current one
  84130. * @param source defines the source Color4 object
  84131. * @returns the current updated Color4 object
  84132. */
  84133. copyFrom(source: Color4): Color4;
  84134. /**
  84135. * Copies the given float values into the current one
  84136. * @param r defines the red component to read from
  84137. * @param g defines the green component to read from
  84138. * @param b defines the blue component to read from
  84139. * @param a defines the alpha component to read from
  84140. * @returns the current updated Color4 object
  84141. */
  84142. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84143. /**
  84144. * Copies the given float values into the current one
  84145. * @param r defines the red component to read from
  84146. * @param g defines the green component to read from
  84147. * @param b defines the blue component to read from
  84148. * @param a defines the alpha component to read from
  84149. * @returns the current updated Color4 object
  84150. */
  84151. set(r: number, g: number, b: number, a: number): Color4;
  84152. /**
  84153. * Compute the Color4 hexadecimal code as a string
  84154. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84155. * @returns a string containing the hexadecimal representation of the Color4 object
  84156. */
  84157. toHexString(returnAsColor3?: boolean): string;
  84158. /**
  84159. * Computes a new Color4 converted from the current one to linear space
  84160. * @returns a new Color4 object
  84161. */
  84162. toLinearSpace(): Color4;
  84163. /**
  84164. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84165. * @param convertedColor defines the Color4 object where to store the linear space version
  84166. * @returns the unmodified Color4
  84167. */
  84168. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84169. /**
  84170. * Computes a new Color4 converted from the current one to gamma space
  84171. * @returns a new Color4 object
  84172. */
  84173. toGammaSpace(): Color4;
  84174. /**
  84175. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84176. * @param convertedColor defines the Color4 object where to store the gamma space version
  84177. * @returns the unmodified Color4
  84178. */
  84179. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84180. /**
  84181. * Creates a new Color4 from the string containing valid hexadecimal values
  84182. * @param hex defines a string containing valid hexadecimal values
  84183. * @returns a new Color4 object
  84184. */
  84185. static FromHexString(hex: string): Color4;
  84186. /**
  84187. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84188. * @param left defines the start value
  84189. * @param right defines the end value
  84190. * @param amount defines the gradient factor
  84191. * @returns a new Color4 object
  84192. */
  84193. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84194. /**
  84195. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84196. * @param left defines the start value
  84197. * @param right defines the end value
  84198. * @param amount defines the gradient factor
  84199. * @param result defines the Color4 object where to store data
  84200. */
  84201. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84202. /**
  84203. * Creates a new Color4 from a Color3 and an alpha value
  84204. * @param color3 defines the source Color3 to read from
  84205. * @param alpha defines the alpha component (1.0 by default)
  84206. * @returns a new Color4 object
  84207. */
  84208. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84209. /**
  84210. * Creates a new Color4 from the starting index element of the given array
  84211. * @param array defines the source array to read from
  84212. * @param offset defines the offset in the source array
  84213. * @returns a new Color4 object
  84214. */
  84215. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84216. /**
  84217. * Creates a new Color3 from integer values (< 256)
  84218. * @param r defines the red component to read from (value between 0 and 255)
  84219. * @param g defines the green component to read from (value between 0 and 255)
  84220. * @param b defines the blue component to read from (value between 0 and 255)
  84221. * @param a defines the alpha component to read from (value between 0 and 255)
  84222. * @returns a new Color3 object
  84223. */
  84224. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84225. /**
  84226. * Check the content of a given array and convert it to an array containing RGBA data
  84227. * If the original array was already containing count * 4 values then it is returned directly
  84228. * @param colors defines the array to check
  84229. * @param count defines the number of RGBA data to expect
  84230. * @returns an array containing count * 4 values (RGBA)
  84231. */
  84232. static CheckColors4(colors: number[], count: number): number[];
  84233. }
  84234. /**
  84235. * @hidden
  84236. */
  84237. export class TmpColors {
  84238. static Color3: Color3[];
  84239. static Color4: Color4[];
  84240. }
  84241. }
  84242. declare module BABYLON {
  84243. /**
  84244. * Defines an interface which represents an animation key frame
  84245. */
  84246. export interface IAnimationKey {
  84247. /**
  84248. * Frame of the key frame
  84249. */
  84250. frame: number;
  84251. /**
  84252. * Value at the specifies key frame
  84253. */
  84254. value: any;
  84255. /**
  84256. * The input tangent for the cubic hermite spline
  84257. */
  84258. inTangent?: any;
  84259. /**
  84260. * The output tangent for the cubic hermite spline
  84261. */
  84262. outTangent?: any;
  84263. /**
  84264. * The animation interpolation type
  84265. */
  84266. interpolation?: AnimationKeyInterpolation;
  84267. }
  84268. /**
  84269. * Enum for the animation key frame interpolation type
  84270. */
  84271. export enum AnimationKeyInterpolation {
  84272. /**
  84273. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84274. */
  84275. STEP = 1
  84276. }
  84277. }
  84278. declare module BABYLON {
  84279. /**
  84280. * Represents the range of an animation
  84281. */
  84282. export class AnimationRange {
  84283. /**The name of the animation range**/
  84284. name: string;
  84285. /**The starting frame of the animation */
  84286. from: number;
  84287. /**The ending frame of the animation*/
  84288. to: number;
  84289. /**
  84290. * Initializes the range of an animation
  84291. * @param name The name of the animation range
  84292. * @param from The starting frame of the animation
  84293. * @param to The ending frame of the animation
  84294. */
  84295. constructor(
  84296. /**The name of the animation range**/
  84297. name: string,
  84298. /**The starting frame of the animation */
  84299. from: number,
  84300. /**The ending frame of the animation*/
  84301. to: number);
  84302. /**
  84303. * Makes a copy of the animation range
  84304. * @returns A copy of the animation range
  84305. */
  84306. clone(): AnimationRange;
  84307. }
  84308. }
  84309. declare module BABYLON {
  84310. /**
  84311. * Composed of a frame, and an action function
  84312. */
  84313. export class AnimationEvent {
  84314. /** The frame for which the event is triggered **/
  84315. frame: number;
  84316. /** The event to perform when triggered **/
  84317. action: (currentFrame: number) => void;
  84318. /** Specifies if the event should be triggered only once**/
  84319. onlyOnce?: boolean | undefined;
  84320. /**
  84321. * Specifies if the animation event is done
  84322. */
  84323. isDone: boolean;
  84324. /**
  84325. * Initializes the animation event
  84326. * @param frame The frame for which the event is triggered
  84327. * @param action The event to perform when triggered
  84328. * @param onlyOnce Specifies if the event should be triggered only once
  84329. */
  84330. constructor(
  84331. /** The frame for which the event is triggered **/
  84332. frame: number,
  84333. /** The event to perform when triggered **/
  84334. action: (currentFrame: number) => void,
  84335. /** Specifies if the event should be triggered only once**/
  84336. onlyOnce?: boolean | undefined);
  84337. /** @hidden */
  84338. _clone(): AnimationEvent;
  84339. }
  84340. }
  84341. declare module BABYLON {
  84342. /**
  84343. * Interface used to define a behavior
  84344. */
  84345. export interface Behavior<T> {
  84346. /** gets or sets behavior's name */
  84347. name: string;
  84348. /**
  84349. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84350. */
  84351. init(): void;
  84352. /**
  84353. * Called when the behavior is attached to a target
  84354. * @param target defines the target where the behavior is attached to
  84355. */
  84356. attach(target: T): void;
  84357. /**
  84358. * Called when the behavior is detached from its target
  84359. */
  84360. detach(): void;
  84361. }
  84362. /**
  84363. * Interface implemented by classes supporting behaviors
  84364. */
  84365. export interface IBehaviorAware<T> {
  84366. /**
  84367. * Attach a behavior
  84368. * @param behavior defines the behavior to attach
  84369. * @returns the current host
  84370. */
  84371. addBehavior(behavior: Behavior<T>): T;
  84372. /**
  84373. * Remove a behavior from the current object
  84374. * @param behavior defines the behavior to detach
  84375. * @returns the current host
  84376. */
  84377. removeBehavior(behavior: Behavior<T>): T;
  84378. /**
  84379. * Gets a behavior using its name to search
  84380. * @param name defines the name to search
  84381. * @returns the behavior or null if not found
  84382. */
  84383. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84384. }
  84385. }
  84386. declare module BABYLON {
  84387. /**
  84388. * Defines an array and its length.
  84389. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84390. */
  84391. export interface ISmartArrayLike<T> {
  84392. /**
  84393. * The data of the array.
  84394. */
  84395. data: Array<T>;
  84396. /**
  84397. * The active length of the array.
  84398. */
  84399. length: number;
  84400. }
  84401. /**
  84402. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84403. */
  84404. export class SmartArray<T> implements ISmartArrayLike<T> {
  84405. /**
  84406. * The full set of data from the array.
  84407. */
  84408. data: Array<T>;
  84409. /**
  84410. * The active length of the array.
  84411. */
  84412. length: number;
  84413. protected _id: number;
  84414. /**
  84415. * Instantiates a Smart Array.
  84416. * @param capacity defines the default capacity of the array.
  84417. */
  84418. constructor(capacity: number);
  84419. /**
  84420. * Pushes a value at the end of the active data.
  84421. * @param value defines the object to push in the array.
  84422. */
  84423. push(value: T): void;
  84424. /**
  84425. * Iterates over the active data and apply the lambda to them.
  84426. * @param func defines the action to apply on each value.
  84427. */
  84428. forEach(func: (content: T) => void): void;
  84429. /**
  84430. * Sorts the full sets of data.
  84431. * @param compareFn defines the comparison function to apply.
  84432. */
  84433. sort(compareFn: (a: T, b: T) => number): void;
  84434. /**
  84435. * Resets the active data to an empty array.
  84436. */
  84437. reset(): void;
  84438. /**
  84439. * Releases all the data from the array as well as the array.
  84440. */
  84441. dispose(): void;
  84442. /**
  84443. * Concats the active data with a given array.
  84444. * @param array defines the data to concatenate with.
  84445. */
  84446. concat(array: any): void;
  84447. /**
  84448. * Returns the position of a value in the active data.
  84449. * @param value defines the value to find the index for
  84450. * @returns the index if found in the active data otherwise -1
  84451. */
  84452. indexOf(value: T): number;
  84453. /**
  84454. * Returns whether an element is part of the active data.
  84455. * @param value defines the value to look for
  84456. * @returns true if found in the active data otherwise false
  84457. */
  84458. contains(value: T): boolean;
  84459. private static _GlobalId;
  84460. }
  84461. /**
  84462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84463. * The data in this array can only be present once
  84464. */
  84465. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84466. private _duplicateId;
  84467. /**
  84468. * Pushes a value at the end of the active data.
  84469. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84470. * @param value defines the object to push in the array.
  84471. */
  84472. push(value: T): void;
  84473. /**
  84474. * Pushes a value at the end of the active data.
  84475. * If the data is already present, it won t be added again
  84476. * @param value defines the object to push in the array.
  84477. * @returns true if added false if it was already present
  84478. */
  84479. pushNoDuplicate(value: T): boolean;
  84480. /**
  84481. * Resets the active data to an empty array.
  84482. */
  84483. reset(): void;
  84484. /**
  84485. * Concats the active data with a given array.
  84486. * This ensures no dupplicate will be present in the result.
  84487. * @param array defines the data to concatenate with.
  84488. */
  84489. concatWithNoDuplicate(array: any): void;
  84490. }
  84491. }
  84492. declare module BABYLON {
  84493. /**
  84494. * @ignore
  84495. * This is a list of all the different input types that are available in the application.
  84496. * Fo instance: ArcRotateCameraGamepadInput...
  84497. */
  84498. export var CameraInputTypes: {};
  84499. /**
  84500. * This is the contract to implement in order to create a new input class.
  84501. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84502. */
  84503. export interface ICameraInput<TCamera extends Camera> {
  84504. /**
  84505. * Defines the camera the input is attached to.
  84506. */
  84507. camera: Nullable<TCamera>;
  84508. /**
  84509. * Gets the class name of the current intput.
  84510. * @returns the class name
  84511. */
  84512. getClassName(): string;
  84513. /**
  84514. * Get the friendly name associated with the input class.
  84515. * @returns the input friendly name
  84516. */
  84517. getSimpleName(): string;
  84518. /**
  84519. * Attach the input controls to a specific dom element to get the input from.
  84520. * @param element Defines the element the controls should be listened from
  84521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84522. */
  84523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84524. /**
  84525. * Detach the current controls from the specified dom element.
  84526. * @param element Defines the element to stop listening the inputs from
  84527. */
  84528. detachControl(element: Nullable<HTMLElement>): void;
  84529. /**
  84530. * Update the current camera state depending on the inputs that have been used this frame.
  84531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84532. */
  84533. checkInputs?: () => void;
  84534. }
  84535. /**
  84536. * Represents a map of input types to input instance or input index to input instance.
  84537. */
  84538. export interface CameraInputsMap<TCamera extends Camera> {
  84539. /**
  84540. * Accessor to the input by input type.
  84541. */
  84542. [name: string]: ICameraInput<TCamera>;
  84543. /**
  84544. * Accessor to the input by input index.
  84545. */
  84546. [idx: number]: ICameraInput<TCamera>;
  84547. }
  84548. /**
  84549. * This represents the input manager used within a camera.
  84550. * It helps dealing with all the different kind of input attached to a camera.
  84551. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84552. */
  84553. export class CameraInputsManager<TCamera extends Camera> {
  84554. /**
  84555. * Defines the list of inputs attahed to the camera.
  84556. */
  84557. attached: CameraInputsMap<TCamera>;
  84558. /**
  84559. * Defines the dom element the camera is collecting inputs from.
  84560. * This is null if the controls have not been attached.
  84561. */
  84562. attachedElement: Nullable<HTMLElement>;
  84563. /**
  84564. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84565. */
  84566. noPreventDefault: boolean;
  84567. /**
  84568. * Defined the camera the input manager belongs to.
  84569. */
  84570. camera: TCamera;
  84571. /**
  84572. * Update the current camera state depending on the inputs that have been used this frame.
  84573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84574. */
  84575. checkInputs: () => void;
  84576. /**
  84577. * Instantiate a new Camera Input Manager.
  84578. * @param camera Defines the camera the input manager blongs to
  84579. */
  84580. constructor(camera: TCamera);
  84581. /**
  84582. * Add an input method to a camera
  84583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84584. * @param input camera input method
  84585. */
  84586. add(input: ICameraInput<TCamera>): void;
  84587. /**
  84588. * Remove a specific input method from a camera
  84589. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84590. * @param inputToRemove camera input method
  84591. */
  84592. remove(inputToRemove: ICameraInput<TCamera>): void;
  84593. /**
  84594. * Remove a specific input type from a camera
  84595. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84596. * @param inputType the type of the input to remove
  84597. */
  84598. removeByType(inputType: string): void;
  84599. private _addCheckInputs;
  84600. /**
  84601. * Attach the input controls to the currently attached dom element to listen the events from.
  84602. * @param input Defines the input to attach
  84603. */
  84604. attachInput(input: ICameraInput<TCamera>): void;
  84605. /**
  84606. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84607. * @param element Defines the dom element to collect the events from
  84608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84609. */
  84610. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84611. /**
  84612. * Detach the current manager inputs controls from a specific dom element.
  84613. * @param element Defines the dom element to collect the events from
  84614. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84615. */
  84616. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84617. /**
  84618. * Rebuild the dynamic inputCheck function from the current list of
  84619. * defined inputs in the manager.
  84620. */
  84621. rebuildInputCheck(): void;
  84622. /**
  84623. * Remove all attached input methods from a camera
  84624. */
  84625. clear(): void;
  84626. /**
  84627. * Serialize the current input manager attached to a camera.
  84628. * This ensures than once parsed,
  84629. * the input associated to the camera will be identical to the current ones
  84630. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84631. */
  84632. serialize(serializedCamera: any): void;
  84633. /**
  84634. * Parses an input manager serialized JSON to restore the previous list of inputs
  84635. * and states associated to a camera.
  84636. * @param parsedCamera Defines the JSON to parse
  84637. */
  84638. parse(parsedCamera: any): void;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. /**
  84643. * Class used to store data that will be store in GPU memory
  84644. */
  84645. export class Buffer {
  84646. private _engine;
  84647. private _buffer;
  84648. /** @hidden */
  84649. _data: Nullable<DataArray>;
  84650. private _updatable;
  84651. private _instanced;
  84652. private _divisor;
  84653. /**
  84654. * Gets the byte stride.
  84655. */
  84656. readonly byteStride: number;
  84657. /**
  84658. * Constructor
  84659. * @param engine the engine
  84660. * @param data the data to use for this buffer
  84661. * @param updatable whether the data is updatable
  84662. * @param stride the stride (optional)
  84663. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84664. * @param instanced whether the buffer is instanced (optional)
  84665. * @param useBytes set to true if the stride in in bytes (optional)
  84666. * @param divisor sets an optional divisor for instances (1 by default)
  84667. */
  84668. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84669. /**
  84670. * Create a new VertexBuffer based on the current buffer
  84671. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84672. * @param offset defines offset in the buffer (0 by default)
  84673. * @param size defines the size in floats of attributes (position is 3 for instance)
  84674. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84675. * @param instanced defines if the vertex buffer contains indexed data
  84676. * @param useBytes defines if the offset and stride are in bytes *
  84677. * @param divisor sets an optional divisor for instances (1 by default)
  84678. * @returns the new vertex buffer
  84679. */
  84680. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84681. /**
  84682. * Gets a boolean indicating if the Buffer is updatable?
  84683. * @returns true if the buffer is updatable
  84684. */
  84685. isUpdatable(): boolean;
  84686. /**
  84687. * Gets current buffer's data
  84688. * @returns a DataArray or null
  84689. */
  84690. getData(): Nullable<DataArray>;
  84691. /**
  84692. * Gets underlying native buffer
  84693. * @returns underlying native buffer
  84694. */
  84695. getBuffer(): Nullable<DataBuffer>;
  84696. /**
  84697. * Gets the stride in float32 units (i.e. byte stride / 4).
  84698. * May not be an integer if the byte stride is not divisible by 4.
  84699. * @returns the stride in float32 units
  84700. * @deprecated Please use byteStride instead.
  84701. */
  84702. getStrideSize(): number;
  84703. /**
  84704. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84705. * @param data defines the data to store
  84706. */
  84707. create(data?: Nullable<DataArray>): void;
  84708. /** @hidden */
  84709. _rebuild(): void;
  84710. /**
  84711. * Update current buffer data
  84712. * @param data defines the data to store
  84713. */
  84714. update(data: DataArray): void;
  84715. /**
  84716. * Updates the data directly.
  84717. * @param data the new data
  84718. * @param offset the new offset
  84719. * @param vertexCount the vertex count (optional)
  84720. * @param useBytes set to true if the offset is in bytes
  84721. */
  84722. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84723. /**
  84724. * Release all resources
  84725. */
  84726. dispose(): void;
  84727. }
  84728. /**
  84729. * Specialized buffer used to store vertex data
  84730. */
  84731. export class VertexBuffer {
  84732. /** @hidden */
  84733. _buffer: Buffer;
  84734. private _kind;
  84735. private _size;
  84736. private _ownsBuffer;
  84737. private _instanced;
  84738. private _instanceDivisor;
  84739. /**
  84740. * The byte type.
  84741. */
  84742. static readonly BYTE: number;
  84743. /**
  84744. * The unsigned byte type.
  84745. */
  84746. static readonly UNSIGNED_BYTE: number;
  84747. /**
  84748. * The short type.
  84749. */
  84750. static readonly SHORT: number;
  84751. /**
  84752. * The unsigned short type.
  84753. */
  84754. static readonly UNSIGNED_SHORT: number;
  84755. /**
  84756. * The integer type.
  84757. */
  84758. static readonly INT: number;
  84759. /**
  84760. * The unsigned integer type.
  84761. */
  84762. static readonly UNSIGNED_INT: number;
  84763. /**
  84764. * The float type.
  84765. */
  84766. static readonly FLOAT: number;
  84767. /**
  84768. * Gets or sets the instance divisor when in instanced mode
  84769. */
  84770. get instanceDivisor(): number;
  84771. set instanceDivisor(value: number);
  84772. /**
  84773. * Gets the byte stride.
  84774. */
  84775. readonly byteStride: number;
  84776. /**
  84777. * Gets the byte offset.
  84778. */
  84779. readonly byteOffset: number;
  84780. /**
  84781. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84782. */
  84783. readonly normalized: boolean;
  84784. /**
  84785. * Gets the data type of each component in the array.
  84786. */
  84787. readonly type: number;
  84788. /**
  84789. * Constructor
  84790. * @param engine the engine
  84791. * @param data the data to use for this vertex buffer
  84792. * @param kind the vertex buffer kind
  84793. * @param updatable whether the data is updatable
  84794. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84795. * @param stride the stride (optional)
  84796. * @param instanced whether the buffer is instanced (optional)
  84797. * @param offset the offset of the data (optional)
  84798. * @param size the number of components (optional)
  84799. * @param type the type of the component (optional)
  84800. * @param normalized whether the data contains normalized data (optional)
  84801. * @param useBytes set to true if stride and offset are in bytes (optional)
  84802. * @param divisor defines the instance divisor to use (1 by default)
  84803. */
  84804. 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);
  84805. /** @hidden */
  84806. _rebuild(): void;
  84807. /**
  84808. * Returns the kind of the VertexBuffer (string)
  84809. * @returns a string
  84810. */
  84811. getKind(): string;
  84812. /**
  84813. * Gets a boolean indicating if the VertexBuffer is updatable?
  84814. * @returns true if the buffer is updatable
  84815. */
  84816. isUpdatable(): boolean;
  84817. /**
  84818. * Gets current buffer's data
  84819. * @returns a DataArray or null
  84820. */
  84821. getData(): Nullable<DataArray>;
  84822. /**
  84823. * Gets underlying native buffer
  84824. * @returns underlying native buffer
  84825. */
  84826. getBuffer(): Nullable<DataBuffer>;
  84827. /**
  84828. * Gets the stride in float32 units (i.e. byte stride / 4).
  84829. * May not be an integer if the byte stride is not divisible by 4.
  84830. * @returns the stride in float32 units
  84831. * @deprecated Please use byteStride instead.
  84832. */
  84833. getStrideSize(): number;
  84834. /**
  84835. * Returns the offset as a multiple of the type byte length.
  84836. * @returns the offset in bytes
  84837. * @deprecated Please use byteOffset instead.
  84838. */
  84839. getOffset(): number;
  84840. /**
  84841. * Returns the number of components per vertex attribute (integer)
  84842. * @returns the size in float
  84843. */
  84844. getSize(): number;
  84845. /**
  84846. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84847. * @returns true if this buffer is instanced
  84848. */
  84849. getIsInstanced(): boolean;
  84850. /**
  84851. * Returns the instancing divisor, zero for non-instanced (integer).
  84852. * @returns a number
  84853. */
  84854. getInstanceDivisor(): number;
  84855. /**
  84856. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84857. * @param data defines the data to store
  84858. */
  84859. create(data?: DataArray): void;
  84860. /**
  84861. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84862. * This function will create a new buffer if the current one is not updatable
  84863. * @param data defines the data to store
  84864. */
  84865. update(data: DataArray): void;
  84866. /**
  84867. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84868. * Returns the directly updated WebGLBuffer.
  84869. * @param data the new data
  84870. * @param offset the new offset
  84871. * @param useBytes set to true if the offset is in bytes
  84872. */
  84873. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84874. /**
  84875. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84876. */
  84877. dispose(): void;
  84878. /**
  84879. * Enumerates each value of this vertex buffer as numbers.
  84880. * @param count the number of values to enumerate
  84881. * @param callback the callback function called for each value
  84882. */
  84883. forEach(count: number, callback: (value: number, index: number) => void): void;
  84884. /**
  84885. * Positions
  84886. */
  84887. static readonly PositionKind: string;
  84888. /**
  84889. * Normals
  84890. */
  84891. static readonly NormalKind: string;
  84892. /**
  84893. * Tangents
  84894. */
  84895. static readonly TangentKind: string;
  84896. /**
  84897. * Texture coordinates
  84898. */
  84899. static readonly UVKind: string;
  84900. /**
  84901. * Texture coordinates 2
  84902. */
  84903. static readonly UV2Kind: string;
  84904. /**
  84905. * Texture coordinates 3
  84906. */
  84907. static readonly UV3Kind: string;
  84908. /**
  84909. * Texture coordinates 4
  84910. */
  84911. static readonly UV4Kind: string;
  84912. /**
  84913. * Texture coordinates 5
  84914. */
  84915. static readonly UV5Kind: string;
  84916. /**
  84917. * Texture coordinates 6
  84918. */
  84919. static readonly UV6Kind: string;
  84920. /**
  84921. * Colors
  84922. */
  84923. static readonly ColorKind: string;
  84924. /**
  84925. * Matrix indices (for bones)
  84926. */
  84927. static readonly MatricesIndicesKind: string;
  84928. /**
  84929. * Matrix weights (for bones)
  84930. */
  84931. static readonly MatricesWeightsKind: string;
  84932. /**
  84933. * Additional matrix indices (for bones)
  84934. */
  84935. static readonly MatricesIndicesExtraKind: string;
  84936. /**
  84937. * Additional matrix weights (for bones)
  84938. */
  84939. static readonly MatricesWeightsExtraKind: string;
  84940. /**
  84941. * Deduces the stride given a kind.
  84942. * @param kind The kind string to deduce
  84943. * @returns The deduced stride
  84944. */
  84945. static DeduceStride(kind: string): number;
  84946. /**
  84947. * Gets the byte length of the given type.
  84948. * @param type the type
  84949. * @returns the number of bytes
  84950. */
  84951. static GetTypeByteLength(type: number): number;
  84952. /**
  84953. * Enumerates each value of the given parameters as numbers.
  84954. * @param data the data to enumerate
  84955. * @param byteOffset the byte offset of the data
  84956. * @param byteStride the byte stride of the data
  84957. * @param componentCount the number of components per element
  84958. * @param componentType the type of the component
  84959. * @param count the number of values to enumerate
  84960. * @param normalized whether the data is normalized
  84961. * @param callback the callback function called for each value
  84962. */
  84963. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84964. private static _GetFloatValue;
  84965. }
  84966. }
  84967. declare module BABYLON {
  84968. /**
  84969. * @hidden
  84970. */
  84971. export class IntersectionInfo {
  84972. bu: Nullable<number>;
  84973. bv: Nullable<number>;
  84974. distance: number;
  84975. faceId: number;
  84976. subMeshId: number;
  84977. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84978. }
  84979. }
  84980. declare module BABYLON {
  84981. /**
  84982. * Class used to store bounding sphere information
  84983. */
  84984. export class BoundingSphere {
  84985. /**
  84986. * Gets the center of the bounding sphere in local space
  84987. */
  84988. readonly center: Vector3;
  84989. /**
  84990. * Radius of the bounding sphere in local space
  84991. */
  84992. radius: number;
  84993. /**
  84994. * Gets the center of the bounding sphere in world space
  84995. */
  84996. readonly centerWorld: Vector3;
  84997. /**
  84998. * Radius of the bounding sphere in world space
  84999. */
  85000. radiusWorld: number;
  85001. /**
  85002. * Gets the minimum vector in local space
  85003. */
  85004. readonly minimum: Vector3;
  85005. /**
  85006. * Gets the maximum vector in local space
  85007. */
  85008. readonly maximum: Vector3;
  85009. private _worldMatrix;
  85010. private static readonly TmpVector3;
  85011. /**
  85012. * Creates a new bounding sphere
  85013. * @param min defines the minimum vector (in local space)
  85014. * @param max defines the maximum vector (in local space)
  85015. * @param worldMatrix defines the new world matrix
  85016. */
  85017. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85018. /**
  85019. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85020. * @param min defines the new minimum vector (in local space)
  85021. * @param max defines the new maximum vector (in local space)
  85022. * @param worldMatrix defines the new world matrix
  85023. */
  85024. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85025. /**
  85026. * Scale the current bounding sphere by applying a scale factor
  85027. * @param factor defines the scale factor to apply
  85028. * @returns the current bounding box
  85029. */
  85030. scale(factor: number): BoundingSphere;
  85031. /**
  85032. * Gets the world matrix of the bounding box
  85033. * @returns a matrix
  85034. */
  85035. getWorldMatrix(): DeepImmutable<Matrix>;
  85036. /** @hidden */
  85037. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85038. /**
  85039. * Tests if the bounding sphere is intersecting the frustum planes
  85040. * @param frustumPlanes defines the frustum planes to test
  85041. * @returns true if there is an intersection
  85042. */
  85043. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85044. /**
  85045. * Tests if the bounding sphere center is in between the frustum planes.
  85046. * Used for optimistic fast inclusion.
  85047. * @param frustumPlanes defines the frustum planes to test
  85048. * @returns true if the sphere center is in between the frustum planes
  85049. */
  85050. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85051. /**
  85052. * Tests if a point is inside the bounding sphere
  85053. * @param point defines the point to test
  85054. * @returns true if the point is inside the bounding sphere
  85055. */
  85056. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85057. /**
  85058. * Checks if two sphere intersct
  85059. * @param sphere0 sphere 0
  85060. * @param sphere1 sphere 1
  85061. * @returns true if the speres intersect
  85062. */
  85063. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85064. }
  85065. }
  85066. declare module BABYLON {
  85067. /**
  85068. * Class used to store bounding box information
  85069. */
  85070. export class BoundingBox implements ICullable {
  85071. /**
  85072. * Gets the 8 vectors representing the bounding box in local space
  85073. */
  85074. readonly vectors: Vector3[];
  85075. /**
  85076. * Gets the center of the bounding box in local space
  85077. */
  85078. readonly center: Vector3;
  85079. /**
  85080. * Gets the center of the bounding box in world space
  85081. */
  85082. readonly centerWorld: Vector3;
  85083. /**
  85084. * Gets the extend size in local space
  85085. */
  85086. readonly extendSize: Vector3;
  85087. /**
  85088. * Gets the extend size in world space
  85089. */
  85090. readonly extendSizeWorld: Vector3;
  85091. /**
  85092. * Gets the OBB (object bounding box) directions
  85093. */
  85094. readonly directions: Vector3[];
  85095. /**
  85096. * Gets the 8 vectors representing the bounding box in world space
  85097. */
  85098. readonly vectorsWorld: Vector3[];
  85099. /**
  85100. * Gets the minimum vector in world space
  85101. */
  85102. readonly minimumWorld: Vector3;
  85103. /**
  85104. * Gets the maximum vector in world space
  85105. */
  85106. readonly maximumWorld: Vector3;
  85107. /**
  85108. * Gets the minimum vector in local space
  85109. */
  85110. readonly minimum: Vector3;
  85111. /**
  85112. * Gets the maximum vector in local space
  85113. */
  85114. readonly maximum: Vector3;
  85115. private _worldMatrix;
  85116. private static readonly TmpVector3;
  85117. /**
  85118. * @hidden
  85119. */
  85120. _tag: number;
  85121. /**
  85122. * Creates a new bounding box
  85123. * @param min defines the minimum vector (in local space)
  85124. * @param max defines the maximum vector (in local space)
  85125. * @param worldMatrix defines the new world matrix
  85126. */
  85127. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85128. /**
  85129. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85130. * @param min defines the new minimum vector (in local space)
  85131. * @param max defines the new maximum vector (in local space)
  85132. * @param worldMatrix defines the new world matrix
  85133. */
  85134. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85135. /**
  85136. * Scale the current bounding box by applying a scale factor
  85137. * @param factor defines the scale factor to apply
  85138. * @returns the current bounding box
  85139. */
  85140. scale(factor: number): BoundingBox;
  85141. /**
  85142. * Gets the world matrix of the bounding box
  85143. * @returns a matrix
  85144. */
  85145. getWorldMatrix(): DeepImmutable<Matrix>;
  85146. /** @hidden */
  85147. _update(world: DeepImmutable<Matrix>): void;
  85148. /**
  85149. * Tests if the bounding box is intersecting the frustum planes
  85150. * @param frustumPlanes defines the frustum planes to test
  85151. * @returns true if there is an intersection
  85152. */
  85153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85154. /**
  85155. * Tests if the bounding box is entirely inside the frustum planes
  85156. * @param frustumPlanes defines the frustum planes to test
  85157. * @returns true if there is an inclusion
  85158. */
  85159. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85160. /**
  85161. * Tests if a point is inside the bounding box
  85162. * @param point defines the point to test
  85163. * @returns true if the point is inside the bounding box
  85164. */
  85165. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85166. /**
  85167. * Tests if the bounding box intersects with a bounding sphere
  85168. * @param sphere defines the sphere to test
  85169. * @returns true if there is an intersection
  85170. */
  85171. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85172. /**
  85173. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85174. * @param min defines the min vector to use
  85175. * @param max defines the max vector to use
  85176. * @returns true if there is an intersection
  85177. */
  85178. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85179. /**
  85180. * Tests if two bounding boxes are intersections
  85181. * @param box0 defines the first box to test
  85182. * @param box1 defines the second box to test
  85183. * @returns true if there is an intersection
  85184. */
  85185. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85186. /**
  85187. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85188. * @param minPoint defines the minimum vector of the bounding box
  85189. * @param maxPoint defines the maximum vector of the bounding box
  85190. * @param sphereCenter defines the sphere center
  85191. * @param sphereRadius defines the sphere radius
  85192. * @returns true if there is an intersection
  85193. */
  85194. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85195. /**
  85196. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85197. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85198. * @param frustumPlanes defines the frustum planes to test
  85199. * @return true if there is an inclusion
  85200. */
  85201. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85202. /**
  85203. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85204. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85205. * @param frustumPlanes defines the frustum planes to test
  85206. * @return true if there is an intersection
  85207. */
  85208. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85209. }
  85210. }
  85211. declare module BABYLON {
  85212. /** @hidden */
  85213. export class Collider {
  85214. /** Define if a collision was found */
  85215. collisionFound: boolean;
  85216. /**
  85217. * Define last intersection point in local space
  85218. */
  85219. intersectionPoint: Vector3;
  85220. /**
  85221. * Define last collided mesh
  85222. */
  85223. collidedMesh: Nullable<AbstractMesh>;
  85224. private _collisionPoint;
  85225. private _planeIntersectionPoint;
  85226. private _tempVector;
  85227. private _tempVector2;
  85228. private _tempVector3;
  85229. private _tempVector4;
  85230. private _edge;
  85231. private _baseToVertex;
  85232. private _destinationPoint;
  85233. private _slidePlaneNormal;
  85234. private _displacementVector;
  85235. /** @hidden */
  85236. _radius: Vector3;
  85237. /** @hidden */
  85238. _retry: number;
  85239. private _velocity;
  85240. private _basePoint;
  85241. private _epsilon;
  85242. /** @hidden */
  85243. _velocityWorldLength: number;
  85244. /** @hidden */
  85245. _basePointWorld: Vector3;
  85246. private _velocityWorld;
  85247. private _normalizedVelocity;
  85248. /** @hidden */
  85249. _initialVelocity: Vector3;
  85250. /** @hidden */
  85251. _initialPosition: Vector3;
  85252. private _nearestDistance;
  85253. private _collisionMask;
  85254. get collisionMask(): number;
  85255. set collisionMask(mask: number);
  85256. /**
  85257. * Gets the plane normal used to compute the sliding response (in local space)
  85258. */
  85259. get slidePlaneNormal(): Vector3;
  85260. /** @hidden */
  85261. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85262. /** @hidden */
  85263. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85264. /** @hidden */
  85265. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85266. /** @hidden */
  85267. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85268. /** @hidden */
  85269. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85270. /** @hidden */
  85271. _getResponse(pos: Vector3, vel: Vector3): void;
  85272. }
  85273. }
  85274. declare module BABYLON {
  85275. /**
  85276. * Interface for cullable objects
  85277. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85278. */
  85279. export interface ICullable {
  85280. /**
  85281. * Checks if the object or part of the object is in the frustum
  85282. * @param frustumPlanes Camera near/planes
  85283. * @returns true if the object is in frustum otherwise false
  85284. */
  85285. isInFrustum(frustumPlanes: Plane[]): boolean;
  85286. /**
  85287. * Checks if a cullable object (mesh...) is in the camera frustum
  85288. * Unlike isInFrustum this cheks the full bounding box
  85289. * @param frustumPlanes Camera near/planes
  85290. * @returns true if the object is in frustum otherwise false
  85291. */
  85292. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85293. }
  85294. /**
  85295. * Info for a bounding data of a mesh
  85296. */
  85297. export class BoundingInfo implements ICullable {
  85298. /**
  85299. * Bounding box for the mesh
  85300. */
  85301. readonly boundingBox: BoundingBox;
  85302. /**
  85303. * Bounding sphere for the mesh
  85304. */
  85305. readonly boundingSphere: BoundingSphere;
  85306. private _isLocked;
  85307. private static readonly TmpVector3;
  85308. /**
  85309. * Constructs bounding info
  85310. * @param minimum min vector of the bounding box/sphere
  85311. * @param maximum max vector of the bounding box/sphere
  85312. * @param worldMatrix defines the new world matrix
  85313. */
  85314. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85315. /**
  85316. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85317. * @param min defines the new minimum vector (in local space)
  85318. * @param max defines the new maximum vector (in local space)
  85319. * @param worldMatrix defines the new world matrix
  85320. */
  85321. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85322. /**
  85323. * min vector of the bounding box/sphere
  85324. */
  85325. get minimum(): Vector3;
  85326. /**
  85327. * max vector of the bounding box/sphere
  85328. */
  85329. get maximum(): Vector3;
  85330. /**
  85331. * If the info is locked and won't be updated to avoid perf overhead
  85332. */
  85333. get isLocked(): boolean;
  85334. set isLocked(value: boolean);
  85335. /**
  85336. * Updates the bounding sphere and box
  85337. * @param world world matrix to be used to update
  85338. */
  85339. update(world: DeepImmutable<Matrix>): void;
  85340. /**
  85341. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85342. * @param center New center of the bounding info
  85343. * @param extend New extend of the bounding info
  85344. * @returns the current bounding info
  85345. */
  85346. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85347. /**
  85348. * Scale the current bounding info by applying a scale factor
  85349. * @param factor defines the scale factor to apply
  85350. * @returns the current bounding info
  85351. */
  85352. scale(factor: number): BoundingInfo;
  85353. /**
  85354. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85355. * @param frustumPlanes defines the frustum to test
  85356. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85357. * @returns true if the bounding info is in the frustum planes
  85358. */
  85359. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85360. /**
  85361. * Gets the world distance between the min and max points of the bounding box
  85362. */
  85363. get diagonalLength(): number;
  85364. /**
  85365. * Checks if a cullable object (mesh...) is in the camera frustum
  85366. * Unlike isInFrustum this cheks the full bounding box
  85367. * @param frustumPlanes Camera near/planes
  85368. * @returns true if the object is in frustum otherwise false
  85369. */
  85370. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85371. /** @hidden */
  85372. _checkCollision(collider: Collider): boolean;
  85373. /**
  85374. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85375. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85376. * @param point the point to check intersection with
  85377. * @returns if the point intersects
  85378. */
  85379. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85380. /**
  85381. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85382. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85383. * @param boundingInfo the bounding info to check intersection with
  85384. * @param precise if the intersection should be done using OBB
  85385. * @returns if the bounding info intersects
  85386. */
  85387. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85388. }
  85389. }
  85390. declare module BABYLON {
  85391. /**
  85392. * Extracts minimum and maximum values from a list of indexed positions
  85393. * @param positions defines the positions to use
  85394. * @param indices defines the indices to the positions
  85395. * @param indexStart defines the start index
  85396. * @param indexCount defines the end index
  85397. * @param bias defines bias value to add to the result
  85398. * @return minimum and maximum values
  85399. */
  85400. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85401. minimum: Vector3;
  85402. maximum: Vector3;
  85403. };
  85404. /**
  85405. * Extracts minimum and maximum values from a list of positions
  85406. * @param positions defines the positions to use
  85407. * @param start defines the start index in the positions array
  85408. * @param count defines the number of positions to handle
  85409. * @param bias defines bias value to add to the result
  85410. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85411. * @return minimum and maximum values
  85412. */
  85413. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85414. minimum: Vector3;
  85415. maximum: Vector3;
  85416. };
  85417. }
  85418. declare module BABYLON {
  85419. /** @hidden */
  85420. export class WebGLDataBuffer extends DataBuffer {
  85421. private _buffer;
  85422. constructor(resource: WebGLBuffer);
  85423. get underlyingResource(): any;
  85424. }
  85425. }
  85426. declare module BABYLON {
  85427. /** @hidden */
  85428. export class WebGLPipelineContext implements IPipelineContext {
  85429. engine: ThinEngine;
  85430. program: Nullable<WebGLProgram>;
  85431. context?: WebGLRenderingContext;
  85432. vertexShader?: WebGLShader;
  85433. fragmentShader?: WebGLShader;
  85434. isParallelCompiled: boolean;
  85435. onCompiled?: () => void;
  85436. transformFeedback?: WebGLTransformFeedback | null;
  85437. vertexCompilationError: Nullable<string>;
  85438. fragmentCompilationError: Nullable<string>;
  85439. programLinkError: Nullable<string>;
  85440. programValidationError: Nullable<string>;
  85441. get isAsync(): boolean;
  85442. get isReady(): boolean;
  85443. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85444. _getVertexShaderCode(): string | null;
  85445. _getFragmentShaderCode(): string | null;
  85446. }
  85447. }
  85448. declare module BABYLON {
  85449. interface ThinEngine {
  85450. /**
  85451. * Create an uniform buffer
  85452. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85453. * @param elements defines the content of the uniform buffer
  85454. * @returns the webGL uniform buffer
  85455. */
  85456. createUniformBuffer(elements: FloatArray): DataBuffer;
  85457. /**
  85458. * Create a dynamic uniform buffer
  85459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85460. * @param elements defines the content of the uniform buffer
  85461. * @returns the webGL uniform buffer
  85462. */
  85463. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85464. /**
  85465. * Update an existing uniform buffer
  85466. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85467. * @param uniformBuffer defines the target uniform buffer
  85468. * @param elements defines the content to update
  85469. * @param offset defines the offset in the uniform buffer where update should start
  85470. * @param count defines the size of the data to update
  85471. */
  85472. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85473. /**
  85474. * Bind an uniform buffer to the current webGL context
  85475. * @param buffer defines the buffer to bind
  85476. */
  85477. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85478. /**
  85479. * Bind a buffer to the current webGL context at a given location
  85480. * @param buffer defines the buffer to bind
  85481. * @param location defines the index where to bind the buffer
  85482. */
  85483. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85484. /**
  85485. * Bind a specific block at a given index in a specific shader program
  85486. * @param pipelineContext defines the pipeline context to use
  85487. * @param blockName defines the block name
  85488. * @param index defines the index where to bind the block
  85489. */
  85490. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85491. }
  85492. }
  85493. declare module BABYLON {
  85494. /**
  85495. * Uniform buffer objects.
  85496. *
  85497. * Handles blocks of uniform on the GPU.
  85498. *
  85499. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85500. *
  85501. * For more information, please refer to :
  85502. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85503. */
  85504. export class UniformBuffer {
  85505. private _engine;
  85506. private _buffer;
  85507. private _data;
  85508. private _bufferData;
  85509. private _dynamic?;
  85510. private _uniformLocations;
  85511. private _uniformSizes;
  85512. private _uniformLocationPointer;
  85513. private _needSync;
  85514. private _noUBO;
  85515. private _currentEffect;
  85516. /** @hidden */
  85517. _alreadyBound: boolean;
  85518. private static _MAX_UNIFORM_SIZE;
  85519. private static _tempBuffer;
  85520. /**
  85521. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85522. * This is dynamic to allow compat with webgl 1 and 2.
  85523. * You will need to pass the name of the uniform as well as the value.
  85524. */
  85525. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85526. /**
  85527. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85528. * This is dynamic to allow compat with webgl 1 and 2.
  85529. * You will need to pass the name of the uniform as well as the value.
  85530. */
  85531. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85532. /**
  85533. * Lambda to Update a single float in a uniform buffer.
  85534. * This is dynamic to allow compat with webgl 1 and 2.
  85535. * You will need to pass the name of the uniform as well as the value.
  85536. */
  85537. updateFloat: (name: string, x: number) => void;
  85538. /**
  85539. * Lambda to Update a vec2 of float in a uniform buffer.
  85540. * This is dynamic to allow compat with webgl 1 and 2.
  85541. * You will need to pass the name of the uniform as well as the value.
  85542. */
  85543. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85544. /**
  85545. * Lambda to Update a vec3 of float in a uniform buffer.
  85546. * This is dynamic to allow compat with webgl 1 and 2.
  85547. * You will need to pass the name of the uniform as well as the value.
  85548. */
  85549. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85550. /**
  85551. * Lambda to Update a vec4 of float in a uniform buffer.
  85552. * This is dynamic to allow compat with webgl 1 and 2.
  85553. * You will need to pass the name of the uniform as well as the value.
  85554. */
  85555. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85556. /**
  85557. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85558. * This is dynamic to allow compat with webgl 1 and 2.
  85559. * You will need to pass the name of the uniform as well as the value.
  85560. */
  85561. updateMatrix: (name: string, mat: Matrix) => void;
  85562. /**
  85563. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85564. * This is dynamic to allow compat with webgl 1 and 2.
  85565. * You will need to pass the name of the uniform as well as the value.
  85566. */
  85567. updateVector3: (name: string, vector: Vector3) => void;
  85568. /**
  85569. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85570. * This is dynamic to allow compat with webgl 1 and 2.
  85571. * You will need to pass the name of the uniform as well as the value.
  85572. */
  85573. updateVector4: (name: string, vector: Vector4) => void;
  85574. /**
  85575. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85576. * This is dynamic to allow compat with webgl 1 and 2.
  85577. * You will need to pass the name of the uniform as well as the value.
  85578. */
  85579. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85580. /**
  85581. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85582. * This is dynamic to allow compat with webgl 1 and 2.
  85583. * You will need to pass the name of the uniform as well as the value.
  85584. */
  85585. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85586. /**
  85587. * Instantiates a new Uniform buffer objects.
  85588. *
  85589. * Handles blocks of uniform on the GPU.
  85590. *
  85591. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85592. *
  85593. * For more information, please refer to :
  85594. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85595. * @param engine Define the engine the buffer is associated with
  85596. * @param data Define the data contained in the buffer
  85597. * @param dynamic Define if the buffer is updatable
  85598. */
  85599. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85600. /**
  85601. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85602. * or just falling back on setUniformXXX calls.
  85603. */
  85604. get useUbo(): boolean;
  85605. /**
  85606. * Indicates if the WebGL underlying uniform buffer is in sync
  85607. * with the javascript cache data.
  85608. */
  85609. get isSync(): boolean;
  85610. /**
  85611. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85612. * Also, a dynamic UniformBuffer will disable cache verification and always
  85613. * update the underlying WebGL uniform buffer to the GPU.
  85614. * @returns if Dynamic, otherwise false
  85615. */
  85616. isDynamic(): boolean;
  85617. /**
  85618. * The data cache on JS side.
  85619. * @returns the underlying data as a float array
  85620. */
  85621. getData(): Float32Array;
  85622. /**
  85623. * The underlying WebGL Uniform buffer.
  85624. * @returns the webgl buffer
  85625. */
  85626. getBuffer(): Nullable<DataBuffer>;
  85627. /**
  85628. * std140 layout specifies how to align data within an UBO structure.
  85629. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85630. * for specs.
  85631. */
  85632. private _fillAlignment;
  85633. /**
  85634. * Adds an uniform in the buffer.
  85635. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85636. * for the layout to be correct !
  85637. * @param name Name of the uniform, as used in the uniform block in the shader.
  85638. * @param size Data size, or data directly.
  85639. */
  85640. addUniform(name: string, size: number | number[]): void;
  85641. /**
  85642. * Adds a Matrix 4x4 to the uniform buffer.
  85643. * @param name Name of the uniform, as used in the uniform block in the shader.
  85644. * @param mat A 4x4 matrix.
  85645. */
  85646. addMatrix(name: string, mat: Matrix): void;
  85647. /**
  85648. * Adds a vec2 to the uniform buffer.
  85649. * @param name Name of the uniform, as used in the uniform block in the shader.
  85650. * @param x Define the x component value of the vec2
  85651. * @param y Define the y component value of the vec2
  85652. */
  85653. addFloat2(name: string, x: number, y: number): void;
  85654. /**
  85655. * Adds a vec3 to the uniform buffer.
  85656. * @param name Name of the uniform, as used in the uniform block in the shader.
  85657. * @param x Define the x component value of the vec3
  85658. * @param y Define the y component value of the vec3
  85659. * @param z Define the z component value of the vec3
  85660. */
  85661. addFloat3(name: string, x: number, y: number, z: number): void;
  85662. /**
  85663. * Adds a vec3 to the uniform buffer.
  85664. * @param name Name of the uniform, as used in the uniform block in the shader.
  85665. * @param color Define the vec3 from a Color
  85666. */
  85667. addColor3(name: string, color: Color3): void;
  85668. /**
  85669. * Adds a vec4 to the uniform buffer.
  85670. * @param name Name of the uniform, as used in the uniform block in the shader.
  85671. * @param color Define the rgb components from a Color
  85672. * @param alpha Define the a component of the vec4
  85673. */
  85674. addColor4(name: string, color: Color3, alpha: number): void;
  85675. /**
  85676. * Adds a vec3 to the uniform buffer.
  85677. * @param name Name of the uniform, as used in the uniform block in the shader.
  85678. * @param vector Define the vec3 components from a Vector
  85679. */
  85680. addVector3(name: string, vector: Vector3): void;
  85681. /**
  85682. * Adds a Matrix 3x3 to the uniform buffer.
  85683. * @param name Name of the uniform, as used in the uniform block in the shader.
  85684. */
  85685. addMatrix3x3(name: string): void;
  85686. /**
  85687. * Adds a Matrix 2x2 to the uniform buffer.
  85688. * @param name Name of the uniform, as used in the uniform block in the shader.
  85689. */
  85690. addMatrix2x2(name: string): void;
  85691. /**
  85692. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85693. */
  85694. create(): void;
  85695. /** @hidden */
  85696. _rebuild(): void;
  85697. /**
  85698. * Updates the WebGL Uniform Buffer on the GPU.
  85699. * If the `dynamic` flag is set to true, no cache comparison is done.
  85700. * Otherwise, the buffer will be updated only if the cache differs.
  85701. */
  85702. update(): void;
  85703. /**
  85704. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85705. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85706. * @param data Define the flattened data
  85707. * @param size Define the size of the data.
  85708. */
  85709. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85710. private _valueCache;
  85711. private _cacheMatrix;
  85712. private _updateMatrix3x3ForUniform;
  85713. private _updateMatrix3x3ForEffect;
  85714. private _updateMatrix2x2ForEffect;
  85715. private _updateMatrix2x2ForUniform;
  85716. private _updateFloatForEffect;
  85717. private _updateFloatForUniform;
  85718. private _updateFloat2ForEffect;
  85719. private _updateFloat2ForUniform;
  85720. private _updateFloat3ForEffect;
  85721. private _updateFloat3ForUniform;
  85722. private _updateFloat4ForEffect;
  85723. private _updateFloat4ForUniform;
  85724. private _updateMatrixForEffect;
  85725. private _updateMatrixForUniform;
  85726. private _updateVector3ForEffect;
  85727. private _updateVector3ForUniform;
  85728. private _updateVector4ForEffect;
  85729. private _updateVector4ForUniform;
  85730. private _updateColor3ForEffect;
  85731. private _updateColor3ForUniform;
  85732. private _updateColor4ForEffect;
  85733. private _updateColor4ForUniform;
  85734. /**
  85735. * Sets a sampler uniform on the effect.
  85736. * @param name Define the name of the sampler.
  85737. * @param texture Define the texture to set in the sampler
  85738. */
  85739. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85740. /**
  85741. * Directly updates the value of the uniform in the cache AND on the GPU.
  85742. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85743. * @param data Define the flattened data
  85744. */
  85745. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85746. /**
  85747. * Binds this uniform buffer to an effect.
  85748. * @param effect Define the effect to bind the buffer to
  85749. * @param name Name of the uniform block in the shader.
  85750. */
  85751. bindToEffect(effect: Effect, name: string): void;
  85752. /**
  85753. * Disposes the uniform buffer.
  85754. */
  85755. dispose(): void;
  85756. }
  85757. }
  85758. declare module BABYLON {
  85759. /**
  85760. * Enum that determines the text-wrapping mode to use.
  85761. */
  85762. export enum InspectableType {
  85763. /**
  85764. * Checkbox for booleans
  85765. */
  85766. Checkbox = 0,
  85767. /**
  85768. * Sliders for numbers
  85769. */
  85770. Slider = 1,
  85771. /**
  85772. * Vector3
  85773. */
  85774. Vector3 = 2,
  85775. /**
  85776. * Quaternions
  85777. */
  85778. Quaternion = 3,
  85779. /**
  85780. * Color3
  85781. */
  85782. Color3 = 4,
  85783. /**
  85784. * String
  85785. */
  85786. String = 5
  85787. }
  85788. /**
  85789. * Interface used to define custom inspectable properties.
  85790. * This interface is used by the inspector to display custom property grids
  85791. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85792. */
  85793. export interface IInspectable {
  85794. /**
  85795. * Gets the label to display
  85796. */
  85797. label: string;
  85798. /**
  85799. * Gets the name of the property to edit
  85800. */
  85801. propertyName: string;
  85802. /**
  85803. * Gets the type of the editor to use
  85804. */
  85805. type: InspectableType;
  85806. /**
  85807. * Gets the minimum value of the property when using in "slider" mode
  85808. */
  85809. min?: number;
  85810. /**
  85811. * Gets the maximum value of the property when using in "slider" mode
  85812. */
  85813. max?: number;
  85814. /**
  85815. * Gets the setp to use when using in "slider" mode
  85816. */
  85817. step?: number;
  85818. }
  85819. }
  85820. declare module BABYLON {
  85821. /**
  85822. * Class used to provide helper for timing
  85823. */
  85824. export class TimingTools {
  85825. /**
  85826. * Polyfill for setImmediate
  85827. * @param action defines the action to execute after the current execution block
  85828. */
  85829. static SetImmediate(action: () => void): void;
  85830. }
  85831. }
  85832. declare module BABYLON {
  85833. /**
  85834. * Class used to enable instatition of objects by class name
  85835. */
  85836. export class InstantiationTools {
  85837. /**
  85838. * Use this object to register external classes like custom textures or material
  85839. * to allow the laoders to instantiate them
  85840. */
  85841. static RegisteredExternalClasses: {
  85842. [key: string]: Object;
  85843. };
  85844. /**
  85845. * Tries to instantiate a new object from a given class name
  85846. * @param className defines the class name to instantiate
  85847. * @returns the new object or null if the system was not able to do the instantiation
  85848. */
  85849. static Instantiate(className: string): any;
  85850. }
  85851. }
  85852. declare module BABYLON {
  85853. /**
  85854. * Define options used to create a depth texture
  85855. */
  85856. export class DepthTextureCreationOptions {
  85857. /** Specifies whether or not a stencil should be allocated in the texture */
  85858. generateStencil?: boolean;
  85859. /** Specifies whether or not bilinear filtering is enable on the texture */
  85860. bilinearFiltering?: boolean;
  85861. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85862. comparisonFunction?: number;
  85863. /** Specifies if the created texture is a cube texture */
  85864. isCube?: boolean;
  85865. }
  85866. }
  85867. declare module BABYLON {
  85868. interface ThinEngine {
  85869. /**
  85870. * Creates a depth stencil cube texture.
  85871. * This is only available in WebGL 2.
  85872. * @param size The size of face edge in the cube texture.
  85873. * @param options The options defining the cube texture.
  85874. * @returns The cube texture
  85875. */
  85876. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85877. /**
  85878. * Creates a cube texture
  85879. * @param rootUrl defines the url where the files to load is located
  85880. * @param scene defines the current scene
  85881. * @param files defines the list of files to load (1 per face)
  85882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85883. * @param onLoad defines an optional callback raised when the texture is loaded
  85884. * @param onError defines an optional callback raised if there is an issue to load the texture
  85885. * @param format defines the format of the data
  85886. * @param forcedExtension defines the extension to use to pick the right loader
  85887. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85888. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85889. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85890. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85891. * @returns the cube texture as an InternalTexture
  85892. */
  85893. 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;
  85894. /**
  85895. * Creates a cube texture
  85896. * @param rootUrl defines the url where the files to load is located
  85897. * @param scene defines the current scene
  85898. * @param files defines the list of files to load (1 per face)
  85899. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85900. * @param onLoad defines an optional callback raised when the texture is loaded
  85901. * @param onError defines an optional callback raised if there is an issue to load the texture
  85902. * @param format defines the format of the data
  85903. * @param forcedExtension defines the extension to use to pick the right loader
  85904. * @returns the cube texture as an InternalTexture
  85905. */
  85906. 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;
  85907. /**
  85908. * Creates a cube texture
  85909. * @param rootUrl defines the url where the files to load is located
  85910. * @param scene defines the current scene
  85911. * @param files defines the list of files to load (1 per face)
  85912. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85913. * @param onLoad defines an optional callback raised when the texture is loaded
  85914. * @param onError defines an optional callback raised if there is an issue to load the texture
  85915. * @param format defines the format of the data
  85916. * @param forcedExtension defines the extension to use to pick the right loader
  85917. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85918. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85919. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85920. * @returns the cube texture as an InternalTexture
  85921. */
  85922. 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;
  85923. /** @hidden */
  85924. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85925. /** @hidden */
  85926. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85927. /** @hidden */
  85928. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85929. /** @hidden */
  85930. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85931. /**
  85932. * @hidden
  85933. */
  85934. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85935. }
  85936. }
  85937. declare module BABYLON {
  85938. /**
  85939. * Class for creating a cube texture
  85940. */
  85941. export class CubeTexture extends BaseTexture {
  85942. private _delayedOnLoad;
  85943. /**
  85944. * Observable triggered once the texture has been loaded.
  85945. */
  85946. onLoadObservable: Observable<CubeTexture>;
  85947. /**
  85948. * The url of the texture
  85949. */
  85950. url: string;
  85951. /**
  85952. * Gets or sets the center of the bounding box associated with the cube texture.
  85953. * It must define where the camera used to render the texture was set
  85954. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85955. */
  85956. boundingBoxPosition: Vector3;
  85957. private _boundingBoxSize;
  85958. /**
  85959. * Gets or sets the size of the bounding box associated with the cube texture
  85960. * When defined, the cubemap will switch to local mode
  85961. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85962. * @example https://www.babylonjs-playground.com/#RNASML
  85963. */
  85964. set boundingBoxSize(value: Vector3);
  85965. /**
  85966. * Returns the bounding box size
  85967. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85968. */
  85969. get boundingBoxSize(): Vector3;
  85970. protected _rotationY: number;
  85971. /**
  85972. * Sets texture matrix rotation angle around Y axis in radians.
  85973. */
  85974. set rotationY(value: number);
  85975. /**
  85976. * Gets texture matrix rotation angle around Y axis radians.
  85977. */
  85978. get rotationY(): number;
  85979. /**
  85980. * Are mip maps generated for this texture or not.
  85981. */
  85982. get noMipmap(): boolean;
  85983. private _noMipmap;
  85984. private _files;
  85985. protected _forcedExtension: Nullable<string>;
  85986. private _extensions;
  85987. private _textureMatrix;
  85988. private _format;
  85989. private _createPolynomials;
  85990. /**
  85991. * Creates a cube texture from an array of image urls
  85992. * @param files defines an array of image urls
  85993. * @param scene defines the hosting scene
  85994. * @param noMipmap specifies if mip maps are not used
  85995. * @returns a cube texture
  85996. */
  85997. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85998. /**
  85999. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86000. * @param url defines the url of the prefiltered texture
  86001. * @param scene defines the scene the texture is attached to
  86002. * @param forcedExtension defines the extension of the file if different from the url
  86003. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86004. * @return the prefiltered texture
  86005. */
  86006. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86007. /**
  86008. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86009. * as prefiltered data.
  86010. * @param rootUrl defines the url of the texture or the root name of the six images
  86011. * @param null defines the scene or engine the texture is attached to
  86012. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86013. * @param noMipmap defines if mipmaps should be created or not
  86014. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86015. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86016. * @param onError defines a callback triggered in case of error during load
  86017. * @param format defines the internal format to use for the texture once loaded
  86018. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86019. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86020. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86023. * @return the cube texture
  86024. */
  86025. 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);
  86026. /**
  86027. * Get the current class name of the texture useful for serialization or dynamic coding.
  86028. * @returns "CubeTexture"
  86029. */
  86030. getClassName(): string;
  86031. /**
  86032. * Update the url (and optional buffer) of this texture if url was null during construction.
  86033. * @param url the url of the texture
  86034. * @param forcedExtension defines the extension to use
  86035. * @param onLoad callback called when the texture is loaded (defaults to null)
  86036. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86037. */
  86038. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86039. /**
  86040. * Delays loading of the cube texture
  86041. * @param forcedExtension defines the extension to use
  86042. */
  86043. delayLoad(forcedExtension?: string): void;
  86044. /**
  86045. * Returns the reflection texture matrix
  86046. * @returns the reflection texture matrix
  86047. */
  86048. getReflectionTextureMatrix(): Matrix;
  86049. /**
  86050. * Sets the reflection texture matrix
  86051. * @param value Reflection texture matrix
  86052. */
  86053. setReflectionTextureMatrix(value: Matrix): void;
  86054. /**
  86055. * Parses text to create a cube texture
  86056. * @param parsedTexture define the serialized text to read from
  86057. * @param scene defines the hosting scene
  86058. * @param rootUrl defines the root url of the cube texture
  86059. * @returns a cube texture
  86060. */
  86061. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86062. /**
  86063. * Makes a clone, or deep copy, of the cube texture
  86064. * @returns a new cube texture
  86065. */
  86066. clone(): CubeTexture;
  86067. }
  86068. }
  86069. declare module BABYLON {
  86070. /**
  86071. * Manages the defines for the Material
  86072. */
  86073. export class MaterialDefines {
  86074. /** @hidden */
  86075. protected _keys: string[];
  86076. private _isDirty;
  86077. /** @hidden */
  86078. _renderId: number;
  86079. /** @hidden */
  86080. _areLightsDirty: boolean;
  86081. /** @hidden */
  86082. _areLightsDisposed: boolean;
  86083. /** @hidden */
  86084. _areAttributesDirty: boolean;
  86085. /** @hidden */
  86086. _areTexturesDirty: boolean;
  86087. /** @hidden */
  86088. _areFresnelDirty: boolean;
  86089. /** @hidden */
  86090. _areMiscDirty: boolean;
  86091. /** @hidden */
  86092. _areImageProcessingDirty: boolean;
  86093. /** @hidden */
  86094. _normals: boolean;
  86095. /** @hidden */
  86096. _uvs: boolean;
  86097. /** @hidden */
  86098. _needNormals: boolean;
  86099. /** @hidden */
  86100. _needUVs: boolean;
  86101. [id: string]: any;
  86102. /**
  86103. * Specifies if the material needs to be re-calculated
  86104. */
  86105. get isDirty(): boolean;
  86106. /**
  86107. * Marks the material to indicate that it has been re-calculated
  86108. */
  86109. markAsProcessed(): void;
  86110. /**
  86111. * Marks the material to indicate that it needs to be re-calculated
  86112. */
  86113. markAsUnprocessed(): void;
  86114. /**
  86115. * Marks the material to indicate all of its defines need to be re-calculated
  86116. */
  86117. markAllAsDirty(): void;
  86118. /**
  86119. * Marks the material to indicate that image processing needs to be re-calculated
  86120. */
  86121. markAsImageProcessingDirty(): void;
  86122. /**
  86123. * Marks the material to indicate the lights need to be re-calculated
  86124. * @param disposed Defines whether the light is dirty due to dispose or not
  86125. */
  86126. markAsLightDirty(disposed?: boolean): void;
  86127. /**
  86128. * Marks the attribute state as changed
  86129. */
  86130. markAsAttributesDirty(): void;
  86131. /**
  86132. * Marks the texture state as changed
  86133. */
  86134. markAsTexturesDirty(): void;
  86135. /**
  86136. * Marks the fresnel state as changed
  86137. */
  86138. markAsFresnelDirty(): void;
  86139. /**
  86140. * Marks the misc state as changed
  86141. */
  86142. markAsMiscDirty(): void;
  86143. /**
  86144. * Rebuilds the material defines
  86145. */
  86146. rebuild(): void;
  86147. /**
  86148. * Specifies if two material defines are equal
  86149. * @param other - A material define instance to compare to
  86150. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86151. */
  86152. isEqual(other: MaterialDefines): boolean;
  86153. /**
  86154. * Clones this instance's defines to another instance
  86155. * @param other - material defines to clone values to
  86156. */
  86157. cloneTo(other: MaterialDefines): void;
  86158. /**
  86159. * Resets the material define values
  86160. */
  86161. reset(): void;
  86162. /**
  86163. * Converts the material define values to a string
  86164. * @returns - String of material define information
  86165. */
  86166. toString(): string;
  86167. }
  86168. }
  86169. declare module BABYLON {
  86170. /**
  86171. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86172. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86173. * 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;
  86174. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86175. */
  86176. export class ColorCurves {
  86177. private _dirty;
  86178. private _tempColor;
  86179. private _globalCurve;
  86180. private _highlightsCurve;
  86181. private _midtonesCurve;
  86182. private _shadowsCurve;
  86183. private _positiveCurve;
  86184. private _negativeCurve;
  86185. private _globalHue;
  86186. private _globalDensity;
  86187. private _globalSaturation;
  86188. private _globalExposure;
  86189. /**
  86190. * Gets the global Hue value.
  86191. * 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).
  86192. */
  86193. get globalHue(): number;
  86194. /**
  86195. * Sets the global Hue value.
  86196. * 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).
  86197. */
  86198. set globalHue(value: number);
  86199. /**
  86200. * Gets the global Density value.
  86201. * 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.
  86202. * Values less than zero provide a filter of opposite hue.
  86203. */
  86204. get globalDensity(): number;
  86205. /**
  86206. * Sets the global Density value.
  86207. * 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.
  86208. * Values less than zero provide a filter of opposite hue.
  86209. */
  86210. set globalDensity(value: number);
  86211. /**
  86212. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  86214. */
  86215. get globalSaturation(): number;
  86216. /**
  86217. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  86219. */
  86220. set globalSaturation(value: number);
  86221. /**
  86222. * Gets the global Exposure value.
  86223. * 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.
  86224. */
  86225. get globalExposure(): number;
  86226. /**
  86227. * Sets the global Exposure value.
  86228. * 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.
  86229. */
  86230. set globalExposure(value: number);
  86231. private _highlightsHue;
  86232. private _highlightsDensity;
  86233. private _highlightsSaturation;
  86234. private _highlightsExposure;
  86235. /**
  86236. * Gets the highlights Hue value.
  86237. * 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).
  86238. */
  86239. get highlightsHue(): number;
  86240. /**
  86241. * Sets the highlights Hue value.
  86242. * 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).
  86243. */
  86244. set highlightsHue(value: number);
  86245. /**
  86246. * Gets the highlights Density value.
  86247. * 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.
  86248. * Values less than zero provide a filter of opposite hue.
  86249. */
  86250. get highlightsDensity(): number;
  86251. /**
  86252. * Sets the highlights Density value.
  86253. * 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.
  86254. * Values less than zero provide a filter of opposite hue.
  86255. */
  86256. set highlightsDensity(value: number);
  86257. /**
  86258. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  86260. */
  86261. get highlightsSaturation(): number;
  86262. /**
  86263. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  86265. */
  86266. set highlightsSaturation(value: number);
  86267. /**
  86268. * Gets the highlights Exposure value.
  86269. * 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.
  86270. */
  86271. get highlightsExposure(): number;
  86272. /**
  86273. * Sets the highlights Exposure value.
  86274. * 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.
  86275. */
  86276. set highlightsExposure(value: number);
  86277. private _midtonesHue;
  86278. private _midtonesDensity;
  86279. private _midtonesSaturation;
  86280. private _midtonesExposure;
  86281. /**
  86282. * Gets the midtones Hue value.
  86283. * 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).
  86284. */
  86285. get midtonesHue(): number;
  86286. /**
  86287. * Sets the midtones Hue value.
  86288. * 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).
  86289. */
  86290. set midtonesHue(value: number);
  86291. /**
  86292. * Gets the midtones Density value.
  86293. * 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.
  86294. * Values less than zero provide a filter of opposite hue.
  86295. */
  86296. get midtonesDensity(): number;
  86297. /**
  86298. * Sets the midtones Density value.
  86299. * 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.
  86300. * Values less than zero provide a filter of opposite hue.
  86301. */
  86302. set midtonesDensity(value: number);
  86303. /**
  86304. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  86306. */
  86307. get midtonesSaturation(): number;
  86308. /**
  86309. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  86311. */
  86312. set midtonesSaturation(value: number);
  86313. /**
  86314. * Gets the midtones Exposure value.
  86315. * 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.
  86316. */
  86317. get midtonesExposure(): number;
  86318. /**
  86319. * Sets the midtones Exposure value.
  86320. * 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.
  86321. */
  86322. set midtonesExposure(value: number);
  86323. private _shadowsHue;
  86324. private _shadowsDensity;
  86325. private _shadowsSaturation;
  86326. private _shadowsExposure;
  86327. /**
  86328. * Gets the shadows Hue value.
  86329. * 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).
  86330. */
  86331. get shadowsHue(): number;
  86332. /**
  86333. * Sets the shadows Hue value.
  86334. * 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).
  86335. */
  86336. set shadowsHue(value: number);
  86337. /**
  86338. * Gets the shadows Density value.
  86339. * 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.
  86340. * Values less than zero provide a filter of opposite hue.
  86341. */
  86342. get shadowsDensity(): number;
  86343. /**
  86344. * Sets the shadows Density value.
  86345. * 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.
  86346. * Values less than zero provide a filter of opposite hue.
  86347. */
  86348. set shadowsDensity(value: number);
  86349. /**
  86350. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  86352. */
  86353. get shadowsSaturation(): number;
  86354. /**
  86355. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  86357. */
  86358. set shadowsSaturation(value: number);
  86359. /**
  86360. * Gets the shadows Exposure value.
  86361. * 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.
  86362. */
  86363. get shadowsExposure(): number;
  86364. /**
  86365. * Sets the shadows Exposure value.
  86366. * 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.
  86367. */
  86368. set shadowsExposure(value: number);
  86369. /**
  86370. * Returns the class name
  86371. * @returns The class name
  86372. */
  86373. getClassName(): string;
  86374. /**
  86375. * Binds the color curves to the shader.
  86376. * @param colorCurves The color curve to bind
  86377. * @param effect The effect to bind to
  86378. * @param positiveUniform The positive uniform shader parameter
  86379. * @param neutralUniform The neutral uniform shader parameter
  86380. * @param negativeUniform The negative uniform shader parameter
  86381. */
  86382. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86383. /**
  86384. * Prepare the list of uniforms associated with the ColorCurves effects.
  86385. * @param uniformsList The list of uniforms used in the effect
  86386. */
  86387. static PrepareUniforms(uniformsList: string[]): void;
  86388. /**
  86389. * Returns color grading data based on a hue, density, saturation and exposure value.
  86390. * @param filterHue The hue of the color filter.
  86391. * @param filterDensity The density of the color filter.
  86392. * @param saturation The saturation.
  86393. * @param exposure The exposure.
  86394. * @param result The result data container.
  86395. */
  86396. private getColorGradingDataToRef;
  86397. /**
  86398. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86399. * @param value The input slider value in range [-100,100].
  86400. * @returns Adjusted value.
  86401. */
  86402. private static applyColorGradingSliderNonlinear;
  86403. /**
  86404. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86405. * @param hue The hue (H) input.
  86406. * @param saturation The saturation (S) input.
  86407. * @param brightness The brightness (B) input.
  86408. * @result An RGBA color represented as Vector4.
  86409. */
  86410. private static fromHSBToRef;
  86411. /**
  86412. * Returns a value clamped between min and max
  86413. * @param value The value to clamp
  86414. * @param min The minimum of value
  86415. * @param max The maximum of value
  86416. * @returns The clamped value.
  86417. */
  86418. private static clamp;
  86419. /**
  86420. * Clones the current color curve instance.
  86421. * @return The cloned curves
  86422. */
  86423. clone(): ColorCurves;
  86424. /**
  86425. * Serializes the current color curve instance to a json representation.
  86426. * @return a JSON representation
  86427. */
  86428. serialize(): any;
  86429. /**
  86430. * Parses the color curve from a json representation.
  86431. * @param source the JSON source to parse
  86432. * @return The parsed curves
  86433. */
  86434. static Parse(source: any): ColorCurves;
  86435. }
  86436. }
  86437. declare module BABYLON {
  86438. /**
  86439. * Interface to follow in your material defines to integrate easily the
  86440. * Image proccessing functions.
  86441. * @hidden
  86442. */
  86443. export interface IImageProcessingConfigurationDefines {
  86444. IMAGEPROCESSING: boolean;
  86445. VIGNETTE: boolean;
  86446. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86447. VIGNETTEBLENDMODEOPAQUE: boolean;
  86448. TONEMAPPING: boolean;
  86449. TONEMAPPING_ACES: boolean;
  86450. CONTRAST: boolean;
  86451. EXPOSURE: boolean;
  86452. COLORCURVES: boolean;
  86453. COLORGRADING: boolean;
  86454. COLORGRADING3D: boolean;
  86455. SAMPLER3DGREENDEPTH: boolean;
  86456. SAMPLER3DBGRMAP: boolean;
  86457. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86458. }
  86459. /**
  86460. * @hidden
  86461. */
  86462. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86463. IMAGEPROCESSING: boolean;
  86464. VIGNETTE: boolean;
  86465. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86466. VIGNETTEBLENDMODEOPAQUE: boolean;
  86467. TONEMAPPING: boolean;
  86468. TONEMAPPING_ACES: boolean;
  86469. CONTRAST: boolean;
  86470. COLORCURVES: boolean;
  86471. COLORGRADING: boolean;
  86472. COLORGRADING3D: boolean;
  86473. SAMPLER3DGREENDEPTH: boolean;
  86474. SAMPLER3DBGRMAP: boolean;
  86475. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86476. EXPOSURE: boolean;
  86477. constructor();
  86478. }
  86479. /**
  86480. * This groups together the common properties used for image processing either in direct forward pass
  86481. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86482. * or not.
  86483. */
  86484. export class ImageProcessingConfiguration {
  86485. /**
  86486. * Default tone mapping applied in BabylonJS.
  86487. */
  86488. static readonly TONEMAPPING_STANDARD: number;
  86489. /**
  86490. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86491. * to other engines rendering to increase portability.
  86492. */
  86493. static readonly TONEMAPPING_ACES: number;
  86494. /**
  86495. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86496. */
  86497. colorCurves: Nullable<ColorCurves>;
  86498. private _colorCurvesEnabled;
  86499. /**
  86500. * Gets wether the color curves effect is enabled.
  86501. */
  86502. get colorCurvesEnabled(): boolean;
  86503. /**
  86504. * Sets wether the color curves effect is enabled.
  86505. */
  86506. set colorCurvesEnabled(value: boolean);
  86507. private _colorGradingTexture;
  86508. /**
  86509. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86510. */
  86511. get colorGradingTexture(): Nullable<BaseTexture>;
  86512. /**
  86513. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86514. */
  86515. set colorGradingTexture(value: Nullable<BaseTexture>);
  86516. private _colorGradingEnabled;
  86517. /**
  86518. * Gets wether the color grading effect is enabled.
  86519. */
  86520. get colorGradingEnabled(): boolean;
  86521. /**
  86522. * Sets wether the color grading effect is enabled.
  86523. */
  86524. set colorGradingEnabled(value: boolean);
  86525. private _colorGradingWithGreenDepth;
  86526. /**
  86527. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86528. */
  86529. get colorGradingWithGreenDepth(): boolean;
  86530. /**
  86531. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86532. */
  86533. set colorGradingWithGreenDepth(value: boolean);
  86534. private _colorGradingBGR;
  86535. /**
  86536. * Gets wether the color grading texture contains BGR values.
  86537. */
  86538. get colorGradingBGR(): boolean;
  86539. /**
  86540. * Sets wether the color grading texture contains BGR values.
  86541. */
  86542. set colorGradingBGR(value: boolean);
  86543. /** @hidden */
  86544. _exposure: number;
  86545. /**
  86546. * Gets the Exposure used in the effect.
  86547. */
  86548. get exposure(): number;
  86549. /**
  86550. * Sets the Exposure used in the effect.
  86551. */
  86552. set exposure(value: number);
  86553. private _toneMappingEnabled;
  86554. /**
  86555. * Gets wether the tone mapping effect is enabled.
  86556. */
  86557. get toneMappingEnabled(): boolean;
  86558. /**
  86559. * Sets wether the tone mapping effect is enabled.
  86560. */
  86561. set toneMappingEnabled(value: boolean);
  86562. private _toneMappingType;
  86563. /**
  86564. * Gets the type of tone mapping effect.
  86565. */
  86566. get toneMappingType(): number;
  86567. /**
  86568. * Sets the type of tone mapping effect used in BabylonJS.
  86569. */
  86570. set toneMappingType(value: number);
  86571. protected _contrast: number;
  86572. /**
  86573. * Gets the contrast used in the effect.
  86574. */
  86575. get contrast(): number;
  86576. /**
  86577. * Sets the contrast used in the effect.
  86578. */
  86579. set contrast(value: number);
  86580. /**
  86581. * Vignette stretch size.
  86582. */
  86583. vignetteStretch: number;
  86584. /**
  86585. * Vignette centre X Offset.
  86586. */
  86587. vignetteCentreX: number;
  86588. /**
  86589. * Vignette centre Y Offset.
  86590. */
  86591. vignetteCentreY: number;
  86592. /**
  86593. * Vignette weight or intensity of the vignette effect.
  86594. */
  86595. vignetteWeight: number;
  86596. /**
  86597. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86598. * if vignetteEnabled is set to true.
  86599. */
  86600. vignetteColor: Color4;
  86601. /**
  86602. * Camera field of view used by the Vignette effect.
  86603. */
  86604. vignetteCameraFov: number;
  86605. private _vignetteBlendMode;
  86606. /**
  86607. * Gets the vignette blend mode allowing different kind of effect.
  86608. */
  86609. get vignetteBlendMode(): number;
  86610. /**
  86611. * Sets the vignette blend mode allowing different kind of effect.
  86612. */
  86613. set vignetteBlendMode(value: number);
  86614. private _vignetteEnabled;
  86615. /**
  86616. * Gets wether the vignette effect is enabled.
  86617. */
  86618. get vignetteEnabled(): boolean;
  86619. /**
  86620. * Sets wether the vignette effect is enabled.
  86621. */
  86622. set vignetteEnabled(value: boolean);
  86623. private _applyByPostProcess;
  86624. /**
  86625. * Gets wether the image processing is applied through a post process or not.
  86626. */
  86627. get applyByPostProcess(): boolean;
  86628. /**
  86629. * Sets wether the image processing is applied through a post process or not.
  86630. */
  86631. set applyByPostProcess(value: boolean);
  86632. private _isEnabled;
  86633. /**
  86634. * Gets wether the image processing is enabled or not.
  86635. */
  86636. get isEnabled(): boolean;
  86637. /**
  86638. * Sets wether the image processing is enabled or not.
  86639. */
  86640. set isEnabled(value: boolean);
  86641. /**
  86642. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86643. */
  86644. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86645. /**
  86646. * Method called each time the image processing information changes requires to recompile the effect.
  86647. */
  86648. protected _updateParameters(): void;
  86649. /**
  86650. * Gets the current class name.
  86651. * @return "ImageProcessingConfiguration"
  86652. */
  86653. getClassName(): string;
  86654. /**
  86655. * Prepare the list of uniforms associated with the Image Processing effects.
  86656. * @param uniforms The list of uniforms used in the effect
  86657. * @param defines the list of defines currently in use
  86658. */
  86659. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86660. /**
  86661. * Prepare the list of samplers associated with the Image Processing effects.
  86662. * @param samplersList The list of uniforms used in the effect
  86663. * @param defines the list of defines currently in use
  86664. */
  86665. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86666. /**
  86667. * Prepare the list of defines associated to the shader.
  86668. * @param defines the list of defines to complete
  86669. * @param forPostProcess Define if we are currently in post process mode or not
  86670. */
  86671. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86672. /**
  86673. * Returns true if all the image processing information are ready.
  86674. * @returns True if ready, otherwise, false
  86675. */
  86676. isReady(): boolean;
  86677. /**
  86678. * Binds the image processing to the shader.
  86679. * @param effect The effect to bind to
  86680. * @param overrideAspectRatio Override the aspect ratio of the effect
  86681. */
  86682. bind(effect: Effect, overrideAspectRatio?: number): void;
  86683. /**
  86684. * Clones the current image processing instance.
  86685. * @return The cloned image processing
  86686. */
  86687. clone(): ImageProcessingConfiguration;
  86688. /**
  86689. * Serializes the current image processing instance to a json representation.
  86690. * @return a JSON representation
  86691. */
  86692. serialize(): any;
  86693. /**
  86694. * Parses the image processing from a json representation.
  86695. * @param source the JSON source to parse
  86696. * @return The parsed image processing
  86697. */
  86698. static Parse(source: any): ImageProcessingConfiguration;
  86699. private static _VIGNETTEMODE_MULTIPLY;
  86700. private static _VIGNETTEMODE_OPAQUE;
  86701. /**
  86702. * Used to apply the vignette as a mix with the pixel color.
  86703. */
  86704. static get VIGNETTEMODE_MULTIPLY(): number;
  86705. /**
  86706. * Used to apply the vignette as a replacement of the pixel color.
  86707. */
  86708. static get VIGNETTEMODE_OPAQUE(): number;
  86709. }
  86710. }
  86711. declare module BABYLON {
  86712. /** @hidden */
  86713. export var postprocessVertexShader: {
  86714. name: string;
  86715. shader: string;
  86716. };
  86717. }
  86718. declare module BABYLON {
  86719. interface ThinEngine {
  86720. /**
  86721. * Creates a new render target texture
  86722. * @param size defines the size of the texture
  86723. * @param options defines the options used to create the texture
  86724. * @returns a new render target texture stored in an InternalTexture
  86725. */
  86726. createRenderTargetTexture(size: number | {
  86727. width: number;
  86728. height: number;
  86729. layers?: number;
  86730. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86731. /**
  86732. * Creates a depth stencil texture.
  86733. * This is only available in WebGL 2 or with the depth texture extension available.
  86734. * @param size The size of face edge in the texture.
  86735. * @param options The options defining the texture.
  86736. * @returns The texture
  86737. */
  86738. createDepthStencilTexture(size: number | {
  86739. width: number;
  86740. height: number;
  86741. layers?: number;
  86742. }, options: DepthTextureCreationOptions): InternalTexture;
  86743. /** @hidden */
  86744. _createDepthStencilTexture(size: number | {
  86745. width: number;
  86746. height: number;
  86747. layers?: number;
  86748. }, options: DepthTextureCreationOptions): InternalTexture;
  86749. }
  86750. }
  86751. declare module BABYLON {
  86752. /**
  86753. * Defines the kind of connection point for node based material
  86754. */
  86755. export enum NodeMaterialBlockConnectionPointTypes {
  86756. /** Float */
  86757. Float = 1,
  86758. /** Int */
  86759. Int = 2,
  86760. /** Vector2 */
  86761. Vector2 = 4,
  86762. /** Vector3 */
  86763. Vector3 = 8,
  86764. /** Vector4 */
  86765. Vector4 = 16,
  86766. /** Color3 */
  86767. Color3 = 32,
  86768. /** Color4 */
  86769. Color4 = 64,
  86770. /** Matrix */
  86771. Matrix = 128,
  86772. /** Custom object */
  86773. Object = 256,
  86774. /** Detect type based on connection */
  86775. AutoDetect = 1024,
  86776. /** Output type that will be defined by input type */
  86777. BasedOnInput = 2048
  86778. }
  86779. }
  86780. declare module BABYLON {
  86781. /**
  86782. * Enum used to define the target of a block
  86783. */
  86784. export enum NodeMaterialBlockTargets {
  86785. /** Vertex shader */
  86786. Vertex = 1,
  86787. /** Fragment shader */
  86788. Fragment = 2,
  86789. /** Neutral */
  86790. Neutral = 4,
  86791. /** Vertex and Fragment */
  86792. VertexAndFragment = 3
  86793. }
  86794. }
  86795. declare module BABYLON {
  86796. /**
  86797. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86798. */
  86799. export enum NodeMaterialBlockConnectionPointMode {
  86800. /** Value is an uniform */
  86801. Uniform = 0,
  86802. /** Value is a mesh attribute */
  86803. Attribute = 1,
  86804. /** Value is a varying between vertex and fragment shaders */
  86805. Varying = 2,
  86806. /** Mode is undefined */
  86807. Undefined = 3
  86808. }
  86809. }
  86810. declare module BABYLON {
  86811. /**
  86812. * Enum used to define system values e.g. values automatically provided by the system
  86813. */
  86814. export enum NodeMaterialSystemValues {
  86815. /** World */
  86816. World = 1,
  86817. /** View */
  86818. View = 2,
  86819. /** Projection */
  86820. Projection = 3,
  86821. /** ViewProjection */
  86822. ViewProjection = 4,
  86823. /** WorldView */
  86824. WorldView = 5,
  86825. /** WorldViewProjection */
  86826. WorldViewProjection = 6,
  86827. /** CameraPosition */
  86828. CameraPosition = 7,
  86829. /** Fog Color */
  86830. FogColor = 8,
  86831. /** Delta time */
  86832. DeltaTime = 9
  86833. }
  86834. }
  86835. declare module BABYLON {
  86836. /** Defines supported spaces */
  86837. export enum Space {
  86838. /** Local (object) space */
  86839. LOCAL = 0,
  86840. /** World space */
  86841. WORLD = 1,
  86842. /** Bone space */
  86843. BONE = 2
  86844. }
  86845. /** Defines the 3 main axes */
  86846. export class Axis {
  86847. /** X axis */
  86848. static X: Vector3;
  86849. /** Y axis */
  86850. static Y: Vector3;
  86851. /** Z axis */
  86852. static Z: Vector3;
  86853. }
  86854. }
  86855. declare module BABYLON {
  86856. /**
  86857. * Represents a camera frustum
  86858. */
  86859. export class Frustum {
  86860. /**
  86861. * Gets the planes representing the frustum
  86862. * @param transform matrix to be applied to the returned planes
  86863. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86864. */
  86865. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86866. /**
  86867. * Gets the near frustum plane transformed by the transform matrix
  86868. * @param transform transformation matrix to be applied to the resulting frustum plane
  86869. * @param frustumPlane the resuling frustum plane
  86870. */
  86871. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86872. /**
  86873. * Gets the far frustum plane transformed by the transform matrix
  86874. * @param transform transformation matrix to be applied to the resulting frustum plane
  86875. * @param frustumPlane the resuling frustum plane
  86876. */
  86877. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86878. /**
  86879. * Gets the left frustum plane transformed by the transform matrix
  86880. * @param transform transformation matrix to be applied to the resulting frustum plane
  86881. * @param frustumPlane the resuling frustum plane
  86882. */
  86883. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86884. /**
  86885. * Gets the right frustum plane transformed by the transform matrix
  86886. * @param transform transformation matrix to be applied to the resulting frustum plane
  86887. * @param frustumPlane the resuling frustum plane
  86888. */
  86889. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86890. /**
  86891. * Gets the top frustum plane transformed by the transform matrix
  86892. * @param transform transformation matrix to be applied to the resulting frustum plane
  86893. * @param frustumPlane the resuling frustum plane
  86894. */
  86895. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86896. /**
  86897. * Gets the bottom frustum plane transformed by the transform matrix
  86898. * @param transform transformation matrix to be applied to the resulting frustum plane
  86899. * @param frustumPlane the resuling frustum plane
  86900. */
  86901. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86902. /**
  86903. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86904. * @param transform transformation matrix to be applied to the resulting frustum planes
  86905. * @param frustumPlanes the resuling frustum planes
  86906. */
  86907. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86908. }
  86909. }
  86910. declare module BABYLON {
  86911. /**
  86912. * Interface for the size containing width and height
  86913. */
  86914. export interface ISize {
  86915. /**
  86916. * Width
  86917. */
  86918. width: number;
  86919. /**
  86920. * Heighht
  86921. */
  86922. height: number;
  86923. }
  86924. /**
  86925. * Size containing widht and height
  86926. */
  86927. export class Size implements ISize {
  86928. /**
  86929. * Width
  86930. */
  86931. width: number;
  86932. /**
  86933. * Height
  86934. */
  86935. height: number;
  86936. /**
  86937. * Creates a Size object from the given width and height (floats).
  86938. * @param width width of the new size
  86939. * @param height height of the new size
  86940. */
  86941. constructor(width: number, height: number);
  86942. /**
  86943. * Returns a string with the Size width and height
  86944. * @returns a string with the Size width and height
  86945. */
  86946. toString(): string;
  86947. /**
  86948. * "Size"
  86949. * @returns the string "Size"
  86950. */
  86951. getClassName(): string;
  86952. /**
  86953. * Returns the Size hash code.
  86954. * @returns a hash code for a unique width and height
  86955. */
  86956. getHashCode(): number;
  86957. /**
  86958. * Updates the current size from the given one.
  86959. * @param src the given size
  86960. */
  86961. copyFrom(src: Size): void;
  86962. /**
  86963. * Updates in place the current Size from the given floats.
  86964. * @param width width of the new size
  86965. * @param height height of the new size
  86966. * @returns the updated Size.
  86967. */
  86968. copyFromFloats(width: number, height: number): Size;
  86969. /**
  86970. * Updates in place the current Size from the given floats.
  86971. * @param width width to set
  86972. * @param height height to set
  86973. * @returns the updated Size.
  86974. */
  86975. set(width: number, height: number): Size;
  86976. /**
  86977. * Multiplies the width and height by numbers
  86978. * @param w factor to multiple the width by
  86979. * @param h factor to multiple the height by
  86980. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86981. */
  86982. multiplyByFloats(w: number, h: number): Size;
  86983. /**
  86984. * Clones the size
  86985. * @returns a new Size copied from the given one.
  86986. */
  86987. clone(): Size;
  86988. /**
  86989. * True if the current Size and the given one width and height are strictly equal.
  86990. * @param other the other size to compare against
  86991. * @returns True if the current Size and the given one width and height are strictly equal.
  86992. */
  86993. equals(other: Size): boolean;
  86994. /**
  86995. * The surface of the Size : width * height (float).
  86996. */
  86997. get surface(): number;
  86998. /**
  86999. * Create a new size of zero
  87000. * @returns a new Size set to (0.0, 0.0)
  87001. */
  87002. static Zero(): Size;
  87003. /**
  87004. * Sums the width and height of two sizes
  87005. * @param otherSize size to add to this size
  87006. * @returns a new Size set as the addition result of the current Size and the given one.
  87007. */
  87008. add(otherSize: Size): Size;
  87009. /**
  87010. * Subtracts the width and height of two
  87011. * @param otherSize size to subtract to this size
  87012. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87013. */
  87014. subtract(otherSize: Size): Size;
  87015. /**
  87016. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87017. * @param start starting size to lerp between
  87018. * @param end end size to lerp between
  87019. * @param amount amount to lerp between the start and end values
  87020. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87021. */
  87022. static Lerp(start: Size, end: Size, amount: number): Size;
  87023. }
  87024. }
  87025. declare module BABYLON {
  87026. /**
  87027. * Contains position and normal vectors for a vertex
  87028. */
  87029. export class PositionNormalVertex {
  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. * Creates a PositionNormalVertex
  87036. * @param position the position of the vertex (defaut: 0,0,0)
  87037. * @param normal the normal of the vertex (defaut: 0,1,0)
  87038. */
  87039. constructor(
  87040. /** the position of the vertex (defaut: 0,0,0) */
  87041. position?: Vector3,
  87042. /** the normal of the vertex (defaut: 0,1,0) */
  87043. normal?: Vector3);
  87044. /**
  87045. * Clones the PositionNormalVertex
  87046. * @returns the cloned PositionNormalVertex
  87047. */
  87048. clone(): PositionNormalVertex;
  87049. }
  87050. /**
  87051. * Contains position, normal and uv vectors for a vertex
  87052. */
  87053. export class PositionNormalTextureVertex {
  87054. /** the position of the vertex (defaut: 0,0,0) */
  87055. position: Vector3;
  87056. /** the normal of the vertex (defaut: 0,1,0) */
  87057. normal: Vector3;
  87058. /** the uv of the vertex (default: 0,0) */
  87059. uv: Vector2;
  87060. /**
  87061. * Creates a PositionNormalTextureVertex
  87062. * @param position the position of the vertex (defaut: 0,0,0)
  87063. * @param normal the normal of the vertex (defaut: 0,1,0)
  87064. * @param uv the uv of the vertex (default: 0,0)
  87065. */
  87066. constructor(
  87067. /** the position of the vertex (defaut: 0,0,0) */
  87068. position?: Vector3,
  87069. /** the normal of the vertex (defaut: 0,1,0) */
  87070. normal?: Vector3,
  87071. /** the uv of the vertex (default: 0,0) */
  87072. uv?: Vector2);
  87073. /**
  87074. * Clones the PositionNormalTextureVertex
  87075. * @returns the cloned PositionNormalTextureVertex
  87076. */
  87077. clone(): PositionNormalTextureVertex;
  87078. }
  87079. }
  87080. declare module BABYLON {
  87081. /**
  87082. * Enum defining the type of animations supported by InputBlock
  87083. */
  87084. export enum AnimatedInputBlockTypes {
  87085. /** No animation */
  87086. None = 0,
  87087. /** Time based animation. Will only work for floats */
  87088. Time = 1
  87089. }
  87090. }
  87091. declare module BABYLON {
  87092. /**
  87093. * Interface describing all the common properties and methods a shadow light needs to implement.
  87094. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87095. * as well as binding the different shadow properties to the effects.
  87096. */
  87097. export interface IShadowLight extends Light {
  87098. /**
  87099. * The light id in the scene (used in scene.findLighById for instance)
  87100. */
  87101. id: string;
  87102. /**
  87103. * The position the shdow will be casted from.
  87104. */
  87105. position: Vector3;
  87106. /**
  87107. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87108. */
  87109. direction: Vector3;
  87110. /**
  87111. * The transformed position. Position of the light in world space taking parenting in account.
  87112. */
  87113. transformedPosition: Vector3;
  87114. /**
  87115. * The transformed direction. Direction of the light in world space taking parenting in account.
  87116. */
  87117. transformedDirection: Vector3;
  87118. /**
  87119. * The friendly name of the light in the scene.
  87120. */
  87121. name: string;
  87122. /**
  87123. * Defines the shadow projection clipping minimum z value.
  87124. */
  87125. shadowMinZ: number;
  87126. /**
  87127. * Defines the shadow projection clipping maximum z value.
  87128. */
  87129. shadowMaxZ: number;
  87130. /**
  87131. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87132. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87133. */
  87134. computeTransformedInformation(): boolean;
  87135. /**
  87136. * Gets the scene the light belongs to.
  87137. * @returns The scene
  87138. */
  87139. getScene(): Scene;
  87140. /**
  87141. * Callback defining a custom Projection Matrix Builder.
  87142. * This can be used to override the default projection matrix computation.
  87143. */
  87144. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87145. /**
  87146. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87147. * @param matrix The materix to updated with the projection information
  87148. * @param viewMatrix The transform matrix of the light
  87149. * @param renderList The list of mesh to render in the map
  87150. * @returns The current light
  87151. */
  87152. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87153. /**
  87154. * Gets the current depth scale used in ESM.
  87155. * @returns The scale
  87156. */
  87157. getDepthScale(): number;
  87158. /**
  87159. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87160. * @returns true if a cube texture needs to be use
  87161. */
  87162. needCube(): boolean;
  87163. /**
  87164. * Detects if the projection matrix requires to be recomputed this frame.
  87165. * @returns true if it requires to be recomputed otherwise, false.
  87166. */
  87167. needProjectionMatrixCompute(): boolean;
  87168. /**
  87169. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87170. */
  87171. forceProjectionMatrixCompute(): void;
  87172. /**
  87173. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87174. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87175. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87176. */
  87177. getShadowDirection(faceIndex?: number): Vector3;
  87178. /**
  87179. * Gets the minZ used for shadow according to both the scene and the light.
  87180. * @param activeCamera The camera we are returning the min for
  87181. * @returns the depth min z
  87182. */
  87183. getDepthMinZ(activeCamera: Camera): number;
  87184. /**
  87185. * Gets the maxZ used for shadow according to both the scene and the light.
  87186. * @param activeCamera The camera we are returning the max for
  87187. * @returns the depth max z
  87188. */
  87189. getDepthMaxZ(activeCamera: Camera): number;
  87190. }
  87191. /**
  87192. * Base implementation IShadowLight
  87193. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87194. */
  87195. export abstract class ShadowLight extends Light implements IShadowLight {
  87196. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87197. protected _position: Vector3;
  87198. protected _setPosition(value: Vector3): void;
  87199. /**
  87200. * Sets the position the shadow will be casted from. Also use as the light position for both
  87201. * point and spot lights.
  87202. */
  87203. get position(): Vector3;
  87204. /**
  87205. * Sets the position the shadow will be casted from. Also use as the light position for both
  87206. * point and spot lights.
  87207. */
  87208. set position(value: Vector3);
  87209. protected _direction: Vector3;
  87210. protected _setDirection(value: Vector3): void;
  87211. /**
  87212. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87213. * Also use as the light direction on spot and directional lights.
  87214. */
  87215. get direction(): Vector3;
  87216. /**
  87217. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87218. * Also use as the light direction on spot and directional lights.
  87219. */
  87220. set direction(value: Vector3);
  87221. protected _shadowMinZ: number;
  87222. /**
  87223. * Gets the shadow projection clipping minimum z value.
  87224. */
  87225. get shadowMinZ(): number;
  87226. /**
  87227. * Sets the shadow projection clipping minimum z value.
  87228. */
  87229. set shadowMinZ(value: number);
  87230. protected _shadowMaxZ: number;
  87231. /**
  87232. * Sets the shadow projection clipping maximum z value.
  87233. */
  87234. get shadowMaxZ(): number;
  87235. /**
  87236. * Gets the shadow projection clipping maximum z value.
  87237. */
  87238. set shadowMaxZ(value: number);
  87239. /**
  87240. * Callback defining a custom Projection Matrix Builder.
  87241. * This can be used to override the default projection matrix computation.
  87242. */
  87243. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87244. /**
  87245. * The transformed position. Position of the light in world space taking parenting in account.
  87246. */
  87247. transformedPosition: Vector3;
  87248. /**
  87249. * The transformed direction. Direction of the light in world space taking parenting in account.
  87250. */
  87251. transformedDirection: Vector3;
  87252. private _needProjectionMatrixCompute;
  87253. /**
  87254. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87255. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87256. */
  87257. computeTransformedInformation(): boolean;
  87258. /**
  87259. * Return the depth scale used for the shadow map.
  87260. * @returns the depth scale.
  87261. */
  87262. getDepthScale(): number;
  87263. /**
  87264. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87265. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87266. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87267. */
  87268. getShadowDirection(faceIndex?: number): Vector3;
  87269. /**
  87270. * Returns the ShadowLight absolute position in the World.
  87271. * @returns the position vector in world space
  87272. */
  87273. getAbsolutePosition(): Vector3;
  87274. /**
  87275. * Sets the ShadowLight direction toward the passed target.
  87276. * @param target The point to target in local space
  87277. * @returns the updated ShadowLight direction
  87278. */
  87279. setDirectionToTarget(target: Vector3): Vector3;
  87280. /**
  87281. * Returns the light rotation in euler definition.
  87282. * @returns the x y z rotation in local space.
  87283. */
  87284. getRotation(): Vector3;
  87285. /**
  87286. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87287. * @returns true if a cube texture needs to be use
  87288. */
  87289. needCube(): boolean;
  87290. /**
  87291. * Detects if the projection matrix requires to be recomputed this frame.
  87292. * @returns true if it requires to be recomputed otherwise, false.
  87293. */
  87294. needProjectionMatrixCompute(): boolean;
  87295. /**
  87296. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87297. */
  87298. forceProjectionMatrixCompute(): void;
  87299. /** @hidden */
  87300. _initCache(): void;
  87301. /** @hidden */
  87302. _isSynchronized(): boolean;
  87303. /**
  87304. * Computes the world matrix of the node
  87305. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87306. * @returns the world matrix
  87307. */
  87308. computeWorldMatrix(force?: boolean): Matrix;
  87309. /**
  87310. * Gets the minZ used for shadow according to both the scene and the light.
  87311. * @param activeCamera The camera we are returning the min for
  87312. * @returns the depth min z
  87313. */
  87314. getDepthMinZ(activeCamera: Camera): number;
  87315. /**
  87316. * Gets the maxZ used for shadow according to both the scene and the light.
  87317. * @param activeCamera The camera we are returning the max for
  87318. * @returns the depth max z
  87319. */
  87320. getDepthMaxZ(activeCamera: Camera): number;
  87321. /**
  87322. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87323. * @param matrix The materix to updated with the projection information
  87324. * @param viewMatrix The transform matrix of the light
  87325. * @param renderList The list of mesh to render in the map
  87326. * @returns The current light
  87327. */
  87328. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87329. }
  87330. }
  87331. declare module BABYLON {
  87332. /** @hidden */
  87333. export var packingFunctions: {
  87334. name: string;
  87335. shader: string;
  87336. };
  87337. }
  87338. declare module BABYLON {
  87339. /** @hidden */
  87340. export var bayerDitherFunctions: {
  87341. name: string;
  87342. shader: string;
  87343. };
  87344. }
  87345. declare module BABYLON {
  87346. /** @hidden */
  87347. export var shadowMapFragmentDeclaration: {
  87348. name: string;
  87349. shader: string;
  87350. };
  87351. }
  87352. declare module BABYLON {
  87353. /** @hidden */
  87354. export var clipPlaneFragmentDeclaration: {
  87355. name: string;
  87356. shader: string;
  87357. };
  87358. }
  87359. declare module BABYLON {
  87360. /** @hidden */
  87361. export var clipPlaneFragment: {
  87362. name: string;
  87363. shader: string;
  87364. };
  87365. }
  87366. declare module BABYLON {
  87367. /** @hidden */
  87368. export var shadowMapFragment: {
  87369. name: string;
  87370. shader: string;
  87371. };
  87372. }
  87373. declare module BABYLON {
  87374. /** @hidden */
  87375. export var shadowMapPixelShader: {
  87376. name: string;
  87377. shader: string;
  87378. };
  87379. }
  87380. declare module BABYLON {
  87381. /** @hidden */
  87382. export var bonesDeclaration: {
  87383. name: string;
  87384. shader: string;
  87385. };
  87386. }
  87387. declare module BABYLON {
  87388. /** @hidden */
  87389. export var morphTargetsVertexGlobalDeclaration: {
  87390. name: string;
  87391. shader: string;
  87392. };
  87393. }
  87394. declare module BABYLON {
  87395. /** @hidden */
  87396. export var morphTargetsVertexDeclaration: {
  87397. name: string;
  87398. shader: string;
  87399. };
  87400. }
  87401. declare module BABYLON {
  87402. /** @hidden */
  87403. export var instancesDeclaration: {
  87404. name: string;
  87405. shader: string;
  87406. };
  87407. }
  87408. declare module BABYLON {
  87409. /** @hidden */
  87410. export var helperFunctions: {
  87411. name: string;
  87412. shader: string;
  87413. };
  87414. }
  87415. declare module BABYLON {
  87416. /** @hidden */
  87417. export var shadowMapVertexDeclaration: {
  87418. name: string;
  87419. shader: string;
  87420. };
  87421. }
  87422. declare module BABYLON {
  87423. /** @hidden */
  87424. export var clipPlaneVertexDeclaration: {
  87425. name: string;
  87426. shader: string;
  87427. };
  87428. }
  87429. declare module BABYLON {
  87430. /** @hidden */
  87431. export var morphTargetsVertex: {
  87432. name: string;
  87433. shader: string;
  87434. };
  87435. }
  87436. declare module BABYLON {
  87437. /** @hidden */
  87438. export var instancesVertex: {
  87439. name: string;
  87440. shader: string;
  87441. };
  87442. }
  87443. declare module BABYLON {
  87444. /** @hidden */
  87445. export var bonesVertex: {
  87446. name: string;
  87447. shader: string;
  87448. };
  87449. }
  87450. declare module BABYLON {
  87451. /** @hidden */
  87452. export var shadowMapVertexNormalBias: {
  87453. name: string;
  87454. shader: string;
  87455. };
  87456. }
  87457. declare module BABYLON {
  87458. /** @hidden */
  87459. export var shadowMapVertexMetric: {
  87460. name: string;
  87461. shader: string;
  87462. };
  87463. }
  87464. declare module BABYLON {
  87465. /** @hidden */
  87466. export var clipPlaneVertex: {
  87467. name: string;
  87468. shader: string;
  87469. };
  87470. }
  87471. declare module BABYLON {
  87472. /** @hidden */
  87473. export var shadowMapVertexShader: {
  87474. name: string;
  87475. shader: string;
  87476. };
  87477. }
  87478. declare module BABYLON {
  87479. /** @hidden */
  87480. export var depthBoxBlurPixelShader: {
  87481. name: string;
  87482. shader: string;
  87483. };
  87484. }
  87485. declare module BABYLON {
  87486. /** @hidden */
  87487. export var shadowMapFragmentSoftTransparentShadow: {
  87488. name: string;
  87489. shader: string;
  87490. };
  87491. }
  87492. declare module BABYLON {
  87493. /**
  87494. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87495. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87496. */
  87497. export class EffectFallbacks implements IEffectFallbacks {
  87498. private _defines;
  87499. private _currentRank;
  87500. private _maxRank;
  87501. private _mesh;
  87502. /**
  87503. * Removes the fallback from the bound mesh.
  87504. */
  87505. unBindMesh(): void;
  87506. /**
  87507. * Adds a fallback on the specified property.
  87508. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87509. * @param define The name of the define in the shader
  87510. */
  87511. addFallback(rank: number, define: string): void;
  87512. /**
  87513. * Sets the mesh to use CPU skinning when needing to fallback.
  87514. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87515. * @param mesh The mesh to use the fallbacks.
  87516. */
  87517. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87518. /**
  87519. * Checks to see if more fallbacks are still availible.
  87520. */
  87521. get hasMoreFallbacks(): boolean;
  87522. /**
  87523. * Removes the defines that should be removed when falling back.
  87524. * @param currentDefines defines the current define statements for the shader.
  87525. * @param effect defines the current effect we try to compile
  87526. * @returns The resulting defines with defines of the current rank removed.
  87527. */
  87528. reduce(currentDefines: string, effect: Effect): string;
  87529. }
  87530. }
  87531. declare module BABYLON {
  87532. /**
  87533. * Interface used to define Action
  87534. */
  87535. export interface IAction {
  87536. /**
  87537. * Trigger for the action
  87538. */
  87539. trigger: number;
  87540. /** Options of the trigger */
  87541. triggerOptions: any;
  87542. /**
  87543. * Gets the trigger parameters
  87544. * @returns the trigger parameters
  87545. */
  87546. getTriggerParameter(): any;
  87547. /**
  87548. * Internal only - executes current action event
  87549. * @hidden
  87550. */
  87551. _executeCurrent(evt?: ActionEvent): void;
  87552. /**
  87553. * Serialize placeholder for child classes
  87554. * @param parent of child
  87555. * @returns the serialized object
  87556. */
  87557. serialize(parent: any): any;
  87558. /**
  87559. * Internal only
  87560. * @hidden
  87561. */
  87562. _prepare(): void;
  87563. /**
  87564. * Internal only - manager for action
  87565. * @hidden
  87566. */
  87567. _actionManager: AbstractActionManager;
  87568. /**
  87569. * Adds action to chain of actions, may be a DoNothingAction
  87570. * @param action defines the next action to execute
  87571. * @returns The action passed in
  87572. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87573. */
  87574. then(action: IAction): IAction;
  87575. }
  87576. /**
  87577. * The action to be carried out following a trigger
  87578. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87579. */
  87580. export class Action implements IAction {
  87581. /** the trigger, with or without parameters, for the action */
  87582. triggerOptions: any;
  87583. /**
  87584. * Trigger for the action
  87585. */
  87586. trigger: number;
  87587. /**
  87588. * Internal only - manager for action
  87589. * @hidden
  87590. */
  87591. _actionManager: ActionManager;
  87592. private _nextActiveAction;
  87593. private _child;
  87594. private _condition?;
  87595. private _triggerParameter;
  87596. /**
  87597. * An event triggered prior to action being executed.
  87598. */
  87599. onBeforeExecuteObservable: Observable<Action>;
  87600. /**
  87601. * Creates a new Action
  87602. * @param triggerOptions the trigger, with or without parameters, for the action
  87603. * @param condition an optional determinant of action
  87604. */
  87605. constructor(
  87606. /** the trigger, with or without parameters, for the action */
  87607. triggerOptions: any, condition?: Condition);
  87608. /**
  87609. * Internal only
  87610. * @hidden
  87611. */
  87612. _prepare(): void;
  87613. /**
  87614. * Gets the trigger parameters
  87615. * @returns the trigger parameters
  87616. */
  87617. getTriggerParameter(): any;
  87618. /**
  87619. * Internal only - executes current action event
  87620. * @hidden
  87621. */
  87622. _executeCurrent(evt?: ActionEvent): void;
  87623. /**
  87624. * Execute placeholder for child classes
  87625. * @param evt optional action event
  87626. */
  87627. execute(evt?: ActionEvent): void;
  87628. /**
  87629. * Skips to next active action
  87630. */
  87631. skipToNextActiveAction(): void;
  87632. /**
  87633. * Adds action to chain of actions, may be a DoNothingAction
  87634. * @param action defines the next action to execute
  87635. * @returns The action passed in
  87636. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87637. */
  87638. then(action: Action): Action;
  87639. /**
  87640. * Internal only
  87641. * @hidden
  87642. */
  87643. _getProperty(propertyPath: string): string;
  87644. /**
  87645. * Internal only
  87646. * @hidden
  87647. */
  87648. _getEffectiveTarget(target: any, propertyPath: string): any;
  87649. /**
  87650. * Serialize placeholder for child classes
  87651. * @param parent of child
  87652. * @returns the serialized object
  87653. */
  87654. serialize(parent: any): any;
  87655. /**
  87656. * Internal only called by serialize
  87657. * @hidden
  87658. */
  87659. protected _serialize(serializedAction: any, parent?: any): any;
  87660. /**
  87661. * Internal only
  87662. * @hidden
  87663. */
  87664. static _SerializeValueAsString: (value: any) => string;
  87665. /**
  87666. * Internal only
  87667. * @hidden
  87668. */
  87669. static _GetTargetProperty: (target: Scene | Node) => {
  87670. name: string;
  87671. targetType: string;
  87672. value: string;
  87673. };
  87674. }
  87675. }
  87676. declare module BABYLON {
  87677. /**
  87678. * A Condition applied to an Action
  87679. */
  87680. export class Condition {
  87681. /**
  87682. * Internal only - manager for action
  87683. * @hidden
  87684. */
  87685. _actionManager: ActionManager;
  87686. /**
  87687. * Internal only
  87688. * @hidden
  87689. */
  87690. _evaluationId: number;
  87691. /**
  87692. * Internal only
  87693. * @hidden
  87694. */
  87695. _currentResult: boolean;
  87696. /**
  87697. * Creates a new Condition
  87698. * @param actionManager the manager of the action the condition is applied to
  87699. */
  87700. constructor(actionManager: ActionManager);
  87701. /**
  87702. * Check if the current condition is valid
  87703. * @returns a boolean
  87704. */
  87705. isValid(): boolean;
  87706. /**
  87707. * Internal only
  87708. * @hidden
  87709. */
  87710. _getProperty(propertyPath: string): string;
  87711. /**
  87712. * Internal only
  87713. * @hidden
  87714. */
  87715. _getEffectiveTarget(target: any, propertyPath: string): any;
  87716. /**
  87717. * Serialize placeholder for child classes
  87718. * @returns the serialized object
  87719. */
  87720. serialize(): any;
  87721. /**
  87722. * Internal only
  87723. * @hidden
  87724. */
  87725. protected _serialize(serializedCondition: any): any;
  87726. }
  87727. /**
  87728. * Defines specific conditional operators as extensions of Condition
  87729. */
  87730. export class ValueCondition extends Condition {
  87731. /** path to specify the property of the target the conditional operator uses */
  87732. propertyPath: string;
  87733. /** the value compared by the conditional operator against the current value of the property */
  87734. value: any;
  87735. /** the conditional operator, default ValueCondition.IsEqual */
  87736. operator: number;
  87737. /**
  87738. * Internal only
  87739. * @hidden
  87740. */
  87741. private static _IsEqual;
  87742. /**
  87743. * Internal only
  87744. * @hidden
  87745. */
  87746. private static _IsDifferent;
  87747. /**
  87748. * Internal only
  87749. * @hidden
  87750. */
  87751. private static _IsGreater;
  87752. /**
  87753. * Internal only
  87754. * @hidden
  87755. */
  87756. private static _IsLesser;
  87757. /**
  87758. * returns the number for IsEqual
  87759. */
  87760. static get IsEqual(): number;
  87761. /**
  87762. * Returns the number for IsDifferent
  87763. */
  87764. static get IsDifferent(): number;
  87765. /**
  87766. * Returns the number for IsGreater
  87767. */
  87768. static get IsGreater(): number;
  87769. /**
  87770. * Returns the number for IsLesser
  87771. */
  87772. static get IsLesser(): number;
  87773. /**
  87774. * Internal only The action manager for the condition
  87775. * @hidden
  87776. */
  87777. _actionManager: ActionManager;
  87778. /**
  87779. * Internal only
  87780. * @hidden
  87781. */
  87782. private _target;
  87783. /**
  87784. * Internal only
  87785. * @hidden
  87786. */
  87787. private _effectiveTarget;
  87788. /**
  87789. * Internal only
  87790. * @hidden
  87791. */
  87792. private _property;
  87793. /**
  87794. * Creates a new ValueCondition
  87795. * @param actionManager manager for the action the condition applies to
  87796. * @param target for the action
  87797. * @param propertyPath path to specify the property of the target the conditional operator uses
  87798. * @param value the value compared by the conditional operator against the current value of the property
  87799. * @param operator the conditional operator, default ValueCondition.IsEqual
  87800. */
  87801. constructor(actionManager: ActionManager, target: any,
  87802. /** path to specify the property of the target the conditional operator uses */
  87803. propertyPath: string,
  87804. /** the value compared by the conditional operator against the current value of the property */
  87805. value: any,
  87806. /** the conditional operator, default ValueCondition.IsEqual */
  87807. operator?: number);
  87808. /**
  87809. * Compares the given value with the property value for the specified conditional operator
  87810. * @returns the result of the comparison
  87811. */
  87812. isValid(): boolean;
  87813. /**
  87814. * Serialize the ValueCondition into a JSON compatible object
  87815. * @returns serialization object
  87816. */
  87817. serialize(): any;
  87818. /**
  87819. * Gets the name of the conditional operator for the ValueCondition
  87820. * @param operator the conditional operator
  87821. * @returns the name
  87822. */
  87823. static GetOperatorName(operator: number): string;
  87824. }
  87825. /**
  87826. * Defines a predicate condition as an extension of Condition
  87827. */
  87828. export class PredicateCondition extends Condition {
  87829. /** defines the predicate function used to validate the condition */
  87830. predicate: () => boolean;
  87831. /**
  87832. * Internal only - manager for action
  87833. * @hidden
  87834. */
  87835. _actionManager: ActionManager;
  87836. /**
  87837. * Creates a new PredicateCondition
  87838. * @param actionManager manager for the action the condition applies to
  87839. * @param predicate defines the predicate function used to validate the condition
  87840. */
  87841. constructor(actionManager: ActionManager,
  87842. /** defines the predicate function used to validate the condition */
  87843. predicate: () => boolean);
  87844. /**
  87845. * @returns the validity of the predicate condition
  87846. */
  87847. isValid(): boolean;
  87848. }
  87849. /**
  87850. * Defines a state condition as an extension of Condition
  87851. */
  87852. export class StateCondition extends Condition {
  87853. /** Value to compare with target state */
  87854. value: string;
  87855. /**
  87856. * Internal only - manager for action
  87857. * @hidden
  87858. */
  87859. _actionManager: ActionManager;
  87860. /**
  87861. * Internal only
  87862. * @hidden
  87863. */
  87864. private _target;
  87865. /**
  87866. * Creates a new StateCondition
  87867. * @param actionManager manager for the action the condition applies to
  87868. * @param target of the condition
  87869. * @param value to compare with target state
  87870. */
  87871. constructor(actionManager: ActionManager, target: any,
  87872. /** Value to compare with target state */
  87873. value: string);
  87874. /**
  87875. * Gets a boolean indicating if the current condition is met
  87876. * @returns the validity of the state
  87877. */
  87878. isValid(): boolean;
  87879. /**
  87880. * Serialize the StateCondition into a JSON compatible object
  87881. * @returns serialization object
  87882. */
  87883. serialize(): any;
  87884. }
  87885. }
  87886. declare module BABYLON {
  87887. /**
  87888. * This defines an action responsible to toggle a boolean once triggered.
  87889. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87890. */
  87891. export class SwitchBooleanAction extends Action {
  87892. /**
  87893. * The path to the boolean property in the target object
  87894. */
  87895. propertyPath: string;
  87896. private _target;
  87897. private _effectiveTarget;
  87898. private _property;
  87899. /**
  87900. * Instantiate the action
  87901. * @param triggerOptions defines the trigger options
  87902. * @param target defines the object containing the boolean
  87903. * @param propertyPath defines the path to the boolean property in the target object
  87904. * @param condition defines the trigger related conditions
  87905. */
  87906. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87907. /** @hidden */
  87908. _prepare(): void;
  87909. /**
  87910. * Execute the action toggle the boolean value.
  87911. */
  87912. execute(): void;
  87913. /**
  87914. * Serializes the actions and its related information.
  87915. * @param parent defines the object to serialize in
  87916. * @returns the serialized object
  87917. */
  87918. serialize(parent: any): any;
  87919. }
  87920. /**
  87921. * This defines an action responsible to set a the state field of the target
  87922. * to a desired value once triggered.
  87923. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87924. */
  87925. export class SetStateAction extends Action {
  87926. /**
  87927. * The value to store in the state field.
  87928. */
  87929. value: string;
  87930. private _target;
  87931. /**
  87932. * Instantiate the action
  87933. * @param triggerOptions defines the trigger options
  87934. * @param target defines the object containing the state property
  87935. * @param value defines the value to store in the state field
  87936. * @param condition defines the trigger related conditions
  87937. */
  87938. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87939. /**
  87940. * Execute the action and store the value on the target state property.
  87941. */
  87942. execute(): void;
  87943. /**
  87944. * Serializes the actions and its related information.
  87945. * @param parent defines the object to serialize in
  87946. * @returns the serialized object
  87947. */
  87948. serialize(parent: any): any;
  87949. }
  87950. /**
  87951. * This defines an action responsible to set a property of the target
  87952. * to a desired value once triggered.
  87953. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87954. */
  87955. export class SetValueAction extends Action {
  87956. /**
  87957. * The path of the property to set in the target.
  87958. */
  87959. propertyPath: string;
  87960. /**
  87961. * The value to set in the property
  87962. */
  87963. value: any;
  87964. private _target;
  87965. private _effectiveTarget;
  87966. private _property;
  87967. /**
  87968. * Instantiate the action
  87969. * @param triggerOptions defines the trigger options
  87970. * @param target defines the object containing the property
  87971. * @param propertyPath defines the path of the property to set in the target
  87972. * @param value defines the value to set in the property
  87973. * @param condition defines the trigger related conditions
  87974. */
  87975. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87976. /** @hidden */
  87977. _prepare(): void;
  87978. /**
  87979. * Execute the action and set the targetted property to the desired value.
  87980. */
  87981. execute(): void;
  87982. /**
  87983. * Serializes the actions and its related information.
  87984. * @param parent defines the object to serialize in
  87985. * @returns the serialized object
  87986. */
  87987. serialize(parent: any): any;
  87988. }
  87989. /**
  87990. * This defines an action responsible to increment the target value
  87991. * to a desired value once triggered.
  87992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  87993. */
  87994. export class IncrementValueAction extends Action {
  87995. /**
  87996. * The path of the property to increment in the target.
  87997. */
  87998. propertyPath: string;
  87999. /**
  88000. * The value we should increment the property by.
  88001. */
  88002. value: any;
  88003. private _target;
  88004. private _effectiveTarget;
  88005. private _property;
  88006. /**
  88007. * Instantiate the action
  88008. * @param triggerOptions defines the trigger options
  88009. * @param target defines the object containing the property
  88010. * @param propertyPath defines the path of the property to increment in the target
  88011. * @param value defines the value value we should increment the property by
  88012. * @param condition defines the trigger related conditions
  88013. */
  88014. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88015. /** @hidden */
  88016. _prepare(): void;
  88017. /**
  88018. * Execute the action and increment the target of the value amount.
  88019. */
  88020. execute(): void;
  88021. /**
  88022. * Serializes the actions and its related information.
  88023. * @param parent defines the object to serialize in
  88024. * @returns the serialized object
  88025. */
  88026. serialize(parent: any): any;
  88027. }
  88028. /**
  88029. * This defines an action responsible to start an animation once triggered.
  88030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88031. */
  88032. export class PlayAnimationAction extends Action {
  88033. /**
  88034. * Where the animation should start (animation frame)
  88035. */
  88036. from: number;
  88037. /**
  88038. * Where the animation should stop (animation frame)
  88039. */
  88040. to: number;
  88041. /**
  88042. * Define if the animation should loop or stop after the first play.
  88043. */
  88044. loop?: boolean;
  88045. private _target;
  88046. /**
  88047. * Instantiate the action
  88048. * @param triggerOptions defines the trigger options
  88049. * @param target defines the target animation or animation name
  88050. * @param from defines from where the animation should start (animation frame)
  88051. * @param end defines where the animation should stop (animation frame)
  88052. * @param loop defines if the animation should loop or stop after the first play
  88053. * @param condition defines the trigger related conditions
  88054. */
  88055. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88056. /** @hidden */
  88057. _prepare(): void;
  88058. /**
  88059. * Execute the action and play the animation.
  88060. */
  88061. execute(): void;
  88062. /**
  88063. * Serializes the actions and its related information.
  88064. * @param parent defines the object to serialize in
  88065. * @returns the serialized object
  88066. */
  88067. serialize(parent: any): any;
  88068. }
  88069. /**
  88070. * This defines an action responsible to stop an animation once triggered.
  88071. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88072. */
  88073. export class StopAnimationAction extends Action {
  88074. private _target;
  88075. /**
  88076. * Instantiate the action
  88077. * @param triggerOptions defines the trigger options
  88078. * @param target defines the target animation or animation name
  88079. * @param condition defines the trigger related conditions
  88080. */
  88081. constructor(triggerOptions: any, target: any, condition?: Condition);
  88082. /** @hidden */
  88083. _prepare(): void;
  88084. /**
  88085. * Execute the action and stop the animation.
  88086. */
  88087. execute(): void;
  88088. /**
  88089. * Serializes the actions and its related information.
  88090. * @param parent defines the object to serialize in
  88091. * @returns the serialized object
  88092. */
  88093. serialize(parent: any): any;
  88094. }
  88095. /**
  88096. * This defines an action responsible that does nothing once triggered.
  88097. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88098. */
  88099. export class DoNothingAction extends Action {
  88100. /**
  88101. * Instantiate the action
  88102. * @param triggerOptions defines the trigger options
  88103. * @param condition defines the trigger related conditions
  88104. */
  88105. constructor(triggerOptions?: any, condition?: Condition);
  88106. /**
  88107. * Execute the action and do nothing.
  88108. */
  88109. execute(): void;
  88110. /**
  88111. * Serializes the actions and its related information.
  88112. * @param parent defines the object to serialize in
  88113. * @returns the serialized object
  88114. */
  88115. serialize(parent: any): any;
  88116. }
  88117. /**
  88118. * This defines an action responsible to trigger several actions once triggered.
  88119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88120. */
  88121. export class CombineAction extends Action {
  88122. /**
  88123. * The list of aggregated animations to run.
  88124. */
  88125. children: Action[];
  88126. /**
  88127. * Instantiate the action
  88128. * @param triggerOptions defines the trigger options
  88129. * @param children defines the list of aggregated animations to run
  88130. * @param condition defines the trigger related conditions
  88131. */
  88132. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88133. /** @hidden */
  88134. _prepare(): void;
  88135. /**
  88136. * Execute the action and executes all the aggregated actions.
  88137. */
  88138. execute(evt: ActionEvent): void;
  88139. /**
  88140. * Serializes the actions and its related information.
  88141. * @param parent defines the object to serialize in
  88142. * @returns the serialized object
  88143. */
  88144. serialize(parent: any): any;
  88145. }
  88146. /**
  88147. * This defines an action responsible to run code (external event) once triggered.
  88148. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88149. */
  88150. export class ExecuteCodeAction extends Action {
  88151. /**
  88152. * The callback function to run.
  88153. */
  88154. func: (evt: ActionEvent) => void;
  88155. /**
  88156. * Instantiate the action
  88157. * @param triggerOptions defines the trigger options
  88158. * @param func defines the callback function to run
  88159. * @param condition defines the trigger related conditions
  88160. */
  88161. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88162. /**
  88163. * Execute the action and run the attached code.
  88164. */
  88165. execute(evt: ActionEvent): void;
  88166. }
  88167. /**
  88168. * This defines an action responsible to set the parent property of the target once triggered.
  88169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88170. */
  88171. export class SetParentAction extends Action {
  88172. private _parent;
  88173. private _target;
  88174. /**
  88175. * Instantiate the action
  88176. * @param triggerOptions defines the trigger options
  88177. * @param target defines the target containing the parent property
  88178. * @param parent defines from where the animation should start (animation frame)
  88179. * @param condition defines the trigger related conditions
  88180. */
  88181. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88182. /** @hidden */
  88183. _prepare(): void;
  88184. /**
  88185. * Execute the action and set the parent property.
  88186. */
  88187. execute(): void;
  88188. /**
  88189. * Serializes the actions and its related information.
  88190. * @param parent defines the object to serialize in
  88191. * @returns the serialized object
  88192. */
  88193. serialize(parent: any): any;
  88194. }
  88195. }
  88196. declare module BABYLON {
  88197. /**
  88198. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88199. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88201. */
  88202. export class ActionManager extends AbstractActionManager {
  88203. /**
  88204. * Nothing
  88205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88206. */
  88207. static readonly NothingTrigger: number;
  88208. /**
  88209. * On pick
  88210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88211. */
  88212. static readonly OnPickTrigger: number;
  88213. /**
  88214. * On left pick
  88215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88216. */
  88217. static readonly OnLeftPickTrigger: number;
  88218. /**
  88219. * On right pick
  88220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88221. */
  88222. static readonly OnRightPickTrigger: number;
  88223. /**
  88224. * On center pick
  88225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88226. */
  88227. static readonly OnCenterPickTrigger: number;
  88228. /**
  88229. * On pick down
  88230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88231. */
  88232. static readonly OnPickDownTrigger: number;
  88233. /**
  88234. * On double pick
  88235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88236. */
  88237. static readonly OnDoublePickTrigger: number;
  88238. /**
  88239. * On pick up
  88240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88241. */
  88242. static readonly OnPickUpTrigger: number;
  88243. /**
  88244. * On pick out.
  88245. * This trigger will only be raised if you also declared a OnPickDown
  88246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88247. */
  88248. static readonly OnPickOutTrigger: number;
  88249. /**
  88250. * On long press
  88251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88252. */
  88253. static readonly OnLongPressTrigger: number;
  88254. /**
  88255. * On pointer over
  88256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88257. */
  88258. static readonly OnPointerOverTrigger: number;
  88259. /**
  88260. * On pointer out
  88261. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88262. */
  88263. static readonly OnPointerOutTrigger: number;
  88264. /**
  88265. * On every frame
  88266. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88267. */
  88268. static readonly OnEveryFrameTrigger: number;
  88269. /**
  88270. * On intersection enter
  88271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88272. */
  88273. static readonly OnIntersectionEnterTrigger: number;
  88274. /**
  88275. * On intersection exit
  88276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88277. */
  88278. static readonly OnIntersectionExitTrigger: number;
  88279. /**
  88280. * On key down
  88281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88282. */
  88283. static readonly OnKeyDownTrigger: number;
  88284. /**
  88285. * On key up
  88286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88287. */
  88288. static readonly OnKeyUpTrigger: number;
  88289. private _scene;
  88290. /**
  88291. * Creates a new action manager
  88292. * @param scene defines the hosting scene
  88293. */
  88294. constructor(scene: Scene);
  88295. /**
  88296. * Releases all associated resources
  88297. */
  88298. dispose(): void;
  88299. /**
  88300. * Gets hosting scene
  88301. * @returns the hosting scene
  88302. */
  88303. getScene(): Scene;
  88304. /**
  88305. * Does this action manager handles actions of any of the given triggers
  88306. * @param triggers defines the triggers to be tested
  88307. * @return a boolean indicating whether one (or more) of the triggers is handled
  88308. */
  88309. hasSpecificTriggers(triggers: number[]): boolean;
  88310. /**
  88311. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88312. * speed.
  88313. * @param triggerA defines the trigger to be tested
  88314. * @param triggerB defines the trigger to be tested
  88315. * @return a boolean indicating whether one (or more) of the triggers is handled
  88316. */
  88317. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88318. /**
  88319. * Does this action manager handles actions of a given trigger
  88320. * @param trigger defines the trigger to be tested
  88321. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88322. * @return whether the trigger is handled
  88323. */
  88324. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88325. /**
  88326. * Does this action manager has pointer triggers
  88327. */
  88328. get hasPointerTriggers(): boolean;
  88329. /**
  88330. * Does this action manager has pick triggers
  88331. */
  88332. get hasPickTriggers(): boolean;
  88333. /**
  88334. * Registers an action to this action manager
  88335. * @param action defines the action to be registered
  88336. * @return the action amended (prepared) after registration
  88337. */
  88338. registerAction(action: IAction): Nullable<IAction>;
  88339. /**
  88340. * Unregisters an action to this action manager
  88341. * @param action defines the action to be unregistered
  88342. * @return a boolean indicating whether the action has been unregistered
  88343. */
  88344. unregisterAction(action: IAction): Boolean;
  88345. /**
  88346. * Process a specific trigger
  88347. * @param trigger defines the trigger to process
  88348. * @param evt defines the event details to be processed
  88349. */
  88350. processTrigger(trigger: number, evt?: IActionEvent): void;
  88351. /** @hidden */
  88352. _getEffectiveTarget(target: any, propertyPath: string): any;
  88353. /** @hidden */
  88354. _getProperty(propertyPath: string): string;
  88355. /**
  88356. * Serialize this manager to a JSON object
  88357. * @param name defines the property name to store this manager
  88358. * @returns a JSON representation of this manager
  88359. */
  88360. serialize(name: string): any;
  88361. /**
  88362. * Creates a new ActionManager from a JSON data
  88363. * @param parsedActions defines the JSON data to read from
  88364. * @param object defines the hosting mesh
  88365. * @param scene defines the hosting scene
  88366. */
  88367. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88368. /**
  88369. * Get a trigger name by index
  88370. * @param trigger defines the trigger index
  88371. * @returns a trigger name
  88372. */
  88373. static GetTriggerName(trigger: number): string;
  88374. }
  88375. }
  88376. declare module BABYLON {
  88377. /**
  88378. * Class used to represent a sprite
  88379. * @see https://doc.babylonjs.com/babylon101/sprites
  88380. */
  88381. export class Sprite implements IAnimatable {
  88382. /** defines the name */
  88383. name: string;
  88384. /** Gets or sets the current world position */
  88385. position: Vector3;
  88386. /** Gets or sets the main color */
  88387. color: Color4;
  88388. /** Gets or sets the width */
  88389. width: number;
  88390. /** Gets or sets the height */
  88391. height: number;
  88392. /** Gets or sets rotation angle */
  88393. angle: number;
  88394. /** Gets or sets the cell index in the sprite sheet */
  88395. cellIndex: number;
  88396. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88397. cellRef: string;
  88398. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88399. invertU: boolean;
  88400. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88401. invertV: boolean;
  88402. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88403. disposeWhenFinishedAnimating: boolean;
  88404. /** Gets the list of attached animations */
  88405. animations: Nullable<Array<Animation>>;
  88406. /** Gets or sets a boolean indicating if the sprite can be picked */
  88407. isPickable: boolean;
  88408. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88409. useAlphaForPicking: boolean;
  88410. /** @hidden */
  88411. _xOffset: number;
  88412. /** @hidden */
  88413. _yOffset: number;
  88414. /** @hidden */
  88415. _xSize: number;
  88416. /** @hidden */
  88417. _ySize: number;
  88418. /**
  88419. * Gets or sets the associated action manager
  88420. */
  88421. actionManager: Nullable<ActionManager>;
  88422. /**
  88423. * An event triggered when the control has been disposed
  88424. */
  88425. onDisposeObservable: Observable<Sprite>;
  88426. private _animationStarted;
  88427. private _loopAnimation;
  88428. private _fromIndex;
  88429. private _toIndex;
  88430. private _delay;
  88431. private _direction;
  88432. private _manager;
  88433. private _time;
  88434. private _onAnimationEnd;
  88435. /**
  88436. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88437. */
  88438. isVisible: boolean;
  88439. /**
  88440. * Gets or sets the sprite size
  88441. */
  88442. get size(): number;
  88443. set size(value: number);
  88444. /**
  88445. * Returns a boolean indicating if the animation is started
  88446. */
  88447. get animationStarted(): boolean;
  88448. /**
  88449. * Gets or sets the unique id of the sprite
  88450. */
  88451. uniqueId: number;
  88452. /**
  88453. * Gets the manager of this sprite
  88454. */
  88455. get manager(): ISpriteManager;
  88456. /**
  88457. * Creates a new Sprite
  88458. * @param name defines the name
  88459. * @param manager defines the manager
  88460. */
  88461. constructor(
  88462. /** defines the name */
  88463. name: string, manager: ISpriteManager);
  88464. /**
  88465. * Returns the string "Sprite"
  88466. * @returns "Sprite"
  88467. */
  88468. getClassName(): string;
  88469. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88470. get fromIndex(): number;
  88471. set fromIndex(value: number);
  88472. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88473. get toIndex(): number;
  88474. set toIndex(value: number);
  88475. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88476. get loopAnimation(): boolean;
  88477. set loopAnimation(value: boolean);
  88478. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88479. get delay(): number;
  88480. set delay(value: number);
  88481. /**
  88482. * Starts an animation
  88483. * @param from defines the initial key
  88484. * @param to defines the end key
  88485. * @param loop defines if the animation must loop
  88486. * @param delay defines the start delay (in ms)
  88487. * @param onAnimationEnd defines a callback to call when animation ends
  88488. */
  88489. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88490. /** Stops current animation (if any) */
  88491. stopAnimation(): void;
  88492. /** @hidden */
  88493. _animate(deltaTime: number): void;
  88494. /** Release associated resources */
  88495. dispose(): void;
  88496. /**
  88497. * Serializes the sprite to a JSON object
  88498. * @returns the JSON object
  88499. */
  88500. serialize(): any;
  88501. /**
  88502. * Parses a JSON object to create a new sprite
  88503. * @param parsedSprite The JSON object to parse
  88504. * @param manager defines the hosting manager
  88505. * @returns the new sprite
  88506. */
  88507. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88508. }
  88509. }
  88510. declare module BABYLON {
  88511. /**
  88512. * Information about the result of picking within a scene
  88513. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88514. */
  88515. export class PickingInfo {
  88516. /** @hidden */
  88517. _pickingUnavailable: boolean;
  88518. /**
  88519. * If the pick collided with an object
  88520. */
  88521. hit: boolean;
  88522. /**
  88523. * Distance away where the pick collided
  88524. */
  88525. distance: number;
  88526. /**
  88527. * The location of pick collision
  88528. */
  88529. pickedPoint: Nullable<Vector3>;
  88530. /**
  88531. * The mesh corresponding the the pick collision
  88532. */
  88533. pickedMesh: Nullable<AbstractMesh>;
  88534. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88535. bu: number;
  88536. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88537. bv: number;
  88538. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88539. faceId: number;
  88540. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88541. subMeshFaceId: number;
  88542. /** Id of the the submesh that was picked */
  88543. subMeshId: number;
  88544. /** If a sprite was picked, this will be the sprite the pick collided with */
  88545. pickedSprite: Nullable<Sprite>;
  88546. /**
  88547. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88548. */
  88549. originMesh: Nullable<AbstractMesh>;
  88550. /**
  88551. * The ray that was used to perform the picking.
  88552. */
  88553. ray: Nullable<Ray>;
  88554. /**
  88555. * Gets the normal correspodning to the face the pick collided with
  88556. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88557. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88558. * @returns The normal correspodning to the face the pick collided with
  88559. */
  88560. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88561. /**
  88562. * Gets the texture coordinates of where the pick occured
  88563. * @returns the vector containing the coordnates of the texture
  88564. */
  88565. getTextureCoordinates(): Nullable<Vector2>;
  88566. }
  88567. }
  88568. declare module BABYLON {
  88569. /**
  88570. * Class representing a ray with position and direction
  88571. */
  88572. export class Ray {
  88573. /** origin point */
  88574. origin: Vector3;
  88575. /** direction */
  88576. direction: Vector3;
  88577. /** length of the ray */
  88578. length: number;
  88579. private static readonly TmpVector3;
  88580. private _tmpRay;
  88581. /**
  88582. * Creates a new ray
  88583. * @param origin origin point
  88584. * @param direction direction
  88585. * @param length length of the ray
  88586. */
  88587. constructor(
  88588. /** origin point */
  88589. origin: Vector3,
  88590. /** direction */
  88591. direction: Vector3,
  88592. /** length of the ray */
  88593. length?: number);
  88594. /**
  88595. * Checks if the ray intersects a box
  88596. * This does not account for the ray lenght by design to improve perfs.
  88597. * @param minimum bound of the box
  88598. * @param maximum bound of the box
  88599. * @param intersectionTreshold extra extend to be added to the box in all direction
  88600. * @returns if the box was hit
  88601. */
  88602. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88603. /**
  88604. * Checks if the ray intersects a box
  88605. * This does not account for the ray lenght by design to improve perfs.
  88606. * @param box the bounding box to check
  88607. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88608. * @returns if the box was hit
  88609. */
  88610. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88611. /**
  88612. * If the ray hits a sphere
  88613. * @param sphere the bounding sphere to check
  88614. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88615. * @returns true if it hits the sphere
  88616. */
  88617. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88618. /**
  88619. * If the ray hits a triange
  88620. * @param vertex0 triangle vertex
  88621. * @param vertex1 triangle vertex
  88622. * @param vertex2 triangle vertex
  88623. * @returns intersection information if hit
  88624. */
  88625. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88626. /**
  88627. * Checks if ray intersects a plane
  88628. * @param plane the plane to check
  88629. * @returns the distance away it was hit
  88630. */
  88631. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88632. /**
  88633. * Calculate the intercept of a ray on a given axis
  88634. * @param axis to check 'x' | 'y' | 'z'
  88635. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88636. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88637. */
  88638. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88639. /**
  88640. * Checks if ray intersects a mesh
  88641. * @param mesh the mesh to check
  88642. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88643. * @returns picking info of the intersecton
  88644. */
  88645. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88646. /**
  88647. * Checks if ray intersects a mesh
  88648. * @param meshes the meshes to check
  88649. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88650. * @param results array to store result in
  88651. * @returns Array of picking infos
  88652. */
  88653. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88654. private _comparePickingInfo;
  88655. private static smallnum;
  88656. private static rayl;
  88657. /**
  88658. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88659. * @param sega the first point of the segment to test the intersection against
  88660. * @param segb the second point of the segment to test the intersection against
  88661. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88662. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88663. */
  88664. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88665. /**
  88666. * Update the ray from viewport position
  88667. * @param x position
  88668. * @param y y position
  88669. * @param viewportWidth viewport width
  88670. * @param viewportHeight viewport height
  88671. * @param world world matrix
  88672. * @param view view matrix
  88673. * @param projection projection matrix
  88674. * @returns this ray updated
  88675. */
  88676. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88677. /**
  88678. * Creates a ray with origin and direction of 0,0,0
  88679. * @returns the new ray
  88680. */
  88681. static Zero(): Ray;
  88682. /**
  88683. * Creates a new ray from screen space and viewport
  88684. * @param x position
  88685. * @param y y position
  88686. * @param viewportWidth viewport width
  88687. * @param viewportHeight viewport height
  88688. * @param world world matrix
  88689. * @param view view matrix
  88690. * @param projection projection matrix
  88691. * @returns new ray
  88692. */
  88693. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88694. /**
  88695. * 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
  88696. * transformed to the given world matrix.
  88697. * @param origin The origin point
  88698. * @param end The end point
  88699. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88700. * @returns the new ray
  88701. */
  88702. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88703. /**
  88704. * Transforms a ray by a matrix
  88705. * @param ray ray to transform
  88706. * @param matrix matrix to apply
  88707. * @returns the resulting new ray
  88708. */
  88709. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88710. /**
  88711. * Transforms a ray by a matrix
  88712. * @param ray ray to transform
  88713. * @param matrix matrix to apply
  88714. * @param result ray to store result in
  88715. */
  88716. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88717. /**
  88718. * Unproject a ray from screen space to object space
  88719. * @param sourceX defines the screen space x coordinate to use
  88720. * @param sourceY defines the screen space y coordinate to use
  88721. * @param viewportWidth defines the current width of the viewport
  88722. * @param viewportHeight defines the current height of the viewport
  88723. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88724. * @param view defines the view matrix to use
  88725. * @param projection defines the projection matrix to use
  88726. */
  88727. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88728. }
  88729. /**
  88730. * Type used to define predicate used to select faces when a mesh intersection is detected
  88731. */
  88732. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88733. interface Scene {
  88734. /** @hidden */
  88735. _tempPickingRay: Nullable<Ray>;
  88736. /** @hidden */
  88737. _cachedRayForTransform: Ray;
  88738. /** @hidden */
  88739. _pickWithRayInverseMatrix: Matrix;
  88740. /** @hidden */
  88741. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88742. /** @hidden */
  88743. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88744. }
  88745. }
  88746. declare module BABYLON {
  88747. /**
  88748. * Groups all the scene component constants in one place to ease maintenance.
  88749. * @hidden
  88750. */
  88751. export class SceneComponentConstants {
  88752. static readonly NAME_EFFECTLAYER: string;
  88753. static readonly NAME_LAYER: string;
  88754. static readonly NAME_LENSFLARESYSTEM: string;
  88755. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88756. static readonly NAME_PARTICLESYSTEM: string;
  88757. static readonly NAME_GAMEPAD: string;
  88758. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88759. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88760. static readonly NAME_PREPASSRENDERER: string;
  88761. static readonly NAME_DEPTHRENDERER: string;
  88762. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88763. static readonly NAME_SPRITE: string;
  88764. static readonly NAME_OUTLINERENDERER: string;
  88765. static readonly NAME_PROCEDURALTEXTURE: string;
  88766. static readonly NAME_SHADOWGENERATOR: string;
  88767. static readonly NAME_OCTREE: string;
  88768. static readonly NAME_PHYSICSENGINE: string;
  88769. static readonly NAME_AUDIO: string;
  88770. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88771. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88772. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88773. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88774. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88775. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88776. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88777. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88778. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88779. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88780. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88781. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88782. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88783. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88784. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88785. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88786. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88787. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88788. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88789. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88790. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88791. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88792. static readonly STEP_AFTERRENDER_AUDIO: number;
  88793. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88794. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88795. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88796. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88797. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88798. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88799. static readonly STEP_POINTERMOVE_SPRITE: number;
  88800. static readonly STEP_POINTERDOWN_SPRITE: number;
  88801. static readonly STEP_POINTERUP_SPRITE: number;
  88802. }
  88803. /**
  88804. * This represents a scene component.
  88805. *
  88806. * This is used to decouple the dependency the scene is having on the different workloads like
  88807. * layers, post processes...
  88808. */
  88809. export interface ISceneComponent {
  88810. /**
  88811. * The name of the component. Each component must have a unique name.
  88812. */
  88813. name: string;
  88814. /**
  88815. * The scene the component belongs to.
  88816. */
  88817. scene: Scene;
  88818. /**
  88819. * Register the component to one instance of a scene.
  88820. */
  88821. register(): void;
  88822. /**
  88823. * Rebuilds the elements related to this component in case of
  88824. * context lost for instance.
  88825. */
  88826. rebuild(): void;
  88827. /**
  88828. * Disposes the component and the associated ressources.
  88829. */
  88830. dispose(): void;
  88831. }
  88832. /**
  88833. * This represents a SERIALIZABLE scene component.
  88834. *
  88835. * This extends Scene Component to add Serialization methods on top.
  88836. */
  88837. export interface ISceneSerializableComponent extends ISceneComponent {
  88838. /**
  88839. * Adds all the elements from the container to the scene
  88840. * @param container the container holding the elements
  88841. */
  88842. addFromContainer(container: AbstractScene): void;
  88843. /**
  88844. * Removes all the elements in the container from the scene
  88845. * @param container contains the elements to remove
  88846. * @param dispose if the removed element should be disposed (default: false)
  88847. */
  88848. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88849. /**
  88850. * Serializes the component data to the specified json object
  88851. * @param serializationObject The object to serialize to
  88852. */
  88853. serialize(serializationObject: any): void;
  88854. }
  88855. /**
  88856. * Strong typing of a Mesh related stage step action
  88857. */
  88858. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88859. /**
  88860. * Strong typing of a Evaluate Sub Mesh related stage step action
  88861. */
  88862. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88863. /**
  88864. * Strong typing of a Active Mesh related stage step action
  88865. */
  88866. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88867. /**
  88868. * Strong typing of a Camera related stage step action
  88869. */
  88870. export type CameraStageAction = (camera: Camera) => void;
  88871. /**
  88872. * Strong typing of a Camera Frame buffer related stage step action
  88873. */
  88874. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88875. /**
  88876. * Strong typing of a Render Target related stage step action
  88877. */
  88878. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88879. /**
  88880. * Strong typing of a RenderingGroup related stage step action
  88881. */
  88882. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88883. /**
  88884. * Strong typing of a Mesh Render related stage step action
  88885. */
  88886. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88887. /**
  88888. * Strong typing of a simple stage step action
  88889. */
  88890. export type SimpleStageAction = () => void;
  88891. /**
  88892. * Strong typing of a render target action.
  88893. */
  88894. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88895. /**
  88896. * Strong typing of a pointer move action.
  88897. */
  88898. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88899. /**
  88900. * Strong typing of a pointer up/down action.
  88901. */
  88902. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88903. /**
  88904. * Representation of a stage in the scene (Basically a list of ordered steps)
  88905. * @hidden
  88906. */
  88907. export class Stage<T extends Function> extends Array<{
  88908. index: number;
  88909. component: ISceneComponent;
  88910. action: T;
  88911. }> {
  88912. /**
  88913. * Hide ctor from the rest of the world.
  88914. * @param items The items to add.
  88915. */
  88916. private constructor();
  88917. /**
  88918. * Creates a new Stage.
  88919. * @returns A new instance of a Stage
  88920. */
  88921. static Create<T extends Function>(): Stage<T>;
  88922. /**
  88923. * Registers a step in an ordered way in the targeted stage.
  88924. * @param index Defines the position to register the step in
  88925. * @param component Defines the component attached to the step
  88926. * @param action Defines the action to launch during the step
  88927. */
  88928. registerStep(index: number, component: ISceneComponent, action: T): void;
  88929. /**
  88930. * Clears all the steps from the stage.
  88931. */
  88932. clear(): void;
  88933. }
  88934. }
  88935. declare module BABYLON {
  88936. interface Scene {
  88937. /** @hidden */
  88938. _pointerOverSprite: Nullable<Sprite>;
  88939. /** @hidden */
  88940. _pickedDownSprite: Nullable<Sprite>;
  88941. /** @hidden */
  88942. _tempSpritePickingRay: Nullable<Ray>;
  88943. /**
  88944. * All of the sprite managers added to this scene
  88945. * @see https://doc.babylonjs.com/babylon101/sprites
  88946. */
  88947. spriteManagers: Array<ISpriteManager>;
  88948. /**
  88949. * An event triggered when sprites rendering is about to start
  88950. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88951. */
  88952. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88953. /**
  88954. * An event triggered when sprites rendering is done
  88955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88956. */
  88957. onAfterSpritesRenderingObservable: Observable<Scene>;
  88958. /** @hidden */
  88959. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88960. /** Launch a ray to try to pick a sprite in the scene
  88961. * @param x position on screen
  88962. * @param y position on screen
  88963. * @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
  88964. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88965. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88966. * @returns a PickingInfo
  88967. */
  88968. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88969. /** Use the given ray to pick a sprite in the scene
  88970. * @param ray The ray (in world space) to use to pick meshes
  88971. * @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
  88972. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88973. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88974. * @returns a PickingInfo
  88975. */
  88976. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88977. /** @hidden */
  88978. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88979. /** Launch a ray to try to pick sprites in the scene
  88980. * @param x position on screen
  88981. * @param y position on screen
  88982. * @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
  88983. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88984. * @returns a PickingInfo array
  88985. */
  88986. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88987. /** Use the given ray to pick sprites in the scene
  88988. * @param ray The ray (in world space) to use to pick meshes
  88989. * @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
  88990. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88991. * @returns a PickingInfo array
  88992. */
  88993. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88994. /**
  88995. * Force the sprite under the pointer
  88996. * @param sprite defines the sprite to use
  88997. */
  88998. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88999. /**
  89000. * Gets the sprite under the pointer
  89001. * @returns a Sprite or null if no sprite is under the pointer
  89002. */
  89003. getPointerOverSprite(): Nullable<Sprite>;
  89004. }
  89005. /**
  89006. * Defines the sprite scene component responsible to manage sprites
  89007. * in a given scene.
  89008. */
  89009. export class SpriteSceneComponent implements ISceneComponent {
  89010. /**
  89011. * The component name helpfull to identify the component in the list of scene components.
  89012. */
  89013. readonly name: string;
  89014. /**
  89015. * The scene the component belongs to.
  89016. */
  89017. scene: Scene;
  89018. /** @hidden */
  89019. private _spritePredicate;
  89020. /**
  89021. * Creates a new instance of the component for the given scene
  89022. * @param scene Defines the scene to register the component in
  89023. */
  89024. constructor(scene: Scene);
  89025. /**
  89026. * Registers the component in a given scene
  89027. */
  89028. register(): void;
  89029. /**
  89030. * Rebuilds the elements related to this component in case of
  89031. * context lost for instance.
  89032. */
  89033. rebuild(): void;
  89034. /**
  89035. * Disposes the component and the associated ressources.
  89036. */
  89037. dispose(): void;
  89038. private _pickSpriteButKeepRay;
  89039. private _pointerMove;
  89040. private _pointerDown;
  89041. private _pointerUp;
  89042. }
  89043. }
  89044. declare module BABYLON {
  89045. /** @hidden */
  89046. export var fogFragmentDeclaration: {
  89047. name: string;
  89048. shader: string;
  89049. };
  89050. }
  89051. declare module BABYLON {
  89052. /** @hidden */
  89053. export var fogFragment: {
  89054. name: string;
  89055. shader: string;
  89056. };
  89057. }
  89058. declare module BABYLON {
  89059. /** @hidden */
  89060. export var spritesPixelShader: {
  89061. name: string;
  89062. shader: string;
  89063. };
  89064. }
  89065. declare module BABYLON {
  89066. /** @hidden */
  89067. export var fogVertexDeclaration: {
  89068. name: string;
  89069. shader: string;
  89070. };
  89071. }
  89072. declare module BABYLON {
  89073. /** @hidden */
  89074. export var spritesVertexShader: {
  89075. name: string;
  89076. shader: string;
  89077. };
  89078. }
  89079. declare module BABYLON {
  89080. /**
  89081. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89082. */
  89083. export interface ISpriteManager extends IDisposable {
  89084. /**
  89085. * Gets manager's name
  89086. */
  89087. name: string;
  89088. /**
  89089. * Restricts the camera to viewing objects with the same layerMask.
  89090. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89091. */
  89092. layerMask: number;
  89093. /**
  89094. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89095. */
  89096. isPickable: boolean;
  89097. /**
  89098. * Gets the hosting scene
  89099. */
  89100. scene: Scene;
  89101. /**
  89102. * Specifies the rendering group id for this mesh (0 by default)
  89103. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89104. */
  89105. renderingGroupId: number;
  89106. /**
  89107. * Defines the list of sprites managed by the manager.
  89108. */
  89109. sprites: Array<Sprite>;
  89110. /**
  89111. * Gets or sets the spritesheet texture
  89112. */
  89113. texture: Texture;
  89114. /** Defines the default width of a cell in the spritesheet */
  89115. cellWidth: number;
  89116. /** Defines the default height of a cell in the spritesheet */
  89117. cellHeight: number;
  89118. /**
  89119. * Tests the intersection of a sprite with a specific ray.
  89120. * @param ray The ray we are sending to test the collision
  89121. * @param camera The camera space we are sending rays in
  89122. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89123. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89124. * @returns picking info or null.
  89125. */
  89126. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89127. /**
  89128. * Intersects the sprites with a ray
  89129. * @param ray defines the ray to intersect with
  89130. * @param camera defines the current active camera
  89131. * @param predicate defines a predicate used to select candidate sprites
  89132. * @returns null if no hit or a PickingInfo array
  89133. */
  89134. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89135. /**
  89136. * Renders the list of sprites on screen.
  89137. */
  89138. render(): void;
  89139. }
  89140. /**
  89141. * Class used to manage multiple sprites on the same spritesheet
  89142. * @see https://doc.babylonjs.com/babylon101/sprites
  89143. */
  89144. export class SpriteManager implements ISpriteManager {
  89145. /** defines the manager's name */
  89146. name: string;
  89147. /** Define the Url to load snippets */
  89148. static SnippetUrl: string;
  89149. /** Snippet ID if the manager was created from the snippet server */
  89150. snippetId: string;
  89151. /** Gets the list of sprites */
  89152. sprites: Sprite[];
  89153. /** Gets or sets the rendering group id (0 by default) */
  89154. renderingGroupId: number;
  89155. /** Gets or sets camera layer mask */
  89156. layerMask: number;
  89157. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89158. fogEnabled: boolean;
  89159. /** Gets or sets a boolean indicating if the sprites are pickable */
  89160. isPickable: boolean;
  89161. /** Defines the default width of a cell in the spritesheet */
  89162. cellWidth: number;
  89163. /** Defines the default height of a cell in the spritesheet */
  89164. cellHeight: number;
  89165. /** Associative array from JSON sprite data file */
  89166. private _cellData;
  89167. /** Array of sprite names from JSON sprite data file */
  89168. private _spriteMap;
  89169. /** True when packed cell data from JSON file is ready*/
  89170. private _packedAndReady;
  89171. private _textureContent;
  89172. /**
  89173. * An event triggered when the manager is disposed.
  89174. */
  89175. onDisposeObservable: Observable<SpriteManager>;
  89176. private _onDisposeObserver;
  89177. /**
  89178. * Callback called when the manager is disposed
  89179. */
  89180. set onDispose(callback: () => void);
  89181. private _capacity;
  89182. private _fromPacked;
  89183. private _spriteTexture;
  89184. private _epsilon;
  89185. private _scene;
  89186. private _vertexData;
  89187. private _buffer;
  89188. private _vertexBuffers;
  89189. private _indexBuffer;
  89190. private _effectBase;
  89191. private _effectFog;
  89192. /**
  89193. * Gets or sets the unique id of the sprite
  89194. */
  89195. uniqueId: number;
  89196. /**
  89197. * Gets the array of sprites
  89198. */
  89199. get children(): Sprite[];
  89200. /**
  89201. * Gets the hosting scene
  89202. */
  89203. get scene(): Scene;
  89204. /**
  89205. * Gets the capacity of the manager
  89206. */
  89207. get capacity(): number;
  89208. /**
  89209. * Gets or sets the spritesheet texture
  89210. */
  89211. get texture(): Texture;
  89212. set texture(value: Texture);
  89213. private _blendMode;
  89214. /**
  89215. * Blend mode use to render the particle, it can be any of
  89216. * the static Constants.ALPHA_x properties provided in this class.
  89217. * Default value is Constants.ALPHA_COMBINE
  89218. */
  89219. get blendMode(): number;
  89220. set blendMode(blendMode: number);
  89221. /** Disables writing to the depth buffer when rendering the sprites.
  89222. * It can be handy to disable depth writing when using textures without alpha channel
  89223. * and setting some specific blend modes.
  89224. */
  89225. disableDepthWrite: boolean;
  89226. /**
  89227. * Creates a new sprite manager
  89228. * @param name defines the manager's name
  89229. * @param imgUrl defines the sprite sheet url
  89230. * @param capacity defines the maximum allowed number of sprites
  89231. * @param cellSize defines the size of a sprite cell
  89232. * @param scene defines the hosting scene
  89233. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89234. * @param samplingMode defines the smapling mode to use with spritesheet
  89235. * @param fromPacked set to false; do not alter
  89236. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89237. */
  89238. constructor(
  89239. /** defines the manager's name */
  89240. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89241. /**
  89242. * Returns the string "SpriteManager"
  89243. * @returns "SpriteManager"
  89244. */
  89245. getClassName(): string;
  89246. private _makePacked;
  89247. private _appendSpriteVertex;
  89248. private _checkTextureAlpha;
  89249. /**
  89250. * Intersects the sprites with a ray
  89251. * @param ray defines the ray to intersect with
  89252. * @param camera defines the current active camera
  89253. * @param predicate defines a predicate used to select candidate sprites
  89254. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89255. * @returns null if no hit or a PickingInfo
  89256. */
  89257. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89258. /**
  89259. * Intersects the sprites with a ray
  89260. * @param ray defines the ray to intersect with
  89261. * @param camera defines the current active camera
  89262. * @param predicate defines a predicate used to select candidate sprites
  89263. * @returns null if no hit or a PickingInfo array
  89264. */
  89265. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89266. /**
  89267. * Render all child sprites
  89268. */
  89269. render(): void;
  89270. /**
  89271. * Release associated resources
  89272. */
  89273. dispose(): void;
  89274. /**
  89275. * Serializes the sprite manager to a JSON object
  89276. * @param serializeTexture defines if the texture must be serialized as well
  89277. * @returns the JSON object
  89278. */
  89279. serialize(serializeTexture?: boolean): any;
  89280. /**
  89281. * Parses a JSON object to create a new sprite manager.
  89282. * @param parsedManager The JSON object to parse
  89283. * @param scene The scene to create the sprite managerin
  89284. * @param rootUrl The root url to use to load external dependencies like texture
  89285. * @returns the new sprite manager
  89286. */
  89287. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89288. /**
  89289. * Creates a sprite manager from a snippet saved in a remote file
  89290. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89291. * @param url defines the url to load from
  89292. * @param scene defines the hosting scene
  89293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89294. * @returns a promise that will resolve to the new sprite manager
  89295. */
  89296. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89297. /**
  89298. * Creates a sprite manager from a snippet saved by the sprite editor
  89299. * @param snippetId defines the snippet to load
  89300. * @param scene defines the hosting scene
  89301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89302. * @returns a promise that will resolve to the new sprite manager
  89303. */
  89304. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89305. }
  89306. }
  89307. declare module BABYLON {
  89308. /** Interface used by value gradients (color, factor, ...) */
  89309. export interface IValueGradient {
  89310. /**
  89311. * Gets or sets the gradient value (between 0 and 1)
  89312. */
  89313. gradient: number;
  89314. }
  89315. /** Class used to store color4 gradient */
  89316. export class ColorGradient implements IValueGradient {
  89317. /**
  89318. * Gets or sets the gradient value (between 0 and 1)
  89319. */
  89320. gradient: number;
  89321. /**
  89322. * Gets or sets first associated color
  89323. */
  89324. color1: Color4;
  89325. /**
  89326. * Gets or sets second associated color
  89327. */
  89328. color2?: Color4 | undefined;
  89329. /**
  89330. * Creates a new color4 gradient
  89331. * @param gradient gets or sets the gradient value (between 0 and 1)
  89332. * @param color1 gets or sets first associated color
  89333. * @param color2 gets or sets first second color
  89334. */
  89335. constructor(
  89336. /**
  89337. * Gets or sets the gradient value (between 0 and 1)
  89338. */
  89339. gradient: number,
  89340. /**
  89341. * Gets or sets first associated color
  89342. */
  89343. color1: Color4,
  89344. /**
  89345. * Gets or sets second associated color
  89346. */
  89347. color2?: Color4 | undefined);
  89348. /**
  89349. * Will get a color picked randomly between color1 and color2.
  89350. * If color2 is undefined then color1 will be used
  89351. * @param result defines the target Color4 to store the result in
  89352. */
  89353. getColorToRef(result: Color4): void;
  89354. }
  89355. /** Class used to store color 3 gradient */
  89356. export class Color3Gradient implements IValueGradient {
  89357. /**
  89358. * Gets or sets the gradient value (between 0 and 1)
  89359. */
  89360. gradient: number;
  89361. /**
  89362. * Gets or sets the associated color
  89363. */
  89364. color: Color3;
  89365. /**
  89366. * Creates a new color3 gradient
  89367. * @param gradient gets or sets the gradient value (between 0 and 1)
  89368. * @param color gets or sets associated color
  89369. */
  89370. constructor(
  89371. /**
  89372. * Gets or sets the gradient value (between 0 and 1)
  89373. */
  89374. gradient: number,
  89375. /**
  89376. * Gets or sets the associated color
  89377. */
  89378. color: Color3);
  89379. }
  89380. /** Class used to store factor gradient */
  89381. export class FactorGradient implements IValueGradient {
  89382. /**
  89383. * Gets or sets the gradient value (between 0 and 1)
  89384. */
  89385. gradient: number;
  89386. /**
  89387. * Gets or sets first associated factor
  89388. */
  89389. factor1: number;
  89390. /**
  89391. * Gets or sets second associated factor
  89392. */
  89393. factor2?: number | undefined;
  89394. /**
  89395. * Creates a new factor gradient
  89396. * @param gradient gets or sets the gradient value (between 0 and 1)
  89397. * @param factor1 gets or sets first associated factor
  89398. * @param factor2 gets or sets second associated factor
  89399. */
  89400. constructor(
  89401. /**
  89402. * Gets or sets the gradient value (between 0 and 1)
  89403. */
  89404. gradient: number,
  89405. /**
  89406. * Gets or sets first associated factor
  89407. */
  89408. factor1: number,
  89409. /**
  89410. * Gets or sets second associated factor
  89411. */
  89412. factor2?: number | undefined);
  89413. /**
  89414. * Will get a number picked randomly between factor1 and factor2.
  89415. * If factor2 is undefined then factor1 will be used
  89416. * @returns the picked number
  89417. */
  89418. getFactor(): number;
  89419. }
  89420. /**
  89421. * Helper used to simplify some generic gradient tasks
  89422. */
  89423. export class GradientHelper {
  89424. /**
  89425. * Gets the current gradient from an array of IValueGradient
  89426. * @param ratio defines the current ratio to get
  89427. * @param gradients defines the array of IValueGradient
  89428. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89429. */
  89430. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89431. }
  89432. }
  89433. declare module BABYLON {
  89434. interface ThinEngine {
  89435. /**
  89436. * Creates a raw texture
  89437. * @param data defines the data to store in the texture
  89438. * @param width defines the width of the texture
  89439. * @param height defines the height of the texture
  89440. * @param format defines the format of the data
  89441. * @param generateMipMaps defines if the engine should generate the mip levels
  89442. * @param invertY defines if data must be stored with Y axis inverted
  89443. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89444. * @param compression defines the compression used (null by default)
  89445. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89446. * @returns the raw texture inside an InternalTexture
  89447. */
  89448. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89449. /**
  89450. * Update a raw texture
  89451. * @param texture defines the texture to update
  89452. * @param data defines the data to store in the texture
  89453. * @param format defines the format of the data
  89454. * @param invertY defines if data must be stored with Y axis inverted
  89455. */
  89456. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89457. /**
  89458. * Update a raw texture
  89459. * @param texture defines the texture to update
  89460. * @param data defines the data to store in the texture
  89461. * @param format defines the format of the data
  89462. * @param invertY defines if data must be stored with Y axis inverted
  89463. * @param compression defines the compression used (null by default)
  89464. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89465. */
  89466. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89467. /**
  89468. * Creates a new raw cube texture
  89469. * @param data defines the array of data to use to create each face
  89470. * @param size defines the size of the textures
  89471. * @param format defines the format of the data
  89472. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89473. * @param generateMipMaps defines if the engine should generate the mip levels
  89474. * @param invertY defines if data must be stored with Y axis inverted
  89475. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89476. * @param compression defines the compression used (null by default)
  89477. * @returns the cube texture as an InternalTexture
  89478. */
  89479. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89480. /**
  89481. * Update a raw cube texture
  89482. * @param texture defines the texture to udpdate
  89483. * @param data defines the data to store
  89484. * @param format defines the data format
  89485. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89486. * @param invertY defines if data must be stored with Y axis inverted
  89487. */
  89488. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): 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. */
  89498. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89499. /**
  89500. * Update a raw cube texture
  89501. * @param texture defines the texture to udpdate
  89502. * @param data defines the data to store
  89503. * @param format defines the data format
  89504. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89505. * @param invertY defines if data must be stored with Y axis inverted
  89506. * @param compression defines the compression used (null by default)
  89507. * @param level defines which level of the texture to update
  89508. */
  89509. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89510. /**
  89511. * Creates a new raw cube texture from a specified url
  89512. * @param url defines the url where the data is located
  89513. * @param scene defines the current scene
  89514. * @param size defines the size of the textures
  89515. * @param format defines the format of the data
  89516. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89517. * @param noMipmap defines if the engine should avoid generating the mip levels
  89518. * @param callback defines a callback used to extract texture data from loaded data
  89519. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89520. * @param onLoad defines a callback called when texture is loaded
  89521. * @param onError defines a callback called if there is an error
  89522. * @returns the cube texture as an InternalTexture
  89523. */
  89524. 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;
  89525. /**
  89526. * Creates a new raw cube texture from a specified url
  89527. * @param url defines the url where the data is located
  89528. * @param scene defines the current scene
  89529. * @param size defines the size of the textures
  89530. * @param format defines the format of the data
  89531. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89532. * @param noMipmap defines if the engine should avoid generating the mip levels
  89533. * @param callback defines a callback used to extract texture data from loaded data
  89534. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89535. * @param onLoad defines a callback called when texture is loaded
  89536. * @param onError defines a callback called if there is an error
  89537. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89538. * @param invertY defines if data must be stored with Y axis inverted
  89539. * @returns the cube texture as an InternalTexture
  89540. */
  89541. 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;
  89542. /**
  89543. * Creates a new raw 3D texture
  89544. * @param data defines the data used to create the texture
  89545. * @param width defines the width of the texture
  89546. * @param height defines the height of the texture
  89547. * @param depth defines the depth of the texture
  89548. * @param format defines the format of the texture
  89549. * @param generateMipMaps defines if the engine must generate mip levels
  89550. * @param invertY defines if data must be stored with Y axis inverted
  89551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89552. * @param compression defines the compressed used (can be null)
  89553. * @param textureType defines the compressed used (can be null)
  89554. * @returns a new raw 3D texture (stored in an InternalTexture)
  89555. */
  89556. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89557. /**
  89558. * Update a raw 3D texture
  89559. * @param texture defines the texture to update
  89560. * @param data defines the data to store
  89561. * @param format defines the data format
  89562. * @param invertY defines if data must be stored with Y axis inverted
  89563. */
  89564. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89565. /**
  89566. * Update a raw 3D texture
  89567. * @param texture defines the texture to update
  89568. * @param data defines the data to store
  89569. * @param format defines the data format
  89570. * @param invertY defines if data must be stored with Y axis inverted
  89571. * @param compression defines the used compression (can be null)
  89572. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89573. */
  89574. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89575. /**
  89576. * Creates a new raw 2D array texture
  89577. * @param data defines the data used to create the texture
  89578. * @param width defines the width of the texture
  89579. * @param height defines the height of the texture
  89580. * @param depth defines the number of layers of the texture
  89581. * @param format defines the format of the texture
  89582. * @param generateMipMaps defines if the engine must generate mip levels
  89583. * @param invertY defines if data must be stored with Y axis inverted
  89584. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89585. * @param compression defines the compressed used (can be null)
  89586. * @param textureType defines the compressed used (can be null)
  89587. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89588. */
  89589. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89590. /**
  89591. * Update a raw 2D array texture
  89592. * @param texture defines the texture to update
  89593. * @param data defines the data to store
  89594. * @param format defines the data format
  89595. * @param invertY defines if data must be stored with Y axis inverted
  89596. */
  89597. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89598. /**
  89599. * Update a raw 2D array texture
  89600. * @param texture defines the texture to update
  89601. * @param data defines the data to store
  89602. * @param format defines the data format
  89603. * @param invertY defines if data must be stored with Y axis inverted
  89604. * @param compression defines the used compression (can be null)
  89605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89606. */
  89607. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89608. }
  89609. }
  89610. declare module BABYLON {
  89611. /**
  89612. * Raw texture can help creating a texture directly from an array of data.
  89613. * This can be super useful if you either get the data from an uncompressed source or
  89614. * if you wish to create your texture pixel by pixel.
  89615. */
  89616. export class RawTexture extends Texture {
  89617. /**
  89618. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89619. */
  89620. format: number;
  89621. /**
  89622. * Instantiates a new RawTexture.
  89623. * Raw texture can help creating a texture directly from an array of data.
  89624. * This can be super useful if you either get the data from an uncompressed source or
  89625. * if you wish to create your texture pixel by pixel.
  89626. * @param data define the array of data to use to create the texture
  89627. * @param width define the width of the texture
  89628. * @param height define the height of the texture
  89629. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89630. * @param scene define the scene the texture belongs to
  89631. * @param generateMipMaps define whether mip maps should be generated or not
  89632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89634. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89635. */
  89636. constructor(data: ArrayBufferView, width: number, height: number,
  89637. /**
  89638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89639. */
  89640. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89641. /**
  89642. * Updates the texture underlying data.
  89643. * @param data Define the new data of the texture
  89644. */
  89645. update(data: ArrayBufferView): void;
  89646. /**
  89647. * Creates a luminance texture from some data.
  89648. * @param data Define the texture data
  89649. * @param width Define the width of the texture
  89650. * @param height Define the height of the texture
  89651. * @param scene Define the scene the texture belongs to
  89652. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89655. * @returns the luminance texture
  89656. */
  89657. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89658. /**
  89659. * Creates a luminance alpha texture from some data.
  89660. * @param data Define the texture data
  89661. * @param width Define the width of the texture
  89662. * @param height Define the height of the texture
  89663. * @param scene Define the scene the texture belongs to
  89664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89667. * @returns the luminance alpha texture
  89668. */
  89669. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89670. /**
  89671. * Creates an alpha texture from some data.
  89672. * @param data Define the texture data
  89673. * @param width Define the width of the texture
  89674. * @param height Define the height of the texture
  89675. * @param scene Define the scene the texture belongs to
  89676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89679. * @returns the alpha texture
  89680. */
  89681. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89682. /**
  89683. * Creates a RGB texture from some data.
  89684. * @param data Define the texture data
  89685. * @param width Define the width of the texture
  89686. * @param height Define the height of the texture
  89687. * @param scene Define the scene the texture belongs to
  89688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89692. * @returns the RGB alpha texture
  89693. */
  89694. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89695. /**
  89696. * Creates a RGBA texture from some data.
  89697. * @param data Define the texture data
  89698. * @param width Define the width of the texture
  89699. * @param height Define the height of the texture
  89700. * @param scene Define the scene the texture belongs to
  89701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89704. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89705. * @returns the RGBA texture
  89706. */
  89707. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89708. /**
  89709. * Creates a R texture from some data.
  89710. * @param data Define the texture data
  89711. * @param width Define the width of the texture
  89712. * @param height Define the height of the texture
  89713. * @param scene Define the scene the texture belongs to
  89714. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89715. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89716. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89717. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89718. * @returns the R texture
  89719. */
  89720. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89721. }
  89722. }
  89723. declare module BABYLON {
  89724. interface AbstractScene {
  89725. /**
  89726. * The list of procedural textures added to the scene
  89727. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89728. */
  89729. proceduralTextures: Array<ProceduralTexture>;
  89730. }
  89731. /**
  89732. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89733. * in a given scene.
  89734. */
  89735. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89736. /**
  89737. * The component name helpfull to identify the component in the list of scene components.
  89738. */
  89739. readonly name: string;
  89740. /**
  89741. * The scene the component belongs to.
  89742. */
  89743. scene: Scene;
  89744. /**
  89745. * Creates a new instance of the component for the given scene
  89746. * @param scene Defines the scene to register the component in
  89747. */
  89748. constructor(scene: Scene);
  89749. /**
  89750. * Registers the component in a given scene
  89751. */
  89752. register(): void;
  89753. /**
  89754. * Rebuilds the elements related to this component in case of
  89755. * context lost for instance.
  89756. */
  89757. rebuild(): void;
  89758. /**
  89759. * Disposes the component and the associated ressources.
  89760. */
  89761. dispose(): void;
  89762. private _beforeClear;
  89763. }
  89764. }
  89765. declare module BABYLON {
  89766. interface ThinEngine {
  89767. /**
  89768. * Creates a new render target cube texture
  89769. * @param size defines the size of the texture
  89770. * @param options defines the options used to create the texture
  89771. * @returns a new render target cube texture stored in an InternalTexture
  89772. */
  89773. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89774. }
  89775. }
  89776. declare module BABYLON {
  89777. /** @hidden */
  89778. export var proceduralVertexShader: {
  89779. name: string;
  89780. shader: string;
  89781. };
  89782. }
  89783. declare module BABYLON {
  89784. /**
  89785. * 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.
  89786. * This is the base class of any Procedural texture and contains most of the shareable code.
  89787. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89788. */
  89789. export class ProceduralTexture extends Texture {
  89790. isCube: boolean;
  89791. /**
  89792. * Define if the texture is enabled or not (disabled texture will not render)
  89793. */
  89794. isEnabled: boolean;
  89795. /**
  89796. * Define if the texture must be cleared before rendering (default is true)
  89797. */
  89798. autoClear: boolean;
  89799. /**
  89800. * Callback called when the texture is generated
  89801. */
  89802. onGenerated: () => void;
  89803. /**
  89804. * Event raised when the texture is generated
  89805. */
  89806. onGeneratedObservable: Observable<ProceduralTexture>;
  89807. /** @hidden */
  89808. _generateMipMaps: boolean;
  89809. /** @hidden **/
  89810. _effect: Effect;
  89811. /** @hidden */
  89812. _textures: {
  89813. [key: string]: Texture;
  89814. };
  89815. /** @hidden */
  89816. protected _fallbackTexture: Nullable<Texture>;
  89817. private _size;
  89818. private _currentRefreshId;
  89819. private _frameId;
  89820. private _refreshRate;
  89821. private _vertexBuffers;
  89822. private _indexBuffer;
  89823. private _uniforms;
  89824. private _samplers;
  89825. private _fragment;
  89826. private _floats;
  89827. private _ints;
  89828. private _floatsArrays;
  89829. private _colors3;
  89830. private _colors4;
  89831. private _vectors2;
  89832. private _vectors3;
  89833. private _matrices;
  89834. private _fallbackTextureUsed;
  89835. private _fullEngine;
  89836. private _cachedDefines;
  89837. private _contentUpdateId;
  89838. private _contentData;
  89839. /**
  89840. * Instantiates a new procedural texture.
  89841. * 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.
  89842. * This is the base class of any Procedural texture and contains most of the shareable code.
  89843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89844. * @param name Define the name of the texture
  89845. * @param size Define the size of the texture to create
  89846. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89847. * @param scene Define the scene the texture belongs to
  89848. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89849. * @param generateMipMaps Define if the texture should creates mip maps or not
  89850. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89851. */
  89852. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89853. /**
  89854. * The effect that is created when initializing the post process.
  89855. * @returns The created effect corresponding the the postprocess.
  89856. */
  89857. getEffect(): Effect;
  89858. /**
  89859. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89860. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89861. */
  89862. getContent(): Nullable<ArrayBufferView>;
  89863. private _createIndexBuffer;
  89864. /** @hidden */
  89865. _rebuild(): void;
  89866. /**
  89867. * Resets the texture in order to recreate its associated resources.
  89868. * This can be called in case of context loss
  89869. */
  89870. reset(): void;
  89871. protected _getDefines(): string;
  89872. /**
  89873. * Is the texture ready to be used ? (rendered at least once)
  89874. * @returns true if ready, otherwise, false.
  89875. */
  89876. isReady(): boolean;
  89877. /**
  89878. * Resets the refresh counter of the texture and start bak from scratch.
  89879. * Could be useful to regenerate the texture if it is setup to render only once.
  89880. */
  89881. resetRefreshCounter(): void;
  89882. /**
  89883. * Set the fragment shader to use in order to render the texture.
  89884. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89885. */
  89886. setFragment(fragment: any): void;
  89887. /**
  89888. * Define the refresh rate of the texture or the rendering frequency.
  89889. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89890. */
  89891. get refreshRate(): number;
  89892. set refreshRate(value: number);
  89893. /** @hidden */
  89894. _shouldRender(): boolean;
  89895. /**
  89896. * Get the size the texture is rendering at.
  89897. * @returns the size (texture is always squared)
  89898. */
  89899. getRenderSize(): number;
  89900. /**
  89901. * Resize the texture to new value.
  89902. * @param size Define the new size the texture should have
  89903. * @param generateMipMaps Define whether the new texture should create mip maps
  89904. */
  89905. resize(size: number, generateMipMaps: boolean): void;
  89906. private _checkUniform;
  89907. /**
  89908. * Set a texture in the shader program used to render.
  89909. * @param name Define the name of the uniform samplers as defined in the shader
  89910. * @param texture Define the texture to bind to this sampler
  89911. * @return the texture itself allowing "fluent" like uniform updates
  89912. */
  89913. setTexture(name: string, texture: Texture): ProceduralTexture;
  89914. /**
  89915. * Set a float in the shader.
  89916. * @param name Define the name of the uniform as defined in the shader
  89917. * @param value Define the value to give to the uniform
  89918. * @return the texture itself allowing "fluent" like uniform updates
  89919. */
  89920. setFloat(name: string, value: number): ProceduralTexture;
  89921. /**
  89922. * Set a int in the shader.
  89923. * @param name Define the name of the uniform as defined in the shader
  89924. * @param value Define the value to give to the uniform
  89925. * @return the texture itself allowing "fluent" like uniform updates
  89926. */
  89927. setInt(name: string, value: number): ProceduralTexture;
  89928. /**
  89929. * Set an array of floats in the shader.
  89930. * @param name Define the name of the uniform as defined in the shader
  89931. * @param value Define the value to give to the uniform
  89932. * @return the texture itself allowing "fluent" like uniform updates
  89933. */
  89934. setFloats(name: string, value: number[]): ProceduralTexture;
  89935. /**
  89936. * Set a vec3 in the shader from a Color3.
  89937. * @param name Define the name of the uniform as defined in the shader
  89938. * @param value Define the value to give to the uniform
  89939. * @return the texture itself allowing "fluent" like uniform updates
  89940. */
  89941. setColor3(name: string, value: Color3): ProceduralTexture;
  89942. /**
  89943. * Set a vec4 in the shader from a Color4.
  89944. * @param name Define the name of the uniform as defined in the shader
  89945. * @param value Define the value to give to the uniform
  89946. * @return the texture itself allowing "fluent" like uniform updates
  89947. */
  89948. setColor4(name: string, value: Color4): ProceduralTexture;
  89949. /**
  89950. * Set a vec2 in the shader from a Vector2.
  89951. * @param name Define the name of the uniform as defined in the shader
  89952. * @param value Define the value to give to the uniform
  89953. * @return the texture itself allowing "fluent" like uniform updates
  89954. */
  89955. setVector2(name: string, value: Vector2): ProceduralTexture;
  89956. /**
  89957. * Set a vec3 in the shader from a Vector3.
  89958. * @param name Define the name of the uniform as defined in the shader
  89959. * @param value Define the value to give to the uniform
  89960. * @return the texture itself allowing "fluent" like uniform updates
  89961. */
  89962. setVector3(name: string, value: Vector3): ProceduralTexture;
  89963. /**
  89964. * Set a mat4 in the shader from a MAtrix.
  89965. * @param name Define the name of the uniform as defined in the shader
  89966. * @param value Define the value to give to the uniform
  89967. * @return the texture itself allowing "fluent" like uniform updates
  89968. */
  89969. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89970. /**
  89971. * Render the texture to its associated render target.
  89972. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89973. */
  89974. render(useCameraPostProcess?: boolean): void;
  89975. /**
  89976. * Clone the texture.
  89977. * @returns the cloned texture
  89978. */
  89979. clone(): ProceduralTexture;
  89980. /**
  89981. * Dispose the texture and release its asoociated resources.
  89982. */
  89983. dispose(): void;
  89984. }
  89985. }
  89986. declare module BABYLON {
  89987. /**
  89988. * This represents the base class for particle system in Babylon.
  89989. * 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.
  89990. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89991. * @example https://doc.babylonjs.com/babylon101/particles
  89992. */
  89993. export class BaseParticleSystem {
  89994. /**
  89995. * Source color is added to the destination color without alpha affecting the result
  89996. */
  89997. static BLENDMODE_ONEONE: number;
  89998. /**
  89999. * Blend current color and particle color using particle’s alpha
  90000. */
  90001. static BLENDMODE_STANDARD: number;
  90002. /**
  90003. * Add current color and particle color multiplied by particle’s alpha
  90004. */
  90005. static BLENDMODE_ADD: number;
  90006. /**
  90007. * Multiply current color with particle color
  90008. */
  90009. static BLENDMODE_MULTIPLY: number;
  90010. /**
  90011. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90012. */
  90013. static BLENDMODE_MULTIPLYADD: number;
  90014. /**
  90015. * List of animations used by the particle system.
  90016. */
  90017. animations: Animation[];
  90018. /**
  90019. * Gets or sets the unique id of the particle system
  90020. */
  90021. uniqueId: number;
  90022. /**
  90023. * The id of the Particle system.
  90024. */
  90025. id: string;
  90026. /**
  90027. * The friendly name of the Particle system.
  90028. */
  90029. name: string;
  90030. /**
  90031. * Snippet ID if the particle system was created from the snippet server
  90032. */
  90033. snippetId: string;
  90034. /**
  90035. * The rendering group used by the Particle system to chose when to render.
  90036. */
  90037. renderingGroupId: number;
  90038. /**
  90039. * The emitter represents the Mesh or position we are attaching the particle system to.
  90040. */
  90041. emitter: Nullable<AbstractMesh | Vector3>;
  90042. /**
  90043. * The maximum number of particles to emit per frame
  90044. */
  90045. emitRate: number;
  90046. /**
  90047. * If you want to launch only a few particles at once, that can be done, as well.
  90048. */
  90049. manualEmitCount: number;
  90050. /**
  90051. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90052. */
  90053. updateSpeed: number;
  90054. /**
  90055. * The amount of time the particle system is running (depends of the overall update speed).
  90056. */
  90057. targetStopDuration: number;
  90058. /**
  90059. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90060. */
  90061. disposeOnStop: boolean;
  90062. /**
  90063. * Minimum power of emitting particles.
  90064. */
  90065. minEmitPower: number;
  90066. /**
  90067. * Maximum power of emitting particles.
  90068. */
  90069. maxEmitPower: number;
  90070. /**
  90071. * Minimum life time of emitting particles.
  90072. */
  90073. minLifeTime: number;
  90074. /**
  90075. * Maximum life time of emitting particles.
  90076. */
  90077. maxLifeTime: number;
  90078. /**
  90079. * Minimum Size of emitting particles.
  90080. */
  90081. minSize: number;
  90082. /**
  90083. * Maximum Size of emitting particles.
  90084. */
  90085. maxSize: number;
  90086. /**
  90087. * Minimum scale of emitting particles on X axis.
  90088. */
  90089. minScaleX: number;
  90090. /**
  90091. * Maximum scale of emitting particles on X axis.
  90092. */
  90093. maxScaleX: number;
  90094. /**
  90095. * Minimum scale of emitting particles on Y axis.
  90096. */
  90097. minScaleY: number;
  90098. /**
  90099. * Maximum scale of emitting particles on Y axis.
  90100. */
  90101. maxScaleY: number;
  90102. /**
  90103. * Gets or sets the minimal initial rotation in radians.
  90104. */
  90105. minInitialRotation: number;
  90106. /**
  90107. * Gets or sets the maximal initial rotation in radians.
  90108. */
  90109. maxInitialRotation: number;
  90110. /**
  90111. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90112. */
  90113. minAngularSpeed: number;
  90114. /**
  90115. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90116. */
  90117. maxAngularSpeed: number;
  90118. /**
  90119. * The texture used to render each particle. (this can be a spritesheet)
  90120. */
  90121. particleTexture: Nullable<Texture>;
  90122. /**
  90123. * The layer mask we are rendering the particles through.
  90124. */
  90125. layerMask: number;
  90126. /**
  90127. * This can help using your own shader to render the particle system.
  90128. * The according effect will be created
  90129. */
  90130. customShader: any;
  90131. /**
  90132. * By default particle system starts as soon as they are created. This prevents the
  90133. * automatic start to happen and let you decide when to start emitting particles.
  90134. */
  90135. preventAutoStart: boolean;
  90136. private _noiseTexture;
  90137. /**
  90138. * Gets or sets a texture used to add random noise to particle positions
  90139. */
  90140. get noiseTexture(): Nullable<ProceduralTexture>;
  90141. set noiseTexture(value: Nullable<ProceduralTexture>);
  90142. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90143. noiseStrength: Vector3;
  90144. /**
  90145. * Callback triggered when the particle animation is ending.
  90146. */
  90147. onAnimationEnd: Nullable<() => void>;
  90148. /**
  90149. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90150. */
  90151. blendMode: number;
  90152. /**
  90153. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90154. * to override the particles.
  90155. */
  90156. forceDepthWrite: boolean;
  90157. /** 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 */
  90158. preWarmCycles: number;
  90159. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90160. preWarmStepOffset: number;
  90161. /**
  90162. * 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)
  90163. */
  90164. spriteCellChangeSpeed: number;
  90165. /**
  90166. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90167. */
  90168. startSpriteCellID: number;
  90169. /**
  90170. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90171. */
  90172. endSpriteCellID: number;
  90173. /**
  90174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90175. */
  90176. spriteCellWidth: number;
  90177. /**
  90178. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90179. */
  90180. spriteCellHeight: number;
  90181. /**
  90182. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90183. */
  90184. spriteRandomStartCell: boolean;
  90185. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90186. translationPivot: Vector2;
  90187. /** @hidden */
  90188. protected _isAnimationSheetEnabled: boolean;
  90189. /**
  90190. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90191. */
  90192. beginAnimationOnStart: boolean;
  90193. /**
  90194. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90195. */
  90196. beginAnimationFrom: number;
  90197. /**
  90198. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90199. */
  90200. beginAnimationTo: number;
  90201. /**
  90202. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90203. */
  90204. beginAnimationLoop: boolean;
  90205. /**
  90206. * Gets or sets a world offset applied to all particles
  90207. */
  90208. worldOffset: Vector3;
  90209. /**
  90210. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90211. */
  90212. get isAnimationSheetEnabled(): boolean;
  90213. set isAnimationSheetEnabled(value: boolean);
  90214. /**
  90215. * Get hosting scene
  90216. * @returns the scene
  90217. */
  90218. getScene(): Scene;
  90219. /**
  90220. * You can use gravity if you want to give an orientation to your particles.
  90221. */
  90222. gravity: Vector3;
  90223. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90224. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90225. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90226. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90227. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90228. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90229. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90230. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90231. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90232. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90233. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90234. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90235. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90236. /**
  90237. * Defines the delay in milliseconds before starting the system (0 by default)
  90238. */
  90239. startDelay: number;
  90240. /**
  90241. * Gets the current list of drag gradients.
  90242. * You must use addDragGradient and removeDragGradient to udpate this list
  90243. * @returns the list of drag gradients
  90244. */
  90245. getDragGradients(): Nullable<Array<FactorGradient>>;
  90246. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90247. limitVelocityDamping: number;
  90248. /**
  90249. * Gets the current list of limit velocity gradients.
  90250. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90251. * @returns the list of limit velocity gradients
  90252. */
  90253. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90254. /**
  90255. * Gets the current list of color gradients.
  90256. * You must use addColorGradient and removeColorGradient to udpate this list
  90257. * @returns the list of color gradients
  90258. */
  90259. getColorGradients(): Nullable<Array<ColorGradient>>;
  90260. /**
  90261. * Gets the current list of size gradients.
  90262. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90263. * @returns the list of size gradients
  90264. */
  90265. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90266. /**
  90267. * Gets the current list of color remap gradients.
  90268. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90269. * @returns the list of color remap gradients
  90270. */
  90271. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90272. /**
  90273. * Gets the current list of alpha remap gradients.
  90274. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90275. * @returns the list of alpha remap gradients
  90276. */
  90277. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90278. /**
  90279. * Gets the current list of life time gradients.
  90280. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90281. * @returns the list of life time gradients
  90282. */
  90283. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90284. /**
  90285. * Gets the current list of angular speed gradients.
  90286. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90287. * @returns the list of angular speed gradients
  90288. */
  90289. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90290. /**
  90291. * Gets the current list of velocity gradients.
  90292. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90293. * @returns the list of velocity gradients
  90294. */
  90295. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90296. /**
  90297. * Gets the current list of start size gradients.
  90298. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90299. * @returns the list of start size gradients
  90300. */
  90301. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90302. /**
  90303. * Gets the current list of emit rate gradients.
  90304. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90305. * @returns the list of emit rate gradients
  90306. */
  90307. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90308. /**
  90309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90310. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90311. */
  90312. get direction1(): Vector3;
  90313. set direction1(value: Vector3);
  90314. /**
  90315. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90316. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90317. */
  90318. get direction2(): Vector3;
  90319. set direction2(value: Vector3);
  90320. /**
  90321. * 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.
  90322. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90323. */
  90324. get minEmitBox(): Vector3;
  90325. set minEmitBox(value: Vector3);
  90326. /**
  90327. * 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.
  90328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90329. */
  90330. get maxEmitBox(): Vector3;
  90331. set maxEmitBox(value: Vector3);
  90332. /**
  90333. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90334. */
  90335. color1: Color4;
  90336. /**
  90337. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90338. */
  90339. color2: Color4;
  90340. /**
  90341. * Color the particle will have at the end of its lifetime
  90342. */
  90343. colorDead: Color4;
  90344. /**
  90345. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90346. */
  90347. textureMask: Color4;
  90348. /**
  90349. * The particle emitter type defines the emitter used by the particle system.
  90350. * It can be for example box, sphere, or cone...
  90351. */
  90352. particleEmitterType: IParticleEmitterType;
  90353. /** @hidden */
  90354. _isSubEmitter: boolean;
  90355. /**
  90356. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90357. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90358. */
  90359. billboardMode: number;
  90360. protected _isBillboardBased: boolean;
  90361. /**
  90362. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90363. */
  90364. get isBillboardBased(): boolean;
  90365. set isBillboardBased(value: boolean);
  90366. /**
  90367. * The scene the particle system belongs to.
  90368. */
  90369. protected _scene: Scene;
  90370. /**
  90371. * Local cache of defines for image processing.
  90372. */
  90373. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90374. /**
  90375. * Default configuration related to image processing available in the standard Material.
  90376. */
  90377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90378. /**
  90379. * Gets the image processing configuration used either in this material.
  90380. */
  90381. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90382. /**
  90383. * Sets the Default image processing configuration used either in the this material.
  90384. *
  90385. * If sets to null, the scene one is in use.
  90386. */
  90387. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90388. /**
  90389. * Attaches a new image processing configuration to the Standard Material.
  90390. * @param configuration
  90391. */
  90392. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90393. /** @hidden */
  90394. protected _reset(): void;
  90395. /** @hidden */
  90396. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90397. /**
  90398. * Instantiates a particle system.
  90399. * 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.
  90400. * @param name The name of the particle system
  90401. */
  90402. constructor(name: string);
  90403. /**
  90404. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90405. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90406. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90407. * @returns the emitter
  90408. */
  90409. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90410. /**
  90411. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90412. * @param radius The radius of the hemisphere to emit from
  90413. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90414. * @returns the emitter
  90415. */
  90416. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90417. /**
  90418. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90419. * @param radius The radius of the sphere to emit from
  90420. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90421. * @returns the emitter
  90422. */
  90423. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90424. /**
  90425. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90426. * @param radius The radius of the sphere to emit from
  90427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90429. * @returns the emitter
  90430. */
  90431. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90432. /**
  90433. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90434. * @param radius The radius of the emission cylinder
  90435. * @param height The height of the emission cylinder
  90436. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90437. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90438. * @returns the emitter
  90439. */
  90440. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90441. /**
  90442. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90443. * @param radius The radius of the cylinder to emit from
  90444. * @param height The height of the emission cylinder
  90445. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90448. * @returns the emitter
  90449. */
  90450. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90451. /**
  90452. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90453. * @param radius The radius of the cone to emit from
  90454. * @param angle The base angle of the cone
  90455. * @returns the emitter
  90456. */
  90457. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90458. /**
  90459. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90462. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90463. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90464. * @returns the emitter
  90465. */
  90466. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90467. }
  90468. }
  90469. declare module BABYLON {
  90470. /**
  90471. * Type of sub emitter
  90472. */
  90473. export enum SubEmitterType {
  90474. /**
  90475. * Attached to the particle over it's lifetime
  90476. */
  90477. ATTACHED = 0,
  90478. /**
  90479. * Created when the particle dies
  90480. */
  90481. END = 1
  90482. }
  90483. /**
  90484. * Sub emitter class used to emit particles from an existing particle
  90485. */
  90486. export class SubEmitter {
  90487. /**
  90488. * the particle system to be used by the sub emitter
  90489. */
  90490. particleSystem: ParticleSystem;
  90491. /**
  90492. * Type of the submitter (Default: END)
  90493. */
  90494. type: SubEmitterType;
  90495. /**
  90496. * 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)
  90497. * Note: This only is supported when using an emitter of type Mesh
  90498. */
  90499. inheritDirection: boolean;
  90500. /**
  90501. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90502. */
  90503. inheritedVelocityAmount: number;
  90504. /**
  90505. * Creates a sub emitter
  90506. * @param particleSystem the particle system to be used by the sub emitter
  90507. */
  90508. constructor(
  90509. /**
  90510. * the particle system to be used by the sub emitter
  90511. */
  90512. particleSystem: ParticleSystem);
  90513. /**
  90514. * Clones the sub emitter
  90515. * @returns the cloned sub emitter
  90516. */
  90517. clone(): SubEmitter;
  90518. /**
  90519. * Serialize current object to a JSON object
  90520. * @returns the serialized object
  90521. */
  90522. serialize(): any;
  90523. /** @hidden */
  90524. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90525. /**
  90526. * Creates a new SubEmitter from a serialized JSON version
  90527. * @param serializationObject defines the JSON object to read from
  90528. * @param scene defines the hosting scene
  90529. * @param rootUrl defines the rootUrl for data loading
  90530. * @returns a new SubEmitter
  90531. */
  90532. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90533. /** Release associated resources */
  90534. dispose(): void;
  90535. }
  90536. }
  90537. declare module BABYLON {
  90538. /** @hidden */
  90539. export var imageProcessingDeclaration: {
  90540. name: string;
  90541. shader: string;
  90542. };
  90543. }
  90544. declare module BABYLON {
  90545. /** @hidden */
  90546. export var imageProcessingFunctions: {
  90547. name: string;
  90548. shader: string;
  90549. };
  90550. }
  90551. declare module BABYLON {
  90552. /** @hidden */
  90553. export var particlesPixelShader: {
  90554. name: string;
  90555. shader: string;
  90556. };
  90557. }
  90558. declare module BABYLON {
  90559. /** @hidden */
  90560. export var particlesVertexShader: {
  90561. name: string;
  90562. shader: string;
  90563. };
  90564. }
  90565. declare module BABYLON {
  90566. /**
  90567. * This represents a particle system in Babylon.
  90568. * 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.
  90569. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90570. * @example https://doc.babylonjs.com/babylon101/particles
  90571. */
  90572. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90573. /**
  90574. * Billboard mode will only apply to Y axis
  90575. */
  90576. static readonly BILLBOARDMODE_Y: number;
  90577. /**
  90578. * Billboard mode will apply to all axes
  90579. */
  90580. static readonly BILLBOARDMODE_ALL: number;
  90581. /**
  90582. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90583. */
  90584. static readonly BILLBOARDMODE_STRETCHED: number;
  90585. /**
  90586. * This function can be defined to provide custom update for active particles.
  90587. * This function will be called instead of regular update (age, position, color, etc.).
  90588. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90589. */
  90590. updateFunction: (particles: Particle[]) => void;
  90591. private _emitterWorldMatrix;
  90592. /**
  90593. * This function can be defined to specify initial direction for every new particle.
  90594. * It by default use the emitterType defined function
  90595. */
  90596. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90597. /**
  90598. * This function can be defined to specify initial position for every new particle.
  90599. * It by default use the emitterType defined function
  90600. */
  90601. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90602. /**
  90603. * @hidden
  90604. */
  90605. _inheritedVelocityOffset: Vector3;
  90606. /**
  90607. * An event triggered when the system is disposed
  90608. */
  90609. onDisposeObservable: Observable<IParticleSystem>;
  90610. private _onDisposeObserver;
  90611. /**
  90612. * Sets a callback that will be triggered when the system is disposed
  90613. */
  90614. set onDispose(callback: () => void);
  90615. private _particles;
  90616. private _epsilon;
  90617. private _capacity;
  90618. private _stockParticles;
  90619. private _newPartsExcess;
  90620. private _vertexData;
  90621. private _vertexBuffer;
  90622. private _vertexBuffers;
  90623. private _spriteBuffer;
  90624. private _indexBuffer;
  90625. private _effect;
  90626. private _customEffect;
  90627. private _cachedDefines;
  90628. private _scaledColorStep;
  90629. private _colorDiff;
  90630. private _scaledDirection;
  90631. private _scaledGravity;
  90632. private _currentRenderId;
  90633. private _alive;
  90634. private _useInstancing;
  90635. private _started;
  90636. private _stopped;
  90637. private _actualFrame;
  90638. private _scaledUpdateSpeed;
  90639. private _vertexBufferSize;
  90640. /** @hidden */
  90641. _currentEmitRateGradient: Nullable<FactorGradient>;
  90642. /** @hidden */
  90643. _currentEmitRate1: number;
  90644. /** @hidden */
  90645. _currentEmitRate2: number;
  90646. /** @hidden */
  90647. _currentStartSizeGradient: Nullable<FactorGradient>;
  90648. /** @hidden */
  90649. _currentStartSize1: number;
  90650. /** @hidden */
  90651. _currentStartSize2: number;
  90652. private readonly _rawTextureWidth;
  90653. private _rampGradientsTexture;
  90654. private _useRampGradients;
  90655. /** Gets or sets a boolean indicating that ramp gradients must be used
  90656. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90657. */
  90658. get useRampGradients(): boolean;
  90659. set useRampGradients(value: boolean);
  90660. /**
  90661. * 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.
  90662. * 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: [])
  90663. */
  90664. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90665. private _subEmitters;
  90666. /**
  90667. * @hidden
  90668. * If the particle systems emitter should be disposed when the particle system is disposed
  90669. */
  90670. _disposeEmitterOnDispose: boolean;
  90671. /**
  90672. * The current active Sub-systems, this property is used by the root particle system only.
  90673. */
  90674. activeSubSystems: Array<ParticleSystem>;
  90675. /**
  90676. * Specifies if the particles are updated in emitter local space or world space
  90677. */
  90678. isLocal: boolean;
  90679. private _rootParticleSystem;
  90680. /**
  90681. * Gets the current list of active particles
  90682. */
  90683. get particles(): Particle[];
  90684. /**
  90685. * Gets the number of particles active at the same time.
  90686. * @returns The number of active particles.
  90687. */
  90688. getActiveCount(): number;
  90689. /**
  90690. * Returns the string "ParticleSystem"
  90691. * @returns a string containing the class name
  90692. */
  90693. getClassName(): string;
  90694. /**
  90695. * Gets a boolean indicating that the system is stopping
  90696. * @returns true if the system is currently stopping
  90697. */
  90698. isStopping(): boolean;
  90699. /**
  90700. * Gets the custom effect used to render the particles
  90701. * @param blendMode Blend mode for which the effect should be retrieved
  90702. * @returns The effect
  90703. */
  90704. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90705. /**
  90706. * Sets the custom effect used to render the particles
  90707. * @param effect The effect to set
  90708. * @param blendMode Blend mode for which the effect should be set
  90709. */
  90710. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90711. /** @hidden */
  90712. private _onBeforeDrawParticlesObservable;
  90713. /**
  90714. * Observable that will be called just before the particles are drawn
  90715. */
  90716. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90717. /**
  90718. * Gets the name of the particle vertex shader
  90719. */
  90720. get vertexShaderName(): string;
  90721. /**
  90722. * Instantiates a particle system.
  90723. * 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.
  90724. * @param name The name of the particle system
  90725. * @param capacity The max number of particles alive at the same time
  90726. * @param scene The scene the particle system belongs to
  90727. * @param customEffect a custom effect used to change the way particles are rendered by default
  90728. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90729. * @param epsilon Offset used to render the particles
  90730. */
  90731. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90732. private _addFactorGradient;
  90733. private _removeFactorGradient;
  90734. /**
  90735. * Adds a new life time gradient
  90736. * @param gradient defines the gradient to use (between 0 and 1)
  90737. * @param factor defines the life time factor to affect to the specified gradient
  90738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90739. * @returns the current particle system
  90740. */
  90741. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90742. /**
  90743. * Remove a specific life time gradient
  90744. * @param gradient defines the gradient to remove
  90745. * @returns the current particle system
  90746. */
  90747. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90748. /**
  90749. * Adds a new size gradient
  90750. * @param gradient defines the gradient to use (between 0 and 1)
  90751. * @param factor defines the size factor to affect to the specified gradient
  90752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90753. * @returns the current particle system
  90754. */
  90755. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90756. /**
  90757. * Remove a specific size gradient
  90758. * @param gradient defines the gradient to remove
  90759. * @returns the current particle system
  90760. */
  90761. removeSizeGradient(gradient: number): IParticleSystem;
  90762. /**
  90763. * Adds a new color remap gradient
  90764. * @param gradient defines the gradient to use (between 0 and 1)
  90765. * @param min defines the color remap minimal range
  90766. * @param max defines the color remap maximal range
  90767. * @returns the current particle system
  90768. */
  90769. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90770. /**
  90771. * Remove a specific color remap gradient
  90772. * @param gradient defines the gradient to remove
  90773. * @returns the current particle system
  90774. */
  90775. removeColorRemapGradient(gradient: number): IParticleSystem;
  90776. /**
  90777. * Adds a new alpha remap gradient
  90778. * @param gradient defines the gradient to use (between 0 and 1)
  90779. * @param min defines the alpha remap minimal range
  90780. * @param max defines the alpha remap maximal range
  90781. * @returns the current particle system
  90782. */
  90783. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90784. /**
  90785. * Remove a specific alpha remap gradient
  90786. * @param gradient defines the gradient to remove
  90787. * @returns the current particle system
  90788. */
  90789. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90790. /**
  90791. * Adds a new angular speed gradient
  90792. * @param gradient defines the gradient to use (between 0 and 1)
  90793. * @param factor defines the angular speed to affect to the specified gradient
  90794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90795. * @returns the current particle system
  90796. */
  90797. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90798. /**
  90799. * Remove a specific angular speed gradient
  90800. * @param gradient defines the gradient to remove
  90801. * @returns the current particle system
  90802. */
  90803. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90804. /**
  90805. * Adds a new velocity gradient
  90806. * @param gradient defines the gradient to use (between 0 and 1)
  90807. * @param factor defines the velocity to affect to the specified gradient
  90808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90809. * @returns the current particle system
  90810. */
  90811. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90812. /**
  90813. * Remove a specific velocity gradient
  90814. * @param gradient defines the gradient to remove
  90815. * @returns the current particle system
  90816. */
  90817. removeVelocityGradient(gradient: number): IParticleSystem;
  90818. /**
  90819. * Adds a new limit velocity gradient
  90820. * @param gradient defines the gradient to use (between 0 and 1)
  90821. * @param factor defines the limit velocity value to affect to the specified gradient
  90822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90823. * @returns the current particle system
  90824. */
  90825. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90826. /**
  90827. * Remove a specific limit velocity gradient
  90828. * @param gradient defines the gradient to remove
  90829. * @returns the current particle system
  90830. */
  90831. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90832. /**
  90833. * Adds a new drag gradient
  90834. * @param gradient defines the gradient to use (between 0 and 1)
  90835. * @param factor defines the drag value to affect to the specified gradient
  90836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90837. * @returns the current particle system
  90838. */
  90839. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90840. /**
  90841. * Remove a specific drag gradient
  90842. * @param gradient defines the gradient to remove
  90843. * @returns the current particle system
  90844. */
  90845. removeDragGradient(gradient: number): IParticleSystem;
  90846. /**
  90847. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90848. * @param gradient defines the gradient to use (between 0 and 1)
  90849. * @param factor defines the emit rate value to affect to the specified gradient
  90850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90851. * @returns the current particle system
  90852. */
  90853. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90854. /**
  90855. * Remove a specific emit rate gradient
  90856. * @param gradient defines the gradient to remove
  90857. * @returns the current particle system
  90858. */
  90859. removeEmitRateGradient(gradient: number): IParticleSystem;
  90860. /**
  90861. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90862. * @param gradient defines the gradient to use (between 0 and 1)
  90863. * @param factor defines the start size value to affect to the specified gradient
  90864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90865. * @returns the current particle system
  90866. */
  90867. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90868. /**
  90869. * Remove a specific start size gradient
  90870. * @param gradient defines the gradient to remove
  90871. * @returns the current particle system
  90872. */
  90873. removeStartSizeGradient(gradient: number): IParticleSystem;
  90874. private _createRampGradientTexture;
  90875. /**
  90876. * Gets the current list of ramp gradients.
  90877. * You must use addRampGradient and removeRampGradient to udpate this list
  90878. * @returns the list of ramp gradients
  90879. */
  90880. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90881. /** Force the system to rebuild all gradients that need to be resync */
  90882. forceRefreshGradients(): void;
  90883. private _syncRampGradientTexture;
  90884. /**
  90885. * Adds a new ramp gradient used to remap particle colors
  90886. * @param gradient defines the gradient to use (between 0 and 1)
  90887. * @param color defines the color to affect to the specified gradient
  90888. * @returns the current particle system
  90889. */
  90890. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90891. /**
  90892. * Remove a specific ramp gradient
  90893. * @param gradient defines the gradient to remove
  90894. * @returns the current particle system
  90895. */
  90896. removeRampGradient(gradient: number): ParticleSystem;
  90897. /**
  90898. * Adds a new color gradient
  90899. * @param gradient defines the gradient to use (between 0 and 1)
  90900. * @param color1 defines the color to affect to the specified gradient
  90901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90902. * @returns this particle system
  90903. */
  90904. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90905. /**
  90906. * Remove a specific color gradient
  90907. * @param gradient defines the gradient to remove
  90908. * @returns this particle system
  90909. */
  90910. removeColorGradient(gradient: number): IParticleSystem;
  90911. private _fetchR;
  90912. protected _reset(): void;
  90913. private _resetEffect;
  90914. private _createVertexBuffers;
  90915. private _createIndexBuffer;
  90916. /**
  90917. * Gets the maximum number of particles active at the same time.
  90918. * @returns The max number of active particles.
  90919. */
  90920. getCapacity(): number;
  90921. /**
  90922. * Gets whether there are still active particles in the system.
  90923. * @returns True if it is alive, otherwise false.
  90924. */
  90925. isAlive(): boolean;
  90926. /**
  90927. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90928. * @returns True if it has been started, otherwise false.
  90929. */
  90930. isStarted(): boolean;
  90931. private _prepareSubEmitterInternalArray;
  90932. /**
  90933. * Starts the particle system and begins to emit
  90934. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90935. */
  90936. start(delay?: number): void;
  90937. /**
  90938. * Stops the particle system.
  90939. * @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.
  90940. */
  90941. stop(stopSubEmitters?: boolean): void;
  90942. /**
  90943. * Remove all active particles
  90944. */
  90945. reset(): void;
  90946. /**
  90947. * @hidden (for internal use only)
  90948. */
  90949. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90950. /**
  90951. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90952. * Its lifetime will start back at 0.
  90953. */
  90954. recycleParticle: (particle: Particle) => void;
  90955. private _stopSubEmitters;
  90956. private _createParticle;
  90957. private _removeFromRoot;
  90958. private _emitFromParticle;
  90959. private _update;
  90960. /** @hidden */
  90961. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90962. /** @hidden */
  90963. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90964. /**
  90965. * Fill the defines array according to the current settings of the particle system
  90966. * @param defines Array to be updated
  90967. * @param blendMode blend mode to take into account when updating the array
  90968. */
  90969. fillDefines(defines: Array<string>, blendMode: number): void;
  90970. /**
  90971. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90972. * @param uniforms Uniforms array to fill
  90973. * @param attributes Attributes array to fill
  90974. * @param samplers Samplers array to fill
  90975. */
  90976. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90977. /** @hidden */
  90978. private _getEffect;
  90979. /**
  90980. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90981. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90982. */
  90983. animate(preWarmOnly?: boolean): void;
  90984. private _appendParticleVertices;
  90985. /**
  90986. * Rebuilds the particle system.
  90987. */
  90988. rebuild(): void;
  90989. /**
  90990. * Is this system ready to be used/rendered
  90991. * @return true if the system is ready
  90992. */
  90993. isReady(): boolean;
  90994. private _render;
  90995. /**
  90996. * Renders the particle system in its current state.
  90997. * @returns the current number of particles
  90998. */
  90999. render(): number;
  91000. /**
  91001. * Disposes the particle system and free the associated resources
  91002. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91003. */
  91004. dispose(disposeTexture?: boolean): void;
  91005. /**
  91006. * Clones the particle system.
  91007. * @param name The name of the cloned object
  91008. * @param newEmitter The new emitter to use
  91009. * @returns the cloned particle system
  91010. */
  91011. clone(name: string, newEmitter: any): ParticleSystem;
  91012. /**
  91013. * Serializes the particle system to a JSON object
  91014. * @param serializeTexture defines if the texture must be serialized as well
  91015. * @returns the JSON object
  91016. */
  91017. serialize(serializeTexture?: boolean): any;
  91018. /** @hidden */
  91019. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91020. /** @hidden */
  91021. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91022. /**
  91023. * Parses a JSON object to create a particle system.
  91024. * @param parsedParticleSystem The JSON object to parse
  91025. * @param scene The scene to create the particle system in
  91026. * @param rootUrl The root url to use to load external dependencies like texture
  91027. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91028. * @returns the Parsed particle system
  91029. */
  91030. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91031. }
  91032. }
  91033. declare module BABYLON {
  91034. /**
  91035. * A particle represents one of the element emitted by a particle system.
  91036. * This is mainly define by its coordinates, direction, velocity and age.
  91037. */
  91038. export class Particle {
  91039. /**
  91040. * The particle system the particle belongs to.
  91041. */
  91042. particleSystem: ParticleSystem;
  91043. private static _Count;
  91044. /**
  91045. * Unique ID of the particle
  91046. */
  91047. id: number;
  91048. /**
  91049. * The world position of the particle in the scene.
  91050. */
  91051. position: Vector3;
  91052. /**
  91053. * The world direction of the particle in the scene.
  91054. */
  91055. direction: Vector3;
  91056. /**
  91057. * The color of the particle.
  91058. */
  91059. color: Color4;
  91060. /**
  91061. * The color change of the particle per step.
  91062. */
  91063. colorStep: Color4;
  91064. /**
  91065. * Defines how long will the life of the particle be.
  91066. */
  91067. lifeTime: number;
  91068. /**
  91069. * The current age of the particle.
  91070. */
  91071. age: number;
  91072. /**
  91073. * The current size of the particle.
  91074. */
  91075. size: number;
  91076. /**
  91077. * The current scale of the particle.
  91078. */
  91079. scale: Vector2;
  91080. /**
  91081. * The current angle of the particle.
  91082. */
  91083. angle: number;
  91084. /**
  91085. * Defines how fast is the angle changing.
  91086. */
  91087. angularSpeed: number;
  91088. /**
  91089. * Defines the cell index used by the particle to be rendered from a sprite.
  91090. */
  91091. cellIndex: number;
  91092. /**
  91093. * The information required to support color remapping
  91094. */
  91095. remapData: Vector4;
  91096. /** @hidden */
  91097. _randomCellOffset?: number;
  91098. /** @hidden */
  91099. _initialDirection: Nullable<Vector3>;
  91100. /** @hidden */
  91101. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91102. /** @hidden */
  91103. _initialStartSpriteCellID: number;
  91104. /** @hidden */
  91105. _initialEndSpriteCellID: number;
  91106. /** @hidden */
  91107. _currentColorGradient: Nullable<ColorGradient>;
  91108. /** @hidden */
  91109. _currentColor1: Color4;
  91110. /** @hidden */
  91111. _currentColor2: Color4;
  91112. /** @hidden */
  91113. _currentSizeGradient: Nullable<FactorGradient>;
  91114. /** @hidden */
  91115. _currentSize1: number;
  91116. /** @hidden */
  91117. _currentSize2: number;
  91118. /** @hidden */
  91119. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91120. /** @hidden */
  91121. _currentAngularSpeed1: number;
  91122. /** @hidden */
  91123. _currentAngularSpeed2: number;
  91124. /** @hidden */
  91125. _currentVelocityGradient: Nullable<FactorGradient>;
  91126. /** @hidden */
  91127. _currentVelocity1: number;
  91128. /** @hidden */
  91129. _currentVelocity2: number;
  91130. /** @hidden */
  91131. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91132. /** @hidden */
  91133. _currentLimitVelocity1: number;
  91134. /** @hidden */
  91135. _currentLimitVelocity2: number;
  91136. /** @hidden */
  91137. _currentDragGradient: Nullable<FactorGradient>;
  91138. /** @hidden */
  91139. _currentDrag1: number;
  91140. /** @hidden */
  91141. _currentDrag2: number;
  91142. /** @hidden */
  91143. _randomNoiseCoordinates1: Vector3;
  91144. /** @hidden */
  91145. _randomNoiseCoordinates2: Vector3;
  91146. /** @hidden */
  91147. _localPosition?: Vector3;
  91148. /**
  91149. * Creates a new instance Particle
  91150. * @param particleSystem the particle system the particle belongs to
  91151. */
  91152. constructor(
  91153. /**
  91154. * The particle system the particle belongs to.
  91155. */
  91156. particleSystem: ParticleSystem);
  91157. private updateCellInfoFromSystem;
  91158. /**
  91159. * Defines how the sprite cell index is updated for the particle
  91160. */
  91161. updateCellIndex(): void;
  91162. /** @hidden */
  91163. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91164. /** @hidden */
  91165. _inheritParticleInfoToSubEmitters(): void;
  91166. /** @hidden */
  91167. _reset(): void;
  91168. /**
  91169. * Copy the properties of particle to another one.
  91170. * @param other the particle to copy the information to.
  91171. */
  91172. copyTo(other: Particle): void;
  91173. }
  91174. }
  91175. declare module BABYLON {
  91176. /**
  91177. * Particle emitter represents a volume emitting particles.
  91178. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91179. */
  91180. export interface IParticleEmitterType {
  91181. /**
  91182. * Called by the particle System when the direction is computed for the created particle.
  91183. * @param worldMatrix is the world matrix of the particle system
  91184. * @param directionToUpdate is the direction vector to update with the result
  91185. * @param particle is the particle we are computed the direction for
  91186. * @param isLocal defines if the direction should be set in local space
  91187. */
  91188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91189. /**
  91190. * Called by the particle System when the position is computed for the created particle.
  91191. * @param worldMatrix is the world matrix of the particle system
  91192. * @param positionToUpdate is the position vector to update with the result
  91193. * @param particle is the particle we are computed the position for
  91194. * @param isLocal defines if the position should be set in local space
  91195. */
  91196. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91197. /**
  91198. * Clones the current emitter and returns a copy of it
  91199. * @returns the new emitter
  91200. */
  91201. clone(): IParticleEmitterType;
  91202. /**
  91203. * Called by the GPUParticleSystem to setup the update shader
  91204. * @param effect defines the update shader
  91205. */
  91206. applyToShader(effect: Effect): void;
  91207. /**
  91208. * Returns a string to use to update the GPU particles update shader
  91209. * @returns the effect defines string
  91210. */
  91211. getEffectDefines(): string;
  91212. /**
  91213. * Returns a string representing the class name
  91214. * @returns a string containing the class name
  91215. */
  91216. getClassName(): string;
  91217. /**
  91218. * Serializes the particle system to a JSON object.
  91219. * @returns the JSON object
  91220. */
  91221. serialize(): any;
  91222. /**
  91223. * Parse properties from a JSON object
  91224. * @param serializationObject defines the JSON object
  91225. * @param scene defines the hosting scene
  91226. */
  91227. parse(serializationObject: any, scene: Scene): void;
  91228. }
  91229. }
  91230. declare module BABYLON {
  91231. /**
  91232. * Particle emitter emitting particles from the inside of a box.
  91233. * It emits the particles randomly between 2 given directions.
  91234. */
  91235. export class BoxParticleEmitter implements IParticleEmitterType {
  91236. /**
  91237. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91238. */
  91239. direction1: Vector3;
  91240. /**
  91241. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91242. */
  91243. direction2: Vector3;
  91244. /**
  91245. * 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.
  91246. */
  91247. minEmitBox: Vector3;
  91248. /**
  91249. * 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.
  91250. */
  91251. maxEmitBox: Vector3;
  91252. /**
  91253. * Creates a new instance BoxParticleEmitter
  91254. */
  91255. constructor();
  91256. /**
  91257. * Called by the particle System when the direction is computed for the created particle.
  91258. * @param worldMatrix is the world matrix of the particle system
  91259. * @param directionToUpdate is the direction vector to update with the result
  91260. * @param particle is the particle we are computed the direction for
  91261. * @param isLocal defines if the direction should be set in local space
  91262. */
  91263. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91264. /**
  91265. * Called by the particle System when the position is computed for the created particle.
  91266. * @param worldMatrix is the world matrix of the particle system
  91267. * @param positionToUpdate is the position vector to update with the result
  91268. * @param particle is the particle we are computed the position for
  91269. * @param isLocal defines if the position should be set in local space
  91270. */
  91271. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91272. /**
  91273. * Clones the current emitter and returns a copy of it
  91274. * @returns the new emitter
  91275. */
  91276. clone(): BoxParticleEmitter;
  91277. /**
  91278. * Called by the GPUParticleSystem to setup the update shader
  91279. * @param effect defines the update shader
  91280. */
  91281. applyToShader(effect: Effect): void;
  91282. /**
  91283. * Returns a string to use to update the GPU particles update shader
  91284. * @returns a string containng the defines string
  91285. */
  91286. getEffectDefines(): string;
  91287. /**
  91288. * Returns the string "BoxParticleEmitter"
  91289. * @returns a string containing the class name
  91290. */
  91291. getClassName(): string;
  91292. /**
  91293. * Serializes the particle system to a JSON object.
  91294. * @returns the JSON object
  91295. */
  91296. serialize(): any;
  91297. /**
  91298. * Parse properties from a JSON object
  91299. * @param serializationObject defines the JSON object
  91300. */
  91301. parse(serializationObject: any): void;
  91302. }
  91303. }
  91304. declare module BABYLON {
  91305. /**
  91306. * Particle emitter emitting particles from the inside of a cone.
  91307. * It emits the particles alongside the cone volume from the base to the particle.
  91308. * The emission direction might be randomized.
  91309. */
  91310. export class ConeParticleEmitter implements IParticleEmitterType {
  91311. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91312. directionRandomizer: number;
  91313. private _radius;
  91314. private _angle;
  91315. private _height;
  91316. /**
  91317. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91318. */
  91319. radiusRange: number;
  91320. /**
  91321. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91322. */
  91323. heightRange: number;
  91324. /**
  91325. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91326. */
  91327. emitFromSpawnPointOnly: boolean;
  91328. /**
  91329. * Gets or sets the radius of the emission cone
  91330. */
  91331. get radius(): number;
  91332. set radius(value: number);
  91333. /**
  91334. * Gets or sets the angle of the emission cone
  91335. */
  91336. get angle(): number;
  91337. set angle(value: number);
  91338. private _buildHeight;
  91339. /**
  91340. * Creates a new instance ConeParticleEmitter
  91341. * @param radius the radius of the emission cone (1 by default)
  91342. * @param angle the cone base angle (PI by default)
  91343. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91344. */
  91345. constructor(radius?: number, angle?: number,
  91346. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91347. directionRandomizer?: number);
  91348. /**
  91349. * Called by the particle System when the direction is computed for the created particle.
  91350. * @param worldMatrix is the world matrix of the particle system
  91351. * @param directionToUpdate is the direction vector to update with the result
  91352. * @param particle is the particle we are computed the direction for
  91353. * @param isLocal defines if the direction should be set in local space
  91354. */
  91355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91356. /**
  91357. * Called by the particle System when the position is computed for the created particle.
  91358. * @param worldMatrix is the world matrix of the particle system
  91359. * @param positionToUpdate is the position vector to update with the result
  91360. * @param particle is the particle we are computed the position for
  91361. * @param isLocal defines if the position should be set in local space
  91362. */
  91363. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91364. /**
  91365. * Clones the current emitter and returns a copy of it
  91366. * @returns the new emitter
  91367. */
  91368. clone(): ConeParticleEmitter;
  91369. /**
  91370. * Called by the GPUParticleSystem to setup the update shader
  91371. * @param effect defines the update shader
  91372. */
  91373. applyToShader(effect: Effect): void;
  91374. /**
  91375. * Returns a string to use to update the GPU particles update shader
  91376. * @returns a string containng the defines string
  91377. */
  91378. getEffectDefines(): string;
  91379. /**
  91380. * Returns the string "ConeParticleEmitter"
  91381. * @returns a string containing the class name
  91382. */
  91383. getClassName(): string;
  91384. /**
  91385. * Serializes the particle system to a JSON object.
  91386. * @returns the JSON object
  91387. */
  91388. serialize(): any;
  91389. /**
  91390. * Parse properties from a JSON object
  91391. * @param serializationObject defines the JSON object
  91392. */
  91393. parse(serializationObject: any): void;
  91394. }
  91395. }
  91396. declare module BABYLON {
  91397. /**
  91398. * Particle emitter emitting particles from the inside of a cylinder.
  91399. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91400. */
  91401. export class CylinderParticleEmitter implements IParticleEmitterType {
  91402. /**
  91403. * The radius of the emission cylinder.
  91404. */
  91405. radius: number;
  91406. /**
  91407. * The height of the emission cylinder.
  91408. */
  91409. height: number;
  91410. /**
  91411. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91412. */
  91413. radiusRange: number;
  91414. /**
  91415. * How much to randomize the particle direction [0-1].
  91416. */
  91417. directionRandomizer: number;
  91418. /**
  91419. * Creates a new instance CylinderParticleEmitter
  91420. * @param radius the radius of the emission cylinder (1 by default)
  91421. * @param height the height of the emission cylinder (1 by default)
  91422. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91423. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91424. */
  91425. constructor(
  91426. /**
  91427. * The radius of the emission cylinder.
  91428. */
  91429. radius?: number,
  91430. /**
  91431. * The height of the emission cylinder.
  91432. */
  91433. height?: number,
  91434. /**
  91435. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91436. */
  91437. radiusRange?: number,
  91438. /**
  91439. * How much to randomize the particle direction [0-1].
  91440. */
  91441. directionRandomizer?: number);
  91442. /**
  91443. * Called by the particle System when the direction is computed for the created particle.
  91444. * @param worldMatrix is the world matrix of the particle system
  91445. * @param directionToUpdate is the direction vector to update with the result
  91446. * @param particle is the particle we are computed the direction for
  91447. * @param isLocal defines if the direction should be set in local space
  91448. */
  91449. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91450. /**
  91451. * Called by the particle System when the position is computed for the created particle.
  91452. * @param worldMatrix is the world matrix of the particle system
  91453. * @param positionToUpdate is the position vector to update with the result
  91454. * @param particle is the particle we are computed the position for
  91455. * @param isLocal defines if the position should be set in local space
  91456. */
  91457. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91458. /**
  91459. * Clones the current emitter and returns a copy of it
  91460. * @returns the new emitter
  91461. */
  91462. clone(): CylinderParticleEmitter;
  91463. /**
  91464. * Called by the GPUParticleSystem to setup the update shader
  91465. * @param effect defines the update shader
  91466. */
  91467. applyToShader(effect: Effect): void;
  91468. /**
  91469. * Returns a string to use to update the GPU particles update shader
  91470. * @returns a string containng the defines string
  91471. */
  91472. getEffectDefines(): string;
  91473. /**
  91474. * Returns the string "CylinderParticleEmitter"
  91475. * @returns a string containing the class name
  91476. */
  91477. getClassName(): string;
  91478. /**
  91479. * Serializes the particle system to a JSON object.
  91480. * @returns the JSON object
  91481. */
  91482. serialize(): any;
  91483. /**
  91484. * Parse properties from a JSON object
  91485. * @param serializationObject defines the JSON object
  91486. */
  91487. parse(serializationObject: any): void;
  91488. }
  91489. /**
  91490. * Particle emitter emitting particles from the inside of a cylinder.
  91491. * It emits the particles randomly between two vectors.
  91492. */
  91493. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91494. /**
  91495. * The min limit of the emission direction.
  91496. */
  91497. direction1: Vector3;
  91498. /**
  91499. * The max limit of the emission direction.
  91500. */
  91501. direction2: Vector3;
  91502. /**
  91503. * Creates a new instance CylinderDirectedParticleEmitter
  91504. * @param radius the radius of the emission cylinder (1 by default)
  91505. * @param height the height of the emission cylinder (1 by default)
  91506. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91507. * @param direction1 the min limit of the emission direction (up vector by default)
  91508. * @param direction2 the max limit of the emission direction (up vector by default)
  91509. */
  91510. constructor(radius?: number, height?: number, radiusRange?: number,
  91511. /**
  91512. * The min limit of the emission direction.
  91513. */
  91514. direction1?: Vector3,
  91515. /**
  91516. * The max limit of the emission direction.
  91517. */
  91518. direction2?: Vector3);
  91519. /**
  91520. * Called by the particle System when the direction is computed for the created particle.
  91521. * @param worldMatrix is the world matrix of the particle system
  91522. * @param directionToUpdate is the direction vector to update with the result
  91523. * @param particle is the particle we are computed the direction for
  91524. */
  91525. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91526. /**
  91527. * Clones the current emitter and returns a copy of it
  91528. * @returns the new emitter
  91529. */
  91530. clone(): CylinderDirectedParticleEmitter;
  91531. /**
  91532. * Called by the GPUParticleSystem to setup the update shader
  91533. * @param effect defines the update shader
  91534. */
  91535. applyToShader(effect: Effect): void;
  91536. /**
  91537. * Returns a string to use to update the GPU particles update shader
  91538. * @returns a string containng the defines string
  91539. */
  91540. getEffectDefines(): string;
  91541. /**
  91542. * Returns the string "CylinderDirectedParticleEmitter"
  91543. * @returns a string containing the class name
  91544. */
  91545. getClassName(): string;
  91546. /**
  91547. * Serializes the particle system to a JSON object.
  91548. * @returns the JSON object
  91549. */
  91550. serialize(): any;
  91551. /**
  91552. * Parse properties from a JSON object
  91553. * @param serializationObject defines the JSON object
  91554. */
  91555. parse(serializationObject: any): void;
  91556. }
  91557. }
  91558. declare module BABYLON {
  91559. /**
  91560. * Particle emitter emitting particles from the inside of a hemisphere.
  91561. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91562. */
  91563. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91564. /**
  91565. * The radius of the emission hemisphere.
  91566. */
  91567. radius: number;
  91568. /**
  91569. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91570. */
  91571. radiusRange: number;
  91572. /**
  91573. * How much to randomize the particle direction [0-1].
  91574. */
  91575. directionRandomizer: number;
  91576. /**
  91577. * Creates a new instance HemisphericParticleEmitter
  91578. * @param radius the radius of the emission hemisphere (1 by default)
  91579. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91581. */
  91582. constructor(
  91583. /**
  91584. * The radius of the emission hemisphere.
  91585. */
  91586. radius?: number,
  91587. /**
  91588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91589. */
  91590. radiusRange?: number,
  91591. /**
  91592. * How much to randomize the particle direction [0-1].
  91593. */
  91594. directionRandomizer?: number);
  91595. /**
  91596. * Called by the particle System when the direction is computed for the created particle.
  91597. * @param worldMatrix is the world matrix of the particle system
  91598. * @param directionToUpdate is the direction vector to update with the result
  91599. * @param particle is the particle we are computed the direction for
  91600. * @param isLocal defines if the direction should be set in local space
  91601. */
  91602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91603. /**
  91604. * Called by the particle System when the position is computed for the created particle.
  91605. * @param worldMatrix is the world matrix of the particle system
  91606. * @param positionToUpdate is the position vector to update with the result
  91607. * @param particle is the particle we are computed the position for
  91608. * @param isLocal defines if the position should be set in local space
  91609. */
  91610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91611. /**
  91612. * Clones the current emitter and returns a copy of it
  91613. * @returns the new emitter
  91614. */
  91615. clone(): HemisphericParticleEmitter;
  91616. /**
  91617. * Called by the GPUParticleSystem to setup the update shader
  91618. * @param effect defines the update shader
  91619. */
  91620. applyToShader(effect: Effect): void;
  91621. /**
  91622. * Returns a string to use to update the GPU particles update shader
  91623. * @returns a string containng the defines string
  91624. */
  91625. getEffectDefines(): string;
  91626. /**
  91627. * Returns the string "HemisphericParticleEmitter"
  91628. * @returns a string containing the class name
  91629. */
  91630. getClassName(): string;
  91631. /**
  91632. * Serializes the particle system to a JSON object.
  91633. * @returns the JSON object
  91634. */
  91635. serialize(): any;
  91636. /**
  91637. * Parse properties from a JSON object
  91638. * @param serializationObject defines the JSON object
  91639. */
  91640. parse(serializationObject: any): void;
  91641. }
  91642. }
  91643. declare module BABYLON {
  91644. /**
  91645. * Particle emitter emitting particles from a point.
  91646. * It emits the particles randomly between 2 given directions.
  91647. */
  91648. export class PointParticleEmitter implements IParticleEmitterType {
  91649. /**
  91650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91651. */
  91652. direction1: Vector3;
  91653. /**
  91654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91655. */
  91656. direction2: Vector3;
  91657. /**
  91658. * Creates a new instance PointParticleEmitter
  91659. */
  91660. constructor();
  91661. /**
  91662. * Called by the particle System when the direction is computed for the created particle.
  91663. * @param worldMatrix is the world matrix of the particle system
  91664. * @param directionToUpdate is the direction vector to update with the result
  91665. * @param particle is the particle we are computed the direction for
  91666. * @param isLocal defines if the direction should be set in local space
  91667. */
  91668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91669. /**
  91670. * Called by the particle System when the position is computed for the created particle.
  91671. * @param worldMatrix is the world matrix of the particle system
  91672. * @param positionToUpdate is the position vector to update with the result
  91673. * @param particle is the particle we are computed the position for
  91674. * @param isLocal defines if the position should be set in local space
  91675. */
  91676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91677. /**
  91678. * Clones the current emitter and returns a copy of it
  91679. * @returns the new emitter
  91680. */
  91681. clone(): PointParticleEmitter;
  91682. /**
  91683. * Called by the GPUParticleSystem to setup the update shader
  91684. * @param effect defines the update shader
  91685. */
  91686. applyToShader(effect: Effect): void;
  91687. /**
  91688. * Returns a string to use to update the GPU particles update shader
  91689. * @returns a string containng the defines string
  91690. */
  91691. getEffectDefines(): string;
  91692. /**
  91693. * Returns the string "PointParticleEmitter"
  91694. * @returns a string containing the class name
  91695. */
  91696. getClassName(): string;
  91697. /**
  91698. * Serializes the particle system to a JSON object.
  91699. * @returns the JSON object
  91700. */
  91701. serialize(): any;
  91702. /**
  91703. * Parse properties from a JSON object
  91704. * @param serializationObject defines the JSON object
  91705. */
  91706. parse(serializationObject: any): void;
  91707. }
  91708. }
  91709. declare module BABYLON {
  91710. /**
  91711. * Particle emitter emitting particles from the inside of a sphere.
  91712. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91713. */
  91714. export class SphereParticleEmitter implements IParticleEmitterType {
  91715. /**
  91716. * The radius of the emission sphere.
  91717. */
  91718. radius: number;
  91719. /**
  91720. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91721. */
  91722. radiusRange: number;
  91723. /**
  91724. * How much to randomize the particle direction [0-1].
  91725. */
  91726. directionRandomizer: number;
  91727. /**
  91728. * Creates a new instance SphereParticleEmitter
  91729. * @param radius the radius of the emission sphere (1 by default)
  91730. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91731. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91732. */
  91733. constructor(
  91734. /**
  91735. * The radius of the emission sphere.
  91736. */
  91737. radius?: number,
  91738. /**
  91739. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91740. */
  91741. radiusRange?: number,
  91742. /**
  91743. * How much to randomize the particle direction [0-1].
  91744. */
  91745. directionRandomizer?: number);
  91746. /**
  91747. * Called by the particle System when the direction is computed for the created particle.
  91748. * @param worldMatrix is the world matrix of the particle system
  91749. * @param directionToUpdate is the direction vector to update with the result
  91750. * @param particle is the particle we are computed the direction for
  91751. * @param isLocal defines if the direction should be set in local space
  91752. */
  91753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91754. /**
  91755. * Called by the particle System when the position is computed for the created particle.
  91756. * @param worldMatrix is the world matrix of the particle system
  91757. * @param positionToUpdate is the position vector to update with the result
  91758. * @param particle is the particle we are computed the position for
  91759. * @param isLocal defines if the position should be set in local space
  91760. */
  91761. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91762. /**
  91763. * Clones the current emitter and returns a copy of it
  91764. * @returns the new emitter
  91765. */
  91766. clone(): SphereParticleEmitter;
  91767. /**
  91768. * Called by the GPUParticleSystem to setup the update shader
  91769. * @param effect defines the update shader
  91770. */
  91771. applyToShader(effect: Effect): void;
  91772. /**
  91773. * Returns a string to use to update the GPU particles update shader
  91774. * @returns a string containng the defines string
  91775. */
  91776. getEffectDefines(): string;
  91777. /**
  91778. * Returns the string "SphereParticleEmitter"
  91779. * @returns a string containing the class name
  91780. */
  91781. getClassName(): string;
  91782. /**
  91783. * Serializes the particle system to a JSON object.
  91784. * @returns the JSON object
  91785. */
  91786. serialize(): any;
  91787. /**
  91788. * Parse properties from a JSON object
  91789. * @param serializationObject defines the JSON object
  91790. */
  91791. parse(serializationObject: any): void;
  91792. }
  91793. /**
  91794. * Particle emitter emitting particles from the inside of a sphere.
  91795. * It emits the particles randomly between two vectors.
  91796. */
  91797. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91798. /**
  91799. * The min limit of the emission direction.
  91800. */
  91801. direction1: Vector3;
  91802. /**
  91803. * The max limit of the emission direction.
  91804. */
  91805. direction2: Vector3;
  91806. /**
  91807. * Creates a new instance SphereDirectedParticleEmitter
  91808. * @param radius the radius of the emission sphere (1 by default)
  91809. * @param direction1 the min limit of the emission direction (up vector by default)
  91810. * @param direction2 the max limit of the emission direction (up vector by default)
  91811. */
  91812. constructor(radius?: number,
  91813. /**
  91814. * The min limit of the emission direction.
  91815. */
  91816. direction1?: Vector3,
  91817. /**
  91818. * The max limit of the emission direction.
  91819. */
  91820. direction2?: Vector3);
  91821. /**
  91822. * Called by the particle System when the direction is computed for the created particle.
  91823. * @param worldMatrix is the world matrix of the particle system
  91824. * @param directionToUpdate is the direction vector to update with the result
  91825. * @param particle is the particle we are computed the direction for
  91826. */
  91827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91828. /**
  91829. * Clones the current emitter and returns a copy of it
  91830. * @returns the new emitter
  91831. */
  91832. clone(): SphereDirectedParticleEmitter;
  91833. /**
  91834. * Called by the GPUParticleSystem to setup the update shader
  91835. * @param effect defines the update shader
  91836. */
  91837. applyToShader(effect: Effect): void;
  91838. /**
  91839. * Returns a string to use to update the GPU particles update shader
  91840. * @returns a string containng the defines string
  91841. */
  91842. getEffectDefines(): string;
  91843. /**
  91844. * Returns the string "SphereDirectedParticleEmitter"
  91845. * @returns a string containing the class name
  91846. */
  91847. getClassName(): string;
  91848. /**
  91849. * Serializes the particle system to a JSON object.
  91850. * @returns the JSON object
  91851. */
  91852. serialize(): any;
  91853. /**
  91854. * Parse properties from a JSON object
  91855. * @param serializationObject defines the JSON object
  91856. */
  91857. parse(serializationObject: any): void;
  91858. }
  91859. }
  91860. declare module BABYLON {
  91861. /**
  91862. * Particle emitter emitting particles from a custom list of positions.
  91863. */
  91864. export class CustomParticleEmitter implements IParticleEmitterType {
  91865. /**
  91866. * Gets or sets the position generator that will create the inital position of each particle.
  91867. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91868. */
  91869. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91870. /**
  91871. * Gets or sets the destination generator that will create the final destination of each particle.
  91872. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91873. */
  91874. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91875. /**
  91876. * Creates a new instance CustomParticleEmitter
  91877. */
  91878. constructor();
  91879. /**
  91880. * Called by the particle System when the direction is computed for the created particle.
  91881. * @param worldMatrix is the world matrix of the particle system
  91882. * @param directionToUpdate is the direction vector to update with the result
  91883. * @param particle is the particle we are computed the direction for
  91884. * @param isLocal defines if the direction should be set in local space
  91885. */
  91886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91887. /**
  91888. * Called by the particle System when the position is computed for the created particle.
  91889. * @param worldMatrix is the world matrix of the particle system
  91890. * @param positionToUpdate is the position vector to update with the result
  91891. * @param particle is the particle we are computed the position for
  91892. * @param isLocal defines if the position should be set in local space
  91893. */
  91894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91895. /**
  91896. * Clones the current emitter and returns a copy of it
  91897. * @returns the new emitter
  91898. */
  91899. clone(): CustomParticleEmitter;
  91900. /**
  91901. * Called by the GPUParticleSystem to setup the update shader
  91902. * @param effect defines the update shader
  91903. */
  91904. applyToShader(effect: Effect): void;
  91905. /**
  91906. * Returns a string to use to update the GPU particles update shader
  91907. * @returns a string containng the defines string
  91908. */
  91909. getEffectDefines(): string;
  91910. /**
  91911. * Returns the string "PointParticleEmitter"
  91912. * @returns a string containing the class name
  91913. */
  91914. getClassName(): string;
  91915. /**
  91916. * Serializes the particle system to a JSON object.
  91917. * @returns the JSON object
  91918. */
  91919. serialize(): any;
  91920. /**
  91921. * Parse properties from a JSON object
  91922. * @param serializationObject defines the JSON object
  91923. */
  91924. parse(serializationObject: any): void;
  91925. }
  91926. }
  91927. declare module BABYLON {
  91928. /**
  91929. * Particle emitter emitting particles from the inside of a box.
  91930. * It emits the particles randomly between 2 given directions.
  91931. */
  91932. export class MeshParticleEmitter implements IParticleEmitterType {
  91933. private _indices;
  91934. private _positions;
  91935. private _normals;
  91936. private _storedNormal;
  91937. private _mesh;
  91938. /**
  91939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91940. */
  91941. direction1: Vector3;
  91942. /**
  91943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91944. */
  91945. direction2: Vector3;
  91946. /**
  91947. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91948. */
  91949. useMeshNormalsForDirection: boolean;
  91950. /** Defines the mesh to use as source */
  91951. get mesh(): Nullable<AbstractMesh>;
  91952. set mesh(value: Nullable<AbstractMesh>);
  91953. /**
  91954. * Creates a new instance MeshParticleEmitter
  91955. * @param mesh defines the mesh to use as source
  91956. */
  91957. constructor(mesh?: Nullable<AbstractMesh>);
  91958. /**
  91959. * Called by the particle System when the direction is computed for the created particle.
  91960. * @param worldMatrix is the world matrix of the particle system
  91961. * @param directionToUpdate is the direction vector to update with the result
  91962. * @param particle is the particle we are computed the direction for
  91963. * @param isLocal defines if the direction should be set in local space
  91964. */
  91965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91966. /**
  91967. * Called by the particle System when the position is computed for the created particle.
  91968. * @param worldMatrix is the world matrix of the particle system
  91969. * @param positionToUpdate is the position vector to update with the result
  91970. * @param particle is the particle we are computed the position for
  91971. * @param isLocal defines if the position should be set in local space
  91972. */
  91973. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91974. /**
  91975. * Clones the current emitter and returns a copy of it
  91976. * @returns the new emitter
  91977. */
  91978. clone(): MeshParticleEmitter;
  91979. /**
  91980. * Called by the GPUParticleSystem to setup the update shader
  91981. * @param effect defines the update shader
  91982. */
  91983. applyToShader(effect: Effect): void;
  91984. /**
  91985. * Returns a string to use to update the GPU particles update shader
  91986. * @returns a string containng the defines string
  91987. */
  91988. getEffectDefines(): string;
  91989. /**
  91990. * Returns the string "BoxParticleEmitter"
  91991. * @returns a string containing the class name
  91992. */
  91993. getClassName(): string;
  91994. /**
  91995. * Serializes the particle system to a JSON object.
  91996. * @returns the JSON object
  91997. */
  91998. serialize(): any;
  91999. /**
  92000. * Parse properties from a JSON object
  92001. * @param serializationObject defines the JSON object
  92002. * @param scene defines the hosting scene
  92003. */
  92004. parse(serializationObject: any, scene: Scene): void;
  92005. }
  92006. }
  92007. declare module BABYLON {
  92008. /**
  92009. * Interface representing a particle system in Babylon.js.
  92010. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92011. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92012. */
  92013. export interface IParticleSystem {
  92014. /**
  92015. * List of animations used by the particle system.
  92016. */
  92017. animations: Animation[];
  92018. /**
  92019. * The id of the Particle system.
  92020. */
  92021. id: string;
  92022. /**
  92023. * The name of the Particle system.
  92024. */
  92025. name: string;
  92026. /**
  92027. * The emitter represents the Mesh or position we are attaching the particle system to.
  92028. */
  92029. emitter: Nullable<AbstractMesh | Vector3>;
  92030. /**
  92031. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92032. */
  92033. isBillboardBased: boolean;
  92034. /**
  92035. * The rendering group used by the Particle system to chose when to render.
  92036. */
  92037. renderingGroupId: number;
  92038. /**
  92039. * The layer mask we are rendering the particles through.
  92040. */
  92041. layerMask: number;
  92042. /**
  92043. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92044. */
  92045. updateSpeed: number;
  92046. /**
  92047. * The amount of time the particle system is running (depends of the overall update speed).
  92048. */
  92049. targetStopDuration: number;
  92050. /**
  92051. * The texture used to render each particle. (this can be a spritesheet)
  92052. */
  92053. particleTexture: Nullable<Texture>;
  92054. /**
  92055. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92056. */
  92057. blendMode: number;
  92058. /**
  92059. * Minimum life time of emitting particles.
  92060. */
  92061. minLifeTime: number;
  92062. /**
  92063. * Maximum life time of emitting particles.
  92064. */
  92065. maxLifeTime: number;
  92066. /**
  92067. * Minimum Size of emitting particles.
  92068. */
  92069. minSize: number;
  92070. /**
  92071. * Maximum Size of emitting particles.
  92072. */
  92073. maxSize: number;
  92074. /**
  92075. * Minimum scale of emitting particles on X axis.
  92076. */
  92077. minScaleX: number;
  92078. /**
  92079. * Maximum scale of emitting particles on X axis.
  92080. */
  92081. maxScaleX: number;
  92082. /**
  92083. * Minimum scale of emitting particles on Y axis.
  92084. */
  92085. minScaleY: number;
  92086. /**
  92087. * Maximum scale of emitting particles on Y axis.
  92088. */
  92089. maxScaleY: number;
  92090. /**
  92091. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92092. */
  92093. color1: Color4;
  92094. /**
  92095. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92096. */
  92097. color2: Color4;
  92098. /**
  92099. * Color the particle will have at the end of its lifetime.
  92100. */
  92101. colorDead: Color4;
  92102. /**
  92103. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92104. */
  92105. emitRate: number;
  92106. /**
  92107. * You can use gravity if you want to give an orientation to your particles.
  92108. */
  92109. gravity: Vector3;
  92110. /**
  92111. * Minimum power of emitting particles.
  92112. */
  92113. minEmitPower: number;
  92114. /**
  92115. * Maximum power of emitting particles.
  92116. */
  92117. maxEmitPower: number;
  92118. /**
  92119. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92120. */
  92121. minAngularSpeed: number;
  92122. /**
  92123. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92124. */
  92125. maxAngularSpeed: number;
  92126. /**
  92127. * Gets or sets the minimal initial rotation in radians.
  92128. */
  92129. minInitialRotation: number;
  92130. /**
  92131. * Gets or sets the maximal initial rotation in radians.
  92132. */
  92133. maxInitialRotation: number;
  92134. /**
  92135. * The particle emitter type defines the emitter used by the particle system.
  92136. * It can be for example box, sphere, or cone...
  92137. */
  92138. particleEmitterType: Nullable<IParticleEmitterType>;
  92139. /**
  92140. * Defines the delay in milliseconds before starting the system (0 by default)
  92141. */
  92142. startDelay: number;
  92143. /**
  92144. * 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
  92145. */
  92146. preWarmCycles: number;
  92147. /**
  92148. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92149. */
  92150. preWarmStepOffset: number;
  92151. /**
  92152. * 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)
  92153. */
  92154. spriteCellChangeSpeed: number;
  92155. /**
  92156. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92157. */
  92158. startSpriteCellID: number;
  92159. /**
  92160. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92161. */
  92162. endSpriteCellID: number;
  92163. /**
  92164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92165. */
  92166. spriteCellWidth: number;
  92167. /**
  92168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92169. */
  92170. spriteCellHeight: number;
  92171. /**
  92172. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92173. */
  92174. spriteRandomStartCell: boolean;
  92175. /**
  92176. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92177. */
  92178. isAnimationSheetEnabled: boolean;
  92179. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92180. translationPivot: Vector2;
  92181. /**
  92182. * Gets or sets a texture used to add random noise to particle positions
  92183. */
  92184. noiseTexture: Nullable<BaseTexture>;
  92185. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92186. noiseStrength: Vector3;
  92187. /**
  92188. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92189. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92190. */
  92191. billboardMode: number;
  92192. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92193. limitVelocityDamping: number;
  92194. /**
  92195. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92196. */
  92197. beginAnimationOnStart: boolean;
  92198. /**
  92199. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92200. */
  92201. beginAnimationFrom: number;
  92202. /**
  92203. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92204. */
  92205. beginAnimationTo: number;
  92206. /**
  92207. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92208. */
  92209. beginAnimationLoop: boolean;
  92210. /**
  92211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92212. */
  92213. disposeOnStop: boolean;
  92214. /**
  92215. * Specifies if the particles are updated in emitter local space or world space
  92216. */
  92217. isLocal: boolean;
  92218. /** Snippet ID if the particle system was created from the snippet server */
  92219. snippetId: string;
  92220. /**
  92221. * Gets the maximum number of particles active at the same time.
  92222. * @returns The max number of active particles.
  92223. */
  92224. getCapacity(): number;
  92225. /**
  92226. * Gets the number of particles active at the same time.
  92227. * @returns The number of active particles.
  92228. */
  92229. getActiveCount(): number;
  92230. /**
  92231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92232. * @returns True if it has been started, otherwise false.
  92233. */
  92234. isStarted(): boolean;
  92235. /**
  92236. * Animates the particle system for this frame.
  92237. */
  92238. animate(): void;
  92239. /**
  92240. * Renders the particle system in its current state.
  92241. * @returns the current number of particles
  92242. */
  92243. render(): number;
  92244. /**
  92245. * Dispose the particle system and frees its associated resources.
  92246. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92247. */
  92248. dispose(disposeTexture?: boolean): void;
  92249. /**
  92250. * An event triggered when the system is disposed
  92251. */
  92252. onDisposeObservable: Observable<IParticleSystem>;
  92253. /**
  92254. * Clones the particle system.
  92255. * @param name The name of the cloned object
  92256. * @param newEmitter The new emitter to use
  92257. * @returns the cloned particle system
  92258. */
  92259. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92260. /**
  92261. * Serializes the particle system to a JSON object
  92262. * @param serializeTexture defines if the texture must be serialized as well
  92263. * @returns the JSON object
  92264. */
  92265. serialize(serializeTexture: boolean): any;
  92266. /**
  92267. * Rebuild the particle system
  92268. */
  92269. rebuild(): void;
  92270. /** Force the system to rebuild all gradients that need to be resync */
  92271. forceRefreshGradients(): void;
  92272. /**
  92273. * Starts the particle system and begins to emit
  92274. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92275. */
  92276. start(delay?: number): void;
  92277. /**
  92278. * Stops the particle system.
  92279. */
  92280. stop(): void;
  92281. /**
  92282. * Remove all active particles
  92283. */
  92284. reset(): void;
  92285. /**
  92286. * Gets a boolean indicating that the system is stopping
  92287. * @returns true if the system is currently stopping
  92288. */
  92289. isStopping(): boolean;
  92290. /**
  92291. * Is this system ready to be used/rendered
  92292. * @return true if the system is ready
  92293. */
  92294. isReady(): boolean;
  92295. /**
  92296. * Returns the string "ParticleSystem"
  92297. * @returns a string containing the class name
  92298. */
  92299. getClassName(): string;
  92300. /**
  92301. * Gets the custom effect used to render the particles
  92302. * @param blendMode Blend mode for which the effect should be retrieved
  92303. * @returns The effect
  92304. */
  92305. getCustomEffect(blendMode: number): Nullable<Effect>;
  92306. /**
  92307. * Sets the custom effect used to render the particles
  92308. * @param effect The effect to set
  92309. * @param blendMode Blend mode for which the effect should be set
  92310. */
  92311. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92312. /**
  92313. * Fill the defines array according to the current settings of the particle system
  92314. * @param defines Array to be updated
  92315. * @param blendMode blend mode to take into account when updating the array
  92316. */
  92317. fillDefines(defines: Array<string>, blendMode: number): void;
  92318. /**
  92319. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92320. * @param uniforms Uniforms array to fill
  92321. * @param attributes Attributes array to fill
  92322. * @param samplers Samplers array to fill
  92323. */
  92324. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92325. /**
  92326. * Observable that will be called just before the particles are drawn
  92327. */
  92328. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92329. /**
  92330. * Gets the name of the particle vertex shader
  92331. */
  92332. vertexShaderName: string;
  92333. /**
  92334. * Adds a new color gradient
  92335. * @param gradient defines the gradient to use (between 0 and 1)
  92336. * @param color1 defines the color to affect to the specified gradient
  92337. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92338. * @returns the current particle system
  92339. */
  92340. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92341. /**
  92342. * Remove a specific color gradient
  92343. * @param gradient defines the gradient to remove
  92344. * @returns the current particle system
  92345. */
  92346. removeColorGradient(gradient: number): IParticleSystem;
  92347. /**
  92348. * Adds a new size gradient
  92349. * @param gradient defines the gradient to use (between 0 and 1)
  92350. * @param factor defines the size factor to affect to the specified gradient
  92351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92352. * @returns the current particle system
  92353. */
  92354. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92355. /**
  92356. * Remove a specific size gradient
  92357. * @param gradient defines the gradient to remove
  92358. * @returns the current particle system
  92359. */
  92360. removeSizeGradient(gradient: number): IParticleSystem;
  92361. /**
  92362. * Gets the current list of color gradients.
  92363. * You must use addColorGradient and removeColorGradient to udpate this list
  92364. * @returns the list of color gradients
  92365. */
  92366. getColorGradients(): Nullable<Array<ColorGradient>>;
  92367. /**
  92368. * Gets the current list of size gradients.
  92369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92370. * @returns the list of size gradients
  92371. */
  92372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92373. /**
  92374. * Gets the current list of angular speed gradients.
  92375. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92376. * @returns the list of angular speed gradients
  92377. */
  92378. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92379. /**
  92380. * Adds a new angular speed gradient
  92381. * @param gradient defines the gradient to use (between 0 and 1)
  92382. * @param factor defines the angular speed to affect to the specified gradient
  92383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92384. * @returns the current particle system
  92385. */
  92386. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92387. /**
  92388. * Remove a specific angular speed gradient
  92389. * @param gradient defines the gradient to remove
  92390. * @returns the current particle system
  92391. */
  92392. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92393. /**
  92394. * Gets the current list of velocity gradients.
  92395. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92396. * @returns the list of velocity gradients
  92397. */
  92398. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92399. /**
  92400. * Adds a new velocity gradient
  92401. * @param gradient defines the gradient to use (between 0 and 1)
  92402. * @param factor defines the velocity to affect to the specified gradient
  92403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92404. * @returns the current particle system
  92405. */
  92406. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92407. /**
  92408. * Remove a specific velocity gradient
  92409. * @param gradient defines the gradient to remove
  92410. * @returns the current particle system
  92411. */
  92412. removeVelocityGradient(gradient: number): IParticleSystem;
  92413. /**
  92414. * Gets the current list of limit velocity gradients.
  92415. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92416. * @returns the list of limit velocity gradients
  92417. */
  92418. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92419. /**
  92420. * Adds a new limit velocity gradient
  92421. * @param gradient defines the gradient to use (between 0 and 1)
  92422. * @param factor defines the limit velocity to affect to the specified gradient
  92423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92424. * @returns the current particle system
  92425. */
  92426. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92427. /**
  92428. * Remove a specific limit velocity gradient
  92429. * @param gradient defines the gradient to remove
  92430. * @returns the current particle system
  92431. */
  92432. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92433. /**
  92434. * Adds a new drag gradient
  92435. * @param gradient defines the gradient to use (between 0 and 1)
  92436. * @param factor defines the drag to affect to the specified gradient
  92437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92438. * @returns the current particle system
  92439. */
  92440. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92441. /**
  92442. * Remove a specific drag gradient
  92443. * @param gradient defines the gradient to remove
  92444. * @returns the current particle system
  92445. */
  92446. removeDragGradient(gradient: number): IParticleSystem;
  92447. /**
  92448. * Gets the current list of drag gradients.
  92449. * You must use addDragGradient and removeDragGradient to udpate this list
  92450. * @returns the list of drag gradients
  92451. */
  92452. getDragGradients(): Nullable<Array<FactorGradient>>;
  92453. /**
  92454. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92455. * @param gradient defines the gradient to use (between 0 and 1)
  92456. * @param factor defines the emit rate to affect to the specified gradient
  92457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92458. * @returns the current particle system
  92459. */
  92460. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92461. /**
  92462. * Remove a specific emit rate gradient
  92463. * @param gradient defines the gradient to remove
  92464. * @returns the current particle system
  92465. */
  92466. removeEmitRateGradient(gradient: number): IParticleSystem;
  92467. /**
  92468. * Gets the current list of emit rate gradients.
  92469. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92470. * @returns the list of emit rate gradients
  92471. */
  92472. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92473. /**
  92474. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92475. * @param gradient defines the gradient to use (between 0 and 1)
  92476. * @param factor defines the start size to affect to the specified gradient
  92477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92478. * @returns the current particle system
  92479. */
  92480. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92481. /**
  92482. * Remove a specific start size gradient
  92483. * @param gradient defines the gradient to remove
  92484. * @returns the current particle system
  92485. */
  92486. removeStartSizeGradient(gradient: number): IParticleSystem;
  92487. /**
  92488. * Gets the current list of start size gradients.
  92489. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92490. * @returns the list of start size gradients
  92491. */
  92492. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92493. /**
  92494. * Adds a new life time gradient
  92495. * @param gradient defines the gradient to use (between 0 and 1)
  92496. * @param factor defines the life time factor to affect to the specified gradient
  92497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92498. * @returns the current particle system
  92499. */
  92500. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92501. /**
  92502. * Remove a specific life time gradient
  92503. * @param gradient defines the gradient to remove
  92504. * @returns the current particle system
  92505. */
  92506. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92507. /**
  92508. * Gets the current list of life time gradients.
  92509. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92510. * @returns the list of life time gradients
  92511. */
  92512. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92513. /**
  92514. * Gets the current list of color gradients.
  92515. * You must use addColorGradient and removeColorGradient to udpate this list
  92516. * @returns the list of color gradients
  92517. */
  92518. getColorGradients(): Nullable<Array<ColorGradient>>;
  92519. /**
  92520. * Adds a new ramp gradient used to remap particle colors
  92521. * @param gradient defines the gradient to use (between 0 and 1)
  92522. * @param color defines the color to affect to the specified gradient
  92523. * @returns the current particle system
  92524. */
  92525. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92526. /**
  92527. * Gets the current list of ramp gradients.
  92528. * You must use addRampGradient and removeRampGradient to udpate this list
  92529. * @returns the list of ramp gradients
  92530. */
  92531. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92532. /** Gets or sets a boolean indicating that ramp gradients must be used
  92533. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92534. */
  92535. useRampGradients: boolean;
  92536. /**
  92537. * Adds a new color remap gradient
  92538. * @param gradient defines the gradient to use (between 0 and 1)
  92539. * @param min defines the color remap minimal range
  92540. * @param max defines the color remap maximal range
  92541. * @returns the current particle system
  92542. */
  92543. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92544. /**
  92545. * Gets the current list of color remap gradients.
  92546. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92547. * @returns the list of color remap gradients
  92548. */
  92549. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92550. /**
  92551. * Adds a new alpha remap gradient
  92552. * @param gradient defines the gradient to use (between 0 and 1)
  92553. * @param min defines the alpha remap minimal range
  92554. * @param max defines the alpha remap maximal range
  92555. * @returns the current particle system
  92556. */
  92557. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92558. /**
  92559. * Gets the current list of alpha remap gradients.
  92560. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92561. * @returns the list of alpha remap gradients
  92562. */
  92563. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92564. /**
  92565. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92568. * @returns the emitter
  92569. */
  92570. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92571. /**
  92572. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92573. * @param radius The radius of the hemisphere to emit from
  92574. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92575. * @returns the emitter
  92576. */
  92577. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92578. /**
  92579. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92580. * @param radius The radius of the sphere to emit from
  92581. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92582. * @returns the emitter
  92583. */
  92584. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92585. /**
  92586. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92587. * @param radius The radius of the sphere to emit from
  92588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92590. * @returns the emitter
  92591. */
  92592. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92593. /**
  92594. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92595. * @param radius The radius of the emission cylinder
  92596. * @param height The height of the emission cylinder
  92597. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92598. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92599. * @returns the emitter
  92600. */
  92601. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92602. /**
  92603. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92604. * @param radius The radius of the cylinder to emit from
  92605. * @param height The height of the emission cylinder
  92606. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92607. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92608. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92609. * @returns the emitter
  92610. */
  92611. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92612. /**
  92613. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92614. * @param radius The radius of the cone to emit from
  92615. * @param angle The base angle of the cone
  92616. * @returns the emitter
  92617. */
  92618. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92619. /**
  92620. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92623. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92624. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92625. * @returns the emitter
  92626. */
  92627. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92628. /**
  92629. * Get hosting scene
  92630. * @returns the scene
  92631. */
  92632. getScene(): Scene;
  92633. }
  92634. }
  92635. declare module BABYLON {
  92636. /**
  92637. * 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.
  92638. * @see https://doc.babylonjs.com/how_to/transformnode
  92639. */
  92640. export class TransformNode extends Node {
  92641. /**
  92642. * Object will not rotate to face the camera
  92643. */
  92644. static BILLBOARDMODE_NONE: number;
  92645. /**
  92646. * Object will rotate to face the camera but only on the x axis
  92647. */
  92648. static BILLBOARDMODE_X: number;
  92649. /**
  92650. * Object will rotate to face the camera but only on the y axis
  92651. */
  92652. static BILLBOARDMODE_Y: number;
  92653. /**
  92654. * Object will rotate to face the camera but only on the z axis
  92655. */
  92656. static BILLBOARDMODE_Z: number;
  92657. /**
  92658. * Object will rotate to face the camera
  92659. */
  92660. static BILLBOARDMODE_ALL: number;
  92661. /**
  92662. * Object will rotate to face the camera's position instead of orientation
  92663. */
  92664. static BILLBOARDMODE_USE_POSITION: number;
  92665. private static _TmpRotation;
  92666. private static _TmpScaling;
  92667. private static _TmpTranslation;
  92668. private _forward;
  92669. private _forwardInverted;
  92670. private _up;
  92671. private _right;
  92672. private _rightInverted;
  92673. private _position;
  92674. private _rotation;
  92675. private _rotationQuaternion;
  92676. protected _scaling: Vector3;
  92677. protected _isDirty: boolean;
  92678. private _transformToBoneReferal;
  92679. private _isAbsoluteSynced;
  92680. private _billboardMode;
  92681. /**
  92682. * Gets or sets the billboard mode. Default is 0.
  92683. *
  92684. * | Value | Type | Description |
  92685. * | --- | --- | --- |
  92686. * | 0 | BILLBOARDMODE_NONE | |
  92687. * | 1 | BILLBOARDMODE_X | |
  92688. * | 2 | BILLBOARDMODE_Y | |
  92689. * | 4 | BILLBOARDMODE_Z | |
  92690. * | 7 | BILLBOARDMODE_ALL | |
  92691. *
  92692. */
  92693. get billboardMode(): number;
  92694. set billboardMode(value: number);
  92695. private _preserveParentRotationForBillboard;
  92696. /**
  92697. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92698. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92699. */
  92700. get preserveParentRotationForBillboard(): boolean;
  92701. set preserveParentRotationForBillboard(value: boolean);
  92702. /**
  92703. * 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
  92704. */
  92705. scalingDeterminant: number;
  92706. private _infiniteDistance;
  92707. /**
  92708. * Gets or sets the distance of the object to max, often used by skybox
  92709. */
  92710. get infiniteDistance(): boolean;
  92711. set infiniteDistance(value: boolean);
  92712. /**
  92713. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92714. * By default the system will update normals to compensate
  92715. */
  92716. ignoreNonUniformScaling: boolean;
  92717. /**
  92718. * 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
  92719. */
  92720. reIntegrateRotationIntoRotationQuaternion: boolean;
  92721. /** @hidden */
  92722. _poseMatrix: Nullable<Matrix>;
  92723. /** @hidden */
  92724. _localMatrix: Matrix;
  92725. private _usePivotMatrix;
  92726. private _absolutePosition;
  92727. private _absoluteScaling;
  92728. private _absoluteRotationQuaternion;
  92729. private _pivotMatrix;
  92730. private _pivotMatrixInverse;
  92731. protected _postMultiplyPivotMatrix: boolean;
  92732. protected _isWorldMatrixFrozen: boolean;
  92733. /** @hidden */
  92734. _indexInSceneTransformNodesArray: number;
  92735. /**
  92736. * An event triggered after the world matrix is updated
  92737. */
  92738. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92739. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92740. /**
  92741. * Gets a string identifying the name of the class
  92742. * @returns "TransformNode" string
  92743. */
  92744. getClassName(): string;
  92745. /**
  92746. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92747. */
  92748. get position(): Vector3;
  92749. set position(newPosition: Vector3);
  92750. /**
  92751. * 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)).
  92752. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92753. */
  92754. get rotation(): Vector3;
  92755. set rotation(newRotation: Vector3);
  92756. /**
  92757. * 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)).
  92758. */
  92759. get scaling(): Vector3;
  92760. set scaling(newScaling: Vector3);
  92761. /**
  92762. * 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).
  92763. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92764. */
  92765. get rotationQuaternion(): Nullable<Quaternion>;
  92766. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92767. /**
  92768. * The forward direction of that transform in world space.
  92769. */
  92770. get forward(): Vector3;
  92771. /**
  92772. * The up direction of that transform in world space.
  92773. */
  92774. get up(): Vector3;
  92775. /**
  92776. * The right direction of that transform in world space.
  92777. */
  92778. get right(): Vector3;
  92779. /**
  92780. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92781. * @param matrix the matrix to copy the pose from
  92782. * @returns this TransformNode.
  92783. */
  92784. updatePoseMatrix(matrix: Matrix): TransformNode;
  92785. /**
  92786. * Returns the mesh Pose matrix.
  92787. * @returns the pose matrix
  92788. */
  92789. getPoseMatrix(): Matrix;
  92790. /** @hidden */
  92791. _isSynchronized(): boolean;
  92792. /** @hidden */
  92793. _initCache(): void;
  92794. /**
  92795. * Flag the transform node as dirty (Forcing it to update everything)
  92796. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92797. * @returns this transform node
  92798. */
  92799. markAsDirty(property: string): TransformNode;
  92800. /**
  92801. * Returns the current mesh absolute position.
  92802. * Returns a Vector3.
  92803. */
  92804. get absolutePosition(): Vector3;
  92805. /**
  92806. * Returns the current mesh absolute scaling.
  92807. * Returns a Vector3.
  92808. */
  92809. get absoluteScaling(): Vector3;
  92810. /**
  92811. * Returns the current mesh absolute rotation.
  92812. * Returns a Quaternion.
  92813. */
  92814. get absoluteRotationQuaternion(): Quaternion;
  92815. /**
  92816. * Sets a new matrix to apply before all other transformation
  92817. * @param matrix defines the transform matrix
  92818. * @returns the current TransformNode
  92819. */
  92820. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92821. /**
  92822. * Sets a new pivot matrix to the current node
  92823. * @param matrix defines the new pivot matrix to use
  92824. * @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
  92825. * @returns the current TransformNode
  92826. */
  92827. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92828. /**
  92829. * Returns the mesh pivot matrix.
  92830. * Default : Identity.
  92831. * @returns the matrix
  92832. */
  92833. getPivotMatrix(): Matrix;
  92834. /**
  92835. * Instantiate (when possible) or clone that node with its hierarchy
  92836. * @param newParent defines the new parent to use for the instance (or clone)
  92837. * @param options defines options to configure how copy is done
  92838. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92839. * @returns an instance (or a clone) of the current node with its hiearchy
  92840. */
  92841. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92842. doNotInstantiate: boolean;
  92843. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92844. /**
  92845. * Prevents the World matrix to be computed any longer
  92846. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92847. * @returns the TransformNode.
  92848. */
  92849. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92850. /**
  92851. * Allows back the World matrix computation.
  92852. * @returns the TransformNode.
  92853. */
  92854. unfreezeWorldMatrix(): this;
  92855. /**
  92856. * True if the World matrix has been frozen.
  92857. */
  92858. get isWorldMatrixFrozen(): boolean;
  92859. /**
  92860. * Retuns the mesh absolute position in the World.
  92861. * @returns a Vector3.
  92862. */
  92863. getAbsolutePosition(): Vector3;
  92864. /**
  92865. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92866. * @param absolutePosition the absolute position to set
  92867. * @returns the TransformNode.
  92868. */
  92869. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92870. /**
  92871. * Sets the mesh position in its local space.
  92872. * @param vector3 the position to set in localspace
  92873. * @returns the TransformNode.
  92874. */
  92875. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92876. /**
  92877. * Returns the mesh position in the local space from the current World matrix values.
  92878. * @returns a new Vector3.
  92879. */
  92880. getPositionExpressedInLocalSpace(): Vector3;
  92881. /**
  92882. * Translates the mesh along the passed Vector3 in its local space.
  92883. * @param vector3 the distance to translate in localspace
  92884. * @returns the TransformNode.
  92885. */
  92886. locallyTranslate(vector3: Vector3): TransformNode;
  92887. private static _lookAtVectorCache;
  92888. /**
  92889. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92890. * @param targetPoint the position (must be in same space as current mesh) to look at
  92891. * @param yawCor optional yaw (y-axis) correction in radians
  92892. * @param pitchCor optional pitch (x-axis) correction in radians
  92893. * @param rollCor optional roll (z-axis) correction in radians
  92894. * @param space the choosen space of the target
  92895. * @returns the TransformNode.
  92896. */
  92897. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92898. /**
  92899. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92900. * This Vector3 is expressed in the World space.
  92901. * @param localAxis axis to rotate
  92902. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92903. */
  92904. getDirection(localAxis: Vector3): Vector3;
  92905. /**
  92906. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92907. * localAxis is expressed in the mesh local space.
  92908. * result is computed in the Wordl space from the mesh World matrix.
  92909. * @param localAxis axis to rotate
  92910. * @param result the resulting transformnode
  92911. * @returns this TransformNode.
  92912. */
  92913. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92914. /**
  92915. * Sets this transform node rotation to the given local axis.
  92916. * @param localAxis the axis in local space
  92917. * @param yawCor optional yaw (y-axis) correction in radians
  92918. * @param pitchCor optional pitch (x-axis) correction in radians
  92919. * @param rollCor optional roll (z-axis) correction in radians
  92920. * @returns this TransformNode
  92921. */
  92922. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92923. /**
  92924. * Sets a new pivot point to the current node
  92925. * @param point defines the new pivot point to use
  92926. * @param space defines if the point is in world or local space (local by default)
  92927. * @returns the current TransformNode
  92928. */
  92929. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92930. /**
  92931. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92932. * @returns the pivot point
  92933. */
  92934. getPivotPoint(): Vector3;
  92935. /**
  92936. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92937. * @param result the vector3 to store the result
  92938. * @returns this TransformNode.
  92939. */
  92940. getPivotPointToRef(result: Vector3): TransformNode;
  92941. /**
  92942. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92943. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92944. */
  92945. getAbsolutePivotPoint(): Vector3;
  92946. /**
  92947. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92948. * @param result vector3 to store the result
  92949. * @returns this TransformNode.
  92950. */
  92951. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92952. /**
  92953. * Defines the passed node as the parent of the current node.
  92954. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92955. * @see https://doc.babylonjs.com/how_to/parenting
  92956. * @param node the node ot set as the parent
  92957. * @returns this TransformNode.
  92958. */
  92959. setParent(node: Nullable<Node>): TransformNode;
  92960. private _nonUniformScaling;
  92961. /**
  92962. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92963. */
  92964. get nonUniformScaling(): boolean;
  92965. /** @hidden */
  92966. _updateNonUniformScalingState(value: boolean): boolean;
  92967. /**
  92968. * Attach the current TransformNode to another TransformNode associated with a bone
  92969. * @param bone Bone affecting the TransformNode
  92970. * @param affectedTransformNode TransformNode associated with the bone
  92971. * @returns this object
  92972. */
  92973. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92974. /**
  92975. * Detach the transform node if its associated with a bone
  92976. * @returns this object
  92977. */
  92978. detachFromBone(): TransformNode;
  92979. private static _rotationAxisCache;
  92980. /**
  92981. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92982. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  92986. * @param amount the amount to rotate in radians
  92987. * @param space Space to rotate in (Default: local)
  92988. * @returns the TransformNode.
  92989. */
  92990. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92991. /**
  92992. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92993. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92994. * The passed axis is also normalized. .
  92995. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92996. * @param point the point to rotate around
  92997. * @param axis the axis to rotate around
  92998. * @param amount the amount to rotate in radians
  92999. * @returns the TransformNode
  93000. */
  93001. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93002. /**
  93003. * Translates the mesh along the axis vector for the passed distance in the given space.
  93004. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93005. * @param axis the axis to translate in
  93006. * @param distance the distance to translate
  93007. * @param space Space to rotate in (Default: local)
  93008. * @returns the TransformNode.
  93009. */
  93010. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93011. /**
  93012. * Adds a rotation step to the mesh current rotation.
  93013. * x, y, z are Euler angles expressed in radians.
  93014. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93015. * This means this rotation is made in the mesh local space only.
  93016. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93017. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93018. * ```javascript
  93019. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93020. * ```
  93021. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93022. * 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.
  93023. * @param x Rotation to add
  93024. * @param y Rotation to add
  93025. * @param z Rotation to add
  93026. * @returns the TransformNode.
  93027. */
  93028. addRotation(x: number, y: number, z: number): TransformNode;
  93029. /**
  93030. * @hidden
  93031. */
  93032. protected _getEffectiveParent(): Nullable<Node>;
  93033. /**
  93034. * Computes the world matrix of the node
  93035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93036. * @returns the world matrix
  93037. */
  93038. computeWorldMatrix(force?: boolean): Matrix;
  93039. /**
  93040. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93041. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93042. */
  93043. resetLocalMatrix(independentOfChildren?: boolean): void;
  93044. protected _afterComputeWorldMatrix(): void;
  93045. /**
  93046. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93047. * @param func callback function to add
  93048. *
  93049. * @returns the TransformNode.
  93050. */
  93051. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93052. /**
  93053. * Removes a registered callback function.
  93054. * @param func callback function to remove
  93055. * @returns the TransformNode.
  93056. */
  93057. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93058. /**
  93059. * Gets the position of the current mesh in camera space
  93060. * @param camera defines the camera to use
  93061. * @returns a position
  93062. */
  93063. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93064. /**
  93065. * Returns the distance from the mesh to the active camera
  93066. * @param camera defines the camera to use
  93067. * @returns the distance
  93068. */
  93069. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93070. /**
  93071. * Clone the current transform node
  93072. * @param name Name of the new clone
  93073. * @param newParent New parent for the clone
  93074. * @param doNotCloneChildren Do not clone children hierarchy
  93075. * @returns the new transform node
  93076. */
  93077. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93078. /**
  93079. * Serializes the objects information.
  93080. * @param currentSerializationObject defines the object to serialize in
  93081. * @returns the serialized object
  93082. */
  93083. serialize(currentSerializationObject?: any): any;
  93084. /**
  93085. * Returns a new TransformNode object parsed from the source provided.
  93086. * @param parsedTransformNode is the source.
  93087. * @param scene the scne the object belongs to
  93088. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93089. * @returns a new TransformNode object parsed from the source provided.
  93090. */
  93091. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93092. /**
  93093. * Get all child-transformNodes of this node
  93094. * @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
  93095. * @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
  93096. * @returns an array of TransformNode
  93097. */
  93098. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93099. /**
  93100. * Releases resources associated with this transform node.
  93101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93103. */
  93104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93105. /**
  93106. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93107. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93108. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93109. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93110. * @returns the current mesh
  93111. */
  93112. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93113. private _syncAbsoluteScalingAndRotation;
  93114. }
  93115. }
  93116. declare module BABYLON {
  93117. /**
  93118. * Class used to override all child animations of a given target
  93119. */
  93120. export class AnimationPropertiesOverride {
  93121. /**
  93122. * Gets or sets a value indicating if animation blending must be used
  93123. */
  93124. enableBlending: boolean;
  93125. /**
  93126. * Gets or sets the blending speed to use when enableBlending is true
  93127. */
  93128. blendingSpeed: number;
  93129. /**
  93130. * Gets or sets the default loop mode to use
  93131. */
  93132. loopMode: number;
  93133. }
  93134. }
  93135. declare module BABYLON {
  93136. /**
  93137. * Class used to store bone information
  93138. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93139. */
  93140. export class Bone extends Node {
  93141. /**
  93142. * defines the bone name
  93143. */
  93144. name: string;
  93145. private static _tmpVecs;
  93146. private static _tmpQuat;
  93147. private static _tmpMats;
  93148. /**
  93149. * Gets the list of child bones
  93150. */
  93151. children: Bone[];
  93152. /** Gets the animations associated with this bone */
  93153. animations: Animation[];
  93154. /**
  93155. * Gets or sets bone length
  93156. */
  93157. length: number;
  93158. /**
  93159. * @hidden Internal only
  93160. * Set this value to map this bone to a different index in the transform matrices
  93161. * Set this value to -1 to exclude the bone from the transform matrices
  93162. */
  93163. _index: Nullable<number>;
  93164. private _skeleton;
  93165. private _localMatrix;
  93166. private _restPose;
  93167. private _baseMatrix;
  93168. private _absoluteTransform;
  93169. private _invertedAbsoluteTransform;
  93170. private _parent;
  93171. private _scalingDeterminant;
  93172. private _worldTransform;
  93173. private _localScaling;
  93174. private _localRotation;
  93175. private _localPosition;
  93176. private _needToDecompose;
  93177. private _needToCompose;
  93178. /** @hidden */
  93179. _linkedTransformNode: Nullable<TransformNode>;
  93180. /** @hidden */
  93181. _waitingTransformNodeId: Nullable<string>;
  93182. /** @hidden */
  93183. get _matrix(): Matrix;
  93184. /** @hidden */
  93185. set _matrix(value: Matrix);
  93186. /**
  93187. * Create a new bone
  93188. * @param name defines the bone name
  93189. * @param skeleton defines the parent skeleton
  93190. * @param parentBone defines the parent (can be null if the bone is the root)
  93191. * @param localMatrix defines the local matrix
  93192. * @param restPose defines the rest pose matrix
  93193. * @param baseMatrix defines the base matrix
  93194. * @param index defines index of the bone in the hiearchy
  93195. */
  93196. constructor(
  93197. /**
  93198. * defines the bone name
  93199. */
  93200. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93201. /**
  93202. * Gets the current object class name.
  93203. * @return the class name
  93204. */
  93205. getClassName(): string;
  93206. /**
  93207. * Gets the parent skeleton
  93208. * @returns a skeleton
  93209. */
  93210. getSkeleton(): Skeleton;
  93211. /**
  93212. * Gets parent bone
  93213. * @returns a bone or null if the bone is the root of the bone hierarchy
  93214. */
  93215. getParent(): Nullable<Bone>;
  93216. /**
  93217. * Returns an array containing the root bones
  93218. * @returns an array containing the root bones
  93219. */
  93220. getChildren(): Array<Bone>;
  93221. /**
  93222. * Gets the node index in matrix array generated for rendering
  93223. * @returns the node index
  93224. */
  93225. getIndex(): number;
  93226. /**
  93227. * Sets the parent bone
  93228. * @param parent defines the parent (can be null if the bone is the root)
  93229. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93230. */
  93231. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93232. /**
  93233. * Gets the local matrix
  93234. * @returns a matrix
  93235. */
  93236. getLocalMatrix(): Matrix;
  93237. /**
  93238. * Gets the base matrix (initial matrix which remains unchanged)
  93239. * @returns a matrix
  93240. */
  93241. getBaseMatrix(): Matrix;
  93242. /**
  93243. * Gets the rest pose matrix
  93244. * @returns a matrix
  93245. */
  93246. getRestPose(): Matrix;
  93247. /**
  93248. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93249. */
  93250. getWorldMatrix(): Matrix;
  93251. /**
  93252. * Sets the local matrix to rest pose matrix
  93253. */
  93254. returnToRest(): void;
  93255. /**
  93256. * Gets the inverse of the absolute transform matrix.
  93257. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93258. * @returns a matrix
  93259. */
  93260. getInvertedAbsoluteTransform(): Matrix;
  93261. /**
  93262. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93263. * @returns a matrix
  93264. */
  93265. getAbsoluteTransform(): Matrix;
  93266. /**
  93267. * Links with the given transform node.
  93268. * The local matrix of this bone is copied from the transform node every frame.
  93269. * @param transformNode defines the transform node to link to
  93270. */
  93271. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93272. /**
  93273. * Gets the node used to drive the bone's transformation
  93274. * @returns a transform node or null
  93275. */
  93276. getTransformNode(): Nullable<TransformNode>;
  93277. /** Gets or sets current position (in local space) */
  93278. get position(): Vector3;
  93279. set position(newPosition: Vector3);
  93280. /** Gets or sets current rotation (in local space) */
  93281. get rotation(): Vector3;
  93282. set rotation(newRotation: Vector3);
  93283. /** Gets or sets current rotation quaternion (in local space) */
  93284. get rotationQuaternion(): Quaternion;
  93285. set rotationQuaternion(newRotation: Quaternion);
  93286. /** Gets or sets current scaling (in local space) */
  93287. get scaling(): Vector3;
  93288. set scaling(newScaling: Vector3);
  93289. /**
  93290. * Gets the animation properties override
  93291. */
  93292. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93293. private _decompose;
  93294. private _compose;
  93295. /**
  93296. * Update the base and local matrices
  93297. * @param matrix defines the new base or local matrix
  93298. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93299. * @param updateLocalMatrix defines if the local matrix should be updated
  93300. */
  93301. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93302. /** @hidden */
  93303. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93304. /**
  93305. * Flag the bone as dirty (Forcing it to update everything)
  93306. */
  93307. markAsDirty(): void;
  93308. /** @hidden */
  93309. _markAsDirtyAndCompose(): void;
  93310. private _markAsDirtyAndDecompose;
  93311. /**
  93312. * Translate the bone in local or world space
  93313. * @param vec The amount to translate the bone
  93314. * @param space The space that the translation is in
  93315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93316. */
  93317. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93318. /**
  93319. * Set the postion of the bone in local or world space
  93320. * @param position The position to set the bone
  93321. * @param space The space that the position is in
  93322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93323. */
  93324. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93325. /**
  93326. * Set the absolute position of the bone (world space)
  93327. * @param position The position to set the bone
  93328. * @param mesh The mesh that this bone is attached to
  93329. */
  93330. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93331. /**
  93332. * Scale the bone on the x, y and z axes (in local space)
  93333. * @param x The amount to scale the bone on the x axis
  93334. * @param y The amount to scale the bone on the y axis
  93335. * @param z The amount to scale the bone on the z axis
  93336. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93337. */
  93338. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93339. /**
  93340. * Set the bone scaling in local space
  93341. * @param scale defines the scaling vector
  93342. */
  93343. setScale(scale: Vector3): void;
  93344. /**
  93345. * Gets the current scaling in local space
  93346. * @returns the current scaling vector
  93347. */
  93348. getScale(): Vector3;
  93349. /**
  93350. * Gets the current scaling in local space and stores it in a target vector
  93351. * @param result defines the target vector
  93352. */
  93353. getScaleToRef(result: Vector3): void;
  93354. /**
  93355. * Set the yaw, pitch, and roll of the bone in local or world space
  93356. * @param yaw The rotation of the bone on the y axis
  93357. * @param pitch The rotation of the bone on the x axis
  93358. * @param roll The rotation of the bone on the z axis
  93359. * @param space The space that the axes of rotation are in
  93360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93361. */
  93362. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93363. /**
  93364. * Add a rotation to the bone on an axis in local or world space
  93365. * @param axis The axis to rotate the bone on
  93366. * @param amount The amount to rotate the bone
  93367. * @param space The space that the axis is in
  93368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93369. */
  93370. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93371. /**
  93372. * Set the rotation of the bone to a particular axis angle in local or world space
  93373. * @param axis The axis to rotate the bone on
  93374. * @param angle The angle that the bone should be rotated to
  93375. * @param space The space that the axis is in
  93376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93377. */
  93378. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93379. /**
  93380. * Set the euler rotation of the bone in local of world space
  93381. * @param rotation The euler rotation that the bone should be set to
  93382. * @param space The space that the rotation is in
  93383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93384. */
  93385. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93386. /**
  93387. * Set the quaternion rotation of the bone in local of world space
  93388. * @param quat The quaternion rotation that the bone should be set to
  93389. * @param space The space that the rotation is in
  93390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93391. */
  93392. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93393. /**
  93394. * Set the rotation matrix of the bone in local of world space
  93395. * @param rotMat The rotation matrix that the bone should be set to
  93396. * @param space The space that the rotation is in
  93397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93398. */
  93399. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93400. private _rotateWithMatrix;
  93401. private _getNegativeRotationToRef;
  93402. /**
  93403. * Get the position of the bone in local or world space
  93404. * @param space The space that the returned position is in
  93405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93406. * @returns The position of the bone
  93407. */
  93408. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93409. /**
  93410. * Copy the position of the bone to a vector3 in local or world space
  93411. * @param space The space that the returned position is in
  93412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93413. * @param result The vector3 to copy the position to
  93414. */
  93415. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93416. /**
  93417. * Get the absolute position of the bone (world space)
  93418. * @param mesh The mesh that this bone is attached to
  93419. * @returns The absolute position of the bone
  93420. */
  93421. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93422. /**
  93423. * Copy the absolute position of the bone (world space) to the result param
  93424. * @param mesh The mesh that this bone is attached to
  93425. * @param result The vector3 to copy the absolute position to
  93426. */
  93427. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93428. /**
  93429. * Compute the absolute transforms of this bone and its children
  93430. */
  93431. computeAbsoluteTransforms(): void;
  93432. /**
  93433. * Get the world direction from an axis that is in the local space of the bone
  93434. * @param localAxis The local direction that is used to compute the world direction
  93435. * @param mesh The mesh that this bone is attached to
  93436. * @returns The world direction
  93437. */
  93438. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93439. /**
  93440. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93441. * @param localAxis The local direction that is used to compute the world direction
  93442. * @param mesh The mesh that this bone is attached to
  93443. * @param result The vector3 that the world direction will be copied to
  93444. */
  93445. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93446. /**
  93447. * Get the euler rotation of the bone in local or world space
  93448. * @param space The space that the rotation should be in
  93449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93450. * @returns The euler rotation
  93451. */
  93452. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93453. /**
  93454. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93455. * @param space The space that the rotation should be in
  93456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93457. * @param result The vector3 that the rotation should be copied to
  93458. */
  93459. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93460. /**
  93461. * Get the quaternion rotation of the bone in either local or world space
  93462. * @param space The space that the rotation should be in
  93463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93464. * @returns The quaternion rotation
  93465. */
  93466. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93467. /**
  93468. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93469. * @param space The space that the rotation should be in
  93470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93471. * @param result The quaternion that the rotation should be copied to
  93472. */
  93473. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93474. /**
  93475. * Get the rotation matrix of the bone in local or world space
  93476. * @param space The space that the rotation should be in
  93477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93478. * @returns The rotation matrix
  93479. */
  93480. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93481. /**
  93482. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93483. * @param space The space that the rotation should be in
  93484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93485. * @param result The quaternion that the rotation should be copied to
  93486. */
  93487. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93488. /**
  93489. * Get the world position of a point that is in the local space of the bone
  93490. * @param position The local position
  93491. * @param mesh The mesh that this bone is attached to
  93492. * @returns The world position
  93493. */
  93494. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93495. /**
  93496. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93497. * @param position The local position
  93498. * @param mesh The mesh that this bone is attached to
  93499. * @param result The vector3 that the world position should be copied to
  93500. */
  93501. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93502. /**
  93503. * Get the local position of a point that is in world space
  93504. * @param position The world position
  93505. * @param mesh The mesh that this bone is attached to
  93506. * @returns The local position
  93507. */
  93508. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93509. /**
  93510. * Get the local position of a point that is in world space and copy it to the result param
  93511. * @param position The world position
  93512. * @param mesh The mesh that this bone is attached to
  93513. * @param result The vector3 that the local position should be copied to
  93514. */
  93515. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93516. }
  93517. }
  93518. declare module BABYLON {
  93519. /**
  93520. * Defines a runtime animation
  93521. */
  93522. export class RuntimeAnimation {
  93523. private _events;
  93524. /**
  93525. * The current frame of the runtime animation
  93526. */
  93527. private _currentFrame;
  93528. /**
  93529. * The animation used by the runtime animation
  93530. */
  93531. private _animation;
  93532. /**
  93533. * The target of the runtime animation
  93534. */
  93535. private _target;
  93536. /**
  93537. * The initiating animatable
  93538. */
  93539. private _host;
  93540. /**
  93541. * The original value of the runtime animation
  93542. */
  93543. private _originalValue;
  93544. /**
  93545. * The original blend value of the runtime animation
  93546. */
  93547. private _originalBlendValue;
  93548. /**
  93549. * The offsets cache of the runtime animation
  93550. */
  93551. private _offsetsCache;
  93552. /**
  93553. * The high limits cache of the runtime animation
  93554. */
  93555. private _highLimitsCache;
  93556. /**
  93557. * Specifies if the runtime animation has been stopped
  93558. */
  93559. private _stopped;
  93560. /**
  93561. * The blending factor of the runtime animation
  93562. */
  93563. private _blendingFactor;
  93564. /**
  93565. * The BabylonJS scene
  93566. */
  93567. private _scene;
  93568. /**
  93569. * The current value of the runtime animation
  93570. */
  93571. private _currentValue;
  93572. /** @hidden */
  93573. _animationState: _IAnimationState;
  93574. /**
  93575. * The active target of the runtime animation
  93576. */
  93577. private _activeTargets;
  93578. private _currentActiveTarget;
  93579. private _directTarget;
  93580. /**
  93581. * The target path of the runtime animation
  93582. */
  93583. private _targetPath;
  93584. /**
  93585. * The weight of the runtime animation
  93586. */
  93587. private _weight;
  93588. /**
  93589. * The ratio offset of the runtime animation
  93590. */
  93591. private _ratioOffset;
  93592. /**
  93593. * The previous delay of the runtime animation
  93594. */
  93595. private _previousDelay;
  93596. /**
  93597. * The previous ratio of the runtime animation
  93598. */
  93599. private _previousRatio;
  93600. private _enableBlending;
  93601. private _keys;
  93602. private _minFrame;
  93603. private _maxFrame;
  93604. private _minValue;
  93605. private _maxValue;
  93606. private _targetIsArray;
  93607. /**
  93608. * Gets the current frame of the runtime animation
  93609. */
  93610. get currentFrame(): number;
  93611. /**
  93612. * Gets the weight of the runtime animation
  93613. */
  93614. get weight(): number;
  93615. /**
  93616. * Gets the current value of the runtime animation
  93617. */
  93618. get currentValue(): any;
  93619. /**
  93620. * Gets the target path of the runtime animation
  93621. */
  93622. get targetPath(): string;
  93623. /**
  93624. * Gets the actual target of the runtime animation
  93625. */
  93626. get target(): any;
  93627. /**
  93628. * Gets the additive state of the runtime animation
  93629. */
  93630. get isAdditive(): boolean;
  93631. /** @hidden */
  93632. _onLoop: () => void;
  93633. /**
  93634. * Create a new RuntimeAnimation object
  93635. * @param target defines the target of the animation
  93636. * @param animation defines the source animation object
  93637. * @param scene defines the hosting scene
  93638. * @param host defines the initiating Animatable
  93639. */
  93640. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93641. private _preparePath;
  93642. /**
  93643. * Gets the animation from the runtime animation
  93644. */
  93645. get animation(): Animation;
  93646. /**
  93647. * Resets the runtime animation to the beginning
  93648. * @param restoreOriginal defines whether to restore the target property to the original value
  93649. */
  93650. reset(restoreOriginal?: boolean): void;
  93651. /**
  93652. * Specifies if the runtime animation is stopped
  93653. * @returns Boolean specifying if the runtime animation is stopped
  93654. */
  93655. isStopped(): boolean;
  93656. /**
  93657. * Disposes of the runtime animation
  93658. */
  93659. dispose(): void;
  93660. /**
  93661. * Apply the interpolated value to the target
  93662. * @param currentValue defines the value computed by the animation
  93663. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93664. */
  93665. setValue(currentValue: any, weight: number): void;
  93666. private _getOriginalValues;
  93667. private _setValue;
  93668. /**
  93669. * Gets the loop pmode of the runtime animation
  93670. * @returns Loop Mode
  93671. */
  93672. private _getCorrectLoopMode;
  93673. /**
  93674. * Move the current animation to a given frame
  93675. * @param frame defines the frame to move to
  93676. */
  93677. goToFrame(frame: number): void;
  93678. /**
  93679. * @hidden Internal use only
  93680. */
  93681. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93682. /**
  93683. * Execute the current animation
  93684. * @param delay defines the delay to add to the current frame
  93685. * @param from defines the lower bound of the animation range
  93686. * @param to defines the upper bound of the animation range
  93687. * @param loop defines if the current animation must loop
  93688. * @param speedRatio defines the current speed ratio
  93689. * @param weight defines the weight of the animation (default is -1 so no weight)
  93690. * @param onLoop optional callback called when animation loops
  93691. * @returns a boolean indicating if the animation is running
  93692. */
  93693. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93694. }
  93695. }
  93696. declare module BABYLON {
  93697. /**
  93698. * Class used to store an actual running animation
  93699. */
  93700. export class Animatable {
  93701. /** defines the target object */
  93702. target: any;
  93703. /** defines the starting frame number (default is 0) */
  93704. fromFrame: number;
  93705. /** defines the ending frame number (default is 100) */
  93706. toFrame: number;
  93707. /** defines if the animation must loop (default is false) */
  93708. loopAnimation: boolean;
  93709. /** defines a callback to call when animation ends if it is not looping */
  93710. onAnimationEnd?: (() => void) | null | undefined;
  93711. /** defines a callback to call when animation loops */
  93712. onAnimationLoop?: (() => void) | null | undefined;
  93713. /** defines whether the animation should be evaluated additively */
  93714. isAdditive: boolean;
  93715. private _localDelayOffset;
  93716. private _pausedDelay;
  93717. private _runtimeAnimations;
  93718. private _paused;
  93719. private _scene;
  93720. private _speedRatio;
  93721. private _weight;
  93722. private _syncRoot;
  93723. /**
  93724. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93725. * This will only apply for non looping animation (default is true)
  93726. */
  93727. disposeOnEnd: boolean;
  93728. /**
  93729. * Gets a boolean indicating if the animation has started
  93730. */
  93731. animationStarted: boolean;
  93732. /**
  93733. * Observer raised when the animation ends
  93734. */
  93735. onAnimationEndObservable: Observable<Animatable>;
  93736. /**
  93737. * Observer raised when the animation loops
  93738. */
  93739. onAnimationLoopObservable: Observable<Animatable>;
  93740. /**
  93741. * Gets the root Animatable used to synchronize and normalize animations
  93742. */
  93743. get syncRoot(): Nullable<Animatable>;
  93744. /**
  93745. * Gets the current frame of the first RuntimeAnimation
  93746. * Used to synchronize Animatables
  93747. */
  93748. get masterFrame(): number;
  93749. /**
  93750. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93751. */
  93752. get weight(): number;
  93753. set weight(value: number);
  93754. /**
  93755. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93756. */
  93757. get speedRatio(): number;
  93758. set speedRatio(value: number);
  93759. /**
  93760. * Creates a new Animatable
  93761. * @param scene defines the hosting scene
  93762. * @param target defines the target object
  93763. * @param fromFrame defines the starting frame number (default is 0)
  93764. * @param toFrame defines the ending frame number (default is 100)
  93765. * @param loopAnimation defines if the animation must loop (default is false)
  93766. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93767. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93768. * @param animations defines a group of animation to add to the new Animatable
  93769. * @param onAnimationLoop defines a callback to call when animation loops
  93770. * @param isAdditive defines whether the animation should be evaluated additively
  93771. */
  93772. constructor(scene: Scene,
  93773. /** defines the target object */
  93774. target: any,
  93775. /** defines the starting frame number (default is 0) */
  93776. fromFrame?: number,
  93777. /** defines the ending frame number (default is 100) */
  93778. toFrame?: number,
  93779. /** defines if the animation must loop (default is false) */
  93780. loopAnimation?: boolean, speedRatio?: number,
  93781. /** defines a callback to call when animation ends if it is not looping */
  93782. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93783. /** defines a callback to call when animation loops */
  93784. onAnimationLoop?: (() => void) | null | undefined,
  93785. /** defines whether the animation should be evaluated additively */
  93786. isAdditive?: boolean);
  93787. /**
  93788. * Synchronize and normalize current Animatable with a source Animatable
  93789. * This is useful when using animation weights and when animations are not of the same length
  93790. * @param root defines the root Animatable to synchronize with
  93791. * @returns the current Animatable
  93792. */
  93793. syncWith(root: Animatable): Animatable;
  93794. /**
  93795. * Gets the list of runtime animations
  93796. * @returns an array of RuntimeAnimation
  93797. */
  93798. getAnimations(): RuntimeAnimation[];
  93799. /**
  93800. * Adds more animations to the current animatable
  93801. * @param target defines the target of the animations
  93802. * @param animations defines the new animations to add
  93803. */
  93804. appendAnimations(target: any, animations: Animation[]): void;
  93805. /**
  93806. * Gets the source animation for a specific property
  93807. * @param property defines the propertyu to look for
  93808. * @returns null or the source animation for the given property
  93809. */
  93810. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93811. /**
  93812. * Gets the runtime animation for a specific property
  93813. * @param property defines the propertyu to look for
  93814. * @returns null or the runtime animation for the given property
  93815. */
  93816. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93817. /**
  93818. * Resets the animatable to its original state
  93819. */
  93820. reset(): void;
  93821. /**
  93822. * Allows the animatable to blend with current running animations
  93823. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93824. * @param blendingSpeed defines the blending speed to use
  93825. */
  93826. enableBlending(blendingSpeed: number): void;
  93827. /**
  93828. * Disable animation blending
  93829. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93830. */
  93831. disableBlending(): void;
  93832. /**
  93833. * Jump directly to a given frame
  93834. * @param frame defines the frame to jump to
  93835. */
  93836. goToFrame(frame: number): void;
  93837. /**
  93838. * Pause the animation
  93839. */
  93840. pause(): void;
  93841. /**
  93842. * Restart the animation
  93843. */
  93844. restart(): void;
  93845. private _raiseOnAnimationEnd;
  93846. /**
  93847. * Stop and delete the current animation
  93848. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93849. * @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)
  93850. */
  93851. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93852. /**
  93853. * Wait asynchronously for the animation to end
  93854. * @returns a promise which will be fullfilled when the animation ends
  93855. */
  93856. waitAsync(): Promise<Animatable>;
  93857. /** @hidden */
  93858. _animate(delay: number): boolean;
  93859. }
  93860. interface Scene {
  93861. /** @hidden */
  93862. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93863. /** @hidden */
  93864. _processLateAnimationBindingsForMatrices(holder: {
  93865. totalWeight: number;
  93866. totalAdditiveWeight: number;
  93867. animations: RuntimeAnimation[];
  93868. additiveAnimations: RuntimeAnimation[];
  93869. originalValue: Matrix;
  93870. }): any;
  93871. /** @hidden */
  93872. _processLateAnimationBindingsForQuaternions(holder: {
  93873. totalWeight: number;
  93874. totalAdditiveWeight: number;
  93875. animations: RuntimeAnimation[];
  93876. additiveAnimations: RuntimeAnimation[];
  93877. originalValue: Quaternion;
  93878. }, refQuaternion: Quaternion): Quaternion;
  93879. /** @hidden */
  93880. _processLateAnimationBindings(): void;
  93881. /**
  93882. * Will start the animation sequence of a given target
  93883. * @param target defines the target
  93884. * @param from defines from which frame should animation start
  93885. * @param to defines until which frame should animation run.
  93886. * @param weight defines the weight to apply to the animation (1.0 by default)
  93887. * @param loop defines if the animation loops
  93888. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93889. * @param onAnimationEnd defines the function to be executed when the animation ends
  93890. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93891. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93892. * @param onAnimationLoop defines the callback to call when an animation loops
  93893. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93894. * @returns the animatable object created for this animation
  93895. */
  93896. 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;
  93897. /**
  93898. * Will start the animation sequence of a given target
  93899. * @param target defines the target
  93900. * @param from defines from which frame should animation start
  93901. * @param to defines until which frame should animation run.
  93902. * @param loop defines if the animation loops
  93903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93904. * @param onAnimationEnd defines the function to be executed when the animation ends
  93905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93906. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93907. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93908. * @param onAnimationLoop defines the callback to call when an animation loops
  93909. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93910. * @returns the animatable object created for this animation
  93911. */
  93912. 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;
  93913. /**
  93914. * Will start the animation sequence of a given target and its hierarchy
  93915. * @param target defines the target
  93916. * @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.
  93917. * @param from defines from which frame should animation start
  93918. * @param to defines until which frame should animation run.
  93919. * @param loop defines if the animation loops
  93920. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93921. * @param onAnimationEnd defines the function to be executed when the animation ends
  93922. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93923. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93924. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93925. * @param onAnimationLoop defines the callback to call when an animation loops
  93926. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93927. * @returns the list of created animatables
  93928. */
  93929. 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[];
  93930. /**
  93931. * Begin a new animation on a given node
  93932. * @param target defines the target where the animation will take place
  93933. * @param animations defines the list of animations to start
  93934. * @param from defines the initial value
  93935. * @param to defines the final value
  93936. * @param loop defines if you want animation to loop (off by default)
  93937. * @param speedRatio defines the speed ratio to apply to all animations
  93938. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93939. * @param onAnimationLoop defines the callback to call when an animation loops
  93940. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93941. * @returns the list of created animatables
  93942. */
  93943. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93944. /**
  93945. * Begin a new animation on a given node and its hierarchy
  93946. * @param target defines the root node where the animation will take place
  93947. * @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.
  93948. * @param animations defines the list of animations to start
  93949. * @param from defines the initial value
  93950. * @param to defines the final value
  93951. * @param loop defines if you want animation to loop (off by default)
  93952. * @param speedRatio defines the speed ratio to apply to all animations
  93953. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93954. * @param onAnimationLoop defines the callback to call when an animation loops
  93955. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93956. * @returns the list of animatables created for all nodes
  93957. */
  93958. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93959. /**
  93960. * Gets the animatable associated with a specific target
  93961. * @param target defines the target of the animatable
  93962. * @returns the required animatable if found
  93963. */
  93964. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93965. /**
  93966. * Gets all animatables associated with a given target
  93967. * @param target defines the target to look animatables for
  93968. * @returns an array of Animatables
  93969. */
  93970. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93971. /**
  93972. * Stops and removes all animations that have been applied to the scene
  93973. */
  93974. stopAllAnimations(): void;
  93975. /**
  93976. * Gets the current delta time used by animation engine
  93977. */
  93978. deltaTime: number;
  93979. }
  93980. interface Bone {
  93981. /**
  93982. * Copy an animation range from another bone
  93983. * @param source defines the source bone
  93984. * @param rangeName defines the range name to copy
  93985. * @param frameOffset defines the frame offset
  93986. * @param rescaleAsRequired defines if rescaling must be applied if required
  93987. * @param skelDimensionsRatio defines the scaling ratio
  93988. * @returns true if operation was successful
  93989. */
  93990. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93991. }
  93992. }
  93993. declare module BABYLON {
  93994. /**
  93995. * Class used to handle skinning animations
  93996. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93997. */
  93998. export class Skeleton implements IAnimatable {
  93999. /** defines the skeleton name */
  94000. name: string;
  94001. /** defines the skeleton Id */
  94002. id: string;
  94003. /**
  94004. * Defines the list of child bones
  94005. */
  94006. bones: Bone[];
  94007. /**
  94008. * Defines an estimate of the dimension of the skeleton at rest
  94009. */
  94010. dimensionsAtRest: Vector3;
  94011. /**
  94012. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94013. */
  94014. needInitialSkinMatrix: boolean;
  94015. /**
  94016. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94017. */
  94018. overrideMesh: Nullable<AbstractMesh>;
  94019. /**
  94020. * Gets the list of animations attached to this skeleton
  94021. */
  94022. animations: Array<Animation>;
  94023. private _scene;
  94024. private _isDirty;
  94025. private _transformMatrices;
  94026. private _transformMatrixTexture;
  94027. private _meshesWithPoseMatrix;
  94028. private _animatables;
  94029. private _identity;
  94030. private _synchronizedWithMesh;
  94031. private _ranges;
  94032. private _lastAbsoluteTransformsUpdateId;
  94033. private _canUseTextureForBones;
  94034. private _uniqueId;
  94035. /** @hidden */
  94036. _numBonesWithLinkedTransformNode: number;
  94037. /** @hidden */
  94038. _hasWaitingData: Nullable<boolean>;
  94039. /**
  94040. * Specifies if the skeleton should be serialized
  94041. */
  94042. doNotSerialize: boolean;
  94043. private _useTextureToStoreBoneMatrices;
  94044. /**
  94045. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94046. * Please note that this option is not available if the hardware does not support it
  94047. */
  94048. get useTextureToStoreBoneMatrices(): boolean;
  94049. set useTextureToStoreBoneMatrices(value: boolean);
  94050. private _animationPropertiesOverride;
  94051. /**
  94052. * Gets or sets the animation properties override
  94053. */
  94054. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94055. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94056. /**
  94057. * List of inspectable custom properties (used by the Inspector)
  94058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94059. */
  94060. inspectableCustomProperties: IInspectable[];
  94061. /**
  94062. * An observable triggered before computing the skeleton's matrices
  94063. */
  94064. onBeforeComputeObservable: Observable<Skeleton>;
  94065. /**
  94066. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94067. */
  94068. get isUsingTextureForMatrices(): boolean;
  94069. /**
  94070. * Gets the unique ID of this skeleton
  94071. */
  94072. get uniqueId(): number;
  94073. /**
  94074. * Creates a new skeleton
  94075. * @param name defines the skeleton name
  94076. * @param id defines the skeleton Id
  94077. * @param scene defines the hosting scene
  94078. */
  94079. constructor(
  94080. /** defines the skeleton name */
  94081. name: string,
  94082. /** defines the skeleton Id */
  94083. id: string, scene: Scene);
  94084. /**
  94085. * Gets the current object class name.
  94086. * @return the class name
  94087. */
  94088. getClassName(): string;
  94089. /**
  94090. * Returns an array containing the root bones
  94091. * @returns an array containing the root bones
  94092. */
  94093. getChildren(): Array<Bone>;
  94094. /**
  94095. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94096. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94097. * @returns a Float32Array containing matrices data
  94098. */
  94099. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94100. /**
  94101. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94102. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94103. * @returns a raw texture containing the data
  94104. */
  94105. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94106. /**
  94107. * Gets the current hosting scene
  94108. * @returns a scene object
  94109. */
  94110. getScene(): Scene;
  94111. /**
  94112. * Gets a string representing the current skeleton data
  94113. * @param fullDetails defines a boolean indicating if we want a verbose version
  94114. * @returns a string representing the current skeleton data
  94115. */
  94116. toString(fullDetails?: boolean): string;
  94117. /**
  94118. * Get bone's index searching by name
  94119. * @param name defines bone's name to search for
  94120. * @return the indice of the bone. Returns -1 if not found
  94121. */
  94122. getBoneIndexByName(name: string): number;
  94123. /**
  94124. * Creater a new animation range
  94125. * @param name defines the name of the range
  94126. * @param from defines the start key
  94127. * @param to defines the end key
  94128. */
  94129. createAnimationRange(name: string, from: number, to: number): void;
  94130. /**
  94131. * Delete a specific animation range
  94132. * @param name defines the name of the range
  94133. * @param deleteFrames defines if frames must be removed as well
  94134. */
  94135. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94136. /**
  94137. * Gets a specific animation range
  94138. * @param name defines the name of the range to look for
  94139. * @returns the requested animation range or null if not found
  94140. */
  94141. getAnimationRange(name: string): Nullable<AnimationRange>;
  94142. /**
  94143. * Gets the list of all animation ranges defined on this skeleton
  94144. * @returns an array
  94145. */
  94146. getAnimationRanges(): Nullable<AnimationRange>[];
  94147. /**
  94148. * Copy animation range from a source skeleton.
  94149. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94150. * @param source defines the source skeleton
  94151. * @param name defines the name of the range to copy
  94152. * @param rescaleAsRequired defines if rescaling must be applied if required
  94153. * @returns true if operation was successful
  94154. */
  94155. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94156. /**
  94157. * Forces the skeleton to go to rest pose
  94158. */
  94159. returnToRest(): void;
  94160. private _getHighestAnimationFrame;
  94161. /**
  94162. * Begin a specific animation range
  94163. * @param name defines the name of the range to start
  94164. * @param loop defines if looping must be turned on (false by default)
  94165. * @param speedRatio defines the speed ratio to apply (1 by default)
  94166. * @param onAnimationEnd defines a callback which will be called when animation will end
  94167. * @returns a new animatable
  94168. */
  94169. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94170. /**
  94171. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94172. * @param skeleton defines the Skeleton containing the animation range to convert
  94173. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94174. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94175. * @returns the original skeleton
  94176. */
  94177. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94178. /** @hidden */
  94179. _markAsDirty(): void;
  94180. /** @hidden */
  94181. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94182. /** @hidden */
  94183. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94184. private _computeTransformMatrices;
  94185. /**
  94186. * Build all resources required to render a skeleton
  94187. */
  94188. prepare(): void;
  94189. /**
  94190. * Gets the list of animatables currently running for this skeleton
  94191. * @returns an array of animatables
  94192. */
  94193. getAnimatables(): IAnimatable[];
  94194. /**
  94195. * Clone the current skeleton
  94196. * @param name defines the name of the new skeleton
  94197. * @param id defines the id of the new skeleton
  94198. * @returns the new skeleton
  94199. */
  94200. clone(name: string, id?: string): Skeleton;
  94201. /**
  94202. * Enable animation blending for this skeleton
  94203. * @param blendingSpeed defines the blending speed to apply
  94204. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94205. */
  94206. enableBlending(blendingSpeed?: number): void;
  94207. /**
  94208. * Releases all resources associated with the current skeleton
  94209. */
  94210. dispose(): void;
  94211. /**
  94212. * Serialize the skeleton in a JSON object
  94213. * @returns a JSON object
  94214. */
  94215. serialize(): any;
  94216. /**
  94217. * Creates a new skeleton from serialized data
  94218. * @param parsedSkeleton defines the serialized data
  94219. * @param scene defines the hosting scene
  94220. * @returns a new skeleton
  94221. */
  94222. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94223. /**
  94224. * Compute all node absolute transforms
  94225. * @param forceUpdate defines if computation must be done even if cache is up to date
  94226. */
  94227. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94228. /**
  94229. * Gets the root pose matrix
  94230. * @returns a matrix
  94231. */
  94232. getPoseMatrix(): Nullable<Matrix>;
  94233. /**
  94234. * Sorts bones per internal index
  94235. */
  94236. sortBones(): void;
  94237. private _sortBones;
  94238. }
  94239. }
  94240. declare module BABYLON {
  94241. /**
  94242. * Creates an instance based on a source mesh.
  94243. */
  94244. export class InstancedMesh extends AbstractMesh {
  94245. private _sourceMesh;
  94246. private _currentLOD;
  94247. /** @hidden */
  94248. _indexInSourceMeshInstanceArray: number;
  94249. constructor(name: string, source: Mesh);
  94250. /**
  94251. * Returns the string "InstancedMesh".
  94252. */
  94253. getClassName(): string;
  94254. /** Gets the list of lights affecting that mesh */
  94255. get lightSources(): Light[];
  94256. _resyncLightSources(): void;
  94257. _resyncLightSource(light: Light): void;
  94258. _removeLightSource(light: Light, dispose: boolean): void;
  94259. /**
  94260. * If the source mesh receives shadows
  94261. */
  94262. get receiveShadows(): boolean;
  94263. /**
  94264. * The material of the source mesh
  94265. */
  94266. get material(): Nullable<Material>;
  94267. /**
  94268. * Visibility of the source mesh
  94269. */
  94270. get visibility(): number;
  94271. /**
  94272. * Skeleton of the source mesh
  94273. */
  94274. get skeleton(): Nullable<Skeleton>;
  94275. /**
  94276. * Rendering ground id of the source mesh
  94277. */
  94278. get renderingGroupId(): number;
  94279. set renderingGroupId(value: number);
  94280. /**
  94281. * Returns the total number of vertices (integer).
  94282. */
  94283. getTotalVertices(): number;
  94284. /**
  94285. * Returns a positive integer : the total number of indices in this mesh geometry.
  94286. * @returns the numner of indices or zero if the mesh has no geometry.
  94287. */
  94288. getTotalIndices(): number;
  94289. /**
  94290. * The source mesh of the instance
  94291. */
  94292. get sourceMesh(): Mesh;
  94293. /**
  94294. * Creates a new InstancedMesh object from the mesh model.
  94295. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94296. * @param name defines the name of the new instance
  94297. * @returns a new InstancedMesh
  94298. */
  94299. createInstance(name: string): InstancedMesh;
  94300. /**
  94301. * Is this node ready to be used/rendered
  94302. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94303. * @return {boolean} is it ready
  94304. */
  94305. isReady(completeCheck?: boolean): boolean;
  94306. /**
  94307. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94308. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94309. * @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.
  94310. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94311. */
  94312. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94313. /**
  94314. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94315. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94316. * The `data` are either a numeric array either a Float32Array.
  94317. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94318. * 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).
  94319. * Note that a new underlying VertexBuffer object is created each call.
  94320. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94321. *
  94322. * Possible `kind` values :
  94323. * - VertexBuffer.PositionKind
  94324. * - VertexBuffer.UVKind
  94325. * - VertexBuffer.UV2Kind
  94326. * - VertexBuffer.UV3Kind
  94327. * - VertexBuffer.UV4Kind
  94328. * - VertexBuffer.UV5Kind
  94329. * - VertexBuffer.UV6Kind
  94330. * - VertexBuffer.ColorKind
  94331. * - VertexBuffer.MatricesIndicesKind
  94332. * - VertexBuffer.MatricesIndicesExtraKind
  94333. * - VertexBuffer.MatricesWeightsKind
  94334. * - VertexBuffer.MatricesWeightsExtraKind
  94335. *
  94336. * Returns the Mesh.
  94337. */
  94338. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94339. /**
  94340. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94341. * If the mesh has no geometry, it is simply returned as it is.
  94342. * The `data` are either a numeric array either a Float32Array.
  94343. * No new underlying VertexBuffer object is created.
  94344. * 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.
  94345. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94346. *
  94347. * Possible `kind` values :
  94348. * - VertexBuffer.PositionKind
  94349. * - VertexBuffer.UVKind
  94350. * - VertexBuffer.UV2Kind
  94351. * - VertexBuffer.UV3Kind
  94352. * - VertexBuffer.UV4Kind
  94353. * - VertexBuffer.UV5Kind
  94354. * - VertexBuffer.UV6Kind
  94355. * - VertexBuffer.ColorKind
  94356. * - VertexBuffer.MatricesIndicesKind
  94357. * - VertexBuffer.MatricesIndicesExtraKind
  94358. * - VertexBuffer.MatricesWeightsKind
  94359. * - VertexBuffer.MatricesWeightsExtraKind
  94360. *
  94361. * Returns the Mesh.
  94362. */
  94363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94364. /**
  94365. * Sets the mesh indices.
  94366. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94367. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94368. * This method creates a new index buffer each call.
  94369. * Returns the Mesh.
  94370. */
  94371. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94372. /**
  94373. * Boolean : True if the mesh owns the requested kind of data.
  94374. */
  94375. isVerticesDataPresent(kind: string): boolean;
  94376. /**
  94377. * Returns an array of indices (IndicesArray).
  94378. */
  94379. getIndices(): Nullable<IndicesArray>;
  94380. get _positions(): Nullable<Vector3[]>;
  94381. /**
  94382. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94383. * This means the mesh underlying bounding box and sphere are recomputed.
  94384. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94385. * @returns the current mesh
  94386. */
  94387. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94388. /** @hidden */
  94389. _preActivate(): InstancedMesh;
  94390. /** @hidden */
  94391. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94392. /** @hidden */
  94393. _postActivate(): void;
  94394. getWorldMatrix(): Matrix;
  94395. get isAnInstance(): boolean;
  94396. /**
  94397. * Returns the current associated LOD AbstractMesh.
  94398. */
  94399. getLOD(camera: Camera): AbstractMesh;
  94400. /** @hidden */
  94401. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94402. /** @hidden */
  94403. _syncSubMeshes(): InstancedMesh;
  94404. /** @hidden */
  94405. _generatePointsArray(): boolean;
  94406. /**
  94407. * Creates a new InstancedMesh from the current mesh.
  94408. * - name (string) : the cloned mesh name
  94409. * - newParent (optional Node) : the optional Node to parent the clone to.
  94410. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94411. *
  94412. * Returns the clone.
  94413. */
  94414. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94415. /**
  94416. * Disposes the InstancedMesh.
  94417. * Returns nothing.
  94418. */
  94419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94420. }
  94421. interface Mesh {
  94422. /**
  94423. * Register a custom buffer that will be instanced
  94424. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94425. * @param kind defines the buffer kind
  94426. * @param stride defines the stride in floats
  94427. */
  94428. registerInstancedBuffer(kind: string, stride: number): void;
  94429. /**
  94430. * true to use the edge renderer for all instances of this mesh
  94431. */
  94432. edgesShareWithInstances: boolean;
  94433. /** @hidden */
  94434. _userInstancedBuffersStorage: {
  94435. data: {
  94436. [key: string]: Float32Array;
  94437. };
  94438. sizes: {
  94439. [key: string]: number;
  94440. };
  94441. vertexBuffers: {
  94442. [key: string]: Nullable<VertexBuffer>;
  94443. };
  94444. strides: {
  94445. [key: string]: number;
  94446. };
  94447. };
  94448. }
  94449. interface AbstractMesh {
  94450. /**
  94451. * Object used to store instanced buffers defined by user
  94452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94453. */
  94454. instancedBuffers: {
  94455. [key: string]: any;
  94456. };
  94457. }
  94458. }
  94459. declare module BABYLON {
  94460. /**
  94461. * Defines the options associated with the creation of a shader material.
  94462. */
  94463. export interface IShaderMaterialOptions {
  94464. /**
  94465. * Does the material work in alpha blend mode
  94466. */
  94467. needAlphaBlending: boolean;
  94468. /**
  94469. * Does the material work in alpha test mode
  94470. */
  94471. needAlphaTesting: boolean;
  94472. /**
  94473. * The list of attribute names used in the shader
  94474. */
  94475. attributes: string[];
  94476. /**
  94477. * The list of unifrom names used in the shader
  94478. */
  94479. uniforms: string[];
  94480. /**
  94481. * The list of UBO names used in the shader
  94482. */
  94483. uniformBuffers: string[];
  94484. /**
  94485. * The list of sampler names used in the shader
  94486. */
  94487. samplers: string[];
  94488. /**
  94489. * The list of defines used in the shader
  94490. */
  94491. defines: string[];
  94492. }
  94493. /**
  94494. * 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.
  94495. *
  94496. * This returned material effects how the mesh will look based on the code in the shaders.
  94497. *
  94498. * @see https://doc.babylonjs.com/how_to/shader_material
  94499. */
  94500. export class ShaderMaterial extends Material {
  94501. private _shaderPath;
  94502. private _options;
  94503. private _textures;
  94504. private _textureArrays;
  94505. private _floats;
  94506. private _ints;
  94507. private _floatsArrays;
  94508. private _colors3;
  94509. private _colors3Arrays;
  94510. private _colors4;
  94511. private _colors4Arrays;
  94512. private _vectors2;
  94513. private _vectors3;
  94514. private _vectors4;
  94515. private _matrices;
  94516. private _matrixArrays;
  94517. private _matrices3x3;
  94518. private _matrices2x2;
  94519. private _vectors2Arrays;
  94520. private _vectors3Arrays;
  94521. private _vectors4Arrays;
  94522. private _cachedWorldViewMatrix;
  94523. private _cachedWorldViewProjectionMatrix;
  94524. private _renderId;
  94525. private _multiview;
  94526. private _cachedDefines;
  94527. /** Define the Url to load snippets */
  94528. static SnippetUrl: string;
  94529. /** Snippet ID if the material was created from the snippet server */
  94530. snippetId: string;
  94531. /**
  94532. * Instantiate a new shader material.
  94533. * 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.
  94534. * This returned material effects how the mesh will look based on the code in the shaders.
  94535. * @see https://doc.babylonjs.com/how_to/shader_material
  94536. * @param name Define the name of the material in the scene
  94537. * @param scene Define the scene the material belongs to
  94538. * @param shaderPath Defines the route to the shader code in one of three ways:
  94539. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94540. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94541. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94542. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94543. * @param options Define the options used to create the shader
  94544. */
  94545. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94546. /**
  94547. * Gets the shader path used to define the shader code
  94548. * It can be modified to trigger a new compilation
  94549. */
  94550. get shaderPath(): any;
  94551. /**
  94552. * Sets the shader path used to define the shader code
  94553. * It can be modified to trigger a new compilation
  94554. */
  94555. set shaderPath(shaderPath: any);
  94556. /**
  94557. * Gets the options used to compile the shader.
  94558. * They can be modified to trigger a new compilation
  94559. */
  94560. get options(): IShaderMaterialOptions;
  94561. /**
  94562. * Gets the current class name of the material e.g. "ShaderMaterial"
  94563. * Mainly use in serialization.
  94564. * @returns the class name
  94565. */
  94566. getClassName(): string;
  94567. /**
  94568. * Specifies if the material will require alpha blending
  94569. * @returns a boolean specifying if alpha blending is needed
  94570. */
  94571. needAlphaBlending(): boolean;
  94572. /**
  94573. * Specifies if this material should be rendered in alpha test mode
  94574. * @returns a boolean specifying if an alpha test is needed.
  94575. */
  94576. needAlphaTesting(): boolean;
  94577. private _checkUniform;
  94578. /**
  94579. * Set a texture in the shader.
  94580. * @param name Define the name of the uniform samplers as defined in the shader
  94581. * @param texture Define the texture to bind to this sampler
  94582. * @return the material itself allowing "fluent" like uniform updates
  94583. */
  94584. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94585. /**
  94586. * Set a texture array in the shader.
  94587. * @param name Define the name of the uniform sampler array as defined in the shader
  94588. * @param textures Define the list of textures to bind to this sampler
  94589. * @return the material itself allowing "fluent" like uniform updates
  94590. */
  94591. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94592. /**
  94593. * Set a float in the shader.
  94594. * @param name Define the name of the uniform as defined in the shader
  94595. * @param value Define the value to give to the uniform
  94596. * @return the material itself allowing "fluent" like uniform updates
  94597. */
  94598. setFloat(name: string, value: number): ShaderMaterial;
  94599. /**
  94600. * Set a int in the shader.
  94601. * @param name Define the name of the uniform as defined in the shader
  94602. * @param value Define the value to give to the uniform
  94603. * @return the material itself allowing "fluent" like uniform updates
  94604. */
  94605. setInt(name: string, value: number): ShaderMaterial;
  94606. /**
  94607. * Set an array of floats in the shader.
  94608. * @param name Define the name of the uniform as defined in the shader
  94609. * @param value Define the value to give to the uniform
  94610. * @return the material itself allowing "fluent" like uniform updates
  94611. */
  94612. setFloats(name: string, value: number[]): ShaderMaterial;
  94613. /**
  94614. * Set a vec3 in the shader from a Color3.
  94615. * @param name Define the name of the uniform as defined in the shader
  94616. * @param value Define the value to give to the uniform
  94617. * @return the material itself allowing "fluent" like uniform updates
  94618. */
  94619. setColor3(name: string, value: Color3): ShaderMaterial;
  94620. /**
  94621. * Set a vec3 array in the shader from a Color3 array.
  94622. * @param name Define the name of the uniform as defined in the shader
  94623. * @param value Define the value to give to the uniform
  94624. * @return the material itself allowing "fluent" like uniform updates
  94625. */
  94626. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94627. /**
  94628. * Set a vec4 in the shader from a Color4.
  94629. * @param name Define the name of the uniform as defined in the shader
  94630. * @param value Define the value to give to the uniform
  94631. * @return the material itself allowing "fluent" like uniform updates
  94632. */
  94633. setColor4(name: string, value: Color4): ShaderMaterial;
  94634. /**
  94635. * Set a vec4 array in the shader from a Color4 array.
  94636. * @param name Define the name of the uniform as defined in the shader
  94637. * @param value Define the value to give to the uniform
  94638. * @return the material itself allowing "fluent" like uniform updates
  94639. */
  94640. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94641. /**
  94642. * Set a vec2 in the shader from a Vector2.
  94643. * @param name Define the name of the uniform as defined in the shader
  94644. * @param value Define the value to give to the uniform
  94645. * @return the material itself allowing "fluent" like uniform updates
  94646. */
  94647. setVector2(name: string, value: Vector2): ShaderMaterial;
  94648. /**
  94649. * Set a vec3 in the shader from a Vector3.
  94650. * @param name Define the name of the uniform as defined in the shader
  94651. * @param value Define the value to give to the uniform
  94652. * @return the material itself allowing "fluent" like uniform updates
  94653. */
  94654. setVector3(name: string, value: Vector3): ShaderMaterial;
  94655. /**
  94656. * Set a vec4 in the shader from a Vector4.
  94657. * @param name Define the name of the uniform as defined in the shader
  94658. * @param value Define the value to give to the uniform
  94659. * @return the material itself allowing "fluent" like uniform updates
  94660. */
  94661. setVector4(name: string, value: Vector4): ShaderMaterial;
  94662. /**
  94663. * Set a mat4 in the shader from a Matrix.
  94664. * @param name Define the name of the uniform as defined in the shader
  94665. * @param value Define the value to give to the uniform
  94666. * @return the material itself allowing "fluent" like uniform updates
  94667. */
  94668. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94669. /**
  94670. * Set a float32Array in the shader from a matrix array.
  94671. * @param name Define the name of the uniform as defined in the shader
  94672. * @param value Define the value to give to the uniform
  94673. * @return the material itself allowing "fluent" like uniform updates
  94674. */
  94675. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94676. /**
  94677. * Set a mat3 in the shader from a Float32Array.
  94678. * @param name Define the name of the uniform as defined in the shader
  94679. * @param value Define the value to give to the uniform
  94680. * @return the material itself allowing "fluent" like uniform updates
  94681. */
  94682. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94683. /**
  94684. * Set a mat2 in the shader from a Float32Array.
  94685. * @param name Define the name of the uniform as defined in the shader
  94686. * @param value Define the value to give to the uniform
  94687. * @return the material itself allowing "fluent" like uniform updates
  94688. */
  94689. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94690. /**
  94691. * Set a vec2 array in the shader from a number array.
  94692. * @param name Define the name of the uniform as defined in the shader
  94693. * @param value Define the value to give to the uniform
  94694. * @return the material itself allowing "fluent" like uniform updates
  94695. */
  94696. setArray2(name: string, value: number[]): ShaderMaterial;
  94697. /**
  94698. * Set a vec3 array in the shader from a number array.
  94699. * @param name Define the name of the uniform as defined in the shader
  94700. * @param value Define the value to give to the uniform
  94701. * @return the material itself allowing "fluent" like uniform updates
  94702. */
  94703. setArray3(name: string, value: number[]): ShaderMaterial;
  94704. /**
  94705. * Set a vec4 array in the shader from a number array.
  94706. * @param name Define the name of the uniform as defined in the shader
  94707. * @param value Define the value to give to the uniform
  94708. * @return the material itself allowing "fluent" like uniform updates
  94709. */
  94710. setArray4(name: string, value: number[]): ShaderMaterial;
  94711. private _checkCache;
  94712. /**
  94713. * Specifies that the submesh is ready to be used
  94714. * @param mesh defines the mesh to check
  94715. * @param subMesh defines which submesh to check
  94716. * @param useInstances specifies that instances should be used
  94717. * @returns a boolean indicating that the submesh is ready or not
  94718. */
  94719. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94720. /**
  94721. * Checks if the material is ready to render the requested mesh
  94722. * @param mesh Define the mesh to render
  94723. * @param useInstances Define whether or not the material is used with instances
  94724. * @returns true if ready, otherwise false
  94725. */
  94726. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94727. /**
  94728. * Binds the world matrix to the material
  94729. * @param world defines the world transformation matrix
  94730. * @param effectOverride - If provided, use this effect instead of internal effect
  94731. */
  94732. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94733. /**
  94734. * Binds the submesh to this material by preparing the effect and shader to draw
  94735. * @param world defines the world transformation matrix
  94736. * @param mesh defines the mesh containing the submesh
  94737. * @param subMesh defines the submesh to bind the material to
  94738. */
  94739. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94740. /**
  94741. * Binds the material to the mesh
  94742. * @param world defines the world transformation matrix
  94743. * @param mesh defines the mesh to bind the material to
  94744. * @param effectOverride - If provided, use this effect instead of internal effect
  94745. */
  94746. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94747. protected _afterBind(mesh?: Mesh): void;
  94748. /**
  94749. * Gets the active textures from the material
  94750. * @returns an array of textures
  94751. */
  94752. getActiveTextures(): BaseTexture[];
  94753. /**
  94754. * Specifies if the material uses a texture
  94755. * @param texture defines the texture to check against the material
  94756. * @returns a boolean specifying if the material uses the texture
  94757. */
  94758. hasTexture(texture: BaseTexture): boolean;
  94759. /**
  94760. * Makes a duplicate of the material, and gives it a new name
  94761. * @param name defines the new name for the duplicated material
  94762. * @returns the cloned material
  94763. */
  94764. clone(name: string): ShaderMaterial;
  94765. /**
  94766. * Disposes the material
  94767. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94768. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94769. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94770. */
  94771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94772. /**
  94773. * Serializes this material in a JSON representation
  94774. * @returns the serialized material object
  94775. */
  94776. serialize(): any;
  94777. /**
  94778. * Creates a shader material from parsed shader material data
  94779. * @param source defines the JSON represnetation of the material
  94780. * @param scene defines the hosting scene
  94781. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94782. * @returns a new material
  94783. */
  94784. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94785. /**
  94786. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94787. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94788. * @param url defines the url to load from
  94789. * @param scene defines the hosting scene
  94790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94791. * @returns a promise that will resolve to the new ShaderMaterial
  94792. */
  94793. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94794. /**
  94795. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94796. * @param snippetId defines the snippet to load
  94797. * @param scene defines the hosting scene
  94798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94799. * @returns a promise that will resolve to the new ShaderMaterial
  94800. */
  94801. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94802. }
  94803. }
  94804. declare module BABYLON {
  94805. /** @hidden */
  94806. export var colorPixelShader: {
  94807. name: string;
  94808. shader: string;
  94809. };
  94810. }
  94811. declare module BABYLON {
  94812. /** @hidden */
  94813. export var colorVertexShader: {
  94814. name: string;
  94815. shader: string;
  94816. };
  94817. }
  94818. declare module BABYLON {
  94819. /**
  94820. * Line mesh
  94821. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94822. */
  94823. export class LinesMesh extends Mesh {
  94824. /**
  94825. * If vertex color should be applied to the mesh
  94826. */
  94827. readonly useVertexColor?: boolean | undefined;
  94828. /**
  94829. * If vertex alpha should be applied to the mesh
  94830. */
  94831. readonly useVertexAlpha?: boolean | undefined;
  94832. /**
  94833. * Color of the line (Default: White)
  94834. */
  94835. color: Color3;
  94836. /**
  94837. * Alpha of the line (Default: 1)
  94838. */
  94839. alpha: number;
  94840. /**
  94841. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94842. * This margin is expressed in world space coordinates, so its value may vary.
  94843. * Default value is 0.1
  94844. */
  94845. intersectionThreshold: number;
  94846. private _colorShader;
  94847. private color4;
  94848. /**
  94849. * Creates a new LinesMesh
  94850. * @param name defines the name
  94851. * @param scene defines the hosting scene
  94852. * @param parent defines the parent mesh if any
  94853. * @param source defines the optional source LinesMesh used to clone data from
  94854. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94855. * When false, achieved by calling a clone(), also passing False.
  94856. * This will make creation of children, recursive.
  94857. * @param useVertexColor defines if this LinesMesh supports vertex color
  94858. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94859. */
  94860. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94861. /**
  94862. * If vertex color should be applied to the mesh
  94863. */
  94864. useVertexColor?: boolean | undefined,
  94865. /**
  94866. * If vertex alpha should be applied to the mesh
  94867. */
  94868. useVertexAlpha?: boolean | undefined);
  94869. private _addClipPlaneDefine;
  94870. private _removeClipPlaneDefine;
  94871. isReady(): boolean;
  94872. /**
  94873. * Returns the string "LineMesh"
  94874. */
  94875. getClassName(): string;
  94876. /**
  94877. * @hidden
  94878. */
  94879. get material(): Material;
  94880. /**
  94881. * @hidden
  94882. */
  94883. set material(value: Material);
  94884. /**
  94885. * @hidden
  94886. */
  94887. get checkCollisions(): boolean;
  94888. /** @hidden */
  94889. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94890. /** @hidden */
  94891. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94892. /**
  94893. * Disposes of the line mesh
  94894. * @param doNotRecurse If children should be disposed
  94895. */
  94896. dispose(doNotRecurse?: boolean): void;
  94897. /**
  94898. * Returns a new LineMesh object cloned from the current one.
  94899. */
  94900. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94901. /**
  94902. * Creates a new InstancedLinesMesh object from the mesh model.
  94903. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94904. * @param name defines the name of the new instance
  94905. * @returns a new InstancedLinesMesh
  94906. */
  94907. createInstance(name: string): InstancedLinesMesh;
  94908. }
  94909. /**
  94910. * Creates an instance based on a source LinesMesh
  94911. */
  94912. export class InstancedLinesMesh extends InstancedMesh {
  94913. /**
  94914. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94915. * This margin is expressed in world space coordinates, so its value may vary.
  94916. * Initilized with the intersectionThreshold value of the source LinesMesh
  94917. */
  94918. intersectionThreshold: number;
  94919. constructor(name: string, source: LinesMesh);
  94920. /**
  94921. * Returns the string "InstancedLinesMesh".
  94922. */
  94923. getClassName(): string;
  94924. }
  94925. }
  94926. declare module BABYLON {
  94927. /** @hidden */
  94928. export var linePixelShader: {
  94929. name: string;
  94930. shader: string;
  94931. };
  94932. }
  94933. declare module BABYLON {
  94934. /** @hidden */
  94935. export var lineVertexShader: {
  94936. name: string;
  94937. shader: string;
  94938. };
  94939. }
  94940. declare module BABYLON {
  94941. interface Scene {
  94942. /** @hidden */
  94943. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94944. }
  94945. interface AbstractMesh {
  94946. /**
  94947. * Gets the edgesRenderer associated with the mesh
  94948. */
  94949. edgesRenderer: Nullable<EdgesRenderer>;
  94950. }
  94951. interface LinesMesh {
  94952. /**
  94953. * Enables the edge rendering mode on the mesh.
  94954. * This mode makes the mesh edges visible
  94955. * @param epsilon defines the maximal distance between two angles to detect a face
  94956. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94957. * @returns the currentAbstractMesh
  94958. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94959. */
  94960. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94961. }
  94962. interface InstancedLinesMesh {
  94963. /**
  94964. * Enables the edge rendering mode on the mesh.
  94965. * This mode makes the mesh edges visible
  94966. * @param epsilon defines the maximal distance between two angles to detect a face
  94967. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94968. * @returns the current InstancedLinesMesh
  94969. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94970. */
  94971. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94972. }
  94973. /**
  94974. * Defines the minimum contract an Edges renderer should follow.
  94975. */
  94976. export interface IEdgesRenderer extends IDisposable {
  94977. /**
  94978. * Gets or sets a boolean indicating if the edgesRenderer is active
  94979. */
  94980. isEnabled: boolean;
  94981. /**
  94982. * Renders the edges of the attached mesh,
  94983. */
  94984. render(): void;
  94985. /**
  94986. * Checks wether or not the edges renderer is ready to render.
  94987. * @return true if ready, otherwise false.
  94988. */
  94989. isReady(): boolean;
  94990. /**
  94991. * List of instances to render in case the source mesh has instances
  94992. */
  94993. customInstances: SmartArray<Matrix>;
  94994. }
  94995. /**
  94996. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94997. */
  94998. export class EdgesRenderer implements IEdgesRenderer {
  94999. /**
  95000. * Define the size of the edges with an orthographic camera
  95001. */
  95002. edgesWidthScalerForOrthographic: number;
  95003. /**
  95004. * Define the size of the edges with a perspective camera
  95005. */
  95006. edgesWidthScalerForPerspective: number;
  95007. protected _source: AbstractMesh;
  95008. protected _linesPositions: number[];
  95009. protected _linesNormals: number[];
  95010. protected _linesIndices: number[];
  95011. protected _epsilon: number;
  95012. protected _indicesCount: number;
  95013. protected _lineShader: ShaderMaterial;
  95014. protected _ib: DataBuffer;
  95015. protected _buffers: {
  95016. [key: string]: Nullable<VertexBuffer>;
  95017. };
  95018. protected _buffersForInstances: {
  95019. [key: string]: Nullable<VertexBuffer>;
  95020. };
  95021. protected _checkVerticesInsteadOfIndices: boolean;
  95022. private _meshRebuildObserver;
  95023. private _meshDisposeObserver;
  95024. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95025. isEnabled: boolean;
  95026. /**
  95027. * List of instances to render in case the source mesh has instances
  95028. */
  95029. customInstances: SmartArray<Matrix>;
  95030. private static GetShader;
  95031. /**
  95032. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95033. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95034. * @param source Mesh used to create edges
  95035. * @param epsilon sum of angles in adjacency to check for edge
  95036. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  95037. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95038. */
  95039. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  95040. protected _prepareRessources(): void;
  95041. /** @hidden */
  95042. _rebuild(): void;
  95043. /**
  95044. * Releases the required resources for the edges renderer
  95045. */
  95046. dispose(): void;
  95047. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95048. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95049. /**
  95050. * Checks if the pair of p0 and p1 is en edge
  95051. * @param faceIndex
  95052. * @param edge
  95053. * @param faceNormals
  95054. * @param p0
  95055. * @param p1
  95056. * @private
  95057. */
  95058. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95059. /**
  95060. * push line into the position, normal and index buffer
  95061. * @protected
  95062. */
  95063. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95064. /**
  95065. * Generates lines edges from adjacencjes
  95066. * @private
  95067. */
  95068. _generateEdgesLines(): void;
  95069. /**
  95070. * Checks wether or not the edges renderer is ready to render.
  95071. * @return true if ready, otherwise false.
  95072. */
  95073. isReady(): boolean;
  95074. /**
  95075. * Renders the edges of the attached mesh,
  95076. */
  95077. render(): void;
  95078. }
  95079. /**
  95080. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95081. */
  95082. export class LineEdgesRenderer extends EdgesRenderer {
  95083. /**
  95084. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95085. * @param source LineMesh used to generate edges
  95086. * @param epsilon not important (specified angle for edge detection)
  95087. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95088. */
  95089. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95090. /**
  95091. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95092. */
  95093. _generateEdgesLines(): void;
  95094. }
  95095. }
  95096. declare module BABYLON {
  95097. /**
  95098. * This represents the object necessary to create a rendering group.
  95099. * This is exclusively used and created by the rendering manager.
  95100. * To modify the behavior, you use the available helpers in your scene or meshes.
  95101. * @hidden
  95102. */
  95103. export class RenderingGroup {
  95104. index: number;
  95105. private static _zeroVector;
  95106. private _scene;
  95107. private _opaqueSubMeshes;
  95108. private _transparentSubMeshes;
  95109. private _alphaTestSubMeshes;
  95110. private _depthOnlySubMeshes;
  95111. private _particleSystems;
  95112. private _spriteManagers;
  95113. private _opaqueSortCompareFn;
  95114. private _alphaTestSortCompareFn;
  95115. private _transparentSortCompareFn;
  95116. private _renderOpaque;
  95117. private _renderAlphaTest;
  95118. private _renderTransparent;
  95119. /** @hidden */
  95120. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95121. onBeforeTransparentRendering: () => void;
  95122. /**
  95123. * Set the opaque sort comparison function.
  95124. * If null the sub meshes will be render in the order they were created
  95125. */
  95126. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95127. /**
  95128. * Set the alpha test sort comparison function.
  95129. * If null the sub meshes will be render in the order they were created
  95130. */
  95131. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95132. /**
  95133. * Set the transparent sort comparison function.
  95134. * If null the sub meshes will be render in the order they were created
  95135. */
  95136. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95137. /**
  95138. * Creates a new rendering group.
  95139. * @param index The rendering group index
  95140. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95141. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95142. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95143. */
  95144. 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>);
  95145. /**
  95146. * Render all the sub meshes contained in the group.
  95147. * @param customRenderFunction Used to override the default render behaviour of the group.
  95148. * @returns true if rendered some submeshes.
  95149. */
  95150. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95151. /**
  95152. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95153. * @param subMeshes The submeshes to render
  95154. */
  95155. private renderOpaqueSorted;
  95156. /**
  95157. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95158. * @param subMeshes The submeshes to render
  95159. */
  95160. private renderAlphaTestSorted;
  95161. /**
  95162. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95163. * @param subMeshes The submeshes to render
  95164. */
  95165. private renderTransparentSorted;
  95166. /**
  95167. * Renders the submeshes in a specified order.
  95168. * @param subMeshes The submeshes to sort before render
  95169. * @param sortCompareFn The comparison function use to sort
  95170. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95171. * @param transparent Specifies to activate blending if true
  95172. */
  95173. private static renderSorted;
  95174. /**
  95175. * Renders the submeshes in the order they were dispatched (no sort applied).
  95176. * @param subMeshes The submeshes to render
  95177. */
  95178. private static renderUnsorted;
  95179. /**
  95180. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95181. * are rendered back to front if in the same alpha index.
  95182. *
  95183. * @param a The first submesh
  95184. * @param b The second submesh
  95185. * @returns The result of the comparison
  95186. */
  95187. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95188. /**
  95189. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95190. * are rendered back to front.
  95191. *
  95192. * @param a The first submesh
  95193. * @param b The second submesh
  95194. * @returns The result of the comparison
  95195. */
  95196. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95197. /**
  95198. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95199. * are rendered front to back (prevent overdraw).
  95200. *
  95201. * @param a The first submesh
  95202. * @param b The second submesh
  95203. * @returns The result of the comparison
  95204. */
  95205. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95206. /**
  95207. * Resets the different lists of submeshes to prepare a new frame.
  95208. */
  95209. prepare(): void;
  95210. dispose(): void;
  95211. /**
  95212. * Inserts the submesh in its correct queue depending on its material.
  95213. * @param subMesh The submesh to dispatch
  95214. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95215. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95216. */
  95217. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95218. dispatchSprites(spriteManager: ISpriteManager): void;
  95219. dispatchParticles(particleSystem: IParticleSystem): void;
  95220. private _renderParticles;
  95221. private _renderSprites;
  95222. }
  95223. }
  95224. declare module BABYLON {
  95225. /**
  95226. * Interface describing the different options available in the rendering manager
  95227. * regarding Auto Clear between groups.
  95228. */
  95229. export interface IRenderingManagerAutoClearSetup {
  95230. /**
  95231. * Defines whether or not autoclear is enable.
  95232. */
  95233. autoClear: boolean;
  95234. /**
  95235. * Defines whether or not to autoclear the depth buffer.
  95236. */
  95237. depth: boolean;
  95238. /**
  95239. * Defines whether or not to autoclear the stencil buffer.
  95240. */
  95241. stencil: boolean;
  95242. }
  95243. /**
  95244. * This class is used by the onRenderingGroupObservable
  95245. */
  95246. export class RenderingGroupInfo {
  95247. /**
  95248. * The Scene that being rendered
  95249. */
  95250. scene: Scene;
  95251. /**
  95252. * The camera currently used for the rendering pass
  95253. */
  95254. camera: Nullable<Camera>;
  95255. /**
  95256. * The ID of the renderingGroup being processed
  95257. */
  95258. renderingGroupId: number;
  95259. }
  95260. /**
  95261. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95262. * It is enable to manage the different groups as well as the different necessary sort functions.
  95263. * This should not be used directly aside of the few static configurations
  95264. */
  95265. export class RenderingManager {
  95266. /**
  95267. * The max id used for rendering groups (not included)
  95268. */
  95269. static MAX_RENDERINGGROUPS: number;
  95270. /**
  95271. * The min id used for rendering groups (included)
  95272. */
  95273. static MIN_RENDERINGGROUPS: number;
  95274. /**
  95275. * Used to globally prevent autoclearing scenes.
  95276. */
  95277. static AUTOCLEAR: boolean;
  95278. /**
  95279. * @hidden
  95280. */
  95281. _useSceneAutoClearSetup: boolean;
  95282. private _scene;
  95283. private _renderingGroups;
  95284. private _depthStencilBufferAlreadyCleaned;
  95285. private _autoClearDepthStencil;
  95286. private _customOpaqueSortCompareFn;
  95287. private _customAlphaTestSortCompareFn;
  95288. private _customTransparentSortCompareFn;
  95289. private _renderingGroupInfo;
  95290. /**
  95291. * Instantiates a new rendering group for a particular scene
  95292. * @param scene Defines the scene the groups belongs to
  95293. */
  95294. constructor(scene: Scene);
  95295. private _clearDepthStencilBuffer;
  95296. /**
  95297. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95298. * @hidden
  95299. */
  95300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95301. /**
  95302. * Resets the different information of the group to prepare a new frame
  95303. * @hidden
  95304. */
  95305. reset(): void;
  95306. /**
  95307. * Dispose and release the group and its associated resources.
  95308. * @hidden
  95309. */
  95310. dispose(): void;
  95311. /**
  95312. * Clear the info related to rendering groups preventing retention points during dispose.
  95313. */
  95314. freeRenderingGroups(): void;
  95315. private _prepareRenderingGroup;
  95316. /**
  95317. * Add a sprite manager to the rendering manager in order to render it this frame.
  95318. * @param spriteManager Define the sprite manager to render
  95319. */
  95320. dispatchSprites(spriteManager: ISpriteManager): void;
  95321. /**
  95322. * Add a particle system to the rendering manager in order to render it this frame.
  95323. * @param particleSystem Define the particle system to render
  95324. */
  95325. dispatchParticles(particleSystem: IParticleSystem): void;
  95326. /**
  95327. * Add a submesh to the manager in order to render it this frame
  95328. * @param subMesh The submesh to dispatch
  95329. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95330. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95331. */
  95332. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95333. /**
  95334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95335. * This allowed control for front to back rendering or reversly depending of the special needs.
  95336. *
  95337. * @param renderingGroupId The rendering group id corresponding to its index
  95338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95341. */
  95342. 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;
  95343. /**
  95344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95345. *
  95346. * @param renderingGroupId The rendering group id corresponding to its index
  95347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95348. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95349. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95350. */
  95351. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95352. /**
  95353. * Gets the current auto clear configuration for one rendering group of the rendering
  95354. * manager.
  95355. * @param index the rendering group index to get the information for
  95356. * @returns The auto clear setup for the requested rendering group
  95357. */
  95358. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95359. }
  95360. }
  95361. declare module BABYLON {
  95362. /**
  95363. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95364. */
  95365. export interface ICustomShaderOptions {
  95366. /**
  95367. * Gets or sets the custom shader name to use
  95368. */
  95369. shaderName: string;
  95370. /**
  95371. * The list of attribute names used in the shader
  95372. */
  95373. attributes?: string[];
  95374. /**
  95375. * The list of unifrom names used in the shader
  95376. */
  95377. uniforms?: string[];
  95378. /**
  95379. * The list of sampler names used in the shader
  95380. */
  95381. samplers?: string[];
  95382. /**
  95383. * The list of defines used in the shader
  95384. */
  95385. defines?: string[];
  95386. }
  95387. /**
  95388. * Interface to implement to create a shadow generator compatible with BJS.
  95389. */
  95390. export interface IShadowGenerator {
  95391. /**
  95392. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95393. * @returns The render target texture if present otherwise, null
  95394. */
  95395. getShadowMap(): Nullable<RenderTargetTexture>;
  95396. /**
  95397. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95398. * @param subMesh The submesh we want to render in the shadow map
  95399. * @param useInstances Defines wether will draw in the map using instances
  95400. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95401. * @returns true if ready otherwise, false
  95402. */
  95403. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95404. /**
  95405. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95406. * @param defines Defines of the material we want to update
  95407. * @param lightIndex Index of the light in the enabled light list of the material
  95408. */
  95409. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95410. /**
  95411. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95412. * defined in the generator but impacting the effect).
  95413. * It implies the unifroms available on the materials are the standard BJS ones.
  95414. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95415. * @param effect The effect we are binfing the information for
  95416. */
  95417. bindShadowLight(lightIndex: string, effect: Effect): void;
  95418. /**
  95419. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95420. * (eq to shadow prjection matrix * light transform matrix)
  95421. * @returns The transform matrix used to create the shadow map
  95422. */
  95423. getTransformMatrix(): Matrix;
  95424. /**
  95425. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95426. * Cube and 2D textures for instance.
  95427. */
  95428. recreateShadowMap(): void;
  95429. /**
  95430. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95431. * @param onCompiled Callback triggered at the and of the effects compilation
  95432. * @param options Sets of optional options forcing the compilation with different modes
  95433. */
  95434. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95435. useInstances: boolean;
  95436. }>): void;
  95437. /**
  95438. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95439. * @param options Sets of optional options forcing the compilation with different modes
  95440. * @returns A promise that resolves when the compilation completes
  95441. */
  95442. forceCompilationAsync(options?: Partial<{
  95443. useInstances: boolean;
  95444. }>): Promise<void>;
  95445. /**
  95446. * Serializes the shadow generator setup to a json object.
  95447. * @returns The serialized JSON object
  95448. */
  95449. serialize(): any;
  95450. /**
  95451. * Disposes the Shadow map and related Textures and effects.
  95452. */
  95453. dispose(): void;
  95454. }
  95455. /**
  95456. * Default implementation IShadowGenerator.
  95457. * This is the main object responsible of generating shadows in the framework.
  95458. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95459. */
  95460. export class ShadowGenerator implements IShadowGenerator {
  95461. /**
  95462. * Name of the shadow generator class
  95463. */
  95464. static CLASSNAME: string;
  95465. /**
  95466. * Shadow generator mode None: no filtering applied.
  95467. */
  95468. static readonly FILTER_NONE: number;
  95469. /**
  95470. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95471. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95472. */
  95473. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95474. /**
  95475. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95476. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95477. */
  95478. static readonly FILTER_POISSONSAMPLING: number;
  95479. /**
  95480. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95481. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95482. */
  95483. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95484. /**
  95485. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95486. * edge artifacts on steep falloff.
  95487. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95488. */
  95489. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95490. /**
  95491. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95492. * edge artifacts on steep falloff.
  95493. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95494. */
  95495. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95496. /**
  95497. * Shadow generator mode PCF: Percentage Closer Filtering
  95498. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95499. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95500. */
  95501. static readonly FILTER_PCF: number;
  95502. /**
  95503. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95504. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95505. * Contact Hardening
  95506. */
  95507. static readonly FILTER_PCSS: number;
  95508. /**
  95509. * Reserved for PCF and PCSS
  95510. * Highest Quality.
  95511. *
  95512. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95513. *
  95514. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95515. */
  95516. static readonly QUALITY_HIGH: number;
  95517. /**
  95518. * Reserved for PCF and PCSS
  95519. * Good tradeoff for quality/perf cross devices
  95520. *
  95521. * Execute PCF on a 3*3 kernel.
  95522. *
  95523. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95524. */
  95525. static readonly QUALITY_MEDIUM: number;
  95526. /**
  95527. * Reserved for PCF and PCSS
  95528. * The lowest quality but the fastest.
  95529. *
  95530. * Execute PCF on a 1*1 kernel.
  95531. *
  95532. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95533. */
  95534. static readonly QUALITY_LOW: number;
  95535. /** Gets or sets the custom shader name to use */
  95536. customShaderOptions: ICustomShaderOptions;
  95537. /**
  95538. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95539. */
  95540. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95541. /**
  95542. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95543. */
  95544. onAfterShadowMapRenderObservable: Observable<Effect>;
  95545. /**
  95546. * Observable triggered before a mesh is rendered in the shadow map.
  95547. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95548. */
  95549. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95550. /**
  95551. * Observable triggered after a mesh is rendered in the shadow map.
  95552. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95553. */
  95554. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95555. protected _bias: number;
  95556. /**
  95557. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95558. */
  95559. get bias(): number;
  95560. /**
  95561. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95562. */
  95563. set bias(bias: number);
  95564. protected _normalBias: number;
  95565. /**
  95566. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95567. */
  95568. get normalBias(): number;
  95569. /**
  95570. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95571. */
  95572. set normalBias(normalBias: number);
  95573. protected _blurBoxOffset: number;
  95574. /**
  95575. * Gets the blur box offset: offset applied during the blur pass.
  95576. * Only useful if useKernelBlur = false
  95577. */
  95578. get blurBoxOffset(): number;
  95579. /**
  95580. * Sets the blur box offset: offset applied during the blur pass.
  95581. * Only useful if useKernelBlur = false
  95582. */
  95583. set blurBoxOffset(value: number);
  95584. protected _blurScale: number;
  95585. /**
  95586. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95587. * 2 means half of the size.
  95588. */
  95589. get blurScale(): number;
  95590. /**
  95591. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95592. * 2 means half of the size.
  95593. */
  95594. set blurScale(value: number);
  95595. protected _blurKernel: number;
  95596. /**
  95597. * Gets the blur kernel: kernel size of the blur pass.
  95598. * Only useful if useKernelBlur = true
  95599. */
  95600. get blurKernel(): number;
  95601. /**
  95602. * Sets the blur kernel: kernel size of the blur pass.
  95603. * Only useful if useKernelBlur = true
  95604. */
  95605. set blurKernel(value: number);
  95606. protected _useKernelBlur: boolean;
  95607. /**
  95608. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95609. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95610. */
  95611. get useKernelBlur(): boolean;
  95612. /**
  95613. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95614. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95615. */
  95616. set useKernelBlur(value: boolean);
  95617. protected _depthScale: number;
  95618. /**
  95619. * Gets the depth scale used in ESM mode.
  95620. */
  95621. get depthScale(): number;
  95622. /**
  95623. * Sets the depth scale used in ESM mode.
  95624. * This can override the scale stored on the light.
  95625. */
  95626. set depthScale(value: number);
  95627. protected _validateFilter(filter: number): number;
  95628. protected _filter: number;
  95629. /**
  95630. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95631. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95632. */
  95633. get filter(): number;
  95634. /**
  95635. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95636. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95637. */
  95638. set filter(value: number);
  95639. /**
  95640. * Gets if the current filter is set to Poisson Sampling.
  95641. */
  95642. get usePoissonSampling(): boolean;
  95643. /**
  95644. * Sets the current filter to Poisson Sampling.
  95645. */
  95646. set usePoissonSampling(value: boolean);
  95647. /**
  95648. * Gets if the current filter is set to ESM.
  95649. */
  95650. get useExponentialShadowMap(): boolean;
  95651. /**
  95652. * Sets the current filter is to ESM.
  95653. */
  95654. set useExponentialShadowMap(value: boolean);
  95655. /**
  95656. * Gets if the current filter is set to filtered ESM.
  95657. */
  95658. get useBlurExponentialShadowMap(): boolean;
  95659. /**
  95660. * Gets if the current filter is set to filtered ESM.
  95661. */
  95662. set useBlurExponentialShadowMap(value: boolean);
  95663. /**
  95664. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95665. * exponential to prevent steep falloff artifacts).
  95666. */
  95667. get useCloseExponentialShadowMap(): boolean;
  95668. /**
  95669. * Sets the current filter to "close ESM" (using the inverse of the
  95670. * exponential to prevent steep falloff artifacts).
  95671. */
  95672. set useCloseExponentialShadowMap(value: boolean);
  95673. /**
  95674. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95675. * exponential to prevent steep falloff artifacts).
  95676. */
  95677. get useBlurCloseExponentialShadowMap(): boolean;
  95678. /**
  95679. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95680. * exponential to prevent steep falloff artifacts).
  95681. */
  95682. set useBlurCloseExponentialShadowMap(value: boolean);
  95683. /**
  95684. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95685. */
  95686. get usePercentageCloserFiltering(): boolean;
  95687. /**
  95688. * Sets the current filter to "PCF" (percentage closer filtering).
  95689. */
  95690. set usePercentageCloserFiltering(value: boolean);
  95691. protected _filteringQuality: number;
  95692. /**
  95693. * Gets the PCF or PCSS Quality.
  95694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95695. */
  95696. get filteringQuality(): number;
  95697. /**
  95698. * Sets the PCF or PCSS Quality.
  95699. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95700. */
  95701. set filteringQuality(filteringQuality: number);
  95702. /**
  95703. * Gets if the current filter is set to "PCSS" (contact hardening).
  95704. */
  95705. get useContactHardeningShadow(): boolean;
  95706. /**
  95707. * Sets the current filter to "PCSS" (contact hardening).
  95708. */
  95709. set useContactHardeningShadow(value: boolean);
  95710. protected _contactHardeningLightSizeUVRatio: number;
  95711. /**
  95712. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  95721. /**
  95722. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95723. * Using a ratio helps keeping shape stability independently of the map size.
  95724. *
  95725. * It does not account for the light projection as it was having too much
  95726. * instability during the light setup or during light position changes.
  95727. *
  95728. * Only valid if useContactHardeningShadow is true.
  95729. */
  95730. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95731. protected _darkness: number;
  95732. /** Gets or sets the actual darkness of a shadow */
  95733. get darkness(): number;
  95734. set darkness(value: number);
  95735. /**
  95736. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95737. * 0 means strongest and 1 would means no shadow.
  95738. * @returns the darkness.
  95739. */
  95740. getDarkness(): number;
  95741. /**
  95742. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95743. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95744. * @returns the shadow generator allowing fluent coding.
  95745. */
  95746. setDarkness(darkness: number): ShadowGenerator;
  95747. protected _transparencyShadow: boolean;
  95748. /** Gets or sets the ability to have transparent shadow */
  95749. get transparencyShadow(): boolean;
  95750. set transparencyShadow(value: boolean);
  95751. /**
  95752. * Sets the ability to have transparent shadow (boolean).
  95753. * @param transparent True if transparent else False
  95754. * @returns the shadow generator allowing fluent coding
  95755. */
  95756. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95757. /**
  95758. * Enables or disables shadows with varying strength based on the transparency
  95759. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95760. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95761. * mesh.visibility * alphaTexture.a
  95762. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95763. */
  95764. enableSoftTransparentShadow: boolean;
  95765. protected _shadowMap: Nullable<RenderTargetTexture>;
  95766. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95767. /**
  95768. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95769. * @returns The render target texture if present otherwise, null
  95770. */
  95771. getShadowMap(): Nullable<RenderTargetTexture>;
  95772. /**
  95773. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95774. * @returns The render target texture if the shadow map is present otherwise, null
  95775. */
  95776. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95777. /**
  95778. * Gets the class name of that object
  95779. * @returns "ShadowGenerator"
  95780. */
  95781. getClassName(): string;
  95782. /**
  95783. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95784. * @param mesh Mesh to add
  95785. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95786. * @returns the Shadow Generator itself
  95787. */
  95788. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95789. /**
  95790. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95791. * @param mesh Mesh to remove
  95792. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95793. * @returns the Shadow Generator itself
  95794. */
  95795. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95796. /**
  95797. * Controls the extent to which the shadows fade out at the edge of the frustum
  95798. */
  95799. frustumEdgeFalloff: number;
  95800. protected _light: IShadowLight;
  95801. /**
  95802. * Returns the associated light object.
  95803. * @returns the light generating the shadow
  95804. */
  95805. getLight(): IShadowLight;
  95806. /**
  95807. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95808. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95809. * It might on the other hand introduce peter panning.
  95810. */
  95811. forceBackFacesOnly: boolean;
  95812. protected _scene: Scene;
  95813. protected _lightDirection: Vector3;
  95814. protected _effect: Effect;
  95815. protected _viewMatrix: Matrix;
  95816. protected _projectionMatrix: Matrix;
  95817. protected _transformMatrix: Matrix;
  95818. protected _cachedPosition: Vector3;
  95819. protected _cachedDirection: Vector3;
  95820. protected _cachedDefines: string;
  95821. protected _currentRenderID: number;
  95822. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95823. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95824. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95825. protected _blurPostProcesses: PostProcess[];
  95826. protected _mapSize: number;
  95827. protected _currentFaceIndex: number;
  95828. protected _currentFaceIndexCache: number;
  95829. protected _textureType: number;
  95830. protected _defaultTextureMatrix: Matrix;
  95831. protected _storedUniqueId: Nullable<number>;
  95832. /** @hidden */
  95833. static _SceneComponentInitialization: (scene: Scene) => void;
  95834. /**
  95835. * Creates a ShadowGenerator object.
  95836. * A ShadowGenerator is the required tool to use the shadows.
  95837. * Each light casting shadows needs to use its own ShadowGenerator.
  95838. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95839. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95840. * @param light The light object generating the shadows.
  95841. * @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.
  95842. */
  95843. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95844. protected _initializeGenerator(): void;
  95845. protected _createTargetRenderTexture(): void;
  95846. protected _initializeShadowMap(): void;
  95847. protected _initializeBlurRTTAndPostProcesses(): void;
  95848. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95849. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95850. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95851. protected _applyFilterValues(): void;
  95852. /**
  95853. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95854. * @param onCompiled Callback triggered at the and of the effects compilation
  95855. * @param options Sets of optional options forcing the compilation with different modes
  95856. */
  95857. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95858. useInstances: boolean;
  95859. }>): void;
  95860. /**
  95861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95862. * @param options Sets of optional options forcing the compilation with different modes
  95863. * @returns A promise that resolves when the compilation completes
  95864. */
  95865. forceCompilationAsync(options?: Partial<{
  95866. useInstances: boolean;
  95867. }>): Promise<void>;
  95868. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95869. private _prepareShadowDefines;
  95870. /**
  95871. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95872. * @param subMesh The submesh we want to render in the shadow map
  95873. * @param useInstances Defines wether will draw in the map using instances
  95874. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95875. * @returns true if ready otherwise, false
  95876. */
  95877. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95878. /**
  95879. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95880. * @param defines Defines of the material we want to update
  95881. * @param lightIndex Index of the light in the enabled light list of the material
  95882. */
  95883. prepareDefines(defines: any, lightIndex: number): void;
  95884. /**
  95885. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95886. * defined in the generator but impacting the effect).
  95887. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95888. * @param effect The effect we are binfing the information for
  95889. */
  95890. bindShadowLight(lightIndex: string, effect: Effect): void;
  95891. /**
  95892. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95893. * (eq to shadow prjection matrix * light transform matrix)
  95894. * @returns The transform matrix used to create the shadow map
  95895. */
  95896. getTransformMatrix(): Matrix;
  95897. /**
  95898. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95899. * Cube and 2D textures for instance.
  95900. */
  95901. recreateShadowMap(): void;
  95902. protected _disposeBlurPostProcesses(): void;
  95903. protected _disposeRTTandPostProcesses(): void;
  95904. /**
  95905. * Disposes the ShadowGenerator.
  95906. * Returns nothing.
  95907. */
  95908. dispose(): void;
  95909. /**
  95910. * Serializes the shadow generator setup to a json object.
  95911. * @returns The serialized JSON object
  95912. */
  95913. serialize(): any;
  95914. /**
  95915. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95916. * @param parsedShadowGenerator The JSON object to parse
  95917. * @param scene The scene to create the shadow map for
  95918. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95919. * @returns The parsed shadow generator
  95920. */
  95921. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95922. }
  95923. }
  95924. declare module BABYLON {
  95925. /**
  95926. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95927. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95928. * 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.
  95929. */
  95930. export abstract class Light extends Node {
  95931. /**
  95932. * Falloff Default: light is falling off following the material specification:
  95933. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95934. */
  95935. static readonly FALLOFF_DEFAULT: number;
  95936. /**
  95937. * Falloff Physical: light is falling off following the inverse squared distance law.
  95938. */
  95939. static readonly FALLOFF_PHYSICAL: number;
  95940. /**
  95941. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95942. * to enhance interoperability with other engines.
  95943. */
  95944. static readonly FALLOFF_GLTF: number;
  95945. /**
  95946. * Falloff Standard: light is falling off like in the standard material
  95947. * to enhance interoperability with other materials.
  95948. */
  95949. static readonly FALLOFF_STANDARD: number;
  95950. /**
  95951. * If every light affecting the material is in this lightmapMode,
  95952. * material.lightmapTexture adds or multiplies
  95953. * (depends on material.useLightmapAsShadowmap)
  95954. * after every other light calculations.
  95955. */
  95956. static readonly LIGHTMAP_DEFAULT: number;
  95957. /**
  95958. * material.lightmapTexture as only diffuse lighting from this light
  95959. * adds only specular lighting from this light
  95960. * adds dynamic shadows
  95961. */
  95962. static readonly LIGHTMAP_SPECULAR: number;
  95963. /**
  95964. * material.lightmapTexture as only lighting
  95965. * no light calculation from this light
  95966. * only adds dynamic shadows from this light
  95967. */
  95968. static readonly LIGHTMAP_SHADOWSONLY: number;
  95969. /**
  95970. * Each light type uses the default quantity according to its type:
  95971. * point/spot lights use luminous intensity
  95972. * directional lights use illuminance
  95973. */
  95974. static readonly INTENSITYMODE_AUTOMATIC: number;
  95975. /**
  95976. * lumen (lm)
  95977. */
  95978. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95979. /**
  95980. * candela (lm/sr)
  95981. */
  95982. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95983. /**
  95984. * lux (lm/m^2)
  95985. */
  95986. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95987. /**
  95988. * nit (cd/m^2)
  95989. */
  95990. static readonly INTENSITYMODE_LUMINANCE: number;
  95991. /**
  95992. * Light type const id of the point light.
  95993. */
  95994. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95995. /**
  95996. * Light type const id of the directional light.
  95997. */
  95998. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95999. /**
  96000. * Light type const id of the spot light.
  96001. */
  96002. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96003. /**
  96004. * Light type const id of the hemispheric light.
  96005. */
  96006. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96007. /**
  96008. * Diffuse gives the basic color to an object.
  96009. */
  96010. diffuse: Color3;
  96011. /**
  96012. * Specular produces a highlight color on an object.
  96013. * Note: This is note affecting PBR materials.
  96014. */
  96015. specular: Color3;
  96016. /**
  96017. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96018. * falling off base on range or angle.
  96019. * This can be set to any values in Light.FALLOFF_x.
  96020. *
  96021. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96022. * other types of materials.
  96023. */
  96024. falloffType: number;
  96025. /**
  96026. * Strength of the light.
  96027. * Note: By default it is define in the framework own unit.
  96028. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96029. */
  96030. intensity: number;
  96031. private _range;
  96032. protected _inverseSquaredRange: number;
  96033. /**
  96034. * Defines how far from the source the light is impacting in scene units.
  96035. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96036. */
  96037. get range(): number;
  96038. /**
  96039. * Defines how far from the source the light is impacting in scene units.
  96040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96041. */
  96042. set range(value: number);
  96043. /**
  96044. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96045. * of light.
  96046. */
  96047. private _photometricScale;
  96048. private _intensityMode;
  96049. /**
  96050. * Gets the photometric scale used to interpret the intensity.
  96051. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96052. */
  96053. get intensityMode(): number;
  96054. /**
  96055. * Sets the photometric scale used to interpret the intensity.
  96056. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96057. */
  96058. set intensityMode(value: number);
  96059. private _radius;
  96060. /**
  96061. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96062. */
  96063. get radius(): number;
  96064. /**
  96065. * sets the light radius used by PBR Materials to simulate soft area lights.
  96066. */
  96067. set radius(value: number);
  96068. private _renderPriority;
  96069. /**
  96070. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96071. * exceeding the number allowed of the materials.
  96072. */
  96073. renderPriority: number;
  96074. private _shadowEnabled;
  96075. /**
  96076. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96077. * the current shadow generator.
  96078. */
  96079. get shadowEnabled(): boolean;
  96080. /**
  96081. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96082. * the current shadow generator.
  96083. */
  96084. set shadowEnabled(value: boolean);
  96085. private _includedOnlyMeshes;
  96086. /**
  96087. * Gets the only meshes impacted by this light.
  96088. */
  96089. get includedOnlyMeshes(): AbstractMesh[];
  96090. /**
  96091. * Sets the only meshes impacted by this light.
  96092. */
  96093. set includedOnlyMeshes(value: AbstractMesh[]);
  96094. private _excludedMeshes;
  96095. /**
  96096. * Gets the meshes not impacted by this light.
  96097. */
  96098. get excludedMeshes(): AbstractMesh[];
  96099. /**
  96100. * Sets the meshes not impacted by this light.
  96101. */
  96102. set excludedMeshes(value: AbstractMesh[]);
  96103. private _excludeWithLayerMask;
  96104. /**
  96105. * Gets the layer id use to find what meshes are not impacted by the light.
  96106. * Inactive if 0
  96107. */
  96108. get excludeWithLayerMask(): number;
  96109. /**
  96110. * Sets the layer id use to find what meshes are not impacted by the light.
  96111. * Inactive if 0
  96112. */
  96113. set excludeWithLayerMask(value: number);
  96114. private _includeOnlyWithLayerMask;
  96115. /**
  96116. * Gets the layer id use to find what meshes are impacted by the light.
  96117. * Inactive if 0
  96118. */
  96119. get includeOnlyWithLayerMask(): number;
  96120. /**
  96121. * Sets the layer id use to find what meshes are impacted by the light.
  96122. * Inactive if 0
  96123. */
  96124. set includeOnlyWithLayerMask(value: number);
  96125. private _lightmapMode;
  96126. /**
  96127. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96128. */
  96129. get lightmapMode(): number;
  96130. /**
  96131. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96132. */
  96133. set lightmapMode(value: number);
  96134. /**
  96135. * Shadow generator associted to the light.
  96136. * @hidden Internal use only.
  96137. */
  96138. _shadowGenerator: Nullable<IShadowGenerator>;
  96139. /**
  96140. * @hidden Internal use only.
  96141. */
  96142. _excludedMeshesIds: string[];
  96143. /**
  96144. * @hidden Internal use only.
  96145. */
  96146. _includedOnlyMeshesIds: string[];
  96147. /**
  96148. * The current light unifom buffer.
  96149. * @hidden Internal use only.
  96150. */
  96151. _uniformBuffer: UniformBuffer;
  96152. /** @hidden */
  96153. _renderId: number;
  96154. /**
  96155. * Creates a Light object in the scene.
  96156. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96157. * @param name The firendly name of the light
  96158. * @param scene The scene the light belongs too
  96159. */
  96160. constructor(name: string, scene: Scene);
  96161. protected abstract _buildUniformLayout(): void;
  96162. /**
  96163. * Sets the passed Effect "effect" with the Light information.
  96164. * @param effect The effect to update
  96165. * @param lightIndex The index of the light in the effect to update
  96166. * @returns The light
  96167. */
  96168. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96169. /**
  96170. * Sets the passed Effect "effect" with the Light textures.
  96171. * @param effect The effect to update
  96172. * @param lightIndex The index of the light in the effect to update
  96173. * @returns The light
  96174. */
  96175. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96176. /**
  96177. * Binds the lights information from the scene to the effect for the given mesh.
  96178. * @param lightIndex Light index
  96179. * @param scene The scene where the light belongs to
  96180. * @param effect The effect we are binding the data to
  96181. * @param useSpecular Defines if specular is supported
  96182. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96183. */
  96184. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96185. /**
  96186. * Sets the passed Effect "effect" with the Light information.
  96187. * @param effect The effect to update
  96188. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96189. * @returns The light
  96190. */
  96191. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96192. /**
  96193. * Returns the string "Light".
  96194. * @returns the class name
  96195. */
  96196. getClassName(): string;
  96197. /** @hidden */
  96198. readonly _isLight: boolean;
  96199. /**
  96200. * Converts the light information to a readable string for debug purpose.
  96201. * @param fullDetails Supports for multiple levels of logging within scene loading
  96202. * @returns the human readable light info
  96203. */
  96204. toString(fullDetails?: boolean): string;
  96205. /** @hidden */
  96206. protected _syncParentEnabledState(): void;
  96207. /**
  96208. * Set the enabled state of this node.
  96209. * @param value - the new enabled state
  96210. */
  96211. setEnabled(value: boolean): void;
  96212. /**
  96213. * Returns the Light associated shadow generator if any.
  96214. * @return the associated shadow generator.
  96215. */
  96216. getShadowGenerator(): Nullable<IShadowGenerator>;
  96217. /**
  96218. * Returns a Vector3, the absolute light position in the World.
  96219. * @returns the world space position of the light
  96220. */
  96221. getAbsolutePosition(): Vector3;
  96222. /**
  96223. * Specifies if the light will affect the passed mesh.
  96224. * @param mesh The mesh to test against the light
  96225. * @return true the mesh is affected otherwise, false.
  96226. */
  96227. canAffectMesh(mesh: AbstractMesh): boolean;
  96228. /**
  96229. * Sort function to order lights for rendering.
  96230. * @param a First Light object to compare to second.
  96231. * @param b Second Light object to compare first.
  96232. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96233. */
  96234. static CompareLightsPriority(a: Light, b: Light): number;
  96235. /**
  96236. * Releases resources associated with this node.
  96237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96239. */
  96240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96241. /**
  96242. * Returns the light type ID (integer).
  96243. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96244. */
  96245. getTypeID(): number;
  96246. /**
  96247. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96248. * @returns the scaled intensity in intensity mode unit
  96249. */
  96250. getScaledIntensity(): number;
  96251. /**
  96252. * Returns a new Light object, named "name", from the current one.
  96253. * @param name The name of the cloned light
  96254. * @param newParent The parent of this light, if it has one
  96255. * @returns the new created light
  96256. */
  96257. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96258. /**
  96259. * Serializes the current light into a Serialization object.
  96260. * @returns the serialized object.
  96261. */
  96262. serialize(): any;
  96263. /**
  96264. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96265. * This new light is named "name" and added to the passed scene.
  96266. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96267. * @param name The friendly name of the light
  96268. * @param scene The scene the new light will belong to
  96269. * @returns the constructor function
  96270. */
  96271. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96272. /**
  96273. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96274. * @param parsedLight The JSON representation of the light
  96275. * @param scene The scene to create the parsed light in
  96276. * @returns the created light after parsing
  96277. */
  96278. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96279. private _hookArrayForExcluded;
  96280. private _hookArrayForIncludedOnly;
  96281. private _resyncMeshes;
  96282. /**
  96283. * Forces the meshes to update their light related information in their rendering used effects
  96284. * @hidden Internal Use Only
  96285. */
  96286. _markMeshesAsLightDirty(): void;
  96287. /**
  96288. * Recomputes the cached photometric scale if needed.
  96289. */
  96290. private _computePhotometricScale;
  96291. /**
  96292. * Returns the Photometric Scale according to the light type and intensity mode.
  96293. */
  96294. private _getPhotometricScale;
  96295. /**
  96296. * Reorder the light in the scene according to their defined priority.
  96297. * @hidden Internal Use Only
  96298. */
  96299. _reorderLightsInScene(): void;
  96300. /**
  96301. * Prepares the list of defines specific to the light type.
  96302. * @param defines the list of defines
  96303. * @param lightIndex defines the index of the light for the effect
  96304. */
  96305. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96306. }
  96307. }
  96308. declare module BABYLON {
  96309. /**
  96310. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96311. * This is the base of the follow, arc rotate cameras and Free camera
  96312. * @see https://doc.babylonjs.com/features/cameras
  96313. */
  96314. export class TargetCamera extends Camera {
  96315. private static _RigCamTransformMatrix;
  96316. private static _TargetTransformMatrix;
  96317. private static _TargetFocalPoint;
  96318. private _tmpUpVector;
  96319. private _tmpTargetVector;
  96320. /**
  96321. * Define the current direction the camera is moving to
  96322. */
  96323. cameraDirection: Vector3;
  96324. /**
  96325. * Define the current rotation the camera is rotating to
  96326. */
  96327. cameraRotation: Vector2;
  96328. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96329. ignoreParentScaling: boolean;
  96330. /**
  96331. * When set, the up vector of the camera will be updated by the rotation of the camera
  96332. */
  96333. updateUpVectorFromRotation: boolean;
  96334. private _tmpQuaternion;
  96335. /**
  96336. * Define the current rotation of the camera
  96337. */
  96338. rotation: Vector3;
  96339. /**
  96340. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96341. */
  96342. rotationQuaternion: Quaternion;
  96343. /**
  96344. * Define the current speed of the camera
  96345. */
  96346. speed: number;
  96347. /**
  96348. * Add constraint to the camera to prevent it to move freely in all directions and
  96349. * around all axis.
  96350. */
  96351. noRotationConstraint: boolean;
  96352. /**
  96353. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96354. * panning
  96355. */
  96356. invertRotation: boolean;
  96357. /**
  96358. * Speed multiplier for inverse camera panning
  96359. */
  96360. inverseRotationSpeed: number;
  96361. /**
  96362. * Define the current target of the camera as an object or a position.
  96363. */
  96364. lockedTarget: any;
  96365. /** @hidden */
  96366. _currentTarget: Vector3;
  96367. /** @hidden */
  96368. _initialFocalDistance: number;
  96369. /** @hidden */
  96370. _viewMatrix: Matrix;
  96371. /** @hidden */
  96372. _camMatrix: Matrix;
  96373. /** @hidden */
  96374. _cameraTransformMatrix: Matrix;
  96375. /** @hidden */
  96376. _cameraRotationMatrix: Matrix;
  96377. /** @hidden */
  96378. _referencePoint: Vector3;
  96379. /** @hidden */
  96380. _transformedReferencePoint: Vector3;
  96381. /** @hidden */
  96382. _reset: () => void;
  96383. private _defaultUp;
  96384. /**
  96385. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96386. * This is the base of the follow, arc rotate cameras and Free camera
  96387. * @see https://doc.babylonjs.com/features/cameras
  96388. * @param name Defines the name of the camera in the scene
  96389. * @param position Defines the start position of the camera in the scene
  96390. * @param scene Defines the scene the camera belongs to
  96391. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96392. */
  96393. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96394. /**
  96395. * Gets the position in front of the camera at a given distance.
  96396. * @param distance The distance from the camera we want the position to be
  96397. * @returns the position
  96398. */
  96399. getFrontPosition(distance: number): Vector3;
  96400. /** @hidden */
  96401. _getLockedTargetPosition(): Nullable<Vector3>;
  96402. private _storedPosition;
  96403. private _storedRotation;
  96404. private _storedRotationQuaternion;
  96405. /**
  96406. * Store current camera state of the camera (fov, position, rotation, etc..)
  96407. * @returns the camera
  96408. */
  96409. storeState(): Camera;
  96410. /**
  96411. * Restored camera state. You must call storeState() first
  96412. * @returns whether it was successful or not
  96413. * @hidden
  96414. */
  96415. _restoreStateValues(): boolean;
  96416. /** @hidden */
  96417. _initCache(): void;
  96418. /** @hidden */
  96419. _updateCache(ignoreParentClass?: boolean): void;
  96420. /** @hidden */
  96421. _isSynchronizedViewMatrix(): boolean;
  96422. /** @hidden */
  96423. _computeLocalCameraSpeed(): number;
  96424. /**
  96425. * Defines the target the camera should look at.
  96426. * @param target Defines the new target as a Vector or a mesh
  96427. */
  96428. setTarget(target: Vector3): void;
  96429. /**
  96430. * Return the current target position of the camera. This value is expressed in local space.
  96431. * @returns the target position
  96432. */
  96433. getTarget(): Vector3;
  96434. /** @hidden */
  96435. _decideIfNeedsToMove(): boolean;
  96436. /** @hidden */
  96437. _updatePosition(): void;
  96438. /** @hidden */
  96439. _checkInputs(): void;
  96440. protected _updateCameraRotationMatrix(): void;
  96441. /**
  96442. * 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)
  96443. * @returns the current camera
  96444. */
  96445. private _rotateUpVectorWithCameraRotationMatrix;
  96446. private _cachedRotationZ;
  96447. private _cachedQuaternionRotationZ;
  96448. /** @hidden */
  96449. _getViewMatrix(): Matrix;
  96450. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96451. /**
  96452. * @hidden
  96453. */
  96454. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96455. /**
  96456. * @hidden
  96457. */
  96458. _updateRigCameras(): void;
  96459. private _getRigCamPositionAndTarget;
  96460. /**
  96461. * Gets the current object class name.
  96462. * @return the class name
  96463. */
  96464. getClassName(): string;
  96465. }
  96466. }
  96467. declare module BABYLON {
  96468. /**
  96469. * Gather the list of keyboard event types as constants.
  96470. */
  96471. export class KeyboardEventTypes {
  96472. /**
  96473. * The keydown event is fired when a key becomes active (pressed).
  96474. */
  96475. static readonly KEYDOWN: number;
  96476. /**
  96477. * The keyup event is fired when a key has been released.
  96478. */
  96479. static readonly KEYUP: number;
  96480. }
  96481. /**
  96482. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96483. */
  96484. export class KeyboardInfo {
  96485. /**
  96486. * Defines the type of event (KeyboardEventTypes)
  96487. */
  96488. type: number;
  96489. /**
  96490. * Defines the related dom event
  96491. */
  96492. event: KeyboardEvent;
  96493. /**
  96494. * Instantiates a new keyboard info.
  96495. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96496. * @param type Defines the type of event (KeyboardEventTypes)
  96497. * @param event Defines the related dom event
  96498. */
  96499. constructor(
  96500. /**
  96501. * Defines the type of event (KeyboardEventTypes)
  96502. */
  96503. type: number,
  96504. /**
  96505. * Defines the related dom event
  96506. */
  96507. event: KeyboardEvent);
  96508. }
  96509. /**
  96510. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96511. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96512. */
  96513. export class KeyboardInfoPre extends KeyboardInfo {
  96514. /**
  96515. * Defines the type of event (KeyboardEventTypes)
  96516. */
  96517. type: number;
  96518. /**
  96519. * Defines the related dom event
  96520. */
  96521. event: KeyboardEvent;
  96522. /**
  96523. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96524. */
  96525. skipOnPointerObservable: boolean;
  96526. /**
  96527. * Instantiates a new keyboard pre info.
  96528. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96529. * @param type Defines the type of event (KeyboardEventTypes)
  96530. * @param event Defines the related dom event
  96531. */
  96532. constructor(
  96533. /**
  96534. * Defines the type of event (KeyboardEventTypes)
  96535. */
  96536. type: number,
  96537. /**
  96538. * Defines the related dom event
  96539. */
  96540. event: KeyboardEvent);
  96541. }
  96542. }
  96543. declare module BABYLON {
  96544. /**
  96545. * Manage the keyboard inputs to control the movement of a free camera.
  96546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96547. */
  96548. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96549. /**
  96550. * Defines the camera the input is attached to.
  96551. */
  96552. camera: FreeCamera;
  96553. /**
  96554. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96555. */
  96556. keysUp: number[];
  96557. /**
  96558. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96559. */
  96560. keysUpward: number[];
  96561. /**
  96562. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96563. */
  96564. keysDown: number[];
  96565. /**
  96566. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96567. */
  96568. keysDownward: number[];
  96569. /**
  96570. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96571. */
  96572. keysLeft: number[];
  96573. /**
  96574. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96575. */
  96576. keysRight: number[];
  96577. private _keys;
  96578. private _onCanvasBlurObserver;
  96579. private _onKeyboardObserver;
  96580. private _engine;
  96581. private _scene;
  96582. /**
  96583. * Attach the input controls to a specific dom element to get the input from.
  96584. * @param element Defines the element the controls should be listened from
  96585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96586. */
  96587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96588. /**
  96589. * Detach the current controls from the specified dom element.
  96590. * @param element Defines the element to stop listening the inputs from
  96591. */
  96592. detachControl(element: Nullable<HTMLElement>): void;
  96593. /**
  96594. * Update the current camera state depending on the inputs that have been used this frame.
  96595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96596. */
  96597. checkInputs(): void;
  96598. /**
  96599. * Gets the class name of the current intput.
  96600. * @returns the class name
  96601. */
  96602. getClassName(): string;
  96603. /** @hidden */
  96604. _onLostFocus(): void;
  96605. /**
  96606. * Get the friendly name associated with the input class.
  96607. * @returns the input friendly name
  96608. */
  96609. getSimpleName(): string;
  96610. }
  96611. }
  96612. declare module BABYLON {
  96613. /**
  96614. * Gather the list of pointer event types as constants.
  96615. */
  96616. export class PointerEventTypes {
  96617. /**
  96618. * 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.
  96619. */
  96620. static readonly POINTERDOWN: number;
  96621. /**
  96622. * The pointerup event is fired when a pointer is no longer active.
  96623. */
  96624. static readonly POINTERUP: number;
  96625. /**
  96626. * The pointermove event is fired when a pointer changes coordinates.
  96627. */
  96628. static readonly POINTERMOVE: number;
  96629. /**
  96630. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96631. */
  96632. static readonly POINTERWHEEL: number;
  96633. /**
  96634. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96635. */
  96636. static readonly POINTERPICK: number;
  96637. /**
  96638. * The pointertap event is fired when a the object has been touched and released without drag.
  96639. */
  96640. static readonly POINTERTAP: number;
  96641. /**
  96642. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96643. */
  96644. static readonly POINTERDOUBLETAP: number;
  96645. }
  96646. /**
  96647. * Base class of pointer info types.
  96648. */
  96649. export class PointerInfoBase {
  96650. /**
  96651. * Defines the type of event (PointerEventTypes)
  96652. */
  96653. type: number;
  96654. /**
  96655. * Defines the related dom event
  96656. */
  96657. event: PointerEvent | MouseWheelEvent;
  96658. /**
  96659. * Instantiates the base class of pointers info.
  96660. * @param type Defines the type of event (PointerEventTypes)
  96661. * @param event Defines the related dom event
  96662. */
  96663. constructor(
  96664. /**
  96665. * Defines the type of event (PointerEventTypes)
  96666. */
  96667. type: number,
  96668. /**
  96669. * Defines the related dom event
  96670. */
  96671. event: PointerEvent | MouseWheelEvent);
  96672. }
  96673. /**
  96674. * This class is used to store pointer related info for the onPrePointerObservable event.
  96675. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96676. */
  96677. export class PointerInfoPre extends PointerInfoBase {
  96678. /**
  96679. * Ray from a pointer if availible (eg. 6dof controller)
  96680. */
  96681. ray: Nullable<Ray>;
  96682. /**
  96683. * Defines the local position of the pointer on the canvas.
  96684. */
  96685. localPosition: Vector2;
  96686. /**
  96687. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96688. */
  96689. skipOnPointerObservable: boolean;
  96690. /**
  96691. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96692. * @param type Defines the type of event (PointerEventTypes)
  96693. * @param event Defines the related dom event
  96694. * @param localX Defines the local x coordinates of the pointer when the event occured
  96695. * @param localY Defines the local y coordinates of the pointer when the event occured
  96696. */
  96697. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96698. }
  96699. /**
  96700. * This type contains all the data related to a pointer event in Babylon.js.
  96701. * 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.
  96702. */
  96703. export class PointerInfo extends PointerInfoBase {
  96704. /**
  96705. * Defines the picking info associated to the info (if any)\
  96706. */
  96707. pickInfo: Nullable<PickingInfo>;
  96708. /**
  96709. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96710. * @param type Defines the type of event (PointerEventTypes)
  96711. * @param event Defines the related dom event
  96712. * @param pickInfo Defines the picking info associated to the info (if any)\
  96713. */
  96714. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96715. /**
  96716. * Defines the picking info associated to the info (if any)\
  96717. */
  96718. pickInfo: Nullable<PickingInfo>);
  96719. }
  96720. /**
  96721. * Data relating to a touch event on the screen.
  96722. */
  96723. export interface PointerTouch {
  96724. /**
  96725. * X coordinate of touch.
  96726. */
  96727. x: number;
  96728. /**
  96729. * Y coordinate of touch.
  96730. */
  96731. y: number;
  96732. /**
  96733. * Id of touch. Unique for each finger.
  96734. */
  96735. pointerId: number;
  96736. /**
  96737. * Event type passed from DOM.
  96738. */
  96739. type: any;
  96740. }
  96741. }
  96742. declare module BABYLON {
  96743. /**
  96744. * Manage the mouse inputs to control the movement of a free camera.
  96745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96746. */
  96747. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96748. /**
  96749. * Define if touch is enabled in the mouse input
  96750. */
  96751. touchEnabled: boolean;
  96752. /**
  96753. * Defines the camera the input is attached to.
  96754. */
  96755. camera: FreeCamera;
  96756. /**
  96757. * Defines the buttons associated with the input to handle camera move.
  96758. */
  96759. buttons: number[];
  96760. /**
  96761. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96762. */
  96763. angularSensibility: number;
  96764. private _pointerInput;
  96765. private _onMouseMove;
  96766. private _observer;
  96767. private previousPosition;
  96768. /**
  96769. * Observable for when a pointer move event occurs containing the move offset
  96770. */
  96771. onPointerMovedObservable: Observable<{
  96772. offsetX: number;
  96773. offsetY: number;
  96774. }>;
  96775. /**
  96776. * @hidden
  96777. * If the camera should be rotated automatically based on pointer movement
  96778. */
  96779. _allowCameraRotation: boolean;
  96780. /**
  96781. * Manage the mouse inputs to control the movement of a free camera.
  96782. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96783. * @param touchEnabled Defines if touch is enabled or not
  96784. */
  96785. constructor(
  96786. /**
  96787. * Define if touch is enabled in the mouse input
  96788. */
  96789. touchEnabled?: boolean);
  96790. /**
  96791. * Attach the input controls to a specific dom element to get the input from.
  96792. * @param element Defines the element the controls should be listened from
  96793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96794. */
  96795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96796. /**
  96797. * Called on JS contextmenu event.
  96798. * Override this method to provide functionality.
  96799. */
  96800. protected onContextMenu(evt: PointerEvent): void;
  96801. /**
  96802. * Detach the current controls from the specified dom element.
  96803. * @param element Defines the element to stop listening the inputs from
  96804. */
  96805. detachControl(element: Nullable<HTMLElement>): void;
  96806. /**
  96807. * Gets the class name of the current intput.
  96808. * @returns the class name
  96809. */
  96810. getClassName(): string;
  96811. /**
  96812. * Get the friendly name associated with the input class.
  96813. * @returns the input friendly name
  96814. */
  96815. getSimpleName(): string;
  96816. }
  96817. }
  96818. declare module BABYLON {
  96819. /**
  96820. * Manage the touch inputs to control the movement of a free camera.
  96821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96822. */
  96823. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96824. /**
  96825. * Defines the camera the input is attached to.
  96826. */
  96827. camera: FreeCamera;
  96828. /**
  96829. * Defines the touch sensibility for rotation.
  96830. * The higher the faster.
  96831. */
  96832. touchAngularSensibility: number;
  96833. /**
  96834. * Defines the touch sensibility for move.
  96835. * The higher the faster.
  96836. */
  96837. touchMoveSensibility: number;
  96838. private _offsetX;
  96839. private _offsetY;
  96840. private _pointerPressed;
  96841. private _pointerInput;
  96842. private _observer;
  96843. private _onLostFocus;
  96844. /**
  96845. * Attach the input controls to a specific dom element to get the input from.
  96846. * @param element Defines the element the controls should be listened from
  96847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96848. */
  96849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96850. /**
  96851. * Detach the current controls from the specified dom element.
  96852. * @param element Defines the element to stop listening the inputs from
  96853. */
  96854. detachControl(element: Nullable<HTMLElement>): void;
  96855. /**
  96856. * Update the current camera state depending on the inputs that have been used this frame.
  96857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96858. */
  96859. checkInputs(): void;
  96860. /**
  96861. * Gets the class name of the current intput.
  96862. * @returns the class name
  96863. */
  96864. getClassName(): string;
  96865. /**
  96866. * Get the friendly name associated with the input class.
  96867. * @returns the input friendly name
  96868. */
  96869. getSimpleName(): string;
  96870. }
  96871. }
  96872. declare module BABYLON {
  96873. /**
  96874. * Default Inputs manager for the FreeCamera.
  96875. * It groups all the default supported inputs for ease of use.
  96876. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96877. */
  96878. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96879. /**
  96880. * @hidden
  96881. */
  96882. _mouseInput: Nullable<FreeCameraMouseInput>;
  96883. /**
  96884. * Instantiates a new FreeCameraInputsManager.
  96885. * @param camera Defines the camera the inputs belong to
  96886. */
  96887. constructor(camera: FreeCamera);
  96888. /**
  96889. * Add keyboard input support to the input manager.
  96890. * @returns the current input manager
  96891. */
  96892. addKeyboard(): FreeCameraInputsManager;
  96893. /**
  96894. * Add mouse input support to the input manager.
  96895. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96896. * @returns the current input manager
  96897. */
  96898. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96899. /**
  96900. * Removes the mouse input support from the manager
  96901. * @returns the current input manager
  96902. */
  96903. removeMouse(): FreeCameraInputsManager;
  96904. /**
  96905. * Add touch input support to the input manager.
  96906. * @returns the current input manager
  96907. */
  96908. addTouch(): FreeCameraInputsManager;
  96909. /**
  96910. * Remove all attached input methods from a camera
  96911. */
  96912. clear(): void;
  96913. }
  96914. }
  96915. declare module BABYLON {
  96916. /**
  96917. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96918. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96919. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  96920. */
  96921. export class FreeCamera extends TargetCamera {
  96922. /**
  96923. * Define the collision ellipsoid of the camera.
  96924. * This is helpful to simulate a camera body like the player body around the camera
  96925. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96926. */
  96927. ellipsoid: Vector3;
  96928. /**
  96929. * Define an offset for the position of the ellipsoid around the camera.
  96930. * This can be helpful to determine the center of the body near the gravity center of the body
  96931. * instead of its head.
  96932. */
  96933. ellipsoidOffset: Vector3;
  96934. /**
  96935. * Enable or disable collisions of the camera with the rest of the scene objects.
  96936. */
  96937. checkCollisions: boolean;
  96938. /**
  96939. * Enable or disable gravity on the camera.
  96940. */
  96941. applyGravity: boolean;
  96942. /**
  96943. * Define the input manager associated to the camera.
  96944. */
  96945. inputs: FreeCameraInputsManager;
  96946. /**
  96947. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96948. * Higher values reduce sensitivity.
  96949. */
  96950. get angularSensibility(): number;
  96951. /**
  96952. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96953. * Higher values reduce sensitivity.
  96954. */
  96955. set angularSensibility(value: number);
  96956. /**
  96957. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96958. */
  96959. get keysUp(): number[];
  96960. set keysUp(value: number[]);
  96961. /**
  96962. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96963. */
  96964. get keysUpward(): number[];
  96965. set keysUpward(value: number[]);
  96966. /**
  96967. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96968. */
  96969. get keysDown(): number[];
  96970. set keysDown(value: number[]);
  96971. /**
  96972. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96973. */
  96974. get keysDownward(): number[];
  96975. set keysDownward(value: number[]);
  96976. /**
  96977. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96978. */
  96979. get keysLeft(): number[];
  96980. set keysLeft(value: number[]);
  96981. /**
  96982. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96983. */
  96984. get keysRight(): number[];
  96985. set keysRight(value: number[]);
  96986. /**
  96987. * Event raised when the camera collide with a mesh in the scene.
  96988. */
  96989. onCollide: (collidedMesh: AbstractMesh) => void;
  96990. private _collider;
  96991. private _needMoveForGravity;
  96992. private _oldPosition;
  96993. private _diffPosition;
  96994. private _newPosition;
  96995. /** @hidden */
  96996. _localDirection: Vector3;
  96997. /** @hidden */
  96998. _transformedDirection: Vector3;
  96999. /**
  97000. * Instantiates a Free Camera.
  97001. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97002. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97003. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97004. * @param name Define the name of the camera in the scene
  97005. * @param position Define the start position of the camera in the scene
  97006. * @param scene Define the scene the camera belongs to
  97007. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97008. */
  97009. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97010. /**
  97011. * Attached controls to the current camera.
  97012. * @param element Defines the element the controls should be listened from
  97013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97014. */
  97015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97016. /**
  97017. * Detach the current controls from the camera.
  97018. * The camera will stop reacting to inputs.
  97019. * @param element Defines the element to stop listening the inputs from
  97020. */
  97021. detachControl(element: HTMLElement): void;
  97022. private _collisionMask;
  97023. /**
  97024. * Define a collision mask to limit the list of object the camera can collide with
  97025. */
  97026. get collisionMask(): number;
  97027. set collisionMask(mask: number);
  97028. /** @hidden */
  97029. _collideWithWorld(displacement: Vector3): void;
  97030. private _onCollisionPositionChange;
  97031. /** @hidden */
  97032. _checkInputs(): void;
  97033. /** @hidden */
  97034. _decideIfNeedsToMove(): boolean;
  97035. /** @hidden */
  97036. _updatePosition(): void;
  97037. /**
  97038. * Destroy the camera and release the current resources hold by it.
  97039. */
  97040. dispose(): void;
  97041. /**
  97042. * Gets the current object class name.
  97043. * @return the class name
  97044. */
  97045. getClassName(): string;
  97046. }
  97047. }
  97048. declare module BABYLON {
  97049. /**
  97050. * Represents a gamepad control stick position
  97051. */
  97052. export class StickValues {
  97053. /**
  97054. * The x component of the control stick
  97055. */
  97056. x: number;
  97057. /**
  97058. * The y component of the control stick
  97059. */
  97060. y: number;
  97061. /**
  97062. * Initializes the gamepad x and y control stick values
  97063. * @param x The x component of the gamepad control stick value
  97064. * @param y The y component of the gamepad control stick value
  97065. */
  97066. constructor(
  97067. /**
  97068. * The x component of the control stick
  97069. */
  97070. x: number,
  97071. /**
  97072. * The y component of the control stick
  97073. */
  97074. y: number);
  97075. }
  97076. /**
  97077. * An interface which manages callbacks for gamepad button changes
  97078. */
  97079. export interface GamepadButtonChanges {
  97080. /**
  97081. * Called when a gamepad has been changed
  97082. */
  97083. changed: boolean;
  97084. /**
  97085. * Called when a gamepad press event has been triggered
  97086. */
  97087. pressChanged: boolean;
  97088. /**
  97089. * Called when a touch event has been triggered
  97090. */
  97091. touchChanged: boolean;
  97092. /**
  97093. * Called when a value has changed
  97094. */
  97095. valueChanged: boolean;
  97096. }
  97097. /**
  97098. * Represents a gamepad
  97099. */
  97100. export class Gamepad {
  97101. /**
  97102. * The id of the gamepad
  97103. */
  97104. id: string;
  97105. /**
  97106. * The index of the gamepad
  97107. */
  97108. index: number;
  97109. /**
  97110. * The browser gamepad
  97111. */
  97112. browserGamepad: any;
  97113. /**
  97114. * Specifies what type of gamepad this represents
  97115. */
  97116. type: number;
  97117. private _leftStick;
  97118. private _rightStick;
  97119. /** @hidden */
  97120. _isConnected: boolean;
  97121. private _leftStickAxisX;
  97122. private _leftStickAxisY;
  97123. private _rightStickAxisX;
  97124. private _rightStickAxisY;
  97125. /**
  97126. * Triggered when the left control stick has been changed
  97127. */
  97128. private _onleftstickchanged;
  97129. /**
  97130. * Triggered when the right control stick has been changed
  97131. */
  97132. private _onrightstickchanged;
  97133. /**
  97134. * Represents a gamepad controller
  97135. */
  97136. static GAMEPAD: number;
  97137. /**
  97138. * Represents a generic controller
  97139. */
  97140. static GENERIC: number;
  97141. /**
  97142. * Represents an XBox controller
  97143. */
  97144. static XBOX: number;
  97145. /**
  97146. * Represents a pose-enabled controller
  97147. */
  97148. static POSE_ENABLED: number;
  97149. /**
  97150. * Represents an Dual Shock controller
  97151. */
  97152. static DUALSHOCK: number;
  97153. /**
  97154. * Specifies whether the left control stick should be Y-inverted
  97155. */
  97156. protected _invertLeftStickY: boolean;
  97157. /**
  97158. * Specifies if the gamepad has been connected
  97159. */
  97160. get isConnected(): boolean;
  97161. /**
  97162. * Initializes the gamepad
  97163. * @param id The id of the gamepad
  97164. * @param index The index of the gamepad
  97165. * @param browserGamepad The browser gamepad
  97166. * @param leftStickX The x component of the left joystick
  97167. * @param leftStickY The y component of the left joystick
  97168. * @param rightStickX The x component of the right joystick
  97169. * @param rightStickY The y component of the right joystick
  97170. */
  97171. constructor(
  97172. /**
  97173. * The id of the gamepad
  97174. */
  97175. id: string,
  97176. /**
  97177. * The index of the gamepad
  97178. */
  97179. index: number,
  97180. /**
  97181. * The browser gamepad
  97182. */
  97183. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97184. /**
  97185. * Callback triggered when the left joystick has changed
  97186. * @param callback
  97187. */
  97188. onleftstickchanged(callback: (values: StickValues) => void): void;
  97189. /**
  97190. * Callback triggered when the right joystick has changed
  97191. * @param callback
  97192. */
  97193. onrightstickchanged(callback: (values: StickValues) => void): void;
  97194. /**
  97195. * Gets the left joystick
  97196. */
  97197. get leftStick(): StickValues;
  97198. /**
  97199. * Sets the left joystick values
  97200. */
  97201. set leftStick(newValues: StickValues);
  97202. /**
  97203. * Gets the right joystick
  97204. */
  97205. get rightStick(): StickValues;
  97206. /**
  97207. * Sets the right joystick value
  97208. */
  97209. set rightStick(newValues: StickValues);
  97210. /**
  97211. * Updates the gamepad joystick positions
  97212. */
  97213. update(): void;
  97214. /**
  97215. * Disposes the gamepad
  97216. */
  97217. dispose(): void;
  97218. }
  97219. /**
  97220. * Represents a generic gamepad
  97221. */
  97222. export class GenericPad extends Gamepad {
  97223. private _buttons;
  97224. private _onbuttondown;
  97225. private _onbuttonup;
  97226. /**
  97227. * Observable triggered when a button has been pressed
  97228. */
  97229. onButtonDownObservable: Observable<number>;
  97230. /**
  97231. * Observable triggered when a button has been released
  97232. */
  97233. onButtonUpObservable: Observable<number>;
  97234. /**
  97235. * Callback triggered when a button has been pressed
  97236. * @param callback Called when a button has been pressed
  97237. */
  97238. onbuttondown(callback: (buttonPressed: number) => void): void;
  97239. /**
  97240. * Callback triggered when a button has been released
  97241. * @param callback Called when a button has been released
  97242. */
  97243. onbuttonup(callback: (buttonReleased: number) => void): void;
  97244. /**
  97245. * Initializes the generic gamepad
  97246. * @param id The id of the generic gamepad
  97247. * @param index The index of the generic gamepad
  97248. * @param browserGamepad The browser gamepad
  97249. */
  97250. constructor(id: string, index: number, browserGamepad: any);
  97251. private _setButtonValue;
  97252. /**
  97253. * Updates the generic gamepad
  97254. */
  97255. update(): void;
  97256. /**
  97257. * Disposes the generic gamepad
  97258. */
  97259. dispose(): void;
  97260. }
  97261. }
  97262. declare module BABYLON {
  97263. /**
  97264. * Defines the types of pose enabled controllers that are supported
  97265. */
  97266. export enum PoseEnabledControllerType {
  97267. /**
  97268. * HTC Vive
  97269. */
  97270. VIVE = 0,
  97271. /**
  97272. * Oculus Rift
  97273. */
  97274. OCULUS = 1,
  97275. /**
  97276. * Windows mixed reality
  97277. */
  97278. WINDOWS = 2,
  97279. /**
  97280. * Samsung gear VR
  97281. */
  97282. GEAR_VR = 3,
  97283. /**
  97284. * Google Daydream
  97285. */
  97286. DAYDREAM = 4,
  97287. /**
  97288. * Generic
  97289. */
  97290. GENERIC = 5
  97291. }
  97292. /**
  97293. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97294. */
  97295. export interface MutableGamepadButton {
  97296. /**
  97297. * Value of the button/trigger
  97298. */
  97299. value: number;
  97300. /**
  97301. * If the button/trigger is currently touched
  97302. */
  97303. touched: boolean;
  97304. /**
  97305. * If the button/trigger is currently pressed
  97306. */
  97307. pressed: boolean;
  97308. }
  97309. /**
  97310. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97311. * @hidden
  97312. */
  97313. export interface ExtendedGamepadButton extends GamepadButton {
  97314. /**
  97315. * If the button/trigger is currently pressed
  97316. */
  97317. readonly pressed: boolean;
  97318. /**
  97319. * If the button/trigger is currently touched
  97320. */
  97321. readonly touched: boolean;
  97322. /**
  97323. * Value of the button/trigger
  97324. */
  97325. readonly value: number;
  97326. }
  97327. /** @hidden */
  97328. export interface _GamePadFactory {
  97329. /**
  97330. * Returns whether or not the current gamepad can be created for this type of controller.
  97331. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97332. * @returns true if it can be created, otherwise false
  97333. */
  97334. canCreate(gamepadInfo: any): boolean;
  97335. /**
  97336. * Creates a new instance of the Gamepad.
  97337. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97338. * @returns the new gamepad instance
  97339. */
  97340. create(gamepadInfo: any): Gamepad;
  97341. }
  97342. /**
  97343. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97344. */
  97345. export class PoseEnabledControllerHelper {
  97346. /** @hidden */
  97347. static _ControllerFactories: _GamePadFactory[];
  97348. /** @hidden */
  97349. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97350. /**
  97351. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97352. * @param vrGamepad the gamepad to initialized
  97353. * @returns a vr controller of the type the gamepad identified as
  97354. */
  97355. static InitiateController(vrGamepad: any): Gamepad;
  97356. }
  97357. /**
  97358. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97359. */
  97360. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97361. /**
  97362. * If the controller is used in a webXR session
  97363. */
  97364. isXR: boolean;
  97365. private _deviceRoomPosition;
  97366. private _deviceRoomRotationQuaternion;
  97367. /**
  97368. * The device position in babylon space
  97369. */
  97370. devicePosition: Vector3;
  97371. /**
  97372. * The device rotation in babylon space
  97373. */
  97374. deviceRotationQuaternion: Quaternion;
  97375. /**
  97376. * The scale factor of the device in babylon space
  97377. */
  97378. deviceScaleFactor: number;
  97379. /**
  97380. * (Likely devicePosition should be used instead) The device position in its room space
  97381. */
  97382. position: Vector3;
  97383. /**
  97384. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97385. */
  97386. rotationQuaternion: Quaternion;
  97387. /**
  97388. * The type of controller (Eg. Windows mixed reality)
  97389. */
  97390. controllerType: PoseEnabledControllerType;
  97391. protected _calculatedPosition: Vector3;
  97392. private _calculatedRotation;
  97393. /**
  97394. * The raw pose from the device
  97395. */
  97396. rawPose: DevicePose;
  97397. private _trackPosition;
  97398. private _maxRotationDistFromHeadset;
  97399. private _draggedRoomRotation;
  97400. /**
  97401. * @hidden
  97402. */
  97403. _disableTrackPosition(fixedPosition: Vector3): void;
  97404. /**
  97405. * Internal, the mesh attached to the controller
  97406. * @hidden
  97407. */
  97408. _mesh: Nullable<AbstractMesh>;
  97409. private _poseControlledCamera;
  97410. private _leftHandSystemQuaternion;
  97411. /**
  97412. * Internal, matrix used to convert room space to babylon space
  97413. * @hidden
  97414. */
  97415. _deviceToWorld: Matrix;
  97416. /**
  97417. * Node to be used when casting a ray from the controller
  97418. * @hidden
  97419. */
  97420. _pointingPoseNode: Nullable<TransformNode>;
  97421. /**
  97422. * Name of the child mesh that can be used to cast a ray from the controller
  97423. */
  97424. static readonly POINTING_POSE: string;
  97425. /**
  97426. * Creates a new PoseEnabledController from a gamepad
  97427. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97428. */
  97429. constructor(browserGamepad: any);
  97430. private _workingMatrix;
  97431. /**
  97432. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97433. */
  97434. update(): void;
  97435. /**
  97436. * Updates only the pose device and mesh without doing any button event checking
  97437. */
  97438. protected _updatePoseAndMesh(): void;
  97439. /**
  97440. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97441. * @param poseData raw pose fromthe device
  97442. */
  97443. updateFromDevice(poseData: DevicePose): void;
  97444. /**
  97445. * @hidden
  97446. */
  97447. _meshAttachedObservable: Observable<AbstractMesh>;
  97448. /**
  97449. * Attaches a mesh to the controller
  97450. * @param mesh the mesh to be attached
  97451. */
  97452. attachToMesh(mesh: AbstractMesh): void;
  97453. /**
  97454. * Attaches the controllers mesh to a camera
  97455. * @param camera the camera the mesh should be attached to
  97456. */
  97457. attachToPoseControlledCamera(camera: TargetCamera): void;
  97458. /**
  97459. * Disposes of the controller
  97460. */
  97461. dispose(): void;
  97462. /**
  97463. * The mesh that is attached to the controller
  97464. */
  97465. get mesh(): Nullable<AbstractMesh>;
  97466. /**
  97467. * Gets the ray of the controller in the direction the controller is pointing
  97468. * @param length the length the resulting ray should be
  97469. * @returns a ray in the direction the controller is pointing
  97470. */
  97471. getForwardRay(length?: number): Ray;
  97472. }
  97473. }
  97474. declare module BABYLON {
  97475. /**
  97476. * Defines the WebVRController object that represents controllers tracked in 3D space
  97477. */
  97478. export abstract class WebVRController extends PoseEnabledController {
  97479. /**
  97480. * Internal, the default controller model for the controller
  97481. */
  97482. protected _defaultModel: Nullable<AbstractMesh>;
  97483. /**
  97484. * Fired when the trigger state has changed
  97485. */
  97486. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97487. /**
  97488. * Fired when the main button state has changed
  97489. */
  97490. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97491. /**
  97492. * Fired when the secondary button state has changed
  97493. */
  97494. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97495. /**
  97496. * Fired when the pad state has changed
  97497. */
  97498. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97499. /**
  97500. * Fired when controllers stick values have changed
  97501. */
  97502. onPadValuesChangedObservable: Observable<StickValues>;
  97503. /**
  97504. * Array of button availible on the controller
  97505. */
  97506. protected _buttons: Array<MutableGamepadButton>;
  97507. private _onButtonStateChange;
  97508. /**
  97509. * Fired when a controller button's state has changed
  97510. * @param callback the callback containing the button that was modified
  97511. */
  97512. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97513. /**
  97514. * X and Y axis corresponding to the controllers joystick
  97515. */
  97516. pad: StickValues;
  97517. /**
  97518. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97519. */
  97520. hand: string;
  97521. /**
  97522. * The default controller model for the controller
  97523. */
  97524. get defaultModel(): Nullable<AbstractMesh>;
  97525. /**
  97526. * Creates a new WebVRController from a gamepad
  97527. * @param vrGamepad the gamepad that the WebVRController should be created from
  97528. */
  97529. constructor(vrGamepad: any);
  97530. /**
  97531. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97532. */
  97533. update(): void;
  97534. /**
  97535. * Function to be called when a button is modified
  97536. */
  97537. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97538. /**
  97539. * Loads a mesh and attaches it to the controller
  97540. * @param scene the scene the mesh should be added to
  97541. * @param meshLoaded callback for when the mesh has been loaded
  97542. */
  97543. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97544. private _setButtonValue;
  97545. private _changes;
  97546. private _checkChanges;
  97547. /**
  97548. * Disposes of th webVRCOntroller
  97549. */
  97550. dispose(): void;
  97551. }
  97552. }
  97553. declare module BABYLON {
  97554. /**
  97555. * The HemisphericLight simulates the ambient environment light,
  97556. * so the passed direction is the light reflection direction, not the incoming direction.
  97557. */
  97558. export class HemisphericLight extends Light {
  97559. /**
  97560. * The groundColor is the light in the opposite direction to the one specified during creation.
  97561. * 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.
  97562. */
  97563. groundColor: Color3;
  97564. /**
  97565. * The light reflection direction, not the incoming direction.
  97566. */
  97567. direction: Vector3;
  97568. /**
  97569. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97570. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97571. * The HemisphericLight can't cast shadows.
  97572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97573. * @param name The friendly name of the light
  97574. * @param direction The direction of the light reflection
  97575. * @param scene The scene the light belongs to
  97576. */
  97577. constructor(name: string, direction: Vector3, scene: Scene);
  97578. protected _buildUniformLayout(): void;
  97579. /**
  97580. * Returns the string "HemisphericLight".
  97581. * @return The class name
  97582. */
  97583. getClassName(): string;
  97584. /**
  97585. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97586. * Returns the updated direction.
  97587. * @param target The target the direction should point to
  97588. * @return The computed direction
  97589. */
  97590. setDirectionToTarget(target: Vector3): Vector3;
  97591. /**
  97592. * Returns the shadow generator associated to the light.
  97593. * @returns Always null for hemispheric lights because it does not support shadows.
  97594. */
  97595. getShadowGenerator(): Nullable<IShadowGenerator>;
  97596. /**
  97597. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97598. * @param effect The effect to update
  97599. * @param lightIndex The index of the light in the effect to update
  97600. * @returns The hemispheric light
  97601. */
  97602. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97603. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97604. /**
  97605. * Computes the world matrix of the node
  97606. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97607. * @param useWasUpdatedFlag defines a reserved property
  97608. * @returns the world matrix
  97609. */
  97610. computeWorldMatrix(): Matrix;
  97611. /**
  97612. * Returns the integer 3.
  97613. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97614. */
  97615. getTypeID(): number;
  97616. /**
  97617. * Prepares the list of defines specific to the light type.
  97618. * @param defines the list of defines
  97619. * @param lightIndex defines the index of the light for the effect
  97620. */
  97621. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97622. }
  97623. }
  97624. declare module BABYLON {
  97625. /** @hidden */
  97626. export var vrMultiviewToSingleviewPixelShader: {
  97627. name: string;
  97628. shader: string;
  97629. };
  97630. }
  97631. declare module BABYLON {
  97632. /**
  97633. * Renders to multiple views with a single draw call
  97634. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97635. */
  97636. export class MultiviewRenderTarget extends RenderTargetTexture {
  97637. /**
  97638. * Creates a multiview render target
  97639. * @param scene scene used with the render target
  97640. * @param size the size of the render target (used for each view)
  97641. */
  97642. constructor(scene: Scene, size?: number | {
  97643. width: number;
  97644. height: number;
  97645. } | {
  97646. ratio: number;
  97647. });
  97648. /**
  97649. * @hidden
  97650. * @param faceIndex the face index, if its a cube texture
  97651. */
  97652. _bindFrameBuffer(faceIndex?: number): void;
  97653. /**
  97654. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97655. * @returns the view count
  97656. */
  97657. getViewCount(): number;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. interface Engine {
  97662. /**
  97663. * Creates a new multiview render target
  97664. * @param width defines the width of the texture
  97665. * @param height defines the height of the texture
  97666. * @returns the created multiview texture
  97667. */
  97668. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97669. /**
  97670. * Binds a multiview framebuffer to be drawn to
  97671. * @param multiviewTexture texture to bind
  97672. */
  97673. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97674. }
  97675. interface Camera {
  97676. /**
  97677. * @hidden
  97678. * 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)
  97679. */
  97680. _useMultiviewToSingleView: boolean;
  97681. /**
  97682. * @hidden
  97683. * 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)
  97684. */
  97685. _multiviewTexture: Nullable<RenderTargetTexture>;
  97686. /**
  97687. * @hidden
  97688. * ensures the multiview texture of the camera exists and has the specified width/height
  97689. * @param width height to set on the multiview texture
  97690. * @param height width to set on the multiview texture
  97691. */
  97692. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97693. }
  97694. interface Scene {
  97695. /** @hidden */
  97696. _transformMatrixR: Matrix;
  97697. /** @hidden */
  97698. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97699. /** @hidden */
  97700. _createMultiviewUbo(): void;
  97701. /** @hidden */
  97702. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97703. /** @hidden */
  97704. _renderMultiviewToSingleView(camera: Camera): void;
  97705. }
  97706. }
  97707. declare module BABYLON {
  97708. /**
  97709. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97710. * This will not be used for webXR as it supports displaying texture arrays directly
  97711. */
  97712. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97713. /**
  97714. * Initializes a VRMultiviewToSingleview
  97715. * @param name name of the post process
  97716. * @param camera camera to be applied to
  97717. * @param scaleFactor scaling factor to the size of the output texture
  97718. */
  97719. constructor(name: string, camera: Camera, scaleFactor: number);
  97720. }
  97721. }
  97722. declare module BABYLON {
  97723. /**
  97724. * Interface used to define additional presentation attributes
  97725. */
  97726. export interface IVRPresentationAttributes {
  97727. /**
  97728. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97729. */
  97730. highRefreshRate: boolean;
  97731. /**
  97732. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97733. */
  97734. foveationLevel: number;
  97735. }
  97736. interface Engine {
  97737. /** @hidden */
  97738. _vrDisplay: any;
  97739. /** @hidden */
  97740. _vrSupported: boolean;
  97741. /** @hidden */
  97742. _oldSize: Size;
  97743. /** @hidden */
  97744. _oldHardwareScaleFactor: number;
  97745. /** @hidden */
  97746. _vrExclusivePointerMode: boolean;
  97747. /** @hidden */
  97748. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97749. /** @hidden */
  97750. _onVRDisplayPointerRestricted: () => void;
  97751. /** @hidden */
  97752. _onVRDisplayPointerUnrestricted: () => void;
  97753. /** @hidden */
  97754. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97755. /** @hidden */
  97756. _onVrDisplayDisconnect: Nullable<() => void>;
  97757. /** @hidden */
  97758. _onVrDisplayPresentChange: Nullable<() => void>;
  97759. /**
  97760. * Observable signaled when VR display mode changes
  97761. */
  97762. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97763. /**
  97764. * Observable signaled when VR request present is complete
  97765. */
  97766. onVRRequestPresentComplete: Observable<boolean>;
  97767. /**
  97768. * Observable signaled when VR request present starts
  97769. */
  97770. onVRRequestPresentStart: Observable<Engine>;
  97771. /**
  97772. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97773. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97774. */
  97775. isInVRExclusivePointerMode: boolean;
  97776. /**
  97777. * Gets a boolean indicating if a webVR device was detected
  97778. * @returns true if a webVR device was detected
  97779. */
  97780. isVRDevicePresent(): boolean;
  97781. /**
  97782. * Gets the current webVR device
  97783. * @returns the current webVR device (or null)
  97784. */
  97785. getVRDevice(): any;
  97786. /**
  97787. * Initializes a webVR display and starts listening to display change events
  97788. * The onVRDisplayChangedObservable will be notified upon these changes
  97789. * @returns A promise containing a VRDisplay and if vr is supported
  97790. */
  97791. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97792. /** @hidden */
  97793. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97794. /**
  97795. * Gets or sets the presentation attributes used to configure VR rendering
  97796. */
  97797. vrPresentationAttributes?: IVRPresentationAttributes;
  97798. /**
  97799. * Call this function to switch to webVR mode
  97800. * Will do nothing if webVR is not supported or if there is no webVR device
  97801. * @param options the webvr options provided to the camera. mainly used for multiview
  97802. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97803. */
  97804. enableVR(options: WebVROptions): void;
  97805. /** @hidden */
  97806. _onVRFullScreenTriggered(): void;
  97807. }
  97808. }
  97809. declare module BABYLON {
  97810. /**
  97811. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97812. * IMPORTANT!! The data is right-hand data.
  97813. * @export
  97814. * @interface DevicePose
  97815. */
  97816. export interface DevicePose {
  97817. /**
  97818. * The position of the device, values in array are [x,y,z].
  97819. */
  97820. readonly position: Nullable<Float32Array>;
  97821. /**
  97822. * The linearVelocity of the device, values in array are [x,y,z].
  97823. */
  97824. readonly linearVelocity: Nullable<Float32Array>;
  97825. /**
  97826. * The linearAcceleration of the device, values in array are [x,y,z].
  97827. */
  97828. readonly linearAcceleration: Nullable<Float32Array>;
  97829. /**
  97830. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97831. */
  97832. readonly orientation: Nullable<Float32Array>;
  97833. /**
  97834. * The angularVelocity of the device, values in array are [x,y,z].
  97835. */
  97836. readonly angularVelocity: Nullable<Float32Array>;
  97837. /**
  97838. * The angularAcceleration of the device, values in array are [x,y,z].
  97839. */
  97840. readonly angularAcceleration: Nullable<Float32Array>;
  97841. }
  97842. /**
  97843. * Interface representing a pose controlled object in Babylon.
  97844. * A pose controlled object has both regular pose values as well as pose values
  97845. * from an external device such as a VR head mounted display
  97846. */
  97847. export interface PoseControlled {
  97848. /**
  97849. * The position of the object in babylon space.
  97850. */
  97851. position: Vector3;
  97852. /**
  97853. * The rotation quaternion of the object in babylon space.
  97854. */
  97855. rotationQuaternion: Quaternion;
  97856. /**
  97857. * The position of the device in babylon space.
  97858. */
  97859. devicePosition?: Vector3;
  97860. /**
  97861. * The rotation quaternion of the device in babylon space.
  97862. */
  97863. deviceRotationQuaternion: Quaternion;
  97864. /**
  97865. * The raw pose coming from the device.
  97866. */
  97867. rawPose: Nullable<DevicePose>;
  97868. /**
  97869. * The scale of the device to be used when translating from device space to babylon space.
  97870. */
  97871. deviceScaleFactor: number;
  97872. /**
  97873. * Updates the poseControlled values based on the input device pose.
  97874. * @param poseData the pose data to update the object with
  97875. */
  97876. updateFromDevice(poseData: DevicePose): void;
  97877. }
  97878. /**
  97879. * Set of options to customize the webVRCamera
  97880. */
  97881. export interface WebVROptions {
  97882. /**
  97883. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97884. */
  97885. trackPosition?: boolean;
  97886. /**
  97887. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97888. */
  97889. positionScale?: number;
  97890. /**
  97891. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97892. */
  97893. displayName?: string;
  97894. /**
  97895. * Should the native controller meshes be initialized. (default: true)
  97896. */
  97897. controllerMeshes?: boolean;
  97898. /**
  97899. * Creating a default HemiLight only on controllers. (default: true)
  97900. */
  97901. defaultLightingOnControllers?: boolean;
  97902. /**
  97903. * If you don't want to use the default VR button of the helper. (default: false)
  97904. */
  97905. useCustomVRButton?: boolean;
  97906. /**
  97907. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97908. */
  97909. customVRButton?: HTMLButtonElement;
  97910. /**
  97911. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97912. */
  97913. rayLength?: number;
  97914. /**
  97915. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97916. */
  97917. defaultHeight?: number;
  97918. /**
  97919. * If multiview should be used if availible (default: false)
  97920. */
  97921. useMultiview?: boolean;
  97922. }
  97923. /**
  97924. * This represents a WebVR camera.
  97925. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97926. * @example https://doc.babylonjs.com/how_to/webvr_camera
  97927. */
  97928. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97929. private webVROptions;
  97930. /**
  97931. * @hidden
  97932. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97933. */
  97934. _vrDevice: any;
  97935. /**
  97936. * The rawPose of the vrDevice.
  97937. */
  97938. rawPose: Nullable<DevicePose>;
  97939. private _onVREnabled;
  97940. private _specsVersion;
  97941. private _attached;
  97942. private _frameData;
  97943. protected _descendants: Array<Node>;
  97944. private _deviceRoomPosition;
  97945. /** @hidden */
  97946. _deviceRoomRotationQuaternion: Quaternion;
  97947. private _standingMatrix;
  97948. /**
  97949. * Represents device position in babylon space.
  97950. */
  97951. devicePosition: Vector3;
  97952. /**
  97953. * Represents device rotation in babylon space.
  97954. */
  97955. deviceRotationQuaternion: Quaternion;
  97956. /**
  97957. * The scale of the device to be used when translating from device space to babylon space.
  97958. */
  97959. deviceScaleFactor: number;
  97960. private _deviceToWorld;
  97961. private _worldToDevice;
  97962. /**
  97963. * References to the webVR controllers for the vrDevice.
  97964. */
  97965. controllers: Array<WebVRController>;
  97966. /**
  97967. * Emits an event when a controller is attached.
  97968. */
  97969. onControllersAttachedObservable: Observable<WebVRController[]>;
  97970. /**
  97971. * Emits an event when a controller's mesh has been loaded;
  97972. */
  97973. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97974. /**
  97975. * Emits an event when the HMD's pose has been updated.
  97976. */
  97977. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97978. private _poseSet;
  97979. /**
  97980. * If the rig cameras be used as parent instead of this camera.
  97981. */
  97982. rigParenting: boolean;
  97983. private _lightOnControllers;
  97984. private _defaultHeight?;
  97985. /**
  97986. * Instantiates a WebVRFreeCamera.
  97987. * @param name The name of the WebVRFreeCamera
  97988. * @param position The starting anchor position for the camera
  97989. * @param scene The scene the camera belongs to
  97990. * @param webVROptions a set of customizable options for the webVRCamera
  97991. */
  97992. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97993. /**
  97994. * Gets the device distance from the ground in meters.
  97995. * @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.
  97996. */
  97997. deviceDistanceToRoomGround(): number;
  97998. /**
  97999. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98000. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98001. */
  98002. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98003. /**
  98004. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98005. * @returns A promise with a boolean set to if the standing matrix is supported.
  98006. */
  98007. useStandingMatrixAsync(): Promise<boolean>;
  98008. /**
  98009. * Disposes the camera
  98010. */
  98011. dispose(): void;
  98012. /**
  98013. * Gets a vrController by name.
  98014. * @param name The name of the controller to retreive
  98015. * @returns the controller matching the name specified or null if not found
  98016. */
  98017. getControllerByName(name: string): Nullable<WebVRController>;
  98018. private _leftController;
  98019. /**
  98020. * The controller corresponding to the users left hand.
  98021. */
  98022. get leftController(): Nullable<WebVRController>;
  98023. private _rightController;
  98024. /**
  98025. * The controller corresponding to the users right hand.
  98026. */
  98027. get rightController(): Nullable<WebVRController>;
  98028. /**
  98029. * Casts a ray forward from the vrCamera's gaze.
  98030. * @param length Length of the ray (default: 100)
  98031. * @returns the ray corresponding to the gaze
  98032. */
  98033. getForwardRay(length?: number): Ray;
  98034. /**
  98035. * @hidden
  98036. * Updates the camera based on device's frame data
  98037. */
  98038. _checkInputs(): void;
  98039. /**
  98040. * Updates the poseControlled values based on the input device pose.
  98041. * @param poseData Pose coming from the device
  98042. */
  98043. updateFromDevice(poseData: DevicePose): void;
  98044. private _htmlElementAttached;
  98045. private _detachIfAttached;
  98046. /**
  98047. * WebVR's attach control will start broadcasting frames to the device.
  98048. * Note that in certain browsers (chrome for example) this function must be called
  98049. * within a user-interaction callback. Example:
  98050. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98051. *
  98052. * @param element html element to attach the vrDevice to
  98053. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98054. */
  98055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98056. /**
  98057. * Detaches the camera from the html element and disables VR
  98058. *
  98059. * @param element html element to detach from
  98060. */
  98061. detachControl(element: HTMLElement): void;
  98062. /**
  98063. * @returns the name of this class
  98064. */
  98065. getClassName(): string;
  98066. /**
  98067. * Calls resetPose on the vrDisplay
  98068. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98069. */
  98070. resetToCurrentRotation(): void;
  98071. /**
  98072. * @hidden
  98073. * Updates the rig cameras (left and right eye)
  98074. */
  98075. _updateRigCameras(): void;
  98076. private _workingVector;
  98077. private _oneVector;
  98078. private _workingMatrix;
  98079. private updateCacheCalled;
  98080. private _correctPositionIfNotTrackPosition;
  98081. /**
  98082. * @hidden
  98083. * Updates the cached values of the camera
  98084. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98085. */
  98086. _updateCache(ignoreParentClass?: boolean): void;
  98087. /**
  98088. * @hidden
  98089. * Get current device position in babylon world
  98090. */
  98091. _computeDevicePosition(): void;
  98092. /**
  98093. * Updates the current device position and rotation in the babylon world
  98094. */
  98095. update(): void;
  98096. /**
  98097. * @hidden
  98098. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98099. * @returns an identity matrix
  98100. */
  98101. _getViewMatrix(): Matrix;
  98102. private _tmpMatrix;
  98103. /**
  98104. * This function is called by the two RIG cameras.
  98105. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98106. * @hidden
  98107. */
  98108. _getWebVRViewMatrix(): Matrix;
  98109. /** @hidden */
  98110. _getWebVRProjectionMatrix(): Matrix;
  98111. private _onGamepadConnectedObserver;
  98112. private _onGamepadDisconnectedObserver;
  98113. private _updateCacheWhenTrackingDisabledObserver;
  98114. /**
  98115. * Initializes the controllers and their meshes
  98116. */
  98117. initControllers(): void;
  98118. }
  98119. }
  98120. declare module BABYLON {
  98121. /**
  98122. * "Static Class" containing the most commonly used helper while dealing with material for
  98123. * rendering purpose.
  98124. *
  98125. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98126. *
  98127. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98128. */
  98129. export class MaterialHelper {
  98130. /**
  98131. * Bind the current view position to an effect.
  98132. * @param effect The effect to be bound
  98133. * @param scene The scene the eyes position is used from
  98134. * @param variableName name of the shader variable that will hold the eye position
  98135. */
  98136. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98137. /**
  98138. * Helps preparing the defines values about the UVs in used in the effect.
  98139. * UVs are shared as much as we can accross channels in the shaders.
  98140. * @param texture The texture we are preparing the UVs for
  98141. * @param defines The defines to update
  98142. * @param key The channel key "diffuse", "specular"... used in the shader
  98143. */
  98144. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98145. /**
  98146. * Binds a texture matrix value to its corrsponding uniform
  98147. * @param texture The texture to bind the matrix for
  98148. * @param uniformBuffer The uniform buffer receivin the data
  98149. * @param key The channel key "diffuse", "specular"... used in the shader
  98150. */
  98151. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98152. /**
  98153. * Gets the current status of the fog (should it be enabled?)
  98154. * @param mesh defines the mesh to evaluate for fog support
  98155. * @param scene defines the hosting scene
  98156. * @returns true if fog must be enabled
  98157. */
  98158. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98159. /**
  98160. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98161. * @param mesh defines the current mesh
  98162. * @param scene defines the current scene
  98163. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98164. * @param pointsCloud defines if point cloud rendering has to be turned on
  98165. * @param fogEnabled defines if fog has to be turned on
  98166. * @param alphaTest defines if alpha testing has to be turned on
  98167. * @param defines defines the current list of defines
  98168. */
  98169. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98170. /**
  98171. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98172. * @param scene defines the current scene
  98173. * @param engine defines the current engine
  98174. * @param defines specifies the list of active defines
  98175. * @param useInstances defines if instances have to be turned on
  98176. * @param useClipPlane defines if clip plane have to be turned on
  98177. * @param useInstances defines if instances have to be turned on
  98178. * @param useThinInstances defines if thin instances have to be turned on
  98179. */
  98180. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98181. /**
  98182. * Prepares the defines for bones
  98183. * @param mesh The mesh containing the geometry data we will draw
  98184. * @param defines The defines to update
  98185. */
  98186. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98187. /**
  98188. * Prepares the defines for morph targets
  98189. * @param mesh The mesh containing the geometry data we will draw
  98190. * @param defines The defines to update
  98191. */
  98192. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98193. /**
  98194. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98195. * @param mesh The mesh containing the geometry data we will draw
  98196. * @param defines The defines to update
  98197. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98198. * @param useBones Precise whether bones should be used or not (override mesh info)
  98199. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98200. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98201. * @returns false if defines are considered not dirty and have not been checked
  98202. */
  98203. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98204. /**
  98205. * Prepares the defines related to multiview
  98206. * @param scene The scene we are intending to draw
  98207. * @param defines The defines to update
  98208. */
  98209. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98210. /**
  98211. * Prepares the defines related to the prepass
  98212. * @param scene The scene we are intending to draw
  98213. * @param defines The defines to update
  98214. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98215. */
  98216. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98217. /**
  98218. * Prepares the defines related to the light information passed in parameter
  98219. * @param scene The scene we are intending to draw
  98220. * @param mesh The mesh the effect is compiling for
  98221. * @param light The light the effect is compiling for
  98222. * @param lightIndex The index of the light
  98223. * @param defines The defines to update
  98224. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98225. * @param state Defines the current state regarding what is needed (normals, etc...)
  98226. */
  98227. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98228. needNormals: boolean;
  98229. needRebuild: boolean;
  98230. shadowEnabled: boolean;
  98231. specularEnabled: boolean;
  98232. lightmapMode: boolean;
  98233. }): void;
  98234. /**
  98235. * Prepares the defines related to the light information passed in parameter
  98236. * @param scene The scene we are intending to draw
  98237. * @param mesh The mesh the effect is compiling for
  98238. * @param defines The defines to update
  98239. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98240. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98241. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98242. * @returns true if normals will be required for the rest of the effect
  98243. */
  98244. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98245. /**
  98246. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98247. * @param lightIndex defines the light index
  98248. * @param uniformsList The uniform list
  98249. * @param samplersList The sampler list
  98250. * @param projectedLightTexture defines if projected texture must be used
  98251. * @param uniformBuffersList defines an optional list of uniform buffers
  98252. */
  98253. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98254. /**
  98255. * Prepares the uniforms and samplers list to be used in the effect
  98256. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98257. * @param samplersList The sampler list
  98258. * @param defines The defines helping in the list generation
  98259. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98260. */
  98261. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98262. /**
  98263. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98264. * @param defines The defines to update while falling back
  98265. * @param fallbacks The authorized effect fallbacks
  98266. * @param maxSimultaneousLights The maximum number of lights allowed
  98267. * @param rank the current rank of the Effect
  98268. * @returns The newly affected rank
  98269. */
  98270. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98271. private static _TmpMorphInfluencers;
  98272. /**
  98273. * Prepares the list of attributes required for morph targets according to the effect defines.
  98274. * @param attribs The current list of supported attribs
  98275. * @param mesh The mesh to prepare the morph targets attributes for
  98276. * @param influencers The number of influencers
  98277. */
  98278. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98279. /**
  98280. * Prepares the list of attributes required for morph targets according to the effect defines.
  98281. * @param attribs The current list of supported attribs
  98282. * @param mesh The mesh to prepare the morph targets attributes for
  98283. * @param defines The current Defines of the effect
  98284. */
  98285. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98286. /**
  98287. * Prepares the list of attributes required for bones according to the effect defines.
  98288. * @param attribs The current list of supported attribs
  98289. * @param mesh The mesh to prepare the bones attributes for
  98290. * @param defines The current Defines of the effect
  98291. * @param fallbacks The current efffect fallback strategy
  98292. */
  98293. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98294. /**
  98295. * Check and prepare the list of attributes required for instances according to the effect defines.
  98296. * @param attribs The current list of supported attribs
  98297. * @param defines The current MaterialDefines of the effect
  98298. */
  98299. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98300. /**
  98301. * Add the list of attributes required for instances to the attribs array.
  98302. * @param attribs The current list of supported attribs
  98303. */
  98304. static PushAttributesForInstances(attribs: string[]): void;
  98305. /**
  98306. * Binds the light information to the effect.
  98307. * @param light The light containing the generator
  98308. * @param effect The effect we are binding the data to
  98309. * @param lightIndex The light index in the effect used to render
  98310. */
  98311. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98312. /**
  98313. * Binds the lights information from the scene to the effect for the given mesh.
  98314. * @param light Light to bind
  98315. * @param lightIndex Light index
  98316. * @param scene The scene where the light belongs to
  98317. * @param effect The effect we are binding the data to
  98318. * @param useSpecular Defines if specular is supported
  98319. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98320. */
  98321. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98322. /**
  98323. * Binds the lights information from the scene to the effect for the given mesh.
  98324. * @param scene The scene the lights belongs to
  98325. * @param mesh The mesh we are binding the information to render
  98326. * @param effect The effect we are binding the data to
  98327. * @param defines The generated defines for the effect
  98328. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98329. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98330. */
  98331. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98332. private static _tempFogColor;
  98333. /**
  98334. * Binds the fog information from the scene to the effect for the given mesh.
  98335. * @param scene The scene the lights belongs to
  98336. * @param mesh The mesh we are binding the information to render
  98337. * @param effect The effect we are binding the data to
  98338. * @param linearSpace Defines if the fog effect is applied in linear space
  98339. */
  98340. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98341. /**
  98342. * Binds the bones information from the mesh to the effect.
  98343. * @param mesh The mesh we are binding the information to render
  98344. * @param effect The effect we are binding the data to
  98345. */
  98346. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98347. /**
  98348. * Binds the morph targets information from the mesh to the effect.
  98349. * @param abstractMesh The mesh we are binding the information to render
  98350. * @param effect The effect we are binding the data to
  98351. */
  98352. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98353. /**
  98354. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98355. * @param defines The generated defines used in the effect
  98356. * @param effect The effect we are binding the data to
  98357. * @param scene The scene we are willing to render with logarithmic scale for
  98358. */
  98359. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98360. /**
  98361. * Binds the clip plane information from the scene to the effect.
  98362. * @param scene The scene the clip plane information are extracted from
  98363. * @param effect The effect we are binding the data to
  98364. */
  98365. static BindClipPlane(effect: Effect, scene: Scene): void;
  98366. }
  98367. }
  98368. declare module BABYLON {
  98369. /**
  98370. * Block used to expose an input value
  98371. */
  98372. export class InputBlock extends NodeMaterialBlock {
  98373. private _mode;
  98374. private _associatedVariableName;
  98375. private _storedValue;
  98376. private _valueCallback;
  98377. private _type;
  98378. private _animationType;
  98379. /** Gets or set a value used to limit the range of float values */
  98380. min: number;
  98381. /** Gets or set a value used to limit the range of float values */
  98382. max: number;
  98383. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98384. isBoolean: boolean;
  98385. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98386. matrixMode: number;
  98387. /** @hidden */
  98388. _systemValue: Nullable<NodeMaterialSystemValues>;
  98389. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98390. visibleInInspector: boolean;
  98391. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98392. isConstant: boolean;
  98393. /** Gets or sets the group to use to display this block in the Inspector */
  98394. groupInInspector: string;
  98395. /** Gets an observable raised when the value is changed */
  98396. onValueChangedObservable: Observable<InputBlock>;
  98397. /**
  98398. * Gets or sets the connection point type (default is float)
  98399. */
  98400. get type(): NodeMaterialBlockConnectionPointTypes;
  98401. /**
  98402. * Creates a new InputBlock
  98403. * @param name defines the block name
  98404. * @param target defines the target of that block (Vertex by default)
  98405. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98406. */
  98407. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98408. /**
  98409. * Gets the output component
  98410. */
  98411. get output(): NodeMaterialConnectionPoint;
  98412. /**
  98413. * Set the source of this connection point to a vertex attribute
  98414. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98415. * @returns the current connection point
  98416. */
  98417. setAsAttribute(attributeName?: string): InputBlock;
  98418. /**
  98419. * Set the source of this connection point to a system value
  98420. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98421. * @returns the current connection point
  98422. */
  98423. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98424. /**
  98425. * Gets or sets the value of that point.
  98426. * Please note that this value will be ignored if valueCallback is defined
  98427. */
  98428. get value(): any;
  98429. set value(value: any);
  98430. /**
  98431. * Gets or sets a callback used to get the value of that point.
  98432. * Please note that setting this value will force the connection point to ignore the value property
  98433. */
  98434. get valueCallback(): () => any;
  98435. set valueCallback(value: () => any);
  98436. /**
  98437. * Gets or sets the associated variable name in the shader
  98438. */
  98439. get associatedVariableName(): string;
  98440. set associatedVariableName(value: string);
  98441. /** Gets or sets the type of animation applied to the input */
  98442. get animationType(): AnimatedInputBlockTypes;
  98443. set animationType(value: AnimatedInputBlockTypes);
  98444. /**
  98445. * Gets a boolean indicating that this connection point not defined yet
  98446. */
  98447. get isUndefined(): boolean;
  98448. /**
  98449. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98450. * In this case the connection point name must be the name of the uniform to use.
  98451. * Can only be set on inputs
  98452. */
  98453. get isUniform(): boolean;
  98454. set isUniform(value: boolean);
  98455. /**
  98456. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98457. * In this case the connection point name must be the name of the attribute to use
  98458. * Can only be set on inputs
  98459. */
  98460. get isAttribute(): boolean;
  98461. set isAttribute(value: boolean);
  98462. /**
  98463. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98464. * Can only be set on exit points
  98465. */
  98466. get isVarying(): boolean;
  98467. set isVarying(value: boolean);
  98468. /**
  98469. * Gets a boolean indicating that the current connection point is a system value
  98470. */
  98471. get isSystemValue(): boolean;
  98472. /**
  98473. * Gets or sets the current well known value or null if not defined as a system value
  98474. */
  98475. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98476. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98477. /**
  98478. * Gets the current class name
  98479. * @returns the class name
  98480. */
  98481. getClassName(): string;
  98482. /**
  98483. * Animate the input if animationType !== None
  98484. * @param scene defines the rendering scene
  98485. */
  98486. animate(scene: Scene): void;
  98487. private _emitDefine;
  98488. initialize(state: NodeMaterialBuildState): void;
  98489. /**
  98490. * Set the input block to its default value (based on its type)
  98491. */
  98492. setDefaultValue(): void;
  98493. private _emitConstant;
  98494. /** @hidden */
  98495. get _noContextSwitch(): boolean;
  98496. private _emit;
  98497. /** @hidden */
  98498. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98499. /** @hidden */
  98500. _transmit(effect: Effect, scene: Scene): void;
  98501. protected _buildBlock(state: NodeMaterialBuildState): void;
  98502. protected _dumpPropertiesCode(): string;
  98503. dispose(): void;
  98504. serialize(): any;
  98505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98506. }
  98507. }
  98508. declare module BABYLON {
  98509. /**
  98510. * Enum used to define the compatibility state between two connection points
  98511. */
  98512. export enum NodeMaterialConnectionPointCompatibilityStates {
  98513. /** Points are compatibles */
  98514. Compatible = 0,
  98515. /** Points are incompatible because of their types */
  98516. TypeIncompatible = 1,
  98517. /** Points are incompatible because of their targets (vertex vs fragment) */
  98518. TargetIncompatible = 2
  98519. }
  98520. /**
  98521. * Defines the direction of a connection point
  98522. */
  98523. export enum NodeMaterialConnectionPointDirection {
  98524. /** Input */
  98525. Input = 0,
  98526. /** Output */
  98527. Output = 1
  98528. }
  98529. /**
  98530. * Defines a connection point for a block
  98531. */
  98532. export class NodeMaterialConnectionPoint {
  98533. /** @hidden */
  98534. _ownerBlock: NodeMaterialBlock;
  98535. /** @hidden */
  98536. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98537. private _endpoints;
  98538. private _associatedVariableName;
  98539. private _direction;
  98540. /** @hidden */
  98541. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98542. /** @hidden */
  98543. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98544. private _type;
  98545. /** @hidden */
  98546. _enforceAssociatedVariableName: boolean;
  98547. /** Gets the direction of the point */
  98548. get direction(): NodeMaterialConnectionPointDirection;
  98549. /** Indicates that this connection point needs dual validation before being connected to another point */
  98550. needDualDirectionValidation: boolean;
  98551. /**
  98552. * Gets or sets the additional types supported by this connection point
  98553. */
  98554. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98555. /**
  98556. * Gets or sets the additional types excluded by this connection point
  98557. */
  98558. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98559. /**
  98560. * Observable triggered when this point is connected
  98561. */
  98562. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98563. /**
  98564. * Gets or sets the associated variable name in the shader
  98565. */
  98566. get associatedVariableName(): string;
  98567. set associatedVariableName(value: string);
  98568. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98569. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98570. /**
  98571. * Gets or sets the connection point type (default is float)
  98572. */
  98573. get type(): NodeMaterialBlockConnectionPointTypes;
  98574. set type(value: NodeMaterialBlockConnectionPointTypes);
  98575. /**
  98576. * Gets or sets the connection point name
  98577. */
  98578. name: string;
  98579. /**
  98580. * Gets or sets the connection point name
  98581. */
  98582. displayName: string;
  98583. /**
  98584. * Gets or sets a boolean indicating that this connection point can be omitted
  98585. */
  98586. isOptional: boolean;
  98587. /**
  98588. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98589. */
  98590. isExposedOnFrame: boolean;
  98591. /**
  98592. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98593. */
  98594. define: string;
  98595. /** @hidden */
  98596. _prioritizeVertex: boolean;
  98597. private _target;
  98598. /** Gets or sets the target of that connection point */
  98599. get target(): NodeMaterialBlockTargets;
  98600. set target(value: NodeMaterialBlockTargets);
  98601. /**
  98602. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98603. */
  98604. get isConnected(): boolean;
  98605. /**
  98606. * Gets a boolean indicating that the current point is connected to an input block
  98607. */
  98608. get isConnectedToInputBlock(): boolean;
  98609. /**
  98610. * Gets a the connected input block (if any)
  98611. */
  98612. get connectInputBlock(): Nullable<InputBlock>;
  98613. /** Get the other side of the connection (if any) */
  98614. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98615. /** Get the block that owns this connection point */
  98616. get ownerBlock(): NodeMaterialBlock;
  98617. /** Get the block connected on the other side of this connection (if any) */
  98618. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98619. /** Get the block connected on the endpoints of this connection (if any) */
  98620. get connectedBlocks(): Array<NodeMaterialBlock>;
  98621. /** Gets the list of connected endpoints */
  98622. get endpoints(): NodeMaterialConnectionPoint[];
  98623. /** Gets a boolean indicating if that output point is connected to at least one input */
  98624. get hasEndpoints(): boolean;
  98625. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98626. get isConnectedInVertexShader(): boolean;
  98627. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98628. get isConnectedInFragmentShader(): boolean;
  98629. /**
  98630. * Creates a block suitable to be used as an input for this input point.
  98631. * If null is returned, a block based on the point type will be created.
  98632. * @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
  98633. */
  98634. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98635. /**
  98636. * Creates a new connection point
  98637. * @param name defines the connection point name
  98638. * @param ownerBlock defines the block hosting this connection point
  98639. * @param direction defines the direction of the connection point
  98640. */
  98641. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98642. /**
  98643. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98644. * @returns the class name
  98645. */
  98646. getClassName(): string;
  98647. /**
  98648. * Gets a boolean indicating if the current point can be connected to another point
  98649. * @param connectionPoint defines the other connection point
  98650. * @returns a boolean
  98651. */
  98652. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98653. /**
  98654. * Gets a number indicating if the current point can be connected to another point
  98655. * @param connectionPoint defines the other connection point
  98656. * @returns a number defining the compatibility state
  98657. */
  98658. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98659. /**
  98660. * Connect this point to another connection point
  98661. * @param connectionPoint defines the other connection point
  98662. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98663. * @returns the current connection point
  98664. */
  98665. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98666. /**
  98667. * Disconnect this point from one of his endpoint
  98668. * @param endpoint defines the other connection point
  98669. * @returns the current connection point
  98670. */
  98671. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98672. /**
  98673. * Serializes this point in a JSON representation
  98674. * @param isInput defines if the connection point is an input (default is true)
  98675. * @returns the serialized point object
  98676. */
  98677. serialize(isInput?: boolean): any;
  98678. /**
  98679. * Release resources
  98680. */
  98681. dispose(): void;
  98682. }
  98683. }
  98684. declare module BABYLON {
  98685. /**
  98686. * Enum used to define the material modes
  98687. */
  98688. export enum NodeMaterialModes {
  98689. /** Regular material */
  98690. Material = 0,
  98691. /** For post process */
  98692. PostProcess = 1,
  98693. /** For particle system */
  98694. Particle = 2
  98695. }
  98696. }
  98697. declare module BABYLON {
  98698. /**
  98699. * Block used to read a texture from a sampler
  98700. */
  98701. export class TextureBlock extends NodeMaterialBlock {
  98702. private _defineName;
  98703. private _linearDefineName;
  98704. private _gammaDefineName;
  98705. private _tempTextureRead;
  98706. private _samplerName;
  98707. private _transformedUVName;
  98708. private _textureTransformName;
  98709. private _textureInfoName;
  98710. private _mainUVName;
  98711. private _mainUVDefineName;
  98712. private _fragmentOnly;
  98713. /**
  98714. * Gets or sets the texture associated with the node
  98715. */
  98716. texture: Nullable<Texture>;
  98717. /**
  98718. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98719. */
  98720. convertToGammaSpace: boolean;
  98721. /**
  98722. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98723. */
  98724. convertToLinearSpace: boolean;
  98725. /**
  98726. * Create a new TextureBlock
  98727. * @param name defines the block name
  98728. */
  98729. constructor(name: string, fragmentOnly?: boolean);
  98730. /**
  98731. * Gets the current class name
  98732. * @returns the class name
  98733. */
  98734. getClassName(): string;
  98735. /**
  98736. * Gets the uv input component
  98737. */
  98738. get uv(): NodeMaterialConnectionPoint;
  98739. /**
  98740. * Gets the rgba output component
  98741. */
  98742. get rgba(): NodeMaterialConnectionPoint;
  98743. /**
  98744. * Gets the rgb output component
  98745. */
  98746. get rgb(): NodeMaterialConnectionPoint;
  98747. /**
  98748. * Gets the r output component
  98749. */
  98750. get r(): NodeMaterialConnectionPoint;
  98751. /**
  98752. * Gets the g output component
  98753. */
  98754. get g(): NodeMaterialConnectionPoint;
  98755. /**
  98756. * Gets the b output component
  98757. */
  98758. get b(): NodeMaterialConnectionPoint;
  98759. /**
  98760. * Gets the a output component
  98761. */
  98762. get a(): NodeMaterialConnectionPoint;
  98763. get target(): NodeMaterialBlockTargets;
  98764. autoConfigure(material: NodeMaterial): void;
  98765. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98767. isReady(): boolean;
  98768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98769. private get _isMixed();
  98770. private _injectVertexCode;
  98771. private _writeTextureRead;
  98772. private _writeOutput;
  98773. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98774. protected _dumpPropertiesCode(): string;
  98775. serialize(): any;
  98776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98777. }
  98778. }
  98779. declare module BABYLON {
  98780. /** @hidden */
  98781. export var reflectionFunction: {
  98782. name: string;
  98783. shader: string;
  98784. };
  98785. }
  98786. declare module BABYLON {
  98787. /**
  98788. * Base block used to read a reflection texture from a sampler
  98789. */
  98790. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98791. /** @hidden */
  98792. _define3DName: string;
  98793. /** @hidden */
  98794. _defineCubicName: string;
  98795. /** @hidden */
  98796. _defineExplicitName: string;
  98797. /** @hidden */
  98798. _defineProjectionName: string;
  98799. /** @hidden */
  98800. _defineLocalCubicName: string;
  98801. /** @hidden */
  98802. _defineSphericalName: string;
  98803. /** @hidden */
  98804. _definePlanarName: string;
  98805. /** @hidden */
  98806. _defineEquirectangularName: string;
  98807. /** @hidden */
  98808. _defineMirroredEquirectangularFixedName: string;
  98809. /** @hidden */
  98810. _defineEquirectangularFixedName: string;
  98811. /** @hidden */
  98812. _defineSkyboxName: string;
  98813. /** @hidden */
  98814. _defineOppositeZ: string;
  98815. /** @hidden */
  98816. _cubeSamplerName: string;
  98817. /** @hidden */
  98818. _2DSamplerName: string;
  98819. protected _positionUVWName: string;
  98820. protected _directionWName: string;
  98821. protected _reflectionVectorName: string;
  98822. /** @hidden */
  98823. _reflectionCoordsName: string;
  98824. /** @hidden */
  98825. _reflectionMatrixName: string;
  98826. protected _reflectionColorName: string;
  98827. /**
  98828. * Gets or sets the texture associated with the node
  98829. */
  98830. texture: Nullable<BaseTexture>;
  98831. /**
  98832. * Create a new ReflectionTextureBaseBlock
  98833. * @param name defines the block name
  98834. */
  98835. constructor(name: string);
  98836. /**
  98837. * Gets the current class name
  98838. * @returns the class name
  98839. */
  98840. getClassName(): string;
  98841. /**
  98842. * Gets the world position input component
  98843. */
  98844. abstract get position(): NodeMaterialConnectionPoint;
  98845. /**
  98846. * Gets the world position input component
  98847. */
  98848. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98849. /**
  98850. * Gets the world normal input component
  98851. */
  98852. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98853. /**
  98854. * Gets the world input component
  98855. */
  98856. abstract get world(): NodeMaterialConnectionPoint;
  98857. /**
  98858. * Gets the camera (or eye) position component
  98859. */
  98860. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98861. /**
  98862. * Gets the view input component
  98863. */
  98864. abstract get view(): NodeMaterialConnectionPoint;
  98865. protected _getTexture(): Nullable<BaseTexture>;
  98866. autoConfigure(material: NodeMaterial): void;
  98867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98868. isReady(): boolean;
  98869. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98870. /**
  98871. * Gets the code to inject in the vertex shader
  98872. * @param state current state of the node material building
  98873. * @returns the shader code
  98874. */
  98875. handleVertexSide(state: NodeMaterialBuildState): string;
  98876. /**
  98877. * Handles the inits for the fragment code path
  98878. * @param state node material build state
  98879. */
  98880. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98881. /**
  98882. * Generates the reflection coords code for the fragment code path
  98883. * @param worldNormalVarName name of the world normal variable
  98884. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98885. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98886. * @returns the shader code
  98887. */
  98888. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98889. /**
  98890. * Generates the reflection color code for the fragment code path
  98891. * @param lodVarName name of the lod variable
  98892. * @param swizzleLookupTexture swizzle to use for the final color variable
  98893. * @returns the shader code
  98894. */
  98895. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98896. /**
  98897. * Generates the code corresponding to the connected output points
  98898. * @param state node material build state
  98899. * @param varName name of the variable to output
  98900. * @returns the shader code
  98901. */
  98902. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98903. protected _buildBlock(state: NodeMaterialBuildState): this;
  98904. protected _dumpPropertiesCode(): string;
  98905. serialize(): any;
  98906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98907. }
  98908. }
  98909. declare module BABYLON {
  98910. /**
  98911. * Defines a connection point to be used for points with a custom object type
  98912. */
  98913. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98914. private _blockType;
  98915. private _blockName;
  98916. private _nameForCheking?;
  98917. /**
  98918. * Creates a new connection point
  98919. * @param name defines the connection point name
  98920. * @param ownerBlock defines the block hosting this connection point
  98921. * @param direction defines the direction of the connection point
  98922. */
  98923. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98924. /**
  98925. * Gets a number indicating if the current point can be connected to another point
  98926. * @param connectionPoint defines the other connection point
  98927. * @returns a number defining the compatibility state
  98928. */
  98929. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98930. /**
  98931. * Creates a block suitable to be used as an input for this input point.
  98932. * If null is returned, a block based on the point type will be created.
  98933. * @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
  98934. */
  98935. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98936. }
  98937. }
  98938. declare module BABYLON {
  98939. /**
  98940. * Enum defining the type of properties that can be edited in the property pages in the NME
  98941. */
  98942. export enum PropertyTypeForEdition {
  98943. /** property is a boolean */
  98944. Boolean = 0,
  98945. /** property is a float */
  98946. Float = 1,
  98947. /** property is a Vector2 */
  98948. Vector2 = 2,
  98949. /** property is a list of values */
  98950. List = 3
  98951. }
  98952. /**
  98953. * Interface that defines an option in a variable of type list
  98954. */
  98955. export interface IEditablePropertyListOption {
  98956. /** label of the option */
  98957. "label": string;
  98958. /** value of the option */
  98959. "value": number;
  98960. }
  98961. /**
  98962. * Interface that defines the options available for an editable property
  98963. */
  98964. export interface IEditablePropertyOption {
  98965. /** min value */
  98966. "min"?: number;
  98967. /** max value */
  98968. "max"?: number;
  98969. /** notifiers: indicates which actions to take when the property is changed */
  98970. "notifiers"?: {
  98971. /** the material should be rebuilt */
  98972. "rebuild"?: boolean;
  98973. /** the preview should be updated */
  98974. "update"?: boolean;
  98975. };
  98976. /** list of the options for a variable of type list */
  98977. "options"?: IEditablePropertyListOption[];
  98978. }
  98979. /**
  98980. * Interface that describes an editable property
  98981. */
  98982. export interface IPropertyDescriptionForEdition {
  98983. /** name of the property */
  98984. "propertyName": string;
  98985. /** display name of the property */
  98986. "displayName": string;
  98987. /** type of the property */
  98988. "type": PropertyTypeForEdition;
  98989. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98990. "groupName": string;
  98991. /** options for the property */
  98992. "options": IEditablePropertyOption;
  98993. }
  98994. /**
  98995. * Decorator that flags a property in a node material block as being editable
  98996. */
  98997. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98998. }
  98999. declare module BABYLON {
  99000. /**
  99001. * Block used to implement the refraction part of the sub surface module of the PBR material
  99002. */
  99003. export class RefractionBlock extends NodeMaterialBlock {
  99004. /** @hidden */
  99005. _define3DName: string;
  99006. /** @hidden */
  99007. _refractionMatrixName: string;
  99008. /** @hidden */
  99009. _defineLODRefractionAlpha: string;
  99010. /** @hidden */
  99011. _defineLinearSpecularRefraction: string;
  99012. /** @hidden */
  99013. _defineOppositeZ: string;
  99014. /** @hidden */
  99015. _cubeSamplerName: string;
  99016. /** @hidden */
  99017. _2DSamplerName: string;
  99018. /** @hidden */
  99019. _vRefractionMicrosurfaceInfosName: string;
  99020. /** @hidden */
  99021. _vRefractionInfosName: string;
  99022. private _scene;
  99023. /**
  99024. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99025. * Materials half opaque for instance using refraction could benefit from this control.
  99026. */
  99027. linkRefractionWithTransparency: boolean;
  99028. /**
  99029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99030. */
  99031. invertRefractionY: boolean;
  99032. /**
  99033. * Gets or sets the texture associated with the node
  99034. */
  99035. texture: Nullable<BaseTexture>;
  99036. /**
  99037. * Create a new RefractionBlock
  99038. * @param name defines the block name
  99039. */
  99040. constructor(name: string);
  99041. /**
  99042. * Gets the current class name
  99043. * @returns the class name
  99044. */
  99045. getClassName(): string;
  99046. /**
  99047. * Gets the intensity input component
  99048. */
  99049. get intensity(): NodeMaterialConnectionPoint;
  99050. /**
  99051. * Gets the index of refraction input component
  99052. */
  99053. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99054. /**
  99055. * Gets the tint at distance input component
  99056. */
  99057. get tintAtDistance(): NodeMaterialConnectionPoint;
  99058. /**
  99059. * Gets the view input component
  99060. */
  99061. get view(): NodeMaterialConnectionPoint;
  99062. /**
  99063. * Gets the refraction object output component
  99064. */
  99065. get refraction(): NodeMaterialConnectionPoint;
  99066. /**
  99067. * Returns true if the block has a texture
  99068. */
  99069. get hasTexture(): boolean;
  99070. protected _getTexture(): Nullable<BaseTexture>;
  99071. autoConfigure(material: NodeMaterial): void;
  99072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99073. isReady(): boolean;
  99074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99075. /**
  99076. * Gets the main code of the block (fragment side)
  99077. * @param state current state of the node material building
  99078. * @returns the shader code
  99079. */
  99080. getCode(state: NodeMaterialBuildState): string;
  99081. protected _buildBlock(state: NodeMaterialBuildState): this;
  99082. protected _dumpPropertiesCode(): string;
  99083. serialize(): any;
  99084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99085. }
  99086. }
  99087. declare module BABYLON {
  99088. /**
  99089. * Base block used as input for post process
  99090. */
  99091. export class CurrentScreenBlock extends NodeMaterialBlock {
  99092. private _samplerName;
  99093. private _linearDefineName;
  99094. private _gammaDefineName;
  99095. private _mainUVName;
  99096. private _tempTextureRead;
  99097. /**
  99098. * Gets or sets the texture associated with the node
  99099. */
  99100. texture: Nullable<BaseTexture>;
  99101. /**
  99102. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99103. */
  99104. convertToGammaSpace: boolean;
  99105. /**
  99106. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99107. */
  99108. convertToLinearSpace: boolean;
  99109. /**
  99110. * Create a new CurrentScreenBlock
  99111. * @param name defines the block name
  99112. */
  99113. constructor(name: string);
  99114. /**
  99115. * Gets the current class name
  99116. * @returns the class name
  99117. */
  99118. getClassName(): string;
  99119. /**
  99120. * Gets the uv input component
  99121. */
  99122. get uv(): NodeMaterialConnectionPoint;
  99123. /**
  99124. * Gets the rgba output component
  99125. */
  99126. get rgba(): NodeMaterialConnectionPoint;
  99127. /**
  99128. * Gets the rgb output component
  99129. */
  99130. get rgb(): NodeMaterialConnectionPoint;
  99131. /**
  99132. * Gets the r output component
  99133. */
  99134. get r(): NodeMaterialConnectionPoint;
  99135. /**
  99136. * Gets the g output component
  99137. */
  99138. get g(): NodeMaterialConnectionPoint;
  99139. /**
  99140. * Gets the b output component
  99141. */
  99142. get b(): NodeMaterialConnectionPoint;
  99143. /**
  99144. * Gets the a output component
  99145. */
  99146. get a(): NodeMaterialConnectionPoint;
  99147. /**
  99148. * Initialize the block and prepare the context for build
  99149. * @param state defines the state that will be used for the build
  99150. */
  99151. initialize(state: NodeMaterialBuildState): void;
  99152. get target(): NodeMaterialBlockTargets;
  99153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99154. isReady(): boolean;
  99155. private _injectVertexCode;
  99156. private _writeTextureRead;
  99157. private _writeOutput;
  99158. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99159. serialize(): any;
  99160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99161. }
  99162. }
  99163. declare module BABYLON {
  99164. /**
  99165. * Base block used for the particle texture
  99166. */
  99167. export class ParticleTextureBlock extends NodeMaterialBlock {
  99168. private _samplerName;
  99169. private _linearDefineName;
  99170. private _gammaDefineName;
  99171. private _tempTextureRead;
  99172. /**
  99173. * Gets or sets the texture associated with the node
  99174. */
  99175. texture: Nullable<BaseTexture>;
  99176. /**
  99177. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99178. */
  99179. convertToGammaSpace: boolean;
  99180. /**
  99181. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99182. */
  99183. convertToLinearSpace: boolean;
  99184. /**
  99185. * Create a new ParticleTextureBlock
  99186. * @param name defines the block name
  99187. */
  99188. constructor(name: string);
  99189. /**
  99190. * Gets the current class name
  99191. * @returns the class name
  99192. */
  99193. getClassName(): string;
  99194. /**
  99195. * Gets the uv input component
  99196. */
  99197. get uv(): NodeMaterialConnectionPoint;
  99198. /**
  99199. * Gets the rgba output component
  99200. */
  99201. get rgba(): NodeMaterialConnectionPoint;
  99202. /**
  99203. * Gets the rgb output component
  99204. */
  99205. get rgb(): NodeMaterialConnectionPoint;
  99206. /**
  99207. * Gets the r output component
  99208. */
  99209. get r(): NodeMaterialConnectionPoint;
  99210. /**
  99211. * Gets the g output component
  99212. */
  99213. get g(): NodeMaterialConnectionPoint;
  99214. /**
  99215. * Gets the b output component
  99216. */
  99217. get b(): NodeMaterialConnectionPoint;
  99218. /**
  99219. * Gets the a output component
  99220. */
  99221. get a(): NodeMaterialConnectionPoint;
  99222. /**
  99223. * Initialize the block and prepare the context for build
  99224. * @param state defines the state that will be used for the build
  99225. */
  99226. initialize(state: NodeMaterialBuildState): void;
  99227. autoConfigure(material: NodeMaterial): void;
  99228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99229. isReady(): boolean;
  99230. private _writeOutput;
  99231. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99232. serialize(): any;
  99233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99234. }
  99235. }
  99236. declare module BABYLON {
  99237. /**
  99238. * Class used to store shared data between 2 NodeMaterialBuildState
  99239. */
  99240. export class NodeMaterialBuildStateSharedData {
  99241. /**
  99242. * Gets the list of emitted varyings
  99243. */
  99244. temps: string[];
  99245. /**
  99246. * Gets the list of emitted varyings
  99247. */
  99248. varyings: string[];
  99249. /**
  99250. * Gets the varying declaration string
  99251. */
  99252. varyingDeclaration: string;
  99253. /**
  99254. * Input blocks
  99255. */
  99256. inputBlocks: InputBlock[];
  99257. /**
  99258. * Input blocks
  99259. */
  99260. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99261. /**
  99262. * Bindable blocks (Blocks that need to set data to the effect)
  99263. */
  99264. bindableBlocks: NodeMaterialBlock[];
  99265. /**
  99266. * List of blocks that can provide a compilation fallback
  99267. */
  99268. blocksWithFallbacks: NodeMaterialBlock[];
  99269. /**
  99270. * List of blocks that can provide a define update
  99271. */
  99272. blocksWithDefines: NodeMaterialBlock[];
  99273. /**
  99274. * List of blocks that can provide a repeatable content
  99275. */
  99276. repeatableContentBlocks: NodeMaterialBlock[];
  99277. /**
  99278. * List of blocks that can provide a dynamic list of uniforms
  99279. */
  99280. dynamicUniformBlocks: NodeMaterialBlock[];
  99281. /**
  99282. * List of blocks that can block the isReady function for the material
  99283. */
  99284. blockingBlocks: NodeMaterialBlock[];
  99285. /**
  99286. * Gets the list of animated inputs
  99287. */
  99288. animatedInputs: InputBlock[];
  99289. /**
  99290. * Build Id used to avoid multiple recompilations
  99291. */
  99292. buildId: number;
  99293. /** List of emitted variables */
  99294. variableNames: {
  99295. [key: string]: number;
  99296. };
  99297. /** List of emitted defines */
  99298. defineNames: {
  99299. [key: string]: number;
  99300. };
  99301. /** Should emit comments? */
  99302. emitComments: boolean;
  99303. /** Emit build activity */
  99304. verbose: boolean;
  99305. /** Gets or sets the hosting scene */
  99306. scene: Scene;
  99307. /**
  99308. * Gets the compilation hints emitted at compilation time
  99309. */
  99310. hints: {
  99311. needWorldViewMatrix: boolean;
  99312. needWorldViewProjectionMatrix: boolean;
  99313. needAlphaBlending: boolean;
  99314. needAlphaTesting: boolean;
  99315. };
  99316. /**
  99317. * List of compilation checks
  99318. */
  99319. checks: {
  99320. emitVertex: boolean;
  99321. emitFragment: boolean;
  99322. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99323. };
  99324. /**
  99325. * Is vertex program allowed to be empty?
  99326. */
  99327. allowEmptyVertexProgram: boolean;
  99328. /** Creates a new shared data */
  99329. constructor();
  99330. /**
  99331. * Emits console errors and exceptions if there is a failing check
  99332. */
  99333. emitErrors(): void;
  99334. }
  99335. }
  99336. declare module BABYLON {
  99337. /**
  99338. * Class used to store node based material build state
  99339. */
  99340. export class NodeMaterialBuildState {
  99341. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99342. supportUniformBuffers: boolean;
  99343. /**
  99344. * Gets the list of emitted attributes
  99345. */
  99346. attributes: string[];
  99347. /**
  99348. * Gets the list of emitted uniforms
  99349. */
  99350. uniforms: string[];
  99351. /**
  99352. * Gets the list of emitted constants
  99353. */
  99354. constants: string[];
  99355. /**
  99356. * Gets the list of emitted samplers
  99357. */
  99358. samplers: string[];
  99359. /**
  99360. * Gets the list of emitted functions
  99361. */
  99362. functions: {
  99363. [key: string]: string;
  99364. };
  99365. /**
  99366. * Gets the list of emitted extensions
  99367. */
  99368. extensions: {
  99369. [key: string]: string;
  99370. };
  99371. /**
  99372. * Gets the target of the compilation state
  99373. */
  99374. target: NodeMaterialBlockTargets;
  99375. /**
  99376. * Gets the list of emitted counters
  99377. */
  99378. counters: {
  99379. [key: string]: number;
  99380. };
  99381. /**
  99382. * Shared data between multiple NodeMaterialBuildState instances
  99383. */
  99384. sharedData: NodeMaterialBuildStateSharedData;
  99385. /** @hidden */
  99386. _vertexState: NodeMaterialBuildState;
  99387. /** @hidden */
  99388. _attributeDeclaration: string;
  99389. /** @hidden */
  99390. _uniformDeclaration: string;
  99391. /** @hidden */
  99392. _constantDeclaration: string;
  99393. /** @hidden */
  99394. _samplerDeclaration: string;
  99395. /** @hidden */
  99396. _varyingTransfer: string;
  99397. /** @hidden */
  99398. _injectAtEnd: string;
  99399. private _repeatableContentAnchorIndex;
  99400. /** @hidden */
  99401. _builtCompilationString: string;
  99402. /**
  99403. * Gets the emitted compilation strings
  99404. */
  99405. compilationString: string;
  99406. /**
  99407. * Finalize the compilation strings
  99408. * @param state defines the current compilation state
  99409. */
  99410. finalize(state: NodeMaterialBuildState): void;
  99411. /** @hidden */
  99412. get _repeatableContentAnchor(): string;
  99413. /** @hidden */
  99414. _getFreeVariableName(prefix: string): string;
  99415. /** @hidden */
  99416. _getFreeDefineName(prefix: string): string;
  99417. /** @hidden */
  99418. _excludeVariableName(name: string): void;
  99419. /** @hidden */
  99420. _emit2DSampler(name: string): void;
  99421. /** @hidden */
  99422. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99423. /** @hidden */
  99424. _emitExtension(name: string, extension: string, define?: string): void;
  99425. /** @hidden */
  99426. _emitFunction(name: string, code: string, comments: string): void;
  99427. /** @hidden */
  99428. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99429. replaceStrings?: {
  99430. search: RegExp;
  99431. replace: string;
  99432. }[];
  99433. repeatKey?: string;
  99434. }): string;
  99435. /** @hidden */
  99436. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99437. repeatKey?: string;
  99438. removeAttributes?: boolean;
  99439. removeUniforms?: boolean;
  99440. removeVaryings?: boolean;
  99441. removeIfDef?: boolean;
  99442. replaceStrings?: {
  99443. search: RegExp;
  99444. replace: string;
  99445. }[];
  99446. }, storeKey?: string): void;
  99447. /** @hidden */
  99448. _registerTempVariable(name: string): boolean;
  99449. /** @hidden */
  99450. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99451. /** @hidden */
  99452. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99453. /** @hidden */
  99454. _emitFloat(value: number): string;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Helper class used to generate session unique ID
  99460. */
  99461. export class UniqueIdGenerator {
  99462. private static _UniqueIdCounter;
  99463. /**
  99464. * Gets an unique (relatively to the current scene) Id
  99465. */
  99466. static get UniqueId(): number;
  99467. }
  99468. }
  99469. declare module BABYLON {
  99470. /**
  99471. * Defines a block that can be used inside a node based material
  99472. */
  99473. export class NodeMaterialBlock {
  99474. private _buildId;
  99475. private _buildTarget;
  99476. private _target;
  99477. private _isFinalMerger;
  99478. private _isInput;
  99479. protected _isUnique: boolean;
  99480. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99481. inputsAreExclusive: boolean;
  99482. /** @hidden */
  99483. _codeVariableName: string;
  99484. /** @hidden */
  99485. _inputs: NodeMaterialConnectionPoint[];
  99486. /** @hidden */
  99487. _outputs: NodeMaterialConnectionPoint[];
  99488. /** @hidden */
  99489. _preparationId: number;
  99490. /**
  99491. * Gets or sets the name of the block
  99492. */
  99493. name: string;
  99494. /**
  99495. * Gets or sets the unique id of the node
  99496. */
  99497. uniqueId: number;
  99498. /**
  99499. * Gets or sets the comments associated with this block
  99500. */
  99501. comments: string;
  99502. /**
  99503. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99504. */
  99505. get isUnique(): boolean;
  99506. /**
  99507. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99508. */
  99509. get isFinalMerger(): boolean;
  99510. /**
  99511. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99512. */
  99513. get isInput(): boolean;
  99514. /**
  99515. * Gets or sets the build Id
  99516. */
  99517. get buildId(): number;
  99518. set buildId(value: number);
  99519. /**
  99520. * Gets or sets the target of the block
  99521. */
  99522. get target(): NodeMaterialBlockTargets;
  99523. set target(value: NodeMaterialBlockTargets);
  99524. /**
  99525. * Gets the list of input points
  99526. */
  99527. get inputs(): NodeMaterialConnectionPoint[];
  99528. /** Gets the list of output points */
  99529. get outputs(): NodeMaterialConnectionPoint[];
  99530. /**
  99531. * Find an input by its name
  99532. * @param name defines the name of the input to look for
  99533. * @returns the input or null if not found
  99534. */
  99535. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99536. /**
  99537. * Find an output by its name
  99538. * @param name defines the name of the outputto look for
  99539. * @returns the output or null if not found
  99540. */
  99541. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99542. /**
  99543. * Creates a new NodeMaterialBlock
  99544. * @param name defines the block name
  99545. * @param target defines the target of that block (Vertex by default)
  99546. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99547. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99548. */
  99549. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99550. /**
  99551. * Initialize the block and prepare the context for build
  99552. * @param state defines the state that will be used for the build
  99553. */
  99554. initialize(state: NodeMaterialBuildState): void;
  99555. /**
  99556. * Bind data to effect. Will only be called for blocks with isBindable === true
  99557. * @param effect defines the effect to bind data to
  99558. * @param nodeMaterial defines the hosting NodeMaterial
  99559. * @param mesh defines the mesh that will be rendered
  99560. * @param subMesh defines the submesh that will be rendered
  99561. */
  99562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99563. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99564. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99565. protected _writeFloat(value: number): string;
  99566. /**
  99567. * Gets the current class name e.g. "NodeMaterialBlock"
  99568. * @returns the class name
  99569. */
  99570. getClassName(): string;
  99571. /**
  99572. * Register a new input. 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 isOptional defines a boolean indicating that this input can be omitted
  99576. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99577. * @param point an already created connection point. If not provided, create a new one
  99578. * @returns the current block
  99579. */
  99580. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99581. /**
  99582. * Register a new output. Must be called inside a block constructor
  99583. * @param name defines the connection point name
  99584. * @param type defines the connection point type
  99585. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99586. * @param point an already created connection point. If not provided, create a new one
  99587. * @returns the current block
  99588. */
  99589. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99590. /**
  99591. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99592. * @param forOutput defines an optional connection point to check compatibility with
  99593. * @returns the first available input or null
  99594. */
  99595. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99596. /**
  99597. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99598. * @param forBlock defines an optional block to check compatibility with
  99599. * @returns the first available input or null
  99600. */
  99601. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99602. /**
  99603. * Gets the sibling of the given output
  99604. * @param current defines the current output
  99605. * @returns the next output in the list or null
  99606. */
  99607. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99608. /**
  99609. * Connect current block with another block
  99610. * @param other defines the block to connect with
  99611. * @param options define the various options to help pick the right connections
  99612. * @returns the current block
  99613. */
  99614. connectTo(other: NodeMaterialBlock, options?: {
  99615. input?: string;
  99616. output?: string;
  99617. outputSwizzle?: string;
  99618. }): this | undefined;
  99619. protected _buildBlock(state: NodeMaterialBuildState): void;
  99620. /**
  99621. * Add uniforms, samplers and uniform buffers at compilation time
  99622. * @param state defines the state to update
  99623. * @param nodeMaterial defines the node material requesting the update
  99624. * @param defines defines the material defines to update
  99625. * @param uniformBuffers defines the list of uniform buffer names
  99626. */
  99627. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99628. /**
  99629. * Add potential fallbacks if shader compilation fails
  99630. * @param mesh defines the mesh to be rendered
  99631. * @param fallbacks defines the current prioritized list of fallbacks
  99632. */
  99633. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99634. /**
  99635. * Initialize defines for shader compilation
  99636. * @param mesh defines the mesh to be rendered
  99637. * @param nodeMaterial defines the node material requesting the update
  99638. * @param defines defines the material defines to update
  99639. * @param useInstances specifies that instances should be used
  99640. */
  99641. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99642. /**
  99643. * Update defines for shader compilation
  99644. * @param mesh defines the mesh to be rendered
  99645. * @param nodeMaterial defines the node material requesting the update
  99646. * @param defines defines the material defines to update
  99647. * @param useInstances specifies that instances should be used
  99648. * @param subMesh defines which submesh to render
  99649. */
  99650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99651. /**
  99652. * Lets the block try to connect some inputs automatically
  99653. * @param material defines the hosting NodeMaterial
  99654. */
  99655. autoConfigure(material: NodeMaterial): void;
  99656. /**
  99657. * Function called when a block is declared as repeatable content generator
  99658. * @param vertexShaderState defines the current compilation state for the vertex shader
  99659. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99660. * @param mesh defines the mesh to be rendered
  99661. * @param defines defines the material defines to update
  99662. */
  99663. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99664. /**
  99665. * Checks if the block is ready
  99666. * @param mesh defines the mesh to be rendered
  99667. * @param nodeMaterial defines the node material requesting the update
  99668. * @param defines defines the material defines to update
  99669. * @param useInstances specifies that instances should be used
  99670. * @returns true if the block is ready
  99671. */
  99672. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99673. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99674. private _processBuild;
  99675. /**
  99676. * Compile the current node and generate the shader code
  99677. * @param state defines the current compilation state (uniforms, samplers, current string)
  99678. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99679. * @returns true if already built
  99680. */
  99681. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99682. protected _inputRename(name: string): string;
  99683. protected _outputRename(name: string): string;
  99684. protected _dumpPropertiesCode(): string;
  99685. /** @hidden */
  99686. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99687. /** @hidden */
  99688. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99689. /**
  99690. * Clone the current block to a new identical block
  99691. * @param scene defines the hosting scene
  99692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99693. * @returns a copy of the current block
  99694. */
  99695. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99696. /**
  99697. * Serializes this block in a JSON representation
  99698. * @returns the serialized block object
  99699. */
  99700. serialize(): any;
  99701. /** @hidden */
  99702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99703. private _deserializePortDisplayNamesAndExposedOnFrame;
  99704. /**
  99705. * Release resources
  99706. */
  99707. dispose(): void;
  99708. }
  99709. }
  99710. declare module BABYLON {
  99711. /**
  99712. * Base class of materials working in push mode in babylon JS
  99713. * @hidden
  99714. */
  99715. export class PushMaterial extends Material {
  99716. protected _activeEffect: Effect;
  99717. protected _normalMatrix: Matrix;
  99718. constructor(name: string, scene: Scene);
  99719. getEffect(): Effect;
  99720. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99721. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99722. /**
  99723. * Binds the given world matrix to the active effect
  99724. *
  99725. * @param world the matrix to bind
  99726. */
  99727. bindOnlyWorldMatrix(world: Matrix): void;
  99728. /**
  99729. * Binds the given normal matrix to the active effect
  99730. *
  99731. * @param normalMatrix the matrix to bind
  99732. */
  99733. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99734. bind(world: Matrix, mesh?: Mesh): void;
  99735. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99736. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99737. }
  99738. }
  99739. declare module BABYLON {
  99740. /**
  99741. * Root class for all node material optimizers
  99742. */
  99743. export class NodeMaterialOptimizer {
  99744. /**
  99745. * Function used to optimize a NodeMaterial graph
  99746. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99747. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99748. */
  99749. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99750. }
  99751. }
  99752. declare module BABYLON {
  99753. /**
  99754. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99755. */
  99756. export class TransformBlock extends NodeMaterialBlock {
  99757. /**
  99758. * Defines the value to use to complement W value to transform it to a Vector4
  99759. */
  99760. complementW: number;
  99761. /**
  99762. * Defines the value to use to complement z value to transform it to a Vector4
  99763. */
  99764. complementZ: number;
  99765. /**
  99766. * Creates a new TransformBlock
  99767. * @param name defines the block name
  99768. */
  99769. constructor(name: string);
  99770. /**
  99771. * Gets the current class name
  99772. * @returns the class name
  99773. */
  99774. getClassName(): string;
  99775. /**
  99776. * Gets the vector input
  99777. */
  99778. get vector(): NodeMaterialConnectionPoint;
  99779. /**
  99780. * Gets the output component
  99781. */
  99782. get output(): NodeMaterialConnectionPoint;
  99783. /**
  99784. * Gets the xyz output component
  99785. */
  99786. get xyz(): NodeMaterialConnectionPoint;
  99787. /**
  99788. * Gets the matrix transform input
  99789. */
  99790. get transform(): NodeMaterialConnectionPoint;
  99791. protected _buildBlock(state: NodeMaterialBuildState): this;
  99792. /**
  99793. * Update defines for shader compilation
  99794. * @param mesh defines the mesh to be rendered
  99795. * @param nodeMaterial defines the node material requesting the update
  99796. * @param defines defines the material defines to update
  99797. * @param useInstances specifies that instances should be used
  99798. * @param subMesh defines which submesh to render
  99799. */
  99800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99801. serialize(): any;
  99802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99803. protected _dumpPropertiesCode(): string;
  99804. }
  99805. }
  99806. declare module BABYLON {
  99807. /**
  99808. * Block used to output the vertex position
  99809. */
  99810. export class VertexOutputBlock extends NodeMaterialBlock {
  99811. /**
  99812. * Creates a new VertexOutputBlock
  99813. * @param name defines the block name
  99814. */
  99815. constructor(name: string);
  99816. /**
  99817. * Gets the current class name
  99818. * @returns the class name
  99819. */
  99820. getClassName(): string;
  99821. /**
  99822. * Gets the vector input component
  99823. */
  99824. get vector(): NodeMaterialConnectionPoint;
  99825. protected _buildBlock(state: NodeMaterialBuildState): this;
  99826. }
  99827. }
  99828. declare module BABYLON {
  99829. /**
  99830. * Block used to output the final color
  99831. */
  99832. export class FragmentOutputBlock extends NodeMaterialBlock {
  99833. /**
  99834. * Create a new FragmentOutputBlock
  99835. * @param name defines the block name
  99836. */
  99837. constructor(name: string);
  99838. /**
  99839. * Gets the current class name
  99840. * @returns the class name
  99841. */
  99842. getClassName(): string;
  99843. /**
  99844. * Gets the rgba input component
  99845. */
  99846. get rgba(): NodeMaterialConnectionPoint;
  99847. /**
  99848. * Gets the rgb input component
  99849. */
  99850. get rgb(): NodeMaterialConnectionPoint;
  99851. /**
  99852. * Gets the a input component
  99853. */
  99854. get a(): NodeMaterialConnectionPoint;
  99855. protected _buildBlock(state: NodeMaterialBuildState): this;
  99856. }
  99857. }
  99858. declare module BABYLON {
  99859. /**
  99860. * Block used for the particle ramp gradient section
  99861. */
  99862. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99863. /**
  99864. * Create a new ParticleRampGradientBlock
  99865. * @param name defines the block name
  99866. */
  99867. constructor(name: string);
  99868. /**
  99869. * Gets the current class name
  99870. * @returns the class name
  99871. */
  99872. getClassName(): string;
  99873. /**
  99874. * Gets the color input component
  99875. */
  99876. get color(): NodeMaterialConnectionPoint;
  99877. /**
  99878. * Gets the rampColor output component
  99879. */
  99880. get rampColor(): NodeMaterialConnectionPoint;
  99881. /**
  99882. * Initialize the block and prepare the context for build
  99883. * @param state defines the state that will be used for the build
  99884. */
  99885. initialize(state: NodeMaterialBuildState): void;
  99886. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99887. }
  99888. }
  99889. declare module BABYLON {
  99890. /**
  99891. * Block used for the particle blend multiply section
  99892. */
  99893. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99894. /**
  99895. * Create a new ParticleBlendMultiplyBlock
  99896. * @param name defines the block name
  99897. */
  99898. constructor(name: string);
  99899. /**
  99900. * Gets the current class name
  99901. * @returns the class name
  99902. */
  99903. getClassName(): string;
  99904. /**
  99905. * Gets the color input component
  99906. */
  99907. get color(): NodeMaterialConnectionPoint;
  99908. /**
  99909. * Gets the alphaTexture input component
  99910. */
  99911. get alphaTexture(): NodeMaterialConnectionPoint;
  99912. /**
  99913. * Gets the alphaColor input component
  99914. */
  99915. get alphaColor(): NodeMaterialConnectionPoint;
  99916. /**
  99917. * Gets the blendColor output component
  99918. */
  99919. get blendColor(): NodeMaterialConnectionPoint;
  99920. /**
  99921. * Initialize the block and prepare the context for build
  99922. * @param state defines the state that will be used for the build
  99923. */
  99924. initialize(state: NodeMaterialBuildState): void;
  99925. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99926. }
  99927. }
  99928. declare module BABYLON {
  99929. /**
  99930. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99931. */
  99932. export class VectorMergerBlock extends NodeMaterialBlock {
  99933. /**
  99934. * Create a new VectorMergerBlock
  99935. * @param name defines the block name
  99936. */
  99937. constructor(name: string);
  99938. /**
  99939. * Gets the current class name
  99940. * @returns the class name
  99941. */
  99942. getClassName(): string;
  99943. /**
  99944. * Gets the xyz component (input)
  99945. */
  99946. get xyzIn(): NodeMaterialConnectionPoint;
  99947. /**
  99948. * Gets the xy component (input)
  99949. */
  99950. get xyIn(): NodeMaterialConnectionPoint;
  99951. /**
  99952. * Gets the x component (input)
  99953. */
  99954. get x(): NodeMaterialConnectionPoint;
  99955. /**
  99956. * Gets the y component (input)
  99957. */
  99958. get y(): NodeMaterialConnectionPoint;
  99959. /**
  99960. * Gets the z component (input)
  99961. */
  99962. get z(): NodeMaterialConnectionPoint;
  99963. /**
  99964. * Gets the w component (input)
  99965. */
  99966. get w(): NodeMaterialConnectionPoint;
  99967. /**
  99968. * Gets the xyzw component (output)
  99969. */
  99970. get xyzw(): NodeMaterialConnectionPoint;
  99971. /**
  99972. * Gets the xyz component (output)
  99973. */
  99974. get xyzOut(): NodeMaterialConnectionPoint;
  99975. /**
  99976. * Gets the xy component (output)
  99977. */
  99978. get xyOut(): NodeMaterialConnectionPoint;
  99979. /**
  99980. * Gets the xy component (output)
  99981. * @deprecated Please use xyOut instead.
  99982. */
  99983. get xy(): NodeMaterialConnectionPoint;
  99984. /**
  99985. * Gets the xyz component (output)
  99986. * @deprecated Please use xyzOut instead.
  99987. */
  99988. get xyz(): NodeMaterialConnectionPoint;
  99989. protected _buildBlock(state: NodeMaterialBuildState): this;
  99990. }
  99991. }
  99992. declare module BABYLON {
  99993. /**
  99994. * Block used to remap a float from a range to a new one
  99995. */
  99996. export class RemapBlock extends NodeMaterialBlock {
  99997. /**
  99998. * Gets or sets the source range
  99999. */
  100000. sourceRange: Vector2;
  100001. /**
  100002. * Gets or sets the target range
  100003. */
  100004. targetRange: Vector2;
  100005. /**
  100006. * Creates a new RemapBlock
  100007. * @param name defines the block name
  100008. */
  100009. constructor(name: string);
  100010. /**
  100011. * Gets the current class name
  100012. * @returns the class name
  100013. */
  100014. getClassName(): string;
  100015. /**
  100016. * Gets the input component
  100017. */
  100018. get input(): NodeMaterialConnectionPoint;
  100019. /**
  100020. * Gets the source min input component
  100021. */
  100022. get sourceMin(): NodeMaterialConnectionPoint;
  100023. /**
  100024. * Gets the source max input component
  100025. */
  100026. get sourceMax(): NodeMaterialConnectionPoint;
  100027. /**
  100028. * Gets the target min input component
  100029. */
  100030. get targetMin(): NodeMaterialConnectionPoint;
  100031. /**
  100032. * Gets the target max input component
  100033. */
  100034. get targetMax(): NodeMaterialConnectionPoint;
  100035. /**
  100036. * Gets the output component
  100037. */
  100038. get output(): NodeMaterialConnectionPoint;
  100039. protected _buildBlock(state: NodeMaterialBuildState): this;
  100040. protected _dumpPropertiesCode(): string;
  100041. serialize(): any;
  100042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100043. }
  100044. }
  100045. declare module BABYLON {
  100046. /**
  100047. * Block used to multiply 2 values
  100048. */
  100049. export class MultiplyBlock extends NodeMaterialBlock {
  100050. /**
  100051. * Creates a new MultiplyBlock
  100052. * @param name defines the block name
  100053. */
  100054. constructor(name: string);
  100055. /**
  100056. * Gets the current class name
  100057. * @returns the class name
  100058. */
  100059. getClassName(): string;
  100060. /**
  100061. * Gets the left operand input component
  100062. */
  100063. get left(): NodeMaterialConnectionPoint;
  100064. /**
  100065. * Gets the right operand input component
  100066. */
  100067. get right(): NodeMaterialConnectionPoint;
  100068. /**
  100069. * Gets the output component
  100070. */
  100071. get output(): NodeMaterialConnectionPoint;
  100072. protected _buildBlock(state: NodeMaterialBuildState): this;
  100073. }
  100074. }
  100075. declare module BABYLON {
  100076. /**
  100077. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100078. */
  100079. export class ColorSplitterBlock extends NodeMaterialBlock {
  100080. /**
  100081. * Create a new ColorSplitterBlock
  100082. * @param name defines the block name
  100083. */
  100084. constructor(name: string);
  100085. /**
  100086. * Gets the current class name
  100087. * @returns the class name
  100088. */
  100089. getClassName(): string;
  100090. /**
  100091. * Gets the rgba component (input)
  100092. */
  100093. get rgba(): NodeMaterialConnectionPoint;
  100094. /**
  100095. * Gets the rgb component (input)
  100096. */
  100097. get rgbIn(): NodeMaterialConnectionPoint;
  100098. /**
  100099. * Gets the rgb component (output)
  100100. */
  100101. get rgbOut(): NodeMaterialConnectionPoint;
  100102. /**
  100103. * Gets the r component (output)
  100104. */
  100105. get r(): NodeMaterialConnectionPoint;
  100106. /**
  100107. * Gets the g component (output)
  100108. */
  100109. get g(): NodeMaterialConnectionPoint;
  100110. /**
  100111. * Gets the b component (output)
  100112. */
  100113. get b(): NodeMaterialConnectionPoint;
  100114. /**
  100115. * Gets the a component (output)
  100116. */
  100117. get a(): NodeMaterialConnectionPoint;
  100118. protected _inputRename(name: string): string;
  100119. protected _outputRename(name: string): string;
  100120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100121. }
  100122. }
  100123. declare module BABYLON {
  100124. /**
  100125. * Interface used to configure the node material editor
  100126. */
  100127. export interface INodeMaterialEditorOptions {
  100128. /** Define the URl to load node editor script */
  100129. editorURL?: string;
  100130. }
  100131. /** @hidden */
  100132. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100133. NORMAL: boolean;
  100134. TANGENT: boolean;
  100135. UV1: boolean;
  100136. /** BONES */
  100137. NUM_BONE_INFLUENCERS: number;
  100138. BonesPerMesh: number;
  100139. BONETEXTURE: boolean;
  100140. /** MORPH TARGETS */
  100141. MORPHTARGETS: boolean;
  100142. MORPHTARGETS_NORMAL: boolean;
  100143. MORPHTARGETS_TANGENT: boolean;
  100144. MORPHTARGETS_UV: boolean;
  100145. NUM_MORPH_INFLUENCERS: number;
  100146. /** IMAGE PROCESSING */
  100147. IMAGEPROCESSING: boolean;
  100148. VIGNETTE: boolean;
  100149. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100150. VIGNETTEBLENDMODEOPAQUE: boolean;
  100151. TONEMAPPING: boolean;
  100152. TONEMAPPING_ACES: boolean;
  100153. CONTRAST: boolean;
  100154. EXPOSURE: boolean;
  100155. COLORCURVES: boolean;
  100156. COLORGRADING: boolean;
  100157. COLORGRADING3D: boolean;
  100158. SAMPLER3DGREENDEPTH: boolean;
  100159. SAMPLER3DBGRMAP: boolean;
  100160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100161. /** MISC. */
  100162. BUMPDIRECTUV: number;
  100163. constructor();
  100164. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100165. }
  100166. /**
  100167. * Class used to configure NodeMaterial
  100168. */
  100169. export interface INodeMaterialOptions {
  100170. /**
  100171. * Defines if blocks should emit comments
  100172. */
  100173. emitComments: boolean;
  100174. }
  100175. /**
  100176. * Class used to create a node based material built by assembling shader blocks
  100177. */
  100178. export class NodeMaterial extends PushMaterial {
  100179. private static _BuildIdGenerator;
  100180. private _options;
  100181. private _vertexCompilationState;
  100182. private _fragmentCompilationState;
  100183. private _sharedData;
  100184. private _buildId;
  100185. private _buildWasSuccessful;
  100186. private _cachedWorldViewMatrix;
  100187. private _cachedWorldViewProjectionMatrix;
  100188. private _optimizers;
  100189. private _animationFrame;
  100190. /** Define the Url to load node editor script */
  100191. static EditorURL: string;
  100192. /** Define the Url to load snippets */
  100193. static SnippetUrl: string;
  100194. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100195. static IgnoreTexturesAtLoadTime: boolean;
  100196. private BJSNODEMATERIALEDITOR;
  100197. /** Get the inspector from bundle or global */
  100198. private _getGlobalNodeMaterialEditor;
  100199. /**
  100200. * Snippet ID if the material was created from the snippet server
  100201. */
  100202. snippetId: string;
  100203. /**
  100204. * Gets or sets data used by visual editor
  100205. * @see https://nme.babylonjs.com
  100206. */
  100207. editorData: any;
  100208. /**
  100209. * 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)
  100210. */
  100211. ignoreAlpha: boolean;
  100212. /**
  100213. * Defines the maximum number of lights that can be used in the material
  100214. */
  100215. maxSimultaneousLights: number;
  100216. /**
  100217. * Observable raised when the material is built
  100218. */
  100219. onBuildObservable: Observable<NodeMaterial>;
  100220. /**
  100221. * Gets or sets the root nodes of the material vertex shader
  100222. */
  100223. _vertexOutputNodes: NodeMaterialBlock[];
  100224. /**
  100225. * Gets or sets the root nodes of the material fragment (pixel) shader
  100226. */
  100227. _fragmentOutputNodes: NodeMaterialBlock[];
  100228. /** Gets or sets options to control the node material overall behavior */
  100229. get options(): INodeMaterialOptions;
  100230. set options(options: INodeMaterialOptions);
  100231. /**
  100232. * Default configuration related to image processing available in the standard Material.
  100233. */
  100234. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100235. /**
  100236. * Gets the image processing configuration used either in this material.
  100237. */
  100238. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100239. /**
  100240. * Sets the Default image processing configuration used either in the this material.
  100241. *
  100242. * If sets to null, the scene one is in use.
  100243. */
  100244. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100245. /**
  100246. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100247. */
  100248. attachedBlocks: NodeMaterialBlock[];
  100249. /**
  100250. * Specifies the mode of the node material
  100251. * @hidden
  100252. */
  100253. _mode: NodeMaterialModes;
  100254. /**
  100255. * Gets the mode property
  100256. */
  100257. get mode(): NodeMaterialModes;
  100258. /**
  100259. * Create a new node based material
  100260. * @param name defines the material name
  100261. * @param scene defines the hosting scene
  100262. * @param options defines creation option
  100263. */
  100264. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100265. /**
  100266. * Gets the current class name of the material e.g. "NodeMaterial"
  100267. * @returns the class name
  100268. */
  100269. getClassName(): string;
  100270. /**
  100271. * Keep track of the image processing observer to allow dispose and replace.
  100272. */
  100273. private _imageProcessingObserver;
  100274. /**
  100275. * Attaches a new image processing configuration to the Standard Material.
  100276. * @param configuration
  100277. */
  100278. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100279. /**
  100280. * Get a block by its name
  100281. * @param name defines the name of the block to retrieve
  100282. * @returns the required block or null if not found
  100283. */
  100284. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100285. /**
  100286. * Get a block by its name
  100287. * @param predicate defines the predicate used to find the good candidate
  100288. * @returns the required block or null if not found
  100289. */
  100290. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100291. /**
  100292. * Get an input block by its name
  100293. * @param predicate defines the predicate used to find the good candidate
  100294. * @returns the required input block or null if not found
  100295. */
  100296. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100297. /**
  100298. * Gets the list of input blocks attached to this material
  100299. * @returns an array of InputBlocks
  100300. */
  100301. getInputBlocks(): InputBlock[];
  100302. /**
  100303. * Adds a new optimizer to the list of optimizers
  100304. * @param optimizer defines the optimizers to add
  100305. * @returns the current material
  100306. */
  100307. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100308. /**
  100309. * Remove an optimizer from the list of optimizers
  100310. * @param optimizer defines the optimizers to remove
  100311. * @returns the current material
  100312. */
  100313. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100314. /**
  100315. * Add a new block to the list of output nodes
  100316. * @param node defines the node to add
  100317. * @returns the current material
  100318. */
  100319. addOutputNode(node: NodeMaterialBlock): this;
  100320. /**
  100321. * Remove a block from the list of root nodes
  100322. * @param node defines the node to remove
  100323. * @returns the current material
  100324. */
  100325. removeOutputNode(node: NodeMaterialBlock): this;
  100326. private _addVertexOutputNode;
  100327. private _removeVertexOutputNode;
  100328. private _addFragmentOutputNode;
  100329. private _removeFragmentOutputNode;
  100330. /**
  100331. * Specifies if the material will require alpha blending
  100332. * @returns a boolean specifying if alpha blending is needed
  100333. */
  100334. needAlphaBlending(): boolean;
  100335. /**
  100336. * Specifies if this material should be rendered in alpha test mode
  100337. * @returns a boolean specifying if an alpha test is needed.
  100338. */
  100339. needAlphaTesting(): boolean;
  100340. private _initializeBlock;
  100341. private _resetDualBlocks;
  100342. /**
  100343. * Remove a block from the current node material
  100344. * @param block defines the block to remove
  100345. */
  100346. removeBlock(block: NodeMaterialBlock): void;
  100347. /**
  100348. * Build the material and generates the inner effect
  100349. * @param verbose defines if the build should log activity
  100350. */
  100351. build(verbose?: boolean): void;
  100352. /**
  100353. * Runs an otpimization phase to try to improve the shader code
  100354. */
  100355. optimize(): void;
  100356. private _prepareDefinesForAttributes;
  100357. /**
  100358. * Create a post process from the material
  100359. * @param camera The camera to apply the render pass to.
  100360. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100362. * @param engine The engine which the post process will be applied. (default: current engine)
  100363. * @param reusable If the post process can be reused on the same frame. (default: false)
  100364. * @param textureType Type of textures used when performing the post process. (default: 0)
  100365. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100366. * @returns the post process created
  100367. */
  100368. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100369. /**
  100370. * Create the post process effect from the material
  100371. * @param postProcess The post process to create the effect for
  100372. */
  100373. createEffectForPostProcess(postProcess: PostProcess): void;
  100374. private _createEffectOrPostProcess;
  100375. private _createEffectForParticles;
  100376. /**
  100377. * Create the effect to be used as the custom effect for a particle system
  100378. * @param particleSystem Particle system to create the effect for
  100379. * @param onCompiled defines a function to call when the effect creation is successful
  100380. * @param onError defines a function to call when the effect creation has failed
  100381. */
  100382. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100383. private _processDefines;
  100384. /**
  100385. * Get if the submesh is ready to be used and all its information available.
  100386. * Child classes can use it to update shaders
  100387. * @param mesh defines the mesh to check
  100388. * @param subMesh defines which submesh to check
  100389. * @param useInstances specifies that instances should be used
  100390. * @returns a boolean indicating that the submesh is ready or not
  100391. */
  100392. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100393. /**
  100394. * Get a string representing the shaders built by the current node graph
  100395. */
  100396. get compiledShaders(): string;
  100397. /**
  100398. * Binds the world matrix to the material
  100399. * @param world defines the world transformation matrix
  100400. */
  100401. bindOnlyWorldMatrix(world: Matrix): void;
  100402. /**
  100403. * Binds the submesh to this material by preparing the effect and shader to draw
  100404. * @param world defines the world transformation matrix
  100405. * @param mesh defines the mesh containing the submesh
  100406. * @param subMesh defines the submesh to bind the material to
  100407. */
  100408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100409. /**
  100410. * Gets the active textures from the material
  100411. * @returns an array of textures
  100412. */
  100413. getActiveTextures(): BaseTexture[];
  100414. /**
  100415. * Gets the list of texture blocks
  100416. * @returns an array of texture blocks
  100417. */
  100418. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100419. /**
  100420. * Specifies if the material uses a texture
  100421. * @param texture defines the texture to check against the material
  100422. * @returns a boolean specifying if the material uses the texture
  100423. */
  100424. hasTexture(texture: BaseTexture): boolean;
  100425. /**
  100426. * Disposes the material
  100427. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100428. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100429. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100430. */
  100431. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100432. /** Creates the node editor window. */
  100433. private _createNodeEditor;
  100434. /**
  100435. * Launch the node material editor
  100436. * @param config Define the configuration of the editor
  100437. * @return a promise fulfilled when the node editor is visible
  100438. */
  100439. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100440. /**
  100441. * Clear the current material
  100442. */
  100443. clear(): void;
  100444. /**
  100445. * Clear the current material and set it to a default state
  100446. */
  100447. setToDefault(): void;
  100448. /**
  100449. * Clear the current material and set it to a default state for post process
  100450. */
  100451. setToDefaultPostProcess(): void;
  100452. /**
  100453. * Clear the current material and set it to a default state for particle
  100454. */
  100455. setToDefaultParticle(): void;
  100456. /**
  100457. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100458. * @param url defines the url to load from
  100459. * @returns a promise that will fullfil when the material is fully loaded
  100460. */
  100461. loadAsync(url: string): Promise<void>;
  100462. private _gatherBlocks;
  100463. /**
  100464. * Generate a string containing the code declaration required to create an equivalent of this material
  100465. * @returns a string
  100466. */
  100467. generateCode(): string;
  100468. /**
  100469. * Serializes this material in a JSON representation
  100470. * @returns the serialized material object
  100471. */
  100472. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100473. private _restoreConnections;
  100474. /**
  100475. * Clear the current graph and load a new one from a serialization object
  100476. * @param source defines the JSON representation of the material
  100477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100478. * @param merge defines whether or not the source must be merged or replace the current content
  100479. */
  100480. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100481. /**
  100482. * Makes a duplicate of the current material.
  100483. * @param name - name to use for the new material.
  100484. */
  100485. clone(name: string): NodeMaterial;
  100486. /**
  100487. * Creates a node material from parsed material data
  100488. * @param source defines the JSON representation of the material
  100489. * @param scene defines the hosting scene
  100490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100491. * @returns a new node material
  100492. */
  100493. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100494. /**
  100495. * Creates a node material from a snippet saved in a remote file
  100496. * @param name defines the name of the material to create
  100497. * @param url defines the url to load from
  100498. * @param scene defines the hosting scene
  100499. * @returns a promise that will resolve to the new node material
  100500. */
  100501. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100502. /**
  100503. * Creates a node material from a snippet saved by the node material editor
  100504. * @param snippetId defines the snippet to load
  100505. * @param scene defines the hosting scene
  100506. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100507. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100508. * @returns a promise that will resolve to the new node material
  100509. */
  100510. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100511. /**
  100512. * Creates a new node material set to default basic configuration
  100513. * @param name defines the name of the material
  100514. * @param scene defines the hosting scene
  100515. * @returns a new NodeMaterial
  100516. */
  100517. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100518. }
  100519. }
  100520. declare module BABYLON {
  100521. /**
  100522. * Size options for a post process
  100523. */
  100524. export type PostProcessOptions = {
  100525. width: number;
  100526. height: number;
  100527. };
  100528. /**
  100529. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100530. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100531. */
  100532. export class PostProcess {
  100533. /** Name of the PostProcess. */
  100534. name: string;
  100535. /**
  100536. * Gets or sets the unique id of the post process
  100537. */
  100538. uniqueId: number;
  100539. /**
  100540. * Width of the texture to apply the post process on
  100541. */
  100542. width: number;
  100543. /**
  100544. * Height of the texture to apply the post process on
  100545. */
  100546. height: number;
  100547. /**
  100548. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100549. */
  100550. nodeMaterialSource: Nullable<NodeMaterial>;
  100551. /**
  100552. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100553. * @hidden
  100554. */
  100555. _outputTexture: Nullable<InternalTexture>;
  100556. /**
  100557. * Sampling mode used by the shader
  100558. * See https://doc.babylonjs.com/classes/3.1/texture
  100559. */
  100560. renderTargetSamplingMode: number;
  100561. /**
  100562. * Clear color to use when screen clearing
  100563. */
  100564. clearColor: Color4;
  100565. /**
  100566. * If the buffer needs to be cleared before applying the post process. (default: true)
  100567. * Should be set to false if shader will overwrite all previous pixels.
  100568. */
  100569. autoClear: boolean;
  100570. /**
  100571. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100572. */
  100573. alphaMode: number;
  100574. /**
  100575. * Sets the setAlphaBlendConstants of the babylon engine
  100576. */
  100577. alphaConstants: Color4;
  100578. /**
  100579. * Animations to be used for the post processing
  100580. */
  100581. animations: Animation[];
  100582. /**
  100583. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100584. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100585. */
  100586. enablePixelPerfectMode: boolean;
  100587. /**
  100588. * Force the postprocess to be applied without taking in account viewport
  100589. */
  100590. forceFullscreenViewport: boolean;
  100591. /**
  100592. * List of inspectable custom properties (used by the Inspector)
  100593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100594. */
  100595. inspectableCustomProperties: IInspectable[];
  100596. /**
  100597. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100598. *
  100599. * | Value | Type | Description |
  100600. * | ----- | ----------------------------------- | ----------- |
  100601. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100602. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100603. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100604. *
  100605. */
  100606. scaleMode: number;
  100607. /**
  100608. * Force textures to be a power of two (default: false)
  100609. */
  100610. alwaysForcePOT: boolean;
  100611. private _samples;
  100612. /**
  100613. * Number of sample textures (default: 1)
  100614. */
  100615. get samples(): number;
  100616. set samples(n: number);
  100617. /**
  100618. * Modify the scale of the post process to be the same as the viewport (default: false)
  100619. */
  100620. adaptScaleToCurrentViewport: boolean;
  100621. private _camera;
  100622. protected _scene: Scene;
  100623. private _engine;
  100624. private _options;
  100625. private _reusable;
  100626. private _textureType;
  100627. private _textureFormat;
  100628. /**
  100629. * Smart array of input and output textures for the post process.
  100630. * @hidden
  100631. */
  100632. _textures: SmartArray<InternalTexture>;
  100633. /**
  100634. * The index in _textures that corresponds to the output texture.
  100635. * @hidden
  100636. */
  100637. _currentRenderTextureInd: number;
  100638. private _effect;
  100639. private _samplers;
  100640. private _fragmentUrl;
  100641. private _vertexUrl;
  100642. private _parameters;
  100643. private _scaleRatio;
  100644. protected _indexParameters: any;
  100645. private _shareOutputWithPostProcess;
  100646. private _texelSize;
  100647. private _forcedOutputTexture;
  100648. /**
  100649. * Returns the fragment url or shader name used in the post process.
  100650. * @returns the fragment url or name in the shader store.
  100651. */
  100652. getEffectName(): string;
  100653. /**
  100654. * An event triggered when the postprocess is activated.
  100655. */
  100656. onActivateObservable: Observable<Camera>;
  100657. private _onActivateObserver;
  100658. /**
  100659. * A function that is added to the onActivateObservable
  100660. */
  100661. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100662. /**
  100663. * An event triggered when the postprocess changes its size.
  100664. */
  100665. onSizeChangedObservable: Observable<PostProcess>;
  100666. private _onSizeChangedObserver;
  100667. /**
  100668. * A function that is added to the onSizeChangedObservable
  100669. */
  100670. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100671. /**
  100672. * An event triggered when the postprocess applies its effect.
  100673. */
  100674. onApplyObservable: Observable<Effect>;
  100675. private _onApplyObserver;
  100676. /**
  100677. * A function that is added to the onApplyObservable
  100678. */
  100679. set onApply(callback: (effect: Effect) => void);
  100680. /**
  100681. * An event triggered before rendering the postprocess
  100682. */
  100683. onBeforeRenderObservable: Observable<Effect>;
  100684. private _onBeforeRenderObserver;
  100685. /**
  100686. * A function that is added to the onBeforeRenderObservable
  100687. */
  100688. set onBeforeRender(callback: (effect: Effect) => void);
  100689. /**
  100690. * An event triggered after rendering the postprocess
  100691. */
  100692. onAfterRenderObservable: Observable<Effect>;
  100693. private _onAfterRenderObserver;
  100694. /**
  100695. * A function that is added to the onAfterRenderObservable
  100696. */
  100697. set onAfterRender(callback: (efect: Effect) => void);
  100698. /**
  100699. * 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
  100700. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100701. */
  100702. get inputTexture(): InternalTexture;
  100703. set inputTexture(value: InternalTexture);
  100704. /**
  100705. * Gets the camera which post process is applied to.
  100706. * @returns The camera the post process is applied to.
  100707. */
  100708. getCamera(): Camera;
  100709. /**
  100710. * Gets the texel size of the postprocess.
  100711. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100712. */
  100713. get texelSize(): Vector2;
  100714. /**
  100715. * Creates a new instance PostProcess
  100716. * @param name The name of the PostProcess.
  100717. * @param fragmentUrl The url of the fragment shader to be used.
  100718. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100719. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100720. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100721. * @param camera The camera to apply the render pass to.
  100722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100723. * @param engine The engine which the post process will be applied. (default: current engine)
  100724. * @param reusable If the post process can be reused on the same frame. (default: false)
  100725. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100726. * @param textureType Type of textures used when performing the post process. (default: 0)
  100727. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100728. * @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
  100729. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100730. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100731. */
  100732. constructor(
  100733. /** Name of the PostProcess. */
  100734. 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);
  100735. /**
  100736. * Gets a string idenfifying the name of the class
  100737. * @returns "PostProcess" string
  100738. */
  100739. getClassName(): string;
  100740. /**
  100741. * Gets the engine which this post process belongs to.
  100742. * @returns The engine the post process was enabled with.
  100743. */
  100744. getEngine(): Engine;
  100745. /**
  100746. * The effect that is created when initializing the post process.
  100747. * @returns The created effect corresponding the the postprocess.
  100748. */
  100749. getEffect(): Effect;
  100750. /**
  100751. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100752. * @param postProcess The post process to share the output with.
  100753. * @returns This post process.
  100754. */
  100755. shareOutputWith(postProcess: PostProcess): PostProcess;
  100756. /**
  100757. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100758. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100759. */
  100760. useOwnOutput(): void;
  100761. /**
  100762. * Updates the effect with the current post process compile time values and recompiles the shader.
  100763. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100764. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100765. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100766. * @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
  100767. * @param onCompiled Called when the shader has been compiled.
  100768. * @param onError Called if there is an error when compiling a shader.
  100769. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100770. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100771. */
  100772. 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;
  100773. /**
  100774. * The post process is reusable if it can be used multiple times within one frame.
  100775. * @returns If the post process is reusable
  100776. */
  100777. isReusable(): boolean;
  100778. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100779. markTextureDirty(): void;
  100780. /**
  100781. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100782. * 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.
  100783. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100784. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100785. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100786. * @returns The target texture that was bound to be written to.
  100787. */
  100788. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100789. /**
  100790. * If the post process is supported.
  100791. */
  100792. get isSupported(): boolean;
  100793. /**
  100794. * The aspect ratio of the output texture.
  100795. */
  100796. get aspectRatio(): number;
  100797. /**
  100798. * Get a value indicating if the post-process is ready to be used
  100799. * @returns true if the post-process is ready (shader is compiled)
  100800. */
  100801. isReady(): boolean;
  100802. /**
  100803. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100804. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100805. */
  100806. apply(): Nullable<Effect>;
  100807. private _disposeTextures;
  100808. /**
  100809. * Disposes the post process.
  100810. * @param camera The camera to dispose the post process on.
  100811. */
  100812. dispose(camera?: Camera): void;
  100813. }
  100814. }
  100815. declare module BABYLON {
  100816. /** @hidden */
  100817. export var kernelBlurVaryingDeclaration: {
  100818. name: string;
  100819. shader: string;
  100820. };
  100821. }
  100822. declare module BABYLON {
  100823. /** @hidden */
  100824. export var kernelBlurFragment: {
  100825. name: string;
  100826. shader: string;
  100827. };
  100828. }
  100829. declare module BABYLON {
  100830. /** @hidden */
  100831. export var kernelBlurFragment2: {
  100832. name: string;
  100833. shader: string;
  100834. };
  100835. }
  100836. declare module BABYLON {
  100837. /** @hidden */
  100838. export var kernelBlurPixelShader: {
  100839. name: string;
  100840. shader: string;
  100841. };
  100842. }
  100843. declare module BABYLON {
  100844. /** @hidden */
  100845. export var kernelBlurVertex: {
  100846. name: string;
  100847. shader: string;
  100848. };
  100849. }
  100850. declare module BABYLON {
  100851. /** @hidden */
  100852. export var kernelBlurVertexShader: {
  100853. name: string;
  100854. shader: string;
  100855. };
  100856. }
  100857. declare module BABYLON {
  100858. /**
  100859. * The Blur Post Process which blurs an image based on a kernel and direction.
  100860. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100861. */
  100862. export class BlurPostProcess extends PostProcess {
  100863. /** The direction in which to blur the image. */
  100864. direction: Vector2;
  100865. private blockCompilation;
  100866. protected _kernel: number;
  100867. protected _idealKernel: number;
  100868. protected _packedFloat: boolean;
  100869. private _staticDefines;
  100870. /**
  100871. * Sets the length in pixels of the blur sample region
  100872. */
  100873. set kernel(v: number);
  100874. /**
  100875. * Gets the length in pixels of the blur sample region
  100876. */
  100877. get kernel(): number;
  100878. /**
  100879. * Sets wether or not the blur needs to unpack/repack floats
  100880. */
  100881. set packedFloat(v: boolean);
  100882. /**
  100883. * Gets wether or not the blur is unpacking/repacking floats
  100884. */
  100885. get packedFloat(): boolean;
  100886. /**
  100887. * Creates a new instance BlurPostProcess
  100888. * @param name The name of the effect.
  100889. * @param direction The direction in which to blur the image.
  100890. * @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.
  100891. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100892. * @param camera The camera to apply the render pass to.
  100893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100894. * @param engine The engine which the post process will be applied. (default: current engine)
  100895. * @param reusable If the post process can be reused on the same frame. (default: false)
  100896. * @param textureType Type of textures used when performing the post process. (default: 0)
  100897. * @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)
  100898. */
  100899. constructor(name: string,
  100900. /** The direction in which to blur the image. */
  100901. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100902. /**
  100903. * Updates the effect with the current post process compile time values and recompiles the shader.
  100904. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100905. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100906. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100907. * @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
  100908. * @param onCompiled Called when the shader has been compiled.
  100909. * @param onError Called if there is an error when compiling a shader.
  100910. */
  100911. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100912. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100913. /**
  100914. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100915. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100916. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100917. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100918. * The gaps between physical kernels are compensated for in the weighting of the samples
  100919. * @param idealKernel Ideal blur kernel.
  100920. * @return Nearest best kernel.
  100921. */
  100922. protected _nearestBestKernel(idealKernel: number): number;
  100923. /**
  100924. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100925. * @param x The point on the Gaussian distribution to sample.
  100926. * @return the value of the Gaussian function at x.
  100927. */
  100928. protected _gaussianWeight(x: number): number;
  100929. /**
  100930. * Generates a string that can be used as a floating point number in GLSL.
  100931. * @param x Value to print.
  100932. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100933. * @return GLSL float string.
  100934. */
  100935. protected _glslFloat(x: number, decimalFigures?: number): string;
  100936. }
  100937. }
  100938. declare module BABYLON {
  100939. /**
  100940. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100941. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100942. * You can then easily use it as a reflectionTexture on a flat surface.
  100943. * In case the surface is not a plane, please consider relying on reflection probes.
  100944. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100945. */
  100946. export class MirrorTexture extends RenderTargetTexture {
  100947. private scene;
  100948. /**
  100949. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100950. * 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.
  100951. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100952. */
  100953. mirrorPlane: Plane;
  100954. /**
  100955. * Define the blur ratio used to blur the reflection if needed.
  100956. */
  100957. set blurRatio(value: number);
  100958. get blurRatio(): number;
  100959. /**
  100960. * Define the adaptive blur kernel used to blur the reflection if needed.
  100961. * This will autocompute the closest best match for the `blurKernel`
  100962. */
  100963. set adaptiveBlurKernel(value: number);
  100964. /**
  100965. * Define the blur kernel used to blur the reflection if needed.
  100966. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100967. */
  100968. set blurKernel(value: number);
  100969. /**
  100970. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100971. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100972. */
  100973. set blurKernelX(value: number);
  100974. get blurKernelX(): number;
  100975. /**
  100976. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100977. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100978. */
  100979. set blurKernelY(value: number);
  100980. get blurKernelY(): number;
  100981. private _autoComputeBlurKernel;
  100982. protected _onRatioRescale(): void;
  100983. private _updateGammaSpace;
  100984. private _imageProcessingConfigChangeObserver;
  100985. private _transformMatrix;
  100986. private _mirrorMatrix;
  100987. private _savedViewMatrix;
  100988. private _blurX;
  100989. private _blurY;
  100990. private _adaptiveBlurKernel;
  100991. private _blurKernelX;
  100992. private _blurKernelY;
  100993. private _blurRatio;
  100994. /**
  100995. * Instantiates a Mirror Texture.
  100996. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100997. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100998. * You can then easily use it as a reflectionTexture on a flat surface.
  100999. * In case the surface is not a plane, please consider relying on reflection probes.
  101000. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101001. * @param name
  101002. * @param size
  101003. * @param scene
  101004. * @param generateMipMaps
  101005. * @param type
  101006. * @param samplingMode
  101007. * @param generateDepthBuffer
  101008. */
  101009. constructor(name: string, size: number | {
  101010. width: number;
  101011. height: number;
  101012. } | {
  101013. ratio: number;
  101014. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101015. private _preparePostProcesses;
  101016. /**
  101017. * Clone the mirror texture.
  101018. * @returns the cloned texture
  101019. */
  101020. clone(): MirrorTexture;
  101021. /**
  101022. * Serialize the texture to a JSON representation you could use in Parse later on
  101023. * @returns the serialized JSON representation
  101024. */
  101025. serialize(): any;
  101026. /**
  101027. * Dispose the texture and release its associated resources.
  101028. */
  101029. dispose(): void;
  101030. }
  101031. }
  101032. declare module BABYLON {
  101033. /**
  101034. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101035. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101036. */
  101037. export class Texture extends BaseTexture {
  101038. /**
  101039. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101040. */
  101041. static SerializeBuffers: boolean;
  101042. /** @hidden */
  101043. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101044. /** @hidden */
  101045. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101046. /** @hidden */
  101047. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101048. /** nearest is mag = nearest and min = nearest and mip = linear */
  101049. static readonly NEAREST_SAMPLINGMODE: number;
  101050. /** nearest is mag = nearest and min = nearest and mip = linear */
  101051. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101053. static readonly BILINEAR_SAMPLINGMODE: number;
  101054. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101055. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101056. /** Trilinear is mag = linear and min = linear and mip = linear */
  101057. static readonly TRILINEAR_SAMPLINGMODE: number;
  101058. /** Trilinear is mag = linear and min = linear and mip = linear */
  101059. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101060. /** mag = nearest and min = nearest and mip = nearest */
  101061. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101062. /** mag = nearest and min = linear and mip = nearest */
  101063. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101064. /** mag = nearest and min = linear and mip = linear */
  101065. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101066. /** mag = nearest and min = linear and mip = none */
  101067. static readonly NEAREST_LINEAR: number;
  101068. /** mag = nearest and min = nearest and mip = none */
  101069. static readonly NEAREST_NEAREST: number;
  101070. /** mag = linear and min = nearest and mip = nearest */
  101071. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101072. /** mag = linear and min = nearest and mip = linear */
  101073. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101074. /** mag = linear and min = linear and mip = none */
  101075. static readonly LINEAR_LINEAR: number;
  101076. /** mag = linear and min = nearest and mip = none */
  101077. static readonly LINEAR_NEAREST: number;
  101078. /** Explicit coordinates mode */
  101079. static readonly EXPLICIT_MODE: number;
  101080. /** Spherical coordinates mode */
  101081. static readonly SPHERICAL_MODE: number;
  101082. /** Planar coordinates mode */
  101083. static readonly PLANAR_MODE: number;
  101084. /** Cubic coordinates mode */
  101085. static readonly CUBIC_MODE: number;
  101086. /** Projection coordinates mode */
  101087. static readonly PROJECTION_MODE: number;
  101088. /** Inverse Cubic coordinates mode */
  101089. static readonly SKYBOX_MODE: number;
  101090. /** Inverse Cubic coordinates mode */
  101091. static readonly INVCUBIC_MODE: number;
  101092. /** Equirectangular coordinates mode */
  101093. static readonly EQUIRECTANGULAR_MODE: number;
  101094. /** Equirectangular Fixed coordinates mode */
  101095. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101096. /** Equirectangular Fixed Mirrored coordinates mode */
  101097. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101098. /** Texture is not repeating outside of 0..1 UVs */
  101099. static readonly CLAMP_ADDRESSMODE: number;
  101100. /** Texture is repeating outside of 0..1 UVs */
  101101. static readonly WRAP_ADDRESSMODE: number;
  101102. /** Texture is repeating and mirrored */
  101103. static readonly MIRROR_ADDRESSMODE: number;
  101104. /**
  101105. * 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
  101106. */
  101107. static UseSerializedUrlIfAny: boolean;
  101108. /**
  101109. * Define the url of the texture.
  101110. */
  101111. url: Nullable<string>;
  101112. /**
  101113. * Define an offset on the texture to offset the u coordinates of the UVs
  101114. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101115. */
  101116. uOffset: number;
  101117. /**
  101118. * Define an offset on the texture to offset the v coordinates of the UVs
  101119. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101120. */
  101121. vOffset: number;
  101122. /**
  101123. * Define an offset on the texture to scale the u coordinates of the UVs
  101124. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101125. */
  101126. uScale: number;
  101127. /**
  101128. * Define an offset on the texture to scale the v coordinates of the UVs
  101129. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101130. */
  101131. vScale: number;
  101132. /**
  101133. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101134. * @see https://doc.babylonjs.com/how_to/more_materials
  101135. */
  101136. uAng: number;
  101137. /**
  101138. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101139. * @see https://doc.babylonjs.com/how_to/more_materials
  101140. */
  101141. vAng: number;
  101142. /**
  101143. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101144. * @see https://doc.babylonjs.com/how_to/more_materials
  101145. */
  101146. wAng: number;
  101147. /**
  101148. * Defines the center of rotation (U)
  101149. */
  101150. uRotationCenter: number;
  101151. /**
  101152. * Defines the center of rotation (V)
  101153. */
  101154. vRotationCenter: number;
  101155. /**
  101156. * Defines the center of rotation (W)
  101157. */
  101158. wRotationCenter: number;
  101159. /**
  101160. * Are mip maps generated for this texture or not.
  101161. */
  101162. get noMipmap(): boolean;
  101163. /**
  101164. * List of inspectable custom properties (used by the Inspector)
  101165. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101166. */
  101167. inspectableCustomProperties: Nullable<IInspectable[]>;
  101168. private _noMipmap;
  101169. /** @hidden */
  101170. _invertY: boolean;
  101171. private _rowGenerationMatrix;
  101172. private _cachedTextureMatrix;
  101173. private _projectionModeMatrix;
  101174. private _t0;
  101175. private _t1;
  101176. private _t2;
  101177. private _cachedUOffset;
  101178. private _cachedVOffset;
  101179. private _cachedUScale;
  101180. private _cachedVScale;
  101181. private _cachedUAng;
  101182. private _cachedVAng;
  101183. private _cachedWAng;
  101184. private _cachedProjectionMatrixId;
  101185. private _cachedCoordinatesMode;
  101186. /** @hidden */
  101187. protected _initialSamplingMode: number;
  101188. /** @hidden */
  101189. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101190. private _deleteBuffer;
  101191. protected _format: Nullable<number>;
  101192. private _delayedOnLoad;
  101193. private _delayedOnError;
  101194. private _mimeType?;
  101195. /**
  101196. * Observable triggered once the texture has been loaded.
  101197. */
  101198. onLoadObservable: Observable<Texture>;
  101199. protected _isBlocking: boolean;
  101200. /**
  101201. * Is the texture preventing material to render while loading.
  101202. * If false, a default texture will be used instead of the loading one during the preparation step.
  101203. */
  101204. set isBlocking(value: boolean);
  101205. get isBlocking(): boolean;
  101206. /**
  101207. * Get the current sampling mode associated with the texture.
  101208. */
  101209. get samplingMode(): number;
  101210. /**
  101211. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101212. */
  101213. get invertY(): boolean;
  101214. /**
  101215. * Instantiates a new texture.
  101216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101217. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101218. * @param url defines the url of the picture to load as a texture
  101219. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101220. * @param noMipmap defines if the texture will require mip maps or not
  101221. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101222. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101223. * @param onLoad defines a callback triggered when the texture has been loaded
  101224. * @param onError defines a callback triggered when an error occurred during the loading session
  101225. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101226. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101227. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101228. * @param mimeType defines an optional mime type information
  101229. */
  101230. 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);
  101231. /**
  101232. * Update the url (and optional buffer) of this texture if url was null during construction.
  101233. * @param url the url of the texture
  101234. * @param buffer the buffer of the texture (defaults to null)
  101235. * @param onLoad callback called when the texture is loaded (defaults to null)
  101236. */
  101237. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101238. /**
  101239. * Finish the loading sequence of a texture flagged as delayed load.
  101240. * @hidden
  101241. */
  101242. delayLoad(): void;
  101243. private _prepareRowForTextureGeneration;
  101244. /**
  101245. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101246. * @returns the transform matrix of the texture.
  101247. */
  101248. getTextureMatrix(uBase?: number): Matrix;
  101249. /**
  101250. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101251. * @returns The reflection texture transform
  101252. */
  101253. getReflectionTextureMatrix(): Matrix;
  101254. /**
  101255. * Clones the texture.
  101256. * @returns the cloned texture
  101257. */
  101258. clone(): Texture;
  101259. /**
  101260. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101261. * @returns The JSON representation of the texture
  101262. */
  101263. serialize(): any;
  101264. /**
  101265. * Get the current class name of the texture useful for serialization or dynamic coding.
  101266. * @returns "Texture"
  101267. */
  101268. getClassName(): string;
  101269. /**
  101270. * Dispose the texture and release its associated resources.
  101271. */
  101272. dispose(): void;
  101273. /**
  101274. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101275. * @param parsedTexture Define the JSON representation of the texture
  101276. * @param scene Define the scene the parsed texture should be instantiated in
  101277. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101278. * @returns The parsed texture if successful
  101279. */
  101280. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101281. /**
  101282. * Creates a texture from its base 64 representation.
  101283. * @param data Define the base64 payload without the data: prefix
  101284. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101285. * @param scene Define the scene the texture should belong to
  101286. * @param noMipmap Forces the texture to not create mip map information if true
  101287. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101288. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101289. * @param onLoad define a callback triggered when the texture has been loaded
  101290. * @param onError define a callback triggered when an error occurred during the loading session
  101291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101292. * @returns the created texture
  101293. */
  101294. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101295. /**
  101296. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101297. * @param data Define the base64 payload without the data: prefix
  101298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101299. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101300. * @param scene Define the scene the texture should belong to
  101301. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101302. * @param noMipmap Forces the texture to not create mip map information if true
  101303. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101304. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101305. * @param onLoad define a callback triggered when the texture has been loaded
  101306. * @param onError define a callback triggered when an error occurred during the loading session
  101307. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101308. * @returns the created texture
  101309. */
  101310. 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;
  101311. }
  101312. }
  101313. declare module BABYLON {
  101314. /**
  101315. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101316. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101317. */
  101318. export class PostProcessManager {
  101319. private _scene;
  101320. private _indexBuffer;
  101321. private _vertexBuffers;
  101322. /**
  101323. * Creates a new instance PostProcess
  101324. * @param scene The scene that the post process is associated with.
  101325. */
  101326. constructor(scene: Scene);
  101327. private _prepareBuffers;
  101328. private _buildIndexBuffer;
  101329. /**
  101330. * Rebuilds the vertex buffers of the manager.
  101331. * @hidden
  101332. */
  101333. _rebuild(): void;
  101334. /**
  101335. * Prepares a frame to be run through a post process.
  101336. * @param sourceTexture The input texture to the post procesess. (default: null)
  101337. * @param postProcesses An array of post processes to be run. (default: null)
  101338. * @returns True if the post processes were able to be run.
  101339. * @hidden
  101340. */
  101341. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101342. /**
  101343. * Manually render a set of post processes to a texture.
  101344. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101345. * @param postProcesses An array of post processes to be run.
  101346. * @param targetTexture The target texture to render to.
  101347. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101348. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101349. * @param lodLevel defines which lod of the texture to render to
  101350. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101351. */
  101352. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101353. /**
  101354. * Finalize the result of the output of the postprocesses.
  101355. * @param doNotPresent If true the result will not be displayed to the screen.
  101356. * @param targetTexture The target texture to render to.
  101357. * @param faceIndex The index of the face to bind the target texture to.
  101358. * @param postProcesses The array of post processes to render.
  101359. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101360. * @hidden
  101361. */
  101362. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101363. /**
  101364. * Disposes of the post process manager.
  101365. */
  101366. dispose(): void;
  101367. }
  101368. }
  101369. declare module BABYLON {
  101370. /**
  101371. * This Helps creating a texture that will be created from a camera in your scene.
  101372. * It is basically a dynamic texture that could be used to create special effects for instance.
  101373. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101374. */
  101375. export class RenderTargetTexture extends Texture {
  101376. isCube: boolean;
  101377. /**
  101378. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101379. */
  101380. static readonly REFRESHRATE_RENDER_ONCE: number;
  101381. /**
  101382. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101383. */
  101384. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101385. /**
  101386. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101387. * the central point of your effect and can save a lot of performances.
  101388. */
  101389. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101390. /**
  101391. * Use this predicate to dynamically define the list of mesh you want to render.
  101392. * If set, the renderList property will be overwritten.
  101393. */
  101394. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101395. private _renderList;
  101396. /**
  101397. * Use this list to define the list of mesh you want to render.
  101398. */
  101399. get renderList(): Nullable<Array<AbstractMesh>>;
  101400. set renderList(value: Nullable<Array<AbstractMesh>>);
  101401. /**
  101402. * Use this function to overload the renderList array at rendering time.
  101403. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101404. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101405. * the cube (if the RTT is a cube, else layerOrFace=0).
  101406. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101407. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101408. * hold dummy elements!
  101409. */
  101410. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101411. private _hookArray;
  101412. /**
  101413. * Define if particles should be rendered in your texture.
  101414. */
  101415. renderParticles: boolean;
  101416. /**
  101417. * Define if sprites should be rendered in your texture.
  101418. */
  101419. renderSprites: boolean;
  101420. /**
  101421. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101422. */
  101423. coordinatesMode: number;
  101424. /**
  101425. * Define the camera used to render the texture.
  101426. */
  101427. activeCamera: Nullable<Camera>;
  101428. /**
  101429. * Override the mesh isReady function with your own one.
  101430. */
  101431. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101432. /**
  101433. * Override the render function of the texture with your own one.
  101434. */
  101435. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101436. /**
  101437. * Define if camera post processes should be use while rendering the texture.
  101438. */
  101439. useCameraPostProcesses: boolean;
  101440. /**
  101441. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101442. */
  101443. ignoreCameraViewport: boolean;
  101444. private _postProcessManager;
  101445. private _postProcesses;
  101446. private _resizeObserver;
  101447. /**
  101448. * An event triggered when the texture is unbind.
  101449. */
  101450. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101451. /**
  101452. * An event triggered when the texture is unbind.
  101453. */
  101454. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101455. private _onAfterUnbindObserver;
  101456. /**
  101457. * Set a after unbind callback in the texture.
  101458. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101459. */
  101460. set onAfterUnbind(callback: () => void);
  101461. /**
  101462. * An event triggered before rendering the texture
  101463. */
  101464. onBeforeRenderObservable: Observable<number>;
  101465. private _onBeforeRenderObserver;
  101466. /**
  101467. * Set a before render callback in the texture.
  101468. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101469. */
  101470. set onBeforeRender(callback: (faceIndex: number) => void);
  101471. /**
  101472. * An event triggered after rendering the texture
  101473. */
  101474. onAfterRenderObservable: Observable<number>;
  101475. private _onAfterRenderObserver;
  101476. /**
  101477. * Set a after render callback in the texture.
  101478. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101479. */
  101480. set onAfterRender(callback: (faceIndex: number) => void);
  101481. /**
  101482. * An event triggered after the texture clear
  101483. */
  101484. onClearObservable: Observable<Engine>;
  101485. private _onClearObserver;
  101486. /**
  101487. * Set a clear callback in the texture.
  101488. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101489. */
  101490. set onClear(callback: (Engine: Engine) => void);
  101491. /**
  101492. * An event triggered when the texture is resized.
  101493. */
  101494. onResizeObservable: Observable<RenderTargetTexture>;
  101495. /**
  101496. * Define the clear color of the Render Target if it should be different from the scene.
  101497. */
  101498. clearColor: Color4;
  101499. protected _size: number | {
  101500. width: number;
  101501. height: number;
  101502. layers?: number;
  101503. };
  101504. protected _initialSizeParameter: number | {
  101505. width: number;
  101506. height: number;
  101507. } | {
  101508. ratio: number;
  101509. };
  101510. protected _sizeRatio: Nullable<number>;
  101511. /** @hidden */
  101512. _generateMipMaps: boolean;
  101513. protected _renderingManager: RenderingManager;
  101514. /** @hidden */
  101515. _waitingRenderList: string[];
  101516. protected _doNotChangeAspectRatio: boolean;
  101517. protected _currentRefreshId: number;
  101518. protected _refreshRate: number;
  101519. protected _textureMatrix: Matrix;
  101520. protected _samples: number;
  101521. protected _renderTargetOptions: RenderTargetCreationOptions;
  101522. /**
  101523. * Gets render target creation options that were used.
  101524. */
  101525. get renderTargetOptions(): RenderTargetCreationOptions;
  101526. protected _onRatioRescale(): void;
  101527. /**
  101528. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101529. * It must define where the camera used to render the texture is set
  101530. */
  101531. boundingBoxPosition: Vector3;
  101532. private _boundingBoxSize;
  101533. /**
  101534. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101535. * When defined, the cubemap will switch to local mode
  101536. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101537. * @example https://www.babylonjs-playground.com/#RNASML
  101538. */
  101539. set boundingBoxSize(value: Vector3);
  101540. get boundingBoxSize(): Vector3;
  101541. /**
  101542. * In case the RTT has been created with a depth texture, get the associated
  101543. * depth texture.
  101544. * Otherwise, return null.
  101545. */
  101546. get depthStencilTexture(): Nullable<InternalTexture>;
  101547. /**
  101548. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101549. * or used a shadow, depth texture...
  101550. * @param name The friendly name of the texture
  101551. * @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)
  101552. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101553. * @param generateMipMaps True if mip maps need to be generated after render.
  101554. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101555. * @param type The type of the buffer in the RTT (int, half float, float...)
  101556. * @param isCube True if a cube texture needs to be created
  101557. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101558. * @param generateDepthBuffer True to generate a depth buffer
  101559. * @param generateStencilBuffer True to generate a stencil buffer
  101560. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101561. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101562. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101563. */
  101564. constructor(name: string, size: number | {
  101565. width: number;
  101566. height: number;
  101567. layers?: number;
  101568. } | {
  101569. ratio: number;
  101570. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101571. /**
  101572. * Creates a depth stencil texture.
  101573. * This is only available in WebGL 2 or with the depth texture extension available.
  101574. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101575. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101576. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101577. */
  101578. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101579. private _processSizeParameter;
  101580. /**
  101581. * Define the number of samples to use in case of MSAA.
  101582. * It defaults to one meaning no MSAA has been enabled.
  101583. */
  101584. get samples(): number;
  101585. set samples(value: number);
  101586. /**
  101587. * Resets the refresh counter of the texture and start bak from scratch.
  101588. * Could be useful to regenerate the texture if it is setup to render only once.
  101589. */
  101590. resetRefreshCounter(): void;
  101591. /**
  101592. * Define the refresh rate of the texture or the rendering frequency.
  101593. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101594. */
  101595. get refreshRate(): number;
  101596. set refreshRate(value: number);
  101597. /**
  101598. * Adds a post process to the render target rendering passes.
  101599. * @param postProcess define the post process to add
  101600. */
  101601. addPostProcess(postProcess: PostProcess): void;
  101602. /**
  101603. * Clear all the post processes attached to the render target
  101604. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101605. */
  101606. clearPostProcesses(dispose?: boolean): void;
  101607. /**
  101608. * Remove one of the post process from the list of attached post processes to the texture
  101609. * @param postProcess define the post process to remove from the list
  101610. */
  101611. removePostProcess(postProcess: PostProcess): void;
  101612. /** @hidden */
  101613. _shouldRender(): boolean;
  101614. /**
  101615. * Gets the actual render size of the texture.
  101616. * @returns the width of the render size
  101617. */
  101618. getRenderSize(): number;
  101619. /**
  101620. * Gets the actual render width of the texture.
  101621. * @returns the width of the render size
  101622. */
  101623. getRenderWidth(): number;
  101624. /**
  101625. * Gets the actual render height of the texture.
  101626. * @returns the height of the render size
  101627. */
  101628. getRenderHeight(): number;
  101629. /**
  101630. * Gets the actual number of layers of the texture.
  101631. * @returns the number of layers
  101632. */
  101633. getRenderLayers(): number;
  101634. /**
  101635. * Get if the texture can be rescaled or not.
  101636. */
  101637. get canRescale(): boolean;
  101638. /**
  101639. * Resize the texture using a ratio.
  101640. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101641. */
  101642. scale(ratio: number): void;
  101643. /**
  101644. * Get the texture reflection matrix used to rotate/transform the reflection.
  101645. * @returns the reflection matrix
  101646. */
  101647. getReflectionTextureMatrix(): Matrix;
  101648. /**
  101649. * Resize the texture to a new desired size.
  101650. * Be carrefull as it will recreate all the data in the new texture.
  101651. * @param size Define the new size. It can be:
  101652. * - a number for squared texture,
  101653. * - an object containing { width: number, height: number }
  101654. * - or an object containing a ratio { ratio: number }
  101655. */
  101656. resize(size: number | {
  101657. width: number;
  101658. height: number;
  101659. } | {
  101660. ratio: number;
  101661. }): void;
  101662. private _defaultRenderListPrepared;
  101663. /**
  101664. * Renders all the objects from the render list into the texture.
  101665. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101666. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101667. */
  101668. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101669. private _bestReflectionRenderTargetDimension;
  101670. private _prepareRenderingManager;
  101671. /**
  101672. * @hidden
  101673. * @param faceIndex face index to bind to if this is a cubetexture
  101674. * @param layer defines the index of the texture to bind in the array
  101675. */
  101676. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101677. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101678. private renderToTarget;
  101679. /**
  101680. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101681. * This allowed control for front to back rendering or reversly depending of the special needs.
  101682. *
  101683. * @param renderingGroupId The rendering group id corresponding to its index
  101684. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101685. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101686. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101687. */
  101688. 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;
  101689. /**
  101690. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101691. *
  101692. * @param renderingGroupId The rendering group id corresponding to its index
  101693. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101694. */
  101695. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101696. /**
  101697. * Clones the texture.
  101698. * @returns the cloned texture
  101699. */
  101700. clone(): RenderTargetTexture;
  101701. /**
  101702. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101703. * @returns The JSON representation of the texture
  101704. */
  101705. serialize(): any;
  101706. /**
  101707. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101708. */
  101709. disposeFramebufferObjects(): void;
  101710. /**
  101711. * Dispose the texture and release its associated resources.
  101712. */
  101713. dispose(): void;
  101714. /** @hidden */
  101715. _rebuild(): void;
  101716. /**
  101717. * Clear the info related to rendering groups preventing retention point in material dispose.
  101718. */
  101719. freeRenderingGroups(): void;
  101720. /**
  101721. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101722. * @returns the view count
  101723. */
  101724. getViewCount(): number;
  101725. }
  101726. }
  101727. declare module BABYLON {
  101728. /**
  101729. * Class used to manipulate GUIDs
  101730. */
  101731. export class GUID {
  101732. /**
  101733. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101734. * Be aware Math.random() could cause collisions, but:
  101735. * "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"
  101736. * @returns a pseudo random id
  101737. */
  101738. static RandomId(): string;
  101739. }
  101740. }
  101741. declare module BABYLON {
  101742. /**
  101743. * Options to be used when creating a shadow depth material
  101744. */
  101745. export interface IIOptionShadowDepthMaterial {
  101746. /** Variables in the vertex shader code that need to have their names remapped.
  101747. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101748. * "var_name" should be either: worldPos or vNormalW
  101749. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101750. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101751. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101752. */
  101753. remappedVariables?: string[];
  101754. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101755. standalone?: boolean;
  101756. }
  101757. /**
  101758. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101759. */
  101760. export class ShadowDepthWrapper {
  101761. private _scene;
  101762. private _options?;
  101763. private _baseMaterial;
  101764. private _onEffectCreatedObserver;
  101765. private _subMeshToEffect;
  101766. private _subMeshToDepthEffect;
  101767. private _meshes;
  101768. /** @hidden */
  101769. _matriceNames: any;
  101770. /** Gets the standalone status of the wrapper */
  101771. get standalone(): boolean;
  101772. /** Gets the base material the wrapper is built upon */
  101773. get baseMaterial(): Material;
  101774. /**
  101775. * Instantiate a new shadow depth wrapper.
  101776. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101777. * generate the shadow depth map. For more information, please refer to the documentation:
  101778. * https://doc.babylonjs.com/babylon101/shadows
  101779. * @param baseMaterial Material to wrap
  101780. * @param scene Define the scene the material belongs to
  101781. * @param options Options used to create the wrapper
  101782. */
  101783. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101784. /**
  101785. * Gets the effect to use to generate the depth map
  101786. * @param subMesh subMesh to get the effect for
  101787. * @param shadowGenerator shadow generator to get the effect for
  101788. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101789. */
  101790. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101791. /**
  101792. * Specifies that the submesh is ready to be used for depth rendering
  101793. * @param subMesh submesh to check
  101794. * @param defines the list of defines to take into account when checking the effect
  101795. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101796. * @param useInstances specifies that instances should be used
  101797. * @returns a boolean indicating that the submesh is ready or not
  101798. */
  101799. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101800. /**
  101801. * Disposes the resources
  101802. */
  101803. dispose(): void;
  101804. private _makeEffect;
  101805. }
  101806. }
  101807. declare module BABYLON {
  101808. /**
  101809. * Options for compiling materials.
  101810. */
  101811. export interface IMaterialCompilationOptions {
  101812. /**
  101813. * Defines whether clip planes are enabled.
  101814. */
  101815. clipPlane: boolean;
  101816. /**
  101817. * Defines whether instances are enabled.
  101818. */
  101819. useInstances: boolean;
  101820. }
  101821. /**
  101822. * Options passed when calling customShaderNameResolve
  101823. */
  101824. export interface ICustomShaderNameResolveOptions {
  101825. /**
  101826. * 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
  101827. */
  101828. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101829. }
  101830. /**
  101831. * Base class for the main features of a material in Babylon.js
  101832. */
  101833. export class Material implements IAnimatable {
  101834. /**
  101835. * Returns the triangle fill mode
  101836. */
  101837. static readonly TriangleFillMode: number;
  101838. /**
  101839. * Returns the wireframe mode
  101840. */
  101841. static readonly WireFrameFillMode: number;
  101842. /**
  101843. * Returns the point fill mode
  101844. */
  101845. static readonly PointFillMode: number;
  101846. /**
  101847. * Returns the point list draw mode
  101848. */
  101849. static readonly PointListDrawMode: number;
  101850. /**
  101851. * Returns the line list draw mode
  101852. */
  101853. static readonly LineListDrawMode: number;
  101854. /**
  101855. * Returns the line loop draw mode
  101856. */
  101857. static readonly LineLoopDrawMode: number;
  101858. /**
  101859. * Returns the line strip draw mode
  101860. */
  101861. static readonly LineStripDrawMode: number;
  101862. /**
  101863. * Returns the triangle strip draw mode
  101864. */
  101865. static readonly TriangleStripDrawMode: number;
  101866. /**
  101867. * Returns the triangle fan draw mode
  101868. */
  101869. static readonly TriangleFanDrawMode: number;
  101870. /**
  101871. * Stores the clock-wise side orientation
  101872. */
  101873. static readonly ClockWiseSideOrientation: number;
  101874. /**
  101875. * Stores the counter clock-wise side orientation
  101876. */
  101877. static readonly CounterClockWiseSideOrientation: number;
  101878. /**
  101879. * The dirty texture flag value
  101880. */
  101881. static readonly TextureDirtyFlag: number;
  101882. /**
  101883. * The dirty light flag value
  101884. */
  101885. static readonly LightDirtyFlag: number;
  101886. /**
  101887. * The dirty fresnel flag value
  101888. */
  101889. static readonly FresnelDirtyFlag: number;
  101890. /**
  101891. * The dirty attribute flag value
  101892. */
  101893. static readonly AttributesDirtyFlag: number;
  101894. /**
  101895. * The dirty misc flag value
  101896. */
  101897. static readonly MiscDirtyFlag: number;
  101898. /**
  101899. * The all dirty flag value
  101900. */
  101901. static readonly AllDirtyFlag: number;
  101902. /**
  101903. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101904. */
  101905. static readonly MATERIAL_OPAQUE: number;
  101906. /**
  101907. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101908. */
  101909. static readonly MATERIAL_ALPHATEST: number;
  101910. /**
  101911. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101912. */
  101913. static readonly MATERIAL_ALPHABLEND: number;
  101914. /**
  101915. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101916. * They are also discarded below the alpha cutoff threshold to improve performances.
  101917. */
  101918. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101919. /**
  101920. * The Whiteout method is used to blend normals.
  101921. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101922. */
  101923. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101924. /**
  101925. * The Reoriented Normal Mapping method is used to blend normals.
  101926. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101927. */
  101928. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101929. /**
  101930. * Custom callback helping to override the default shader used in the material.
  101931. */
  101932. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101933. /**
  101934. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101935. */
  101936. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101937. /**
  101938. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101939. * This means that the material can keep using a previous shader while a new one is being compiled.
  101940. * This is mostly used when shader parallel compilation is supported (true by default)
  101941. */
  101942. allowShaderHotSwapping: boolean;
  101943. /**
  101944. * The ID of the material
  101945. */
  101946. id: string;
  101947. /**
  101948. * Gets or sets the unique id of the material
  101949. */
  101950. uniqueId: number;
  101951. /**
  101952. * The name of the material
  101953. */
  101954. name: string;
  101955. /**
  101956. * Gets or sets user defined metadata
  101957. */
  101958. metadata: any;
  101959. /**
  101960. * For internal use only. Please do not use.
  101961. */
  101962. reservedDataStore: any;
  101963. /**
  101964. * Specifies if the ready state should be checked on each call
  101965. */
  101966. checkReadyOnEveryCall: boolean;
  101967. /**
  101968. * Specifies if the ready state should be checked once
  101969. */
  101970. checkReadyOnlyOnce: boolean;
  101971. /**
  101972. * The state of the material
  101973. */
  101974. state: string;
  101975. /**
  101976. * If the material should be rendered to several textures with MRT extension
  101977. */
  101978. get shouldRenderToMRT(): boolean;
  101979. /**
  101980. * The alpha value of the material
  101981. */
  101982. protected _alpha: number;
  101983. /**
  101984. * List of inspectable custom properties (used by the Inspector)
  101985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101986. */
  101987. inspectableCustomProperties: IInspectable[];
  101988. /**
  101989. * Sets the alpha value of the material
  101990. */
  101991. set alpha(value: number);
  101992. /**
  101993. * Gets the alpha value of the material
  101994. */
  101995. get alpha(): number;
  101996. /**
  101997. * Specifies if back face culling is enabled
  101998. */
  101999. protected _backFaceCulling: boolean;
  102000. /**
  102001. * Sets the back-face culling state
  102002. */
  102003. set backFaceCulling(value: boolean);
  102004. /**
  102005. * Gets the back-face culling state
  102006. */
  102007. get backFaceCulling(): boolean;
  102008. /**
  102009. * Stores the value for side orientation
  102010. */
  102011. sideOrientation: number;
  102012. /**
  102013. * Callback triggered when the material is compiled
  102014. */
  102015. onCompiled: Nullable<(effect: Effect) => void>;
  102016. /**
  102017. * Callback triggered when an error occurs
  102018. */
  102019. onError: Nullable<(effect: Effect, errors: string) => void>;
  102020. /**
  102021. * Callback triggered to get the render target textures
  102022. */
  102023. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102024. /**
  102025. * Gets a boolean indicating that current material needs to register RTT
  102026. */
  102027. get hasRenderTargetTextures(): boolean;
  102028. /**
  102029. * Specifies if the material should be serialized
  102030. */
  102031. doNotSerialize: boolean;
  102032. /**
  102033. * @hidden
  102034. */
  102035. _storeEffectOnSubMeshes: boolean;
  102036. /**
  102037. * Stores the animations for the material
  102038. */
  102039. animations: Nullable<Array<Animation>>;
  102040. /**
  102041. * An event triggered when the material is disposed
  102042. */
  102043. onDisposeObservable: Observable<Material>;
  102044. /**
  102045. * An observer which watches for dispose events
  102046. */
  102047. private _onDisposeObserver;
  102048. private _onUnBindObservable;
  102049. /**
  102050. * Called during a dispose event
  102051. */
  102052. set onDispose(callback: () => void);
  102053. private _onBindObservable;
  102054. /**
  102055. * An event triggered when the material is bound
  102056. */
  102057. get onBindObservable(): Observable<AbstractMesh>;
  102058. /**
  102059. * An observer which watches for bind events
  102060. */
  102061. private _onBindObserver;
  102062. /**
  102063. * Called during a bind event
  102064. */
  102065. set onBind(callback: (Mesh: AbstractMesh) => void);
  102066. /**
  102067. * An event triggered when the material is unbound
  102068. */
  102069. get onUnBindObservable(): Observable<Material>;
  102070. protected _onEffectCreatedObservable: Nullable<Observable<{
  102071. effect: Effect;
  102072. subMesh: Nullable<SubMesh>;
  102073. }>>;
  102074. /**
  102075. * An event triggered when the effect is (re)created
  102076. */
  102077. get onEffectCreatedObservable(): Observable<{
  102078. effect: Effect;
  102079. subMesh: Nullable<SubMesh>;
  102080. }>;
  102081. /**
  102082. * Stores the value of the alpha mode
  102083. */
  102084. private _alphaMode;
  102085. /**
  102086. * Sets the value of the alpha mode.
  102087. *
  102088. * | Value | Type | Description |
  102089. * | --- | --- | --- |
  102090. * | 0 | ALPHA_DISABLE | |
  102091. * | 1 | ALPHA_ADD | |
  102092. * | 2 | ALPHA_COMBINE | |
  102093. * | 3 | ALPHA_SUBTRACT | |
  102094. * | 4 | ALPHA_MULTIPLY | |
  102095. * | 5 | ALPHA_MAXIMIZED | |
  102096. * | 6 | ALPHA_ONEONE | |
  102097. * | 7 | ALPHA_PREMULTIPLIED | |
  102098. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102099. * | 9 | ALPHA_INTERPOLATE | |
  102100. * | 10 | ALPHA_SCREENMODE | |
  102101. *
  102102. */
  102103. set alphaMode(value: number);
  102104. /**
  102105. * Gets the value of the alpha mode
  102106. */
  102107. get alphaMode(): number;
  102108. /**
  102109. * Stores the state of the need depth pre-pass value
  102110. */
  102111. private _needDepthPrePass;
  102112. /**
  102113. * Sets the need depth pre-pass value
  102114. */
  102115. set needDepthPrePass(value: boolean);
  102116. /**
  102117. * Gets the depth pre-pass value
  102118. */
  102119. get needDepthPrePass(): boolean;
  102120. /**
  102121. * Specifies if depth writing should be disabled
  102122. */
  102123. disableDepthWrite: boolean;
  102124. /**
  102125. * Specifies if color writing should be disabled
  102126. */
  102127. disableColorWrite: boolean;
  102128. /**
  102129. * Specifies if depth writing should be forced
  102130. */
  102131. forceDepthWrite: boolean;
  102132. /**
  102133. * Specifies the depth function that should be used. 0 means the default engine function
  102134. */
  102135. depthFunction: number;
  102136. /**
  102137. * Specifies if there should be a separate pass for culling
  102138. */
  102139. separateCullingPass: boolean;
  102140. /**
  102141. * Stores the state specifing if fog should be enabled
  102142. */
  102143. private _fogEnabled;
  102144. /**
  102145. * Sets the state for enabling fog
  102146. */
  102147. set fogEnabled(value: boolean);
  102148. /**
  102149. * Gets the value of the fog enabled state
  102150. */
  102151. get fogEnabled(): boolean;
  102152. /**
  102153. * Stores the size of points
  102154. */
  102155. pointSize: number;
  102156. /**
  102157. * Stores the z offset value
  102158. */
  102159. zOffset: number;
  102160. get wireframe(): boolean;
  102161. /**
  102162. * Sets the state of wireframe mode
  102163. */
  102164. set wireframe(value: boolean);
  102165. /**
  102166. * Gets the value specifying if point clouds are enabled
  102167. */
  102168. get pointsCloud(): boolean;
  102169. /**
  102170. * Sets the state of point cloud mode
  102171. */
  102172. set pointsCloud(value: boolean);
  102173. /**
  102174. * Gets the material fill mode
  102175. */
  102176. get fillMode(): number;
  102177. /**
  102178. * Sets the material fill mode
  102179. */
  102180. set fillMode(value: number);
  102181. /**
  102182. * @hidden
  102183. * Stores the effects for the material
  102184. */
  102185. _effect: Nullable<Effect>;
  102186. /**
  102187. * Specifies if uniform buffers should be used
  102188. */
  102189. private _useUBO;
  102190. /**
  102191. * Stores a reference to the scene
  102192. */
  102193. private _scene;
  102194. /**
  102195. * Stores the fill mode state
  102196. */
  102197. private _fillMode;
  102198. /**
  102199. * Specifies if the depth write state should be cached
  102200. */
  102201. private _cachedDepthWriteState;
  102202. /**
  102203. * Specifies if the color write state should be cached
  102204. */
  102205. private _cachedColorWriteState;
  102206. /**
  102207. * Specifies if the depth function state should be cached
  102208. */
  102209. private _cachedDepthFunctionState;
  102210. /**
  102211. * Stores the uniform buffer
  102212. */
  102213. protected _uniformBuffer: UniformBuffer;
  102214. /** @hidden */
  102215. _indexInSceneMaterialArray: number;
  102216. /** @hidden */
  102217. meshMap: Nullable<{
  102218. [id: string]: AbstractMesh | undefined;
  102219. }>;
  102220. /**
  102221. * Creates a material instance
  102222. * @param name defines the name of the material
  102223. * @param scene defines the scene to reference
  102224. * @param doNotAdd specifies if the material should be added to the scene
  102225. */
  102226. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102227. /**
  102228. * Returns a string representation of the current material
  102229. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102230. * @returns a string with material information
  102231. */
  102232. toString(fullDetails?: boolean): string;
  102233. /**
  102234. * Gets the class name of the material
  102235. * @returns a string with the class name of the material
  102236. */
  102237. getClassName(): string;
  102238. /**
  102239. * Specifies if updates for the material been locked
  102240. */
  102241. get isFrozen(): boolean;
  102242. /**
  102243. * Locks updates for the material
  102244. */
  102245. freeze(): void;
  102246. /**
  102247. * Unlocks updates for the material
  102248. */
  102249. unfreeze(): void;
  102250. /**
  102251. * Specifies if the material is ready to be used
  102252. * @param mesh defines the mesh to check
  102253. * @param useInstances specifies if instances should be used
  102254. * @returns a boolean indicating if the material is ready to be used
  102255. */
  102256. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102257. /**
  102258. * Specifies that the submesh is ready to be used
  102259. * @param mesh defines the mesh to check
  102260. * @param subMesh defines which submesh to check
  102261. * @param useInstances specifies that instances should be used
  102262. * @returns a boolean indicating that the submesh is ready or not
  102263. */
  102264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102265. /**
  102266. * Returns the material effect
  102267. * @returns the effect associated with the material
  102268. */
  102269. getEffect(): Nullable<Effect>;
  102270. /**
  102271. * Returns the current scene
  102272. * @returns a Scene
  102273. */
  102274. getScene(): Scene;
  102275. /**
  102276. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102277. */
  102278. protected _forceAlphaTest: boolean;
  102279. /**
  102280. * The transparency mode of the material.
  102281. */
  102282. protected _transparencyMode: Nullable<number>;
  102283. /**
  102284. * Gets the current transparency mode.
  102285. */
  102286. get transparencyMode(): Nullable<number>;
  102287. /**
  102288. * Sets the transparency mode of the material.
  102289. *
  102290. * | Value | Type | Description |
  102291. * | ----- | ----------------------------------- | ----------- |
  102292. * | 0 | OPAQUE | |
  102293. * | 1 | ALPHATEST | |
  102294. * | 2 | ALPHABLEND | |
  102295. * | 3 | ALPHATESTANDBLEND | |
  102296. *
  102297. */
  102298. set transparencyMode(value: Nullable<number>);
  102299. /**
  102300. * Returns true if alpha blending should be disabled.
  102301. */
  102302. protected get _disableAlphaBlending(): boolean;
  102303. /**
  102304. * Specifies whether or not this material should be rendered in alpha blend mode.
  102305. * @returns a boolean specifying if alpha blending is needed
  102306. */
  102307. needAlphaBlending(): boolean;
  102308. /**
  102309. * Specifies if the mesh will require alpha blending
  102310. * @param mesh defines the mesh to check
  102311. * @returns a boolean specifying if alpha blending is needed for the mesh
  102312. */
  102313. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102314. /**
  102315. * Specifies whether or not this material should be rendered in alpha test mode.
  102316. * @returns a boolean specifying if an alpha test is needed.
  102317. */
  102318. needAlphaTesting(): boolean;
  102319. /**
  102320. * Specifies if material alpha testing should be turned on for the mesh
  102321. * @param mesh defines the mesh to check
  102322. */
  102323. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102324. /**
  102325. * Gets the texture used for the alpha test
  102326. * @returns the texture to use for alpha testing
  102327. */
  102328. getAlphaTestTexture(): Nullable<BaseTexture>;
  102329. /**
  102330. * Marks the material to indicate that it needs to be re-calculated
  102331. */
  102332. markDirty(): void;
  102333. /** @hidden */
  102334. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102335. /**
  102336. * Binds the material to the mesh
  102337. * @param world defines the world transformation matrix
  102338. * @param mesh defines the mesh to bind the material to
  102339. */
  102340. bind(world: Matrix, mesh?: Mesh): void;
  102341. /**
  102342. * Binds the submesh to the material
  102343. * @param world defines the world transformation matrix
  102344. * @param mesh defines the mesh containing the submesh
  102345. * @param subMesh defines the submesh to bind the material to
  102346. */
  102347. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102348. /**
  102349. * Binds the world matrix to the material
  102350. * @param world defines the world transformation matrix
  102351. */
  102352. bindOnlyWorldMatrix(world: Matrix): void;
  102353. /**
  102354. * Binds the scene's uniform buffer to the effect.
  102355. * @param effect defines the effect to bind to the scene uniform buffer
  102356. * @param sceneUbo defines the uniform buffer storing scene data
  102357. */
  102358. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102359. /**
  102360. * Binds the view matrix to the effect
  102361. * @param effect defines the effect to bind the view matrix to
  102362. */
  102363. bindView(effect: Effect): void;
  102364. /**
  102365. * Binds the view projection matrix to the effect
  102366. * @param effect defines the effect to bind the view projection matrix to
  102367. */
  102368. bindViewProjection(effect: Effect): void;
  102369. /**
  102370. * Processes to execute after binding the material to a mesh
  102371. * @param mesh defines the rendered mesh
  102372. */
  102373. protected _afterBind(mesh?: Mesh): void;
  102374. /**
  102375. * Unbinds the material from the mesh
  102376. */
  102377. unbind(): void;
  102378. /**
  102379. * Gets the active textures from the material
  102380. * @returns an array of textures
  102381. */
  102382. getActiveTextures(): BaseTexture[];
  102383. /**
  102384. * Specifies if the material uses a texture
  102385. * @param texture defines the texture to check against the material
  102386. * @returns a boolean specifying if the material uses the texture
  102387. */
  102388. hasTexture(texture: BaseTexture): boolean;
  102389. /**
  102390. * Makes a duplicate of the material, and gives it a new name
  102391. * @param name defines the new name for the duplicated material
  102392. * @returns the cloned material
  102393. */
  102394. clone(name: string): Nullable<Material>;
  102395. /**
  102396. * Gets the meshes bound to the material
  102397. * @returns an array of meshes bound to the material
  102398. */
  102399. getBindedMeshes(): AbstractMesh[];
  102400. /**
  102401. * Force shader compilation
  102402. * @param mesh defines the mesh associated with this material
  102403. * @param onCompiled defines a function to execute once the material is compiled
  102404. * @param options defines the options to configure the compilation
  102405. * @param onError defines a function to execute if the material fails compiling
  102406. */
  102407. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102408. /**
  102409. * Force shader compilation
  102410. * @param mesh defines the mesh that will use this material
  102411. * @param options defines additional options for compiling the shaders
  102412. * @returns a promise that resolves when the compilation completes
  102413. */
  102414. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102415. private static readonly _AllDirtyCallBack;
  102416. private static readonly _ImageProcessingDirtyCallBack;
  102417. private static readonly _TextureDirtyCallBack;
  102418. private static readonly _FresnelDirtyCallBack;
  102419. private static readonly _MiscDirtyCallBack;
  102420. private static readonly _LightsDirtyCallBack;
  102421. private static readonly _AttributeDirtyCallBack;
  102422. private static _FresnelAndMiscDirtyCallBack;
  102423. private static _TextureAndMiscDirtyCallBack;
  102424. private static readonly _DirtyCallbackArray;
  102425. private static readonly _RunDirtyCallBacks;
  102426. /**
  102427. * Marks a define in the material to indicate that it needs to be re-computed
  102428. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102429. */
  102430. markAsDirty(flag: number): void;
  102431. /**
  102432. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102433. * @param func defines a function which checks material defines against the submeshes
  102434. */
  102435. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102436. /**
  102437. * Indicates that the scene should check if the rendering now needs a prepass
  102438. */
  102439. protected _markScenePrePassDirty(): void;
  102440. /**
  102441. * Indicates that we need to re-calculated for all submeshes
  102442. */
  102443. protected _markAllSubMeshesAsAllDirty(): void;
  102444. /**
  102445. * Indicates that image processing needs to be re-calculated for all submeshes
  102446. */
  102447. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102448. /**
  102449. * Indicates that textures need to be re-calculated for all submeshes
  102450. */
  102451. protected _markAllSubMeshesAsTexturesDirty(): void;
  102452. /**
  102453. * Indicates that fresnel needs to be re-calculated for all submeshes
  102454. */
  102455. protected _markAllSubMeshesAsFresnelDirty(): void;
  102456. /**
  102457. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102458. */
  102459. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102460. /**
  102461. * Indicates that lights need to be re-calculated for all submeshes
  102462. */
  102463. protected _markAllSubMeshesAsLightsDirty(): void;
  102464. /**
  102465. * Indicates that attributes need to be re-calculated for all submeshes
  102466. */
  102467. protected _markAllSubMeshesAsAttributesDirty(): void;
  102468. /**
  102469. * Indicates that misc needs to be re-calculated for all submeshes
  102470. */
  102471. protected _markAllSubMeshesAsMiscDirty(): void;
  102472. /**
  102473. * Indicates that textures and misc need to be re-calculated for all submeshes
  102474. */
  102475. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102476. /**
  102477. * Disposes the material
  102478. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102479. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102480. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102481. */
  102482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102483. /** @hidden */
  102484. private releaseVertexArrayObject;
  102485. /**
  102486. * Serializes this material
  102487. * @returns the serialized material object
  102488. */
  102489. serialize(): any;
  102490. /**
  102491. * Creates a material from parsed material data
  102492. * @param parsedMaterial defines parsed material data
  102493. * @param scene defines the hosting scene
  102494. * @param rootUrl defines the root URL to use to load textures
  102495. * @returns a new material
  102496. */
  102497. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102498. }
  102499. }
  102500. declare module BABYLON {
  102501. /**
  102502. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102503. * separate meshes. This can be use to improve performances.
  102504. * @see https://doc.babylonjs.com/how_to/multi_materials
  102505. */
  102506. export class MultiMaterial extends Material {
  102507. private _subMaterials;
  102508. /**
  102509. * Gets or Sets the list of Materials used within the multi material.
  102510. * They need to be ordered according to the submeshes order in the associated mesh
  102511. */
  102512. get subMaterials(): Nullable<Material>[];
  102513. set subMaterials(value: Nullable<Material>[]);
  102514. /**
  102515. * Function used to align with Node.getChildren()
  102516. * @returns the list of Materials used within the multi material
  102517. */
  102518. getChildren(): Nullable<Material>[];
  102519. /**
  102520. * Instantiates a new Multi Material
  102521. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102522. * separate meshes. This can be use to improve performances.
  102523. * @see https://doc.babylonjs.com/how_to/multi_materials
  102524. * @param name Define the name in the scene
  102525. * @param scene Define the scene the material belongs to
  102526. */
  102527. constructor(name: string, scene: Scene);
  102528. private _hookArray;
  102529. /**
  102530. * Get one of the submaterial by its index in the submaterials array
  102531. * @param index The index to look the sub material at
  102532. * @returns The Material if the index has been defined
  102533. */
  102534. getSubMaterial(index: number): Nullable<Material>;
  102535. /**
  102536. * Get the list of active textures for the whole sub materials list.
  102537. * @returns All the textures that will be used during the rendering
  102538. */
  102539. getActiveTextures(): BaseTexture[];
  102540. /**
  102541. * Gets the current class name of the material e.g. "MultiMaterial"
  102542. * Mainly use in serialization.
  102543. * @returns the class name
  102544. */
  102545. getClassName(): string;
  102546. /**
  102547. * Checks if the material is ready to render the requested sub mesh
  102548. * @param mesh Define the mesh the submesh belongs to
  102549. * @param subMesh Define the sub mesh to look readyness for
  102550. * @param useInstances Define whether or not the material is used with instances
  102551. * @returns true if ready, otherwise false
  102552. */
  102553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102554. /**
  102555. * Clones the current material and its related sub materials
  102556. * @param name Define the name of the newly cloned material
  102557. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102558. * @returns the cloned material
  102559. */
  102560. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102561. /**
  102562. * Serializes the materials into a JSON representation.
  102563. * @returns the JSON representation
  102564. */
  102565. serialize(): any;
  102566. /**
  102567. * Dispose the material and release its associated resources
  102568. * @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)
  102569. * @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)
  102570. * @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)
  102571. */
  102572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102573. /**
  102574. * Creates a MultiMaterial from parsed MultiMaterial data.
  102575. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102576. * @param scene defines the hosting scene
  102577. * @returns a new MultiMaterial
  102578. */
  102579. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Defines a subdivision inside a mesh
  102585. */
  102586. export class SubMesh implements ICullable {
  102587. /** the material index to use */
  102588. materialIndex: number;
  102589. /** vertex index start */
  102590. verticesStart: number;
  102591. /** vertices count */
  102592. verticesCount: number;
  102593. /** index start */
  102594. indexStart: number;
  102595. /** indices count */
  102596. indexCount: number;
  102597. /** @hidden */
  102598. _materialDefines: Nullable<MaterialDefines>;
  102599. /** @hidden */
  102600. _materialEffect: Nullable<Effect>;
  102601. /** @hidden */
  102602. _effectOverride: Nullable<Effect>;
  102603. /**
  102604. * Gets material defines used by the effect associated to the sub mesh
  102605. */
  102606. get materialDefines(): Nullable<MaterialDefines>;
  102607. /**
  102608. * Sets material defines used by the effect associated to the sub mesh
  102609. */
  102610. set materialDefines(defines: Nullable<MaterialDefines>);
  102611. /**
  102612. * Gets associated effect
  102613. */
  102614. get effect(): Nullable<Effect>;
  102615. /**
  102616. * Sets associated effect (effect used to render this submesh)
  102617. * @param effect defines the effect to associate with
  102618. * @param defines defines the set of defines used to compile this effect
  102619. */
  102620. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102621. /** @hidden */
  102622. _linesIndexCount: number;
  102623. private _mesh;
  102624. private _renderingMesh;
  102625. private _boundingInfo;
  102626. private _linesIndexBuffer;
  102627. /** @hidden */
  102628. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102629. /** @hidden */
  102630. _trianglePlanes: Plane[];
  102631. /** @hidden */
  102632. _lastColliderTransformMatrix: Nullable<Matrix>;
  102633. /** @hidden */
  102634. _renderId: number;
  102635. /** @hidden */
  102636. _alphaIndex: number;
  102637. /** @hidden */
  102638. _distanceToCamera: number;
  102639. /** @hidden */
  102640. _id: number;
  102641. private _currentMaterial;
  102642. /**
  102643. * Add a new submesh to a mesh
  102644. * @param materialIndex defines the material index to use
  102645. * @param verticesStart defines vertex index start
  102646. * @param verticesCount defines vertices count
  102647. * @param indexStart defines index start
  102648. * @param indexCount defines indices count
  102649. * @param mesh defines the parent mesh
  102650. * @param renderingMesh defines an optional rendering mesh
  102651. * @param createBoundingBox defines if bounding box should be created for this submesh
  102652. * @returns the new submesh
  102653. */
  102654. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102655. /**
  102656. * Creates a new submesh
  102657. * @param materialIndex defines the material index to use
  102658. * @param verticesStart defines vertex index start
  102659. * @param verticesCount defines vertices count
  102660. * @param indexStart defines index start
  102661. * @param indexCount defines indices count
  102662. * @param mesh defines the parent mesh
  102663. * @param renderingMesh defines an optional rendering mesh
  102664. * @param createBoundingBox defines if bounding box should be created for this submesh
  102665. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102666. */
  102667. constructor(
  102668. /** the material index to use */
  102669. materialIndex: number,
  102670. /** vertex index start */
  102671. verticesStart: number,
  102672. /** vertices count */
  102673. verticesCount: number,
  102674. /** index start */
  102675. indexStart: number,
  102676. /** indices count */
  102677. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102678. /**
  102679. * Returns true if this submesh covers the entire parent mesh
  102680. * @ignorenaming
  102681. */
  102682. get IsGlobal(): boolean;
  102683. /**
  102684. * Returns the submesh BoudingInfo object
  102685. * @returns current bounding info (or mesh's one if the submesh is global)
  102686. */
  102687. getBoundingInfo(): BoundingInfo;
  102688. /**
  102689. * Sets the submesh BoundingInfo
  102690. * @param boundingInfo defines the new bounding info to use
  102691. * @returns the SubMesh
  102692. */
  102693. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102694. /**
  102695. * Returns the mesh of the current submesh
  102696. * @return the parent mesh
  102697. */
  102698. getMesh(): AbstractMesh;
  102699. /**
  102700. * Returns the rendering mesh of the submesh
  102701. * @returns the rendering mesh (could be different from parent mesh)
  102702. */
  102703. getRenderingMesh(): Mesh;
  102704. /**
  102705. * Returns the replacement mesh of the submesh
  102706. * @returns the replacement mesh (could be different from parent mesh)
  102707. */
  102708. getReplacementMesh(): Nullable<AbstractMesh>;
  102709. /**
  102710. * Returns the effective mesh of the submesh
  102711. * @returns the effective mesh (could be different from parent mesh)
  102712. */
  102713. getEffectiveMesh(): AbstractMesh;
  102714. /**
  102715. * Returns the submesh material
  102716. * @returns null or the current material
  102717. */
  102718. getMaterial(): Nullable<Material>;
  102719. private _IsMultiMaterial;
  102720. /**
  102721. * Sets a new updated BoundingInfo object to the submesh
  102722. * @param data defines an optional position array to use to determine the bounding info
  102723. * @returns the SubMesh
  102724. */
  102725. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102726. /** @hidden */
  102727. _checkCollision(collider: Collider): boolean;
  102728. /**
  102729. * Updates the submesh BoundingInfo
  102730. * @param world defines the world matrix to use to update the bounding info
  102731. * @returns the submesh
  102732. */
  102733. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102734. /**
  102735. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102736. * @param frustumPlanes defines the frustum planes
  102737. * @returns true if the submesh is intersecting with the frustum
  102738. */
  102739. isInFrustum(frustumPlanes: Plane[]): boolean;
  102740. /**
  102741. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102742. * @param frustumPlanes defines the frustum planes
  102743. * @returns true if the submesh is inside the frustum
  102744. */
  102745. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102746. /**
  102747. * Renders the submesh
  102748. * @param enableAlphaMode defines if alpha needs to be used
  102749. * @returns the submesh
  102750. */
  102751. render(enableAlphaMode: boolean): SubMesh;
  102752. /**
  102753. * @hidden
  102754. */
  102755. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102756. /**
  102757. * Checks if the submesh intersects with a ray
  102758. * @param ray defines the ray to test
  102759. * @returns true is the passed ray intersects the submesh bounding box
  102760. */
  102761. canIntersects(ray: Ray): boolean;
  102762. /**
  102763. * Intersects current submesh with a ray
  102764. * @param ray defines the ray to test
  102765. * @param positions defines mesh's positions array
  102766. * @param indices defines mesh's indices array
  102767. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102768. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102769. * @returns intersection info or null if no intersection
  102770. */
  102771. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102772. /** @hidden */
  102773. private _intersectLines;
  102774. /** @hidden */
  102775. private _intersectUnIndexedLines;
  102776. /** @hidden */
  102777. private _intersectTriangles;
  102778. /** @hidden */
  102779. private _intersectUnIndexedTriangles;
  102780. /** @hidden */
  102781. _rebuild(): void;
  102782. /**
  102783. * Creates a new submesh from the passed mesh
  102784. * @param newMesh defines the new hosting mesh
  102785. * @param newRenderingMesh defines an optional rendering mesh
  102786. * @returns the new submesh
  102787. */
  102788. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102789. /**
  102790. * Release associated resources
  102791. */
  102792. dispose(): void;
  102793. /**
  102794. * Gets the class name
  102795. * @returns the string "SubMesh".
  102796. */
  102797. getClassName(): string;
  102798. /**
  102799. * Creates a new submesh from indices data
  102800. * @param materialIndex the index of the main mesh material
  102801. * @param startIndex the index where to start the copy in the mesh indices array
  102802. * @param indexCount the number of indices to copy then from the startIndex
  102803. * @param mesh the main mesh to create the submesh from
  102804. * @param renderingMesh the optional rendering mesh
  102805. * @returns a new submesh
  102806. */
  102807. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102808. }
  102809. }
  102810. declare module BABYLON {
  102811. /**
  102812. * Class used to represent data loading progression
  102813. */
  102814. export class SceneLoaderFlags {
  102815. private static _ForceFullSceneLoadingForIncremental;
  102816. private static _ShowLoadingScreen;
  102817. private static _CleanBoneMatrixWeights;
  102818. private static _loggingLevel;
  102819. /**
  102820. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102821. */
  102822. static get ForceFullSceneLoadingForIncremental(): boolean;
  102823. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102824. /**
  102825. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102826. */
  102827. static get ShowLoadingScreen(): boolean;
  102828. static set ShowLoadingScreen(value: boolean);
  102829. /**
  102830. * Defines the current logging level (while loading the scene)
  102831. * @ignorenaming
  102832. */
  102833. static get loggingLevel(): number;
  102834. static set loggingLevel(value: number);
  102835. /**
  102836. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102837. */
  102838. static get CleanBoneMatrixWeights(): boolean;
  102839. static set CleanBoneMatrixWeights(value: boolean);
  102840. }
  102841. }
  102842. declare module BABYLON {
  102843. /**
  102844. * Class used to store geometry data (vertex buffers + index buffer)
  102845. */
  102846. export class Geometry implements IGetSetVerticesData {
  102847. /**
  102848. * Gets or sets the ID of the geometry
  102849. */
  102850. id: string;
  102851. /**
  102852. * Gets or sets the unique ID of the geometry
  102853. */
  102854. uniqueId: number;
  102855. /**
  102856. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102857. */
  102858. delayLoadState: number;
  102859. /**
  102860. * Gets the file containing the data to load when running in delay load state
  102861. */
  102862. delayLoadingFile: Nullable<string>;
  102863. /**
  102864. * Callback called when the geometry is updated
  102865. */
  102866. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102867. private _scene;
  102868. private _engine;
  102869. private _meshes;
  102870. private _totalVertices;
  102871. /** @hidden */
  102872. _indices: IndicesArray;
  102873. /** @hidden */
  102874. _vertexBuffers: {
  102875. [key: string]: VertexBuffer;
  102876. };
  102877. private _isDisposed;
  102878. private _extend;
  102879. private _boundingBias;
  102880. /** @hidden */
  102881. _delayInfo: Array<string>;
  102882. private _indexBuffer;
  102883. private _indexBufferIsUpdatable;
  102884. /** @hidden */
  102885. _boundingInfo: Nullable<BoundingInfo>;
  102886. /** @hidden */
  102887. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102888. /** @hidden */
  102889. _softwareSkinningFrameId: number;
  102890. private _vertexArrayObjects;
  102891. private _updatable;
  102892. /** @hidden */
  102893. _positions: Nullable<Vector3[]>;
  102894. /**
  102895. * 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
  102896. */
  102897. get boundingBias(): Vector2;
  102898. /**
  102899. * 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
  102900. */
  102901. set boundingBias(value: Vector2);
  102902. /**
  102903. * Static function used to attach a new empty geometry to a mesh
  102904. * @param mesh defines the mesh to attach the geometry to
  102905. * @returns the new Geometry
  102906. */
  102907. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102908. /** Get the list of meshes using this geometry */
  102909. get meshes(): Mesh[];
  102910. /**
  102911. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  102912. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  102913. */
  102914. useBoundingInfoFromGeometry: boolean;
  102915. /**
  102916. * Creates a new geometry
  102917. * @param id defines the unique ID
  102918. * @param scene defines the hosting scene
  102919. * @param vertexData defines the VertexData used to get geometry data
  102920. * @param updatable defines if geometry must be updatable (false by default)
  102921. * @param mesh defines the mesh that will be associated with the geometry
  102922. */
  102923. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102924. /**
  102925. * Gets the current extend of the geometry
  102926. */
  102927. get extend(): {
  102928. minimum: Vector3;
  102929. maximum: Vector3;
  102930. };
  102931. /**
  102932. * Gets the hosting scene
  102933. * @returns the hosting Scene
  102934. */
  102935. getScene(): Scene;
  102936. /**
  102937. * Gets the hosting engine
  102938. * @returns the hosting Engine
  102939. */
  102940. getEngine(): Engine;
  102941. /**
  102942. * Defines if the geometry is ready to use
  102943. * @returns true if the geometry is ready to be used
  102944. */
  102945. isReady(): boolean;
  102946. /**
  102947. * Gets a value indicating that the geometry should not be serialized
  102948. */
  102949. get doNotSerialize(): boolean;
  102950. /** @hidden */
  102951. _rebuild(): void;
  102952. /**
  102953. * Affects all geometry data in one call
  102954. * @param vertexData defines the geometry data
  102955. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102956. */
  102957. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102958. /**
  102959. * Set specific vertex data
  102960. * @param kind defines the data kind (Position, normal, etc...)
  102961. * @param data defines the vertex data to use
  102962. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102963. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102964. */
  102965. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102966. /**
  102967. * Removes a specific vertex data
  102968. * @param kind defines the data kind (Position, normal, etc...)
  102969. */
  102970. removeVerticesData(kind: string): void;
  102971. /**
  102972. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102973. * @param buffer defines the vertex buffer to use
  102974. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102975. */
  102976. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102977. /**
  102978. * Update a specific vertex buffer
  102979. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102980. * It will do nothing if the buffer is not updatable
  102981. * @param kind defines the data kind (Position, normal, etc...)
  102982. * @param data defines the data to use
  102983. * @param offset defines the offset in the target buffer where to store the data
  102984. * @param useBytes set to true if the offset is in bytes
  102985. */
  102986. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102987. /**
  102988. * Update a specific vertex buffer
  102989. * This function will create a new buffer if the current one is not updatable
  102990. * @param kind defines the data kind (Position, normal, etc...)
  102991. * @param data defines the data to use
  102992. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102993. */
  102994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102995. private _updateBoundingInfo;
  102996. /** @hidden */
  102997. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102998. /**
  102999. * Gets total number of vertices
  103000. * @returns the total number of vertices
  103001. */
  103002. getTotalVertices(): number;
  103003. /**
  103004. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103005. * @param kind defines the data kind (Position, normal, etc...)
  103006. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103007. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103008. * @returns a float array containing vertex data
  103009. */
  103010. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103011. /**
  103012. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103013. * @param kind defines the data kind (Position, normal, etc...)
  103014. * @returns true if the vertex buffer with the specified kind is updatable
  103015. */
  103016. isVertexBufferUpdatable(kind: string): boolean;
  103017. /**
  103018. * Gets a specific vertex buffer
  103019. * @param kind defines the data kind (Position, normal, etc...)
  103020. * @returns a VertexBuffer
  103021. */
  103022. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103023. /**
  103024. * Returns all vertex buffers
  103025. * @return an object holding all vertex buffers indexed by kind
  103026. */
  103027. getVertexBuffers(): Nullable<{
  103028. [key: string]: VertexBuffer;
  103029. }>;
  103030. /**
  103031. * Gets a boolean indicating if specific vertex buffer is present
  103032. * @param kind defines the data kind (Position, normal, etc...)
  103033. * @returns true if data is present
  103034. */
  103035. isVerticesDataPresent(kind: string): boolean;
  103036. /**
  103037. * Gets a list of all attached data kinds (Position, normal, etc...)
  103038. * @returns a list of string containing all kinds
  103039. */
  103040. getVerticesDataKinds(): string[];
  103041. /**
  103042. * Update index buffer
  103043. * @param indices defines the indices to store in the index buffer
  103044. * @param offset defines the offset in the target buffer where to store the data
  103045. * @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)
  103046. */
  103047. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103048. /**
  103049. * Creates a new index buffer
  103050. * @param indices defines the indices to store in the index buffer
  103051. * @param totalVertices defines the total number of vertices (could be null)
  103052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103053. */
  103054. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103055. /**
  103056. * Return the total number of indices
  103057. * @returns the total number of indices
  103058. */
  103059. getTotalIndices(): number;
  103060. /**
  103061. * Gets the index buffer array
  103062. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103063. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103064. * @returns the index buffer array
  103065. */
  103066. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103067. /**
  103068. * Gets the index buffer
  103069. * @return the index buffer
  103070. */
  103071. getIndexBuffer(): Nullable<DataBuffer>;
  103072. /** @hidden */
  103073. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103074. /**
  103075. * Release the associated resources for a specific mesh
  103076. * @param mesh defines the source mesh
  103077. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103078. */
  103079. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103080. /**
  103081. * Apply current geometry to a given mesh
  103082. * @param mesh defines the mesh to apply geometry to
  103083. */
  103084. applyToMesh(mesh: Mesh): void;
  103085. private _updateExtend;
  103086. private _applyToMesh;
  103087. private notifyUpdate;
  103088. /**
  103089. * Load the geometry if it was flagged as delay loaded
  103090. * @param scene defines the hosting scene
  103091. * @param onLoaded defines a callback called when the geometry is loaded
  103092. */
  103093. load(scene: Scene, onLoaded?: () => void): void;
  103094. private _queueLoad;
  103095. /**
  103096. * Invert the geometry to move from a right handed system to a left handed one.
  103097. */
  103098. toLeftHanded(): void;
  103099. /** @hidden */
  103100. _resetPointsArrayCache(): void;
  103101. /** @hidden */
  103102. _generatePointsArray(): boolean;
  103103. /**
  103104. * Gets a value indicating if the geometry is disposed
  103105. * @returns true if the geometry was disposed
  103106. */
  103107. isDisposed(): boolean;
  103108. private _disposeVertexArrayObjects;
  103109. /**
  103110. * Free all associated resources
  103111. */
  103112. dispose(): void;
  103113. /**
  103114. * Clone the current geometry into a new geometry
  103115. * @param id defines the unique ID of the new geometry
  103116. * @returns a new geometry object
  103117. */
  103118. copy(id: string): Geometry;
  103119. /**
  103120. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103121. * @return a JSON representation of the current geometry data (without the vertices data)
  103122. */
  103123. serialize(): any;
  103124. private toNumberArray;
  103125. /**
  103126. * Serialize all vertices data into a JSON oject
  103127. * @returns a JSON representation of the current geometry data
  103128. */
  103129. serializeVerticeData(): any;
  103130. /**
  103131. * Extracts a clone of a mesh geometry
  103132. * @param mesh defines the source mesh
  103133. * @param id defines the unique ID of the new geometry object
  103134. * @returns the new geometry object
  103135. */
  103136. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103137. /**
  103138. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103139. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103140. * Be aware Math.random() could cause collisions, but:
  103141. * "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"
  103142. * @returns a string containing a new GUID
  103143. */
  103144. static RandomId(): string;
  103145. /** @hidden */
  103146. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103147. private static _CleanMatricesWeights;
  103148. /**
  103149. * Create a new geometry from persisted data (Using .babylon file format)
  103150. * @param parsedVertexData defines the persisted data
  103151. * @param scene defines the hosting scene
  103152. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103153. * @returns the new geometry object
  103154. */
  103155. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103156. }
  103157. }
  103158. declare module BABYLON {
  103159. /**
  103160. * Define an interface for all classes that will get and set the data on vertices
  103161. */
  103162. export interface IGetSetVerticesData {
  103163. /**
  103164. * Gets a boolean indicating if specific vertex data is present
  103165. * @param kind defines the vertex data kind to use
  103166. * @returns true is data kind is present
  103167. */
  103168. isVerticesDataPresent(kind: string): boolean;
  103169. /**
  103170. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103171. * @param kind defines the data kind (Position, normal, etc...)
  103172. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103173. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103174. * @returns a float array containing vertex data
  103175. */
  103176. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103177. /**
  103178. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103179. * @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.
  103180. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103181. * @returns the indices array or an empty array if the mesh has no geometry
  103182. */
  103183. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103184. /**
  103185. * Set specific vertex data
  103186. * @param kind defines the data kind (Position, normal, etc...)
  103187. * @param data defines the vertex data to use
  103188. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103189. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103190. */
  103191. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103192. /**
  103193. * Update a specific associated vertex buffer
  103194. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103195. * - VertexBuffer.PositionKind
  103196. * - VertexBuffer.UVKind
  103197. * - VertexBuffer.UV2Kind
  103198. * - VertexBuffer.UV3Kind
  103199. * - VertexBuffer.UV4Kind
  103200. * - VertexBuffer.UV5Kind
  103201. * - VertexBuffer.UV6Kind
  103202. * - VertexBuffer.ColorKind
  103203. * - VertexBuffer.MatricesIndicesKind
  103204. * - VertexBuffer.MatricesIndicesExtraKind
  103205. * - VertexBuffer.MatricesWeightsKind
  103206. * - VertexBuffer.MatricesWeightsExtraKind
  103207. * @param data defines the data source
  103208. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103209. * @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)
  103210. */
  103211. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103212. /**
  103213. * Creates a new index buffer
  103214. * @param indices defines the indices to store in the index buffer
  103215. * @param totalVertices defines the total number of vertices (could be null)
  103216. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103217. */
  103218. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103219. }
  103220. /**
  103221. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103222. */
  103223. export class VertexData {
  103224. /**
  103225. * Mesh side orientation : usually the external or front surface
  103226. */
  103227. static readonly FRONTSIDE: number;
  103228. /**
  103229. * Mesh side orientation : usually the internal or back surface
  103230. */
  103231. static readonly BACKSIDE: number;
  103232. /**
  103233. * Mesh side orientation : both internal and external or front and back surfaces
  103234. */
  103235. static readonly DOUBLESIDE: number;
  103236. /**
  103237. * Mesh side orientation : by default, `FRONTSIDE`
  103238. */
  103239. static readonly DEFAULTSIDE: number;
  103240. /**
  103241. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103242. */
  103243. positions: Nullable<FloatArray>;
  103244. /**
  103245. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103246. */
  103247. normals: Nullable<FloatArray>;
  103248. /**
  103249. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103250. */
  103251. tangents: Nullable<FloatArray>;
  103252. /**
  103253. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103254. */
  103255. uvs: Nullable<FloatArray>;
  103256. /**
  103257. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103258. */
  103259. uvs2: Nullable<FloatArray>;
  103260. /**
  103261. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103262. */
  103263. uvs3: Nullable<FloatArray>;
  103264. /**
  103265. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103266. */
  103267. uvs4: Nullable<FloatArray>;
  103268. /**
  103269. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103270. */
  103271. uvs5: Nullable<FloatArray>;
  103272. /**
  103273. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103274. */
  103275. uvs6: Nullable<FloatArray>;
  103276. /**
  103277. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103278. */
  103279. colors: Nullable<FloatArray>;
  103280. /**
  103281. * 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).
  103282. */
  103283. matricesIndices: Nullable<FloatArray>;
  103284. /**
  103285. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103286. */
  103287. matricesWeights: Nullable<FloatArray>;
  103288. /**
  103289. * An array extending the number of possible indices
  103290. */
  103291. matricesIndicesExtra: Nullable<FloatArray>;
  103292. /**
  103293. * An array extending the number of possible weights when the number of indices is extended
  103294. */
  103295. matricesWeightsExtra: Nullable<FloatArray>;
  103296. /**
  103297. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103298. */
  103299. indices: Nullable<IndicesArray>;
  103300. /**
  103301. * Uses the passed data array to set the set the values for the specified kind of data
  103302. * @param data a linear array of floating numbers
  103303. * @param kind the type of data that is being set, eg positions, colors etc
  103304. */
  103305. set(data: FloatArray, kind: string): void;
  103306. /**
  103307. * Associates the vertexData to the passed Mesh.
  103308. * Sets it as updatable or not (default `false`)
  103309. * @param mesh the mesh the vertexData is applied to
  103310. * @param updatable when used and having the value true allows new data to update the vertexData
  103311. * @returns the VertexData
  103312. */
  103313. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103314. /**
  103315. * Associates the vertexData to the passed Geometry.
  103316. * Sets it as updatable or not (default `false`)
  103317. * @param geometry the geometry the vertexData is applied to
  103318. * @param updatable when used and having the value true allows new data to update the vertexData
  103319. * @returns VertexData
  103320. */
  103321. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103322. /**
  103323. * Updates the associated mesh
  103324. * @param mesh the mesh to be updated
  103325. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103326. * @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
  103327. * @returns VertexData
  103328. */
  103329. updateMesh(mesh: Mesh): VertexData;
  103330. /**
  103331. * Updates the associated geometry
  103332. * @param geometry the geometry to be updated
  103333. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103334. * @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
  103335. * @returns VertexData.
  103336. */
  103337. updateGeometry(geometry: Geometry): VertexData;
  103338. private _applyTo;
  103339. private _update;
  103340. /**
  103341. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103342. * @param matrix the transforming matrix
  103343. * @returns the VertexData
  103344. */
  103345. transform(matrix: Matrix): VertexData;
  103346. /**
  103347. * Merges the passed VertexData into the current one
  103348. * @param other the VertexData to be merged into the current one
  103349. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103350. * @returns the modified VertexData
  103351. */
  103352. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103353. private _mergeElement;
  103354. private _validate;
  103355. /**
  103356. * Serializes the VertexData
  103357. * @returns a serialized object
  103358. */
  103359. serialize(): any;
  103360. /**
  103361. * Extracts the vertexData from a mesh
  103362. * @param mesh the mesh from which to extract the VertexData
  103363. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103364. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103365. * @returns the object VertexData associated to the passed mesh
  103366. */
  103367. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103368. /**
  103369. * Extracts the vertexData from the geometry
  103370. * @param geometry the geometry from which to extract the VertexData
  103371. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103372. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103373. * @returns the object VertexData associated to the passed mesh
  103374. */
  103375. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103376. private static _ExtractFrom;
  103377. /**
  103378. * Creates the VertexData for a Ribbon
  103379. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103380. * * pathArray array of paths, each of which an array of successive Vector3
  103381. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103382. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103383. * * 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
  103384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103385. * * 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)
  103386. * * 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)
  103387. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103388. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103389. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103390. * @returns the VertexData of the ribbon
  103391. */
  103392. static CreateRibbon(options: {
  103393. pathArray: Vector3[][];
  103394. closeArray?: boolean;
  103395. closePath?: boolean;
  103396. offset?: number;
  103397. sideOrientation?: number;
  103398. frontUVs?: Vector4;
  103399. backUVs?: Vector4;
  103400. invertUV?: boolean;
  103401. uvs?: Vector2[];
  103402. colors?: Color4[];
  103403. }): VertexData;
  103404. /**
  103405. * Creates the VertexData for a box
  103406. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103407. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103408. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103409. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103410. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103411. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103412. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103414. * * 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)
  103415. * * 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)
  103416. * @returns the VertexData of the box
  103417. */
  103418. static CreateBox(options: {
  103419. size?: number;
  103420. width?: number;
  103421. height?: number;
  103422. depth?: number;
  103423. faceUV?: Vector4[];
  103424. faceColors?: Color4[];
  103425. sideOrientation?: number;
  103426. frontUVs?: Vector4;
  103427. backUVs?: Vector4;
  103428. }): VertexData;
  103429. /**
  103430. * Creates the VertexData for a tiled box
  103431. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103432. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103433. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103434. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103436. * @returns the VertexData of the box
  103437. */
  103438. static CreateTiledBox(options: {
  103439. pattern?: number;
  103440. width?: number;
  103441. height?: number;
  103442. depth?: number;
  103443. tileSize?: number;
  103444. tileWidth?: number;
  103445. tileHeight?: number;
  103446. alignHorizontal?: number;
  103447. alignVertical?: number;
  103448. faceUV?: Vector4[];
  103449. faceColors?: Color4[];
  103450. sideOrientation?: number;
  103451. }): VertexData;
  103452. /**
  103453. * Creates the VertexData for a tiled plane
  103454. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103455. * * pattern a limited pattern arrangement depending on the number
  103456. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103457. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103458. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103460. * * 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)
  103461. * * 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)
  103462. * @returns the VertexData of the tiled plane
  103463. */
  103464. static CreateTiledPlane(options: {
  103465. pattern?: number;
  103466. tileSize?: number;
  103467. tileWidth?: number;
  103468. tileHeight?: number;
  103469. size?: number;
  103470. width?: number;
  103471. height?: number;
  103472. alignHorizontal?: number;
  103473. alignVertical?: number;
  103474. sideOrientation?: number;
  103475. frontUVs?: Vector4;
  103476. backUVs?: Vector4;
  103477. }): VertexData;
  103478. /**
  103479. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103480. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103481. * * segments sets the number of horizontal strips optional, default 32
  103482. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103483. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103484. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103485. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103486. * * 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
  103487. * * 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
  103488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103489. * * 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)
  103490. * * 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)
  103491. * @returns the VertexData of the ellipsoid
  103492. */
  103493. static CreateSphere(options: {
  103494. segments?: number;
  103495. diameter?: number;
  103496. diameterX?: number;
  103497. diameterY?: number;
  103498. diameterZ?: number;
  103499. arc?: number;
  103500. slice?: number;
  103501. sideOrientation?: number;
  103502. frontUVs?: Vector4;
  103503. backUVs?: Vector4;
  103504. }): VertexData;
  103505. /**
  103506. * Creates the VertexData for a cylinder, cone or prism
  103507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103508. * * height sets the height (y direction) of the cylinder, optional, default 2
  103509. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103510. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103511. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103512. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103513. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103514. * * 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
  103515. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103516. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103517. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103518. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103520. * * 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)
  103521. * * 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)
  103522. * @returns the VertexData of the cylinder, cone or prism
  103523. */
  103524. static CreateCylinder(options: {
  103525. height?: number;
  103526. diameterTop?: number;
  103527. diameterBottom?: number;
  103528. diameter?: number;
  103529. tessellation?: number;
  103530. subdivisions?: number;
  103531. arc?: number;
  103532. faceColors?: Color4[];
  103533. faceUV?: Vector4[];
  103534. hasRings?: boolean;
  103535. enclose?: boolean;
  103536. sideOrientation?: number;
  103537. frontUVs?: Vector4;
  103538. backUVs?: Vector4;
  103539. }): VertexData;
  103540. /**
  103541. * Creates the VertexData for a torus
  103542. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103543. * * diameter the diameter of the torus, optional default 1
  103544. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103545. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103547. * * 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)
  103548. * * 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)
  103549. * @returns the VertexData of the torus
  103550. */
  103551. static CreateTorus(options: {
  103552. diameter?: number;
  103553. thickness?: number;
  103554. tessellation?: number;
  103555. sideOrientation?: number;
  103556. frontUVs?: Vector4;
  103557. backUVs?: Vector4;
  103558. }): VertexData;
  103559. /**
  103560. * Creates the VertexData of the LineSystem
  103561. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103562. * - lines an array of lines, each line being an array of successive Vector3
  103563. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103564. * @returns the VertexData of the LineSystem
  103565. */
  103566. static CreateLineSystem(options: {
  103567. lines: Vector3[][];
  103568. colors?: Nullable<Color4[][]>;
  103569. }): VertexData;
  103570. /**
  103571. * Create the VertexData for a DashedLines
  103572. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103573. * - points an array successive Vector3
  103574. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103575. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103576. * - dashNb the intended total number of dashes, optional, default 200
  103577. * @returns the VertexData for the DashedLines
  103578. */
  103579. static CreateDashedLines(options: {
  103580. points: Vector3[];
  103581. dashSize?: number;
  103582. gapSize?: number;
  103583. dashNb?: number;
  103584. }): VertexData;
  103585. /**
  103586. * Creates the VertexData for a Ground
  103587. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103588. * - width the width (x direction) of the ground, optional, default 1
  103589. * - height the height (z direction) of the ground, optional, default 1
  103590. * - subdivisions the number of subdivisions per side, optional, default 1
  103591. * @returns the VertexData of the Ground
  103592. */
  103593. static CreateGround(options: {
  103594. width?: number;
  103595. height?: number;
  103596. subdivisions?: number;
  103597. subdivisionsX?: number;
  103598. subdivisionsY?: number;
  103599. }): VertexData;
  103600. /**
  103601. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103602. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103603. * * xmin the ground minimum X coordinate, optional, default -1
  103604. * * zmin the ground minimum Z coordinate, optional, default -1
  103605. * * xmax the ground maximum X coordinate, optional, default 1
  103606. * * zmax the ground maximum Z coordinate, optional, default 1
  103607. * * 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}
  103608. * * 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}
  103609. * @returns the VertexData of the TiledGround
  103610. */
  103611. static CreateTiledGround(options: {
  103612. xmin: number;
  103613. zmin: number;
  103614. xmax: number;
  103615. zmax: number;
  103616. subdivisions?: {
  103617. w: number;
  103618. h: number;
  103619. };
  103620. precision?: {
  103621. w: number;
  103622. h: number;
  103623. };
  103624. }): VertexData;
  103625. /**
  103626. * Creates the VertexData of the Ground designed from a heightmap
  103627. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103628. * * width the width (x direction) of the ground
  103629. * * height the height (z direction) of the ground
  103630. * * subdivisions the number of subdivisions per side
  103631. * * minHeight the minimum altitude on the ground, optional, default 0
  103632. * * maxHeight the maximum altitude on the ground, optional default 1
  103633. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103634. * * buffer the array holding the image color data
  103635. * * bufferWidth the width of image
  103636. * * bufferHeight the height of image
  103637. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103638. * @returns the VertexData of the Ground designed from a heightmap
  103639. */
  103640. static CreateGroundFromHeightMap(options: {
  103641. width: number;
  103642. height: number;
  103643. subdivisions: number;
  103644. minHeight: number;
  103645. maxHeight: number;
  103646. colorFilter: Color3;
  103647. buffer: Uint8Array;
  103648. bufferWidth: number;
  103649. bufferHeight: number;
  103650. alphaFilter: number;
  103651. }): VertexData;
  103652. /**
  103653. * Creates the VertexData for a Plane
  103654. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103655. * * size sets the width and height of the plane to the value of size, optional default 1
  103656. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103657. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103659. * * 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)
  103660. * * 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)
  103661. * @returns the VertexData of the box
  103662. */
  103663. static CreatePlane(options: {
  103664. size?: number;
  103665. width?: number;
  103666. height?: number;
  103667. sideOrientation?: number;
  103668. frontUVs?: Vector4;
  103669. backUVs?: Vector4;
  103670. }): VertexData;
  103671. /**
  103672. * Creates the VertexData of the Disc or regular Polygon
  103673. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103674. * * radius the radius of the disc, optional default 0.5
  103675. * * tessellation the number of polygon sides, optional, default 64
  103676. * * 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
  103677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103678. * * 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)
  103679. * * 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)
  103680. * @returns the VertexData of the box
  103681. */
  103682. static CreateDisc(options: {
  103683. radius?: number;
  103684. tessellation?: number;
  103685. arc?: number;
  103686. sideOrientation?: number;
  103687. frontUVs?: Vector4;
  103688. backUVs?: Vector4;
  103689. }): VertexData;
  103690. /**
  103691. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103692. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103693. * @param polygon a mesh built from polygonTriangulation.build()
  103694. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103695. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103696. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103697. * @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)
  103698. * @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)
  103699. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103700. * @returns the VertexData of the Polygon
  103701. */
  103702. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103703. /**
  103704. * Creates the VertexData of the IcoSphere
  103705. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103706. * * radius the radius of the IcoSphere, optional default 1
  103707. * * radiusX allows stretching in the x direction, optional, default radius
  103708. * * radiusY allows stretching in the y direction, optional, default radius
  103709. * * radiusZ allows stretching in the z direction, optional, default radius
  103710. * * flat when true creates a flat shaded mesh, optional, default true
  103711. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103713. * * 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)
  103714. * * 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)
  103715. * @returns the VertexData of the IcoSphere
  103716. */
  103717. static CreateIcoSphere(options: {
  103718. radius?: number;
  103719. radiusX?: number;
  103720. radiusY?: number;
  103721. radiusZ?: number;
  103722. flat?: boolean;
  103723. subdivisions?: number;
  103724. sideOrientation?: number;
  103725. frontUVs?: Vector4;
  103726. backUVs?: Vector4;
  103727. }): VertexData;
  103728. /**
  103729. * Creates the VertexData for a Polyhedron
  103730. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103731. * * type provided types are:
  103732. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103733. * * 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)
  103734. * * size the size of the IcoSphere, optional default 1
  103735. * * sizeX allows stretching in the x direction, optional, default size
  103736. * * sizeY allows stretching in the y direction, optional, default size
  103737. * * sizeZ allows stretching in the z direction, optional, default size
  103738. * * 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
  103739. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103740. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103741. * * flat when true creates a flat shaded mesh, optional, default true
  103742. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103744. * * 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)
  103745. * * 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)
  103746. * @returns the VertexData of the Polyhedron
  103747. */
  103748. static CreatePolyhedron(options: {
  103749. type?: number;
  103750. size?: number;
  103751. sizeX?: number;
  103752. sizeY?: number;
  103753. sizeZ?: number;
  103754. custom?: any;
  103755. faceUV?: Vector4[];
  103756. faceColors?: Color4[];
  103757. flat?: boolean;
  103758. sideOrientation?: number;
  103759. frontUVs?: Vector4;
  103760. backUVs?: Vector4;
  103761. }): VertexData;
  103762. /**
  103763. * Creates the VertexData for a TorusKnot
  103764. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103765. * * radius the radius of the torus knot, optional, default 2
  103766. * * tube the thickness of the tube, optional, default 0.5
  103767. * * radialSegments the number of sides on each tube segments, optional, default 32
  103768. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103769. * * p the number of windings around the z axis, optional, default 2
  103770. * * q the number of windings around the x axis, optional, default 3
  103771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103772. * * 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)
  103773. * * 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)
  103774. * @returns the VertexData of the Torus Knot
  103775. */
  103776. static CreateTorusKnot(options: {
  103777. radius?: number;
  103778. tube?: number;
  103779. radialSegments?: number;
  103780. tubularSegments?: number;
  103781. p?: number;
  103782. q?: number;
  103783. sideOrientation?: number;
  103784. frontUVs?: Vector4;
  103785. backUVs?: Vector4;
  103786. }): VertexData;
  103787. /**
  103788. * Compute normals for given positions and indices
  103789. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103790. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103791. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103792. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103793. * * facetNormals : optional array of facet normals (vector3)
  103794. * * facetPositions : optional array of facet positions (vector3)
  103795. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103796. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103797. * * bInfo : optional bounding info, required for facetPartitioning computation
  103798. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103799. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103800. * * useRightHandedSystem: optional boolean to for right handed system computation
  103801. * * depthSort : optional boolean to enable the facet depth sort computation
  103802. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103803. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103804. */
  103805. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103806. facetNormals?: any;
  103807. facetPositions?: any;
  103808. facetPartitioning?: any;
  103809. ratio?: number;
  103810. bInfo?: any;
  103811. bbSize?: Vector3;
  103812. subDiv?: any;
  103813. useRightHandedSystem?: boolean;
  103814. depthSort?: boolean;
  103815. distanceTo?: Vector3;
  103816. depthSortedFacets?: any;
  103817. }): void;
  103818. /** @hidden */
  103819. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103820. /**
  103821. * Applies VertexData created from the imported parameters to the geometry
  103822. * @param parsedVertexData the parsed data from an imported file
  103823. * @param geometry the geometry to apply the VertexData to
  103824. */
  103825. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103826. }
  103827. }
  103828. declare module BABYLON {
  103829. /**
  103830. * Defines a target to use with MorphTargetManager
  103831. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103832. */
  103833. export class MorphTarget implements IAnimatable {
  103834. /** defines the name of the target */
  103835. name: string;
  103836. /**
  103837. * Gets or sets the list of animations
  103838. */
  103839. animations: Animation[];
  103840. private _scene;
  103841. private _positions;
  103842. private _normals;
  103843. private _tangents;
  103844. private _uvs;
  103845. private _influence;
  103846. private _uniqueId;
  103847. /**
  103848. * Observable raised when the influence changes
  103849. */
  103850. onInfluenceChanged: Observable<boolean>;
  103851. /** @hidden */
  103852. _onDataLayoutChanged: Observable<void>;
  103853. /**
  103854. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103855. */
  103856. get influence(): number;
  103857. set influence(influence: number);
  103858. /**
  103859. * Gets or sets the id of the morph Target
  103860. */
  103861. id: string;
  103862. private _animationPropertiesOverride;
  103863. /**
  103864. * Gets or sets the animation properties override
  103865. */
  103866. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103867. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103868. /**
  103869. * Creates a new MorphTarget
  103870. * @param name defines the name of the target
  103871. * @param influence defines the influence to use
  103872. * @param scene defines the scene the morphtarget belongs to
  103873. */
  103874. constructor(
  103875. /** defines the name of the target */
  103876. name: string, influence?: number, scene?: Nullable<Scene>);
  103877. /**
  103878. * Gets the unique ID of this manager
  103879. */
  103880. get uniqueId(): number;
  103881. /**
  103882. * Gets a boolean defining if the target contains position data
  103883. */
  103884. get hasPositions(): boolean;
  103885. /**
  103886. * Gets a boolean defining if the target contains normal data
  103887. */
  103888. get hasNormals(): boolean;
  103889. /**
  103890. * Gets a boolean defining if the target contains tangent data
  103891. */
  103892. get hasTangents(): boolean;
  103893. /**
  103894. * Gets a boolean defining if the target contains texture coordinates data
  103895. */
  103896. get hasUVs(): boolean;
  103897. /**
  103898. * Affects position data to this target
  103899. * @param data defines the position data to use
  103900. */
  103901. setPositions(data: Nullable<FloatArray>): void;
  103902. /**
  103903. * Gets the position data stored in this target
  103904. * @returns a FloatArray containing the position data (or null if not present)
  103905. */
  103906. getPositions(): Nullable<FloatArray>;
  103907. /**
  103908. * Affects normal data to this target
  103909. * @param data defines the normal data to use
  103910. */
  103911. setNormals(data: Nullable<FloatArray>): void;
  103912. /**
  103913. * Gets the normal data stored in this target
  103914. * @returns a FloatArray containing the normal data (or null if not present)
  103915. */
  103916. getNormals(): Nullable<FloatArray>;
  103917. /**
  103918. * Affects tangent data to this target
  103919. * @param data defines the tangent data to use
  103920. */
  103921. setTangents(data: Nullable<FloatArray>): void;
  103922. /**
  103923. * Gets the tangent data stored in this target
  103924. * @returns a FloatArray containing the tangent data (or null if not present)
  103925. */
  103926. getTangents(): Nullable<FloatArray>;
  103927. /**
  103928. * Affects texture coordinates data to this target
  103929. * @param data defines the texture coordinates data to use
  103930. */
  103931. setUVs(data: Nullable<FloatArray>): void;
  103932. /**
  103933. * Gets the texture coordinates data stored in this target
  103934. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103935. */
  103936. getUVs(): Nullable<FloatArray>;
  103937. /**
  103938. * Clone the current target
  103939. * @returns a new MorphTarget
  103940. */
  103941. clone(): MorphTarget;
  103942. /**
  103943. * Serializes the current target into a Serialization object
  103944. * @returns the serialized object
  103945. */
  103946. serialize(): any;
  103947. /**
  103948. * Returns the string "MorphTarget"
  103949. * @returns "MorphTarget"
  103950. */
  103951. getClassName(): string;
  103952. /**
  103953. * Creates a new target from serialized data
  103954. * @param serializationObject defines the serialized data to use
  103955. * @returns a new MorphTarget
  103956. */
  103957. static Parse(serializationObject: any): MorphTarget;
  103958. /**
  103959. * Creates a MorphTarget from mesh data
  103960. * @param mesh defines the source mesh
  103961. * @param name defines the name to use for the new target
  103962. * @param influence defines the influence to attach to the target
  103963. * @returns a new MorphTarget
  103964. */
  103965. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103966. }
  103967. }
  103968. declare module BABYLON {
  103969. /**
  103970. * This class is used to deform meshes using morphing between different targets
  103971. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103972. */
  103973. export class MorphTargetManager {
  103974. private _targets;
  103975. private _targetInfluenceChangedObservers;
  103976. private _targetDataLayoutChangedObservers;
  103977. private _activeTargets;
  103978. private _scene;
  103979. private _influences;
  103980. private _supportsNormals;
  103981. private _supportsTangents;
  103982. private _supportsUVs;
  103983. private _vertexCount;
  103984. private _uniqueId;
  103985. private _tempInfluences;
  103986. /**
  103987. * Gets or sets a boolean indicating if normals must be morphed
  103988. */
  103989. enableNormalMorphing: boolean;
  103990. /**
  103991. * Gets or sets a boolean indicating if tangents must be morphed
  103992. */
  103993. enableTangentMorphing: boolean;
  103994. /**
  103995. * Gets or sets a boolean indicating if UV must be morphed
  103996. */
  103997. enableUVMorphing: boolean;
  103998. /**
  103999. * Creates a new MorphTargetManager
  104000. * @param scene defines the current scene
  104001. */
  104002. constructor(scene?: Nullable<Scene>);
  104003. /**
  104004. * Gets the unique ID of this manager
  104005. */
  104006. get uniqueId(): number;
  104007. /**
  104008. * Gets the number of vertices handled by this manager
  104009. */
  104010. get vertexCount(): number;
  104011. /**
  104012. * Gets a boolean indicating if this manager supports morphing of normals
  104013. */
  104014. get supportsNormals(): boolean;
  104015. /**
  104016. * Gets a boolean indicating if this manager supports morphing of tangents
  104017. */
  104018. get supportsTangents(): boolean;
  104019. /**
  104020. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104021. */
  104022. get supportsUVs(): boolean;
  104023. /**
  104024. * Gets the number of targets stored in this manager
  104025. */
  104026. get numTargets(): number;
  104027. /**
  104028. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104029. */
  104030. get numInfluencers(): number;
  104031. /**
  104032. * Gets the list of influences (one per target)
  104033. */
  104034. get influences(): Float32Array;
  104035. /**
  104036. * Gets the active target at specified index. An active target is a target with an influence > 0
  104037. * @param index defines the index to check
  104038. * @returns the requested target
  104039. */
  104040. getActiveTarget(index: number): MorphTarget;
  104041. /**
  104042. * Gets the target at specified index
  104043. * @param index defines the index to check
  104044. * @returns the requested target
  104045. */
  104046. getTarget(index: number): MorphTarget;
  104047. /**
  104048. * Add a new target to this manager
  104049. * @param target defines the target to add
  104050. */
  104051. addTarget(target: MorphTarget): void;
  104052. /**
  104053. * Removes a target from the manager
  104054. * @param target defines the target to remove
  104055. */
  104056. removeTarget(target: MorphTarget): void;
  104057. /**
  104058. * Clone the current manager
  104059. * @returns a new MorphTargetManager
  104060. */
  104061. clone(): MorphTargetManager;
  104062. /**
  104063. * Serializes the current manager into a Serialization object
  104064. * @returns the serialized object
  104065. */
  104066. serialize(): any;
  104067. private _syncActiveTargets;
  104068. /**
  104069. * Syncrhonize the targets with all the meshes using this morph target manager
  104070. */
  104071. synchronize(): void;
  104072. /**
  104073. * Creates a new MorphTargetManager from serialized data
  104074. * @param serializationObject defines the serialized data
  104075. * @param scene defines the hosting scene
  104076. * @returns the new MorphTargetManager
  104077. */
  104078. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104079. }
  104080. }
  104081. declare module BABYLON {
  104082. /**
  104083. * Class used to represent a specific level of detail of a mesh
  104084. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104085. */
  104086. export class MeshLODLevel {
  104087. /** Defines the distance where this level should start being displayed */
  104088. distance: number;
  104089. /** Defines the mesh to use to render this level */
  104090. mesh: Nullable<Mesh>;
  104091. /**
  104092. * Creates a new LOD level
  104093. * @param distance defines the distance where this level should star being displayed
  104094. * @param mesh defines the mesh to use to render this level
  104095. */
  104096. constructor(
  104097. /** Defines the distance where this level should start being displayed */
  104098. distance: number,
  104099. /** Defines the mesh to use to render this level */
  104100. mesh: Nullable<Mesh>);
  104101. }
  104102. }
  104103. declare module BABYLON {
  104104. /**
  104105. * Helper class used to generate a canvas to manipulate images
  104106. */
  104107. export class CanvasGenerator {
  104108. /**
  104109. * Create a new canvas (or offscreen canvas depending on the context)
  104110. * @param width defines the expected width
  104111. * @param height defines the expected height
  104112. * @return a new canvas or offscreen canvas
  104113. */
  104114. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104115. }
  104116. }
  104117. declare module BABYLON {
  104118. /**
  104119. * Mesh representing the gorund
  104120. */
  104121. export class GroundMesh extends Mesh {
  104122. /** If octree should be generated */
  104123. generateOctree: boolean;
  104124. private _heightQuads;
  104125. /** @hidden */
  104126. _subdivisionsX: number;
  104127. /** @hidden */
  104128. _subdivisionsY: number;
  104129. /** @hidden */
  104130. _width: number;
  104131. /** @hidden */
  104132. _height: number;
  104133. /** @hidden */
  104134. _minX: number;
  104135. /** @hidden */
  104136. _maxX: number;
  104137. /** @hidden */
  104138. _minZ: number;
  104139. /** @hidden */
  104140. _maxZ: number;
  104141. constructor(name: string, scene: Scene);
  104142. /**
  104143. * "GroundMesh"
  104144. * @returns "GroundMesh"
  104145. */
  104146. getClassName(): string;
  104147. /**
  104148. * The minimum of x and y subdivisions
  104149. */
  104150. get subdivisions(): number;
  104151. /**
  104152. * X subdivisions
  104153. */
  104154. get subdivisionsX(): number;
  104155. /**
  104156. * Y subdivisions
  104157. */
  104158. get subdivisionsY(): number;
  104159. /**
  104160. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104161. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104162. * @param chunksCount the number of subdivisions for x and y
  104163. * @param octreeBlocksSize (Default: 32)
  104164. */
  104165. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104166. /**
  104167. * Returns a height (y) value in the Worl system :
  104168. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104169. * @param x x coordinate
  104170. * @param z z coordinate
  104171. * @returns the ground y position if (x, z) are outside the ground surface.
  104172. */
  104173. getHeightAtCoordinates(x: number, z: number): number;
  104174. /**
  104175. * Returns a normalized vector (Vector3) orthogonal to the ground
  104176. * at the ground coordinates (x, z) expressed in the World system.
  104177. * @param x x coordinate
  104178. * @param z z coordinate
  104179. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104180. */
  104181. getNormalAtCoordinates(x: number, z: number): Vector3;
  104182. /**
  104183. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104184. * at the ground coordinates (x, z) expressed in the World system.
  104185. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104186. * @param x x coordinate
  104187. * @param z z coordinate
  104188. * @param ref vector to store the result
  104189. * @returns the GroundMesh.
  104190. */
  104191. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104192. /**
  104193. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104194. * if the ground has been updated.
  104195. * This can be used in the render loop.
  104196. * @returns the GroundMesh.
  104197. */
  104198. updateCoordinateHeights(): GroundMesh;
  104199. private _getFacetAt;
  104200. private _initHeightQuads;
  104201. private _computeHeightQuads;
  104202. /**
  104203. * Serializes this ground mesh
  104204. * @param serializationObject object to write serialization to
  104205. */
  104206. serialize(serializationObject: any): void;
  104207. /**
  104208. * Parses a serialized ground mesh
  104209. * @param parsedMesh the serialized mesh
  104210. * @param scene the scene to create the ground mesh in
  104211. * @returns the created ground mesh
  104212. */
  104213. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104214. }
  104215. }
  104216. declare module BABYLON {
  104217. /**
  104218. * Interface for Physics-Joint data
  104219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104220. */
  104221. export interface PhysicsJointData {
  104222. /**
  104223. * The main pivot of the joint
  104224. */
  104225. mainPivot?: Vector3;
  104226. /**
  104227. * The connected pivot of the joint
  104228. */
  104229. connectedPivot?: Vector3;
  104230. /**
  104231. * The main axis of the joint
  104232. */
  104233. mainAxis?: Vector3;
  104234. /**
  104235. * The connected axis of the joint
  104236. */
  104237. connectedAxis?: Vector3;
  104238. /**
  104239. * The collision of the joint
  104240. */
  104241. collision?: boolean;
  104242. /**
  104243. * Native Oimo/Cannon/Energy data
  104244. */
  104245. nativeParams?: any;
  104246. }
  104247. /**
  104248. * This is a holder class for the physics joint created by the physics plugin
  104249. * It holds a set of functions to control the underlying joint
  104250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104251. */
  104252. export class PhysicsJoint {
  104253. /**
  104254. * The type of the physics joint
  104255. */
  104256. type: number;
  104257. /**
  104258. * The data for the physics joint
  104259. */
  104260. jointData: PhysicsJointData;
  104261. private _physicsJoint;
  104262. protected _physicsPlugin: IPhysicsEnginePlugin;
  104263. /**
  104264. * Initializes the physics joint
  104265. * @param type The type of the physics joint
  104266. * @param jointData The data for the physics joint
  104267. */
  104268. constructor(
  104269. /**
  104270. * The type of the physics joint
  104271. */
  104272. type: number,
  104273. /**
  104274. * The data for the physics joint
  104275. */
  104276. jointData: PhysicsJointData);
  104277. /**
  104278. * Gets the physics joint
  104279. */
  104280. get physicsJoint(): any;
  104281. /**
  104282. * Sets the physics joint
  104283. */
  104284. set physicsJoint(newJoint: any);
  104285. /**
  104286. * Sets the physics plugin
  104287. */
  104288. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104289. /**
  104290. * Execute a function that is physics-plugin specific.
  104291. * @param {Function} func the function that will be executed.
  104292. * It accepts two parameters: the physics world and the physics joint
  104293. */
  104294. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104295. /**
  104296. * Distance-Joint type
  104297. */
  104298. static DistanceJoint: number;
  104299. /**
  104300. * Hinge-Joint type
  104301. */
  104302. static HingeJoint: number;
  104303. /**
  104304. * Ball-and-Socket joint type
  104305. */
  104306. static BallAndSocketJoint: number;
  104307. /**
  104308. * Wheel-Joint type
  104309. */
  104310. static WheelJoint: number;
  104311. /**
  104312. * Slider-Joint type
  104313. */
  104314. static SliderJoint: number;
  104315. /**
  104316. * Prismatic-Joint type
  104317. */
  104318. static PrismaticJoint: number;
  104319. /**
  104320. * Universal-Joint type
  104321. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104322. */
  104323. static UniversalJoint: number;
  104324. /**
  104325. * Hinge-Joint 2 type
  104326. */
  104327. static Hinge2Joint: number;
  104328. /**
  104329. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104330. */
  104331. static PointToPointJoint: number;
  104332. /**
  104333. * Spring-Joint type
  104334. */
  104335. static SpringJoint: number;
  104336. /**
  104337. * Lock-Joint type
  104338. */
  104339. static LockJoint: number;
  104340. }
  104341. /**
  104342. * A class representing a physics distance joint
  104343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104344. */
  104345. export class DistanceJoint extends PhysicsJoint {
  104346. /**
  104347. *
  104348. * @param jointData The data for the Distance-Joint
  104349. */
  104350. constructor(jointData: DistanceJointData);
  104351. /**
  104352. * Update the predefined distance.
  104353. * @param maxDistance The maximum preferred distance
  104354. * @param minDistance The minimum preferred distance
  104355. */
  104356. updateDistance(maxDistance: number, minDistance?: number): void;
  104357. }
  104358. /**
  104359. * Represents a Motor-Enabled Joint
  104360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104361. */
  104362. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104363. /**
  104364. * Initializes the Motor-Enabled Joint
  104365. * @param type The type of the joint
  104366. * @param jointData The physica joint data for the joint
  104367. */
  104368. constructor(type: number, jointData: PhysicsJointData);
  104369. /**
  104370. * Set the motor values.
  104371. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104372. * @param force the force to apply
  104373. * @param maxForce max force for this motor.
  104374. */
  104375. setMotor(force?: number, maxForce?: number): void;
  104376. /**
  104377. * Set the motor's limits.
  104378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104379. * @param upperLimit The upper limit of the motor
  104380. * @param lowerLimit The lower limit of the motor
  104381. */
  104382. setLimit(upperLimit: number, lowerLimit?: number): void;
  104383. }
  104384. /**
  104385. * This class represents a single physics Hinge-Joint
  104386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104387. */
  104388. export class HingeJoint extends MotorEnabledJoint {
  104389. /**
  104390. * Initializes the Hinge-Joint
  104391. * @param jointData The joint data for the Hinge-Joint
  104392. */
  104393. constructor(jointData: PhysicsJointData);
  104394. /**
  104395. * Set the motor values.
  104396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104397. * @param {number} force the force to apply
  104398. * @param {number} maxForce max force for this motor.
  104399. */
  104400. setMotor(force?: number, maxForce?: number): void;
  104401. /**
  104402. * Set the motor's limits.
  104403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104404. * @param upperLimit The upper limit of the motor
  104405. * @param lowerLimit The lower limit of the motor
  104406. */
  104407. setLimit(upperLimit: number, lowerLimit?: number): void;
  104408. }
  104409. /**
  104410. * This class represents a dual hinge physics joint (same as wheel joint)
  104411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104412. */
  104413. export class Hinge2Joint extends MotorEnabledJoint {
  104414. /**
  104415. * Initializes the Hinge2-Joint
  104416. * @param jointData The joint data for the Hinge2-Joint
  104417. */
  104418. constructor(jointData: PhysicsJointData);
  104419. /**
  104420. * Set the motor values.
  104421. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104422. * @param {number} targetSpeed the speed the motor is to reach
  104423. * @param {number} maxForce max force for this motor.
  104424. * @param {motorIndex} the motor's index, 0 or 1.
  104425. */
  104426. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104427. /**
  104428. * Set the motor limits.
  104429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104430. * @param {number} upperLimit the upper limit
  104431. * @param {number} lowerLimit lower limit
  104432. * @param {motorIndex} the motor's index, 0 or 1.
  104433. */
  104434. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104435. }
  104436. /**
  104437. * Interface for a motor enabled joint
  104438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104439. */
  104440. export interface IMotorEnabledJoint {
  104441. /**
  104442. * Physics joint
  104443. */
  104444. physicsJoint: any;
  104445. /**
  104446. * Sets the motor of the motor-enabled joint
  104447. * @param force The force of the motor
  104448. * @param maxForce The maximum force of the motor
  104449. * @param motorIndex The index of the motor
  104450. */
  104451. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104452. /**
  104453. * Sets the limit of the motor
  104454. * @param upperLimit The upper limit of the motor
  104455. * @param lowerLimit The lower limit of the motor
  104456. * @param motorIndex The index of the motor
  104457. */
  104458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104459. }
  104460. /**
  104461. * Joint data for a Distance-Joint
  104462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104463. */
  104464. export interface DistanceJointData extends PhysicsJointData {
  104465. /**
  104466. * Max distance the 2 joint objects can be apart
  104467. */
  104468. maxDistance: number;
  104469. }
  104470. /**
  104471. * Joint data from a spring joint
  104472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104473. */
  104474. export interface SpringJointData extends PhysicsJointData {
  104475. /**
  104476. * Length of the spring
  104477. */
  104478. length: number;
  104479. /**
  104480. * Stiffness of the spring
  104481. */
  104482. stiffness: number;
  104483. /**
  104484. * Damping of the spring
  104485. */
  104486. damping: number;
  104487. /** this callback will be called when applying the force to the impostors. */
  104488. forceApplicationCallback: () => void;
  104489. }
  104490. }
  104491. declare module BABYLON {
  104492. /**
  104493. * Holds the data for the raycast result
  104494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104495. */
  104496. export class PhysicsRaycastResult {
  104497. private _hasHit;
  104498. private _hitDistance;
  104499. private _hitNormalWorld;
  104500. private _hitPointWorld;
  104501. private _rayFromWorld;
  104502. private _rayToWorld;
  104503. /**
  104504. * Gets if there was a hit
  104505. */
  104506. get hasHit(): boolean;
  104507. /**
  104508. * Gets the distance from the hit
  104509. */
  104510. get hitDistance(): number;
  104511. /**
  104512. * Gets the hit normal/direction in the world
  104513. */
  104514. get hitNormalWorld(): Vector3;
  104515. /**
  104516. * Gets the hit point in the world
  104517. */
  104518. get hitPointWorld(): Vector3;
  104519. /**
  104520. * Gets the ray "start point" of the ray in the world
  104521. */
  104522. get rayFromWorld(): Vector3;
  104523. /**
  104524. * Gets the ray "end point" of the ray in the world
  104525. */
  104526. get rayToWorld(): Vector3;
  104527. /**
  104528. * Sets the hit data (normal & point in world space)
  104529. * @param hitNormalWorld defines the normal in world space
  104530. * @param hitPointWorld defines the point in world space
  104531. */
  104532. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104533. /**
  104534. * Sets the distance from the start point to the hit point
  104535. * @param distance
  104536. */
  104537. setHitDistance(distance: number): void;
  104538. /**
  104539. * Calculates the distance manually
  104540. */
  104541. calculateHitDistance(): void;
  104542. /**
  104543. * Resets all the values to default
  104544. * @param from The from point on world space
  104545. * @param to The to point on world space
  104546. */
  104547. reset(from?: Vector3, to?: Vector3): void;
  104548. }
  104549. /**
  104550. * Interface for the size containing width and height
  104551. */
  104552. interface IXYZ {
  104553. /**
  104554. * X
  104555. */
  104556. x: number;
  104557. /**
  104558. * Y
  104559. */
  104560. y: number;
  104561. /**
  104562. * Z
  104563. */
  104564. z: number;
  104565. }
  104566. }
  104567. declare module BABYLON {
  104568. /**
  104569. * Interface used to describe a physics joint
  104570. */
  104571. export interface PhysicsImpostorJoint {
  104572. /** Defines the main impostor to which the joint is linked */
  104573. mainImpostor: PhysicsImpostor;
  104574. /** Defines the impostor that is connected to the main impostor using this joint */
  104575. connectedImpostor: PhysicsImpostor;
  104576. /** Defines the joint itself */
  104577. joint: PhysicsJoint;
  104578. }
  104579. /** @hidden */
  104580. export interface IPhysicsEnginePlugin {
  104581. world: any;
  104582. name: string;
  104583. setGravity(gravity: Vector3): void;
  104584. setTimeStep(timeStep: number): void;
  104585. getTimeStep(): number;
  104586. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104588. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104589. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104590. removePhysicsBody(impostor: PhysicsImpostor): void;
  104591. generateJoint(joint: PhysicsImpostorJoint): void;
  104592. removeJoint(joint: PhysicsImpostorJoint): void;
  104593. isSupported(): boolean;
  104594. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104595. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104596. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104597. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104599. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104600. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104601. getBodyMass(impostor: PhysicsImpostor): number;
  104602. getBodyFriction(impostor: PhysicsImpostor): number;
  104603. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104604. getBodyRestitution(impostor: PhysicsImpostor): number;
  104605. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104606. getBodyPressure?(impostor: PhysicsImpostor): number;
  104607. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104608. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104609. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104610. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104611. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104612. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104613. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104614. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104615. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104616. sleepBody(impostor: PhysicsImpostor): void;
  104617. wakeUpBody(impostor: PhysicsImpostor): void;
  104618. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104619. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104620. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104621. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104622. getRadius(impostor: PhysicsImpostor): number;
  104623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104625. dispose(): void;
  104626. }
  104627. /**
  104628. * Interface used to define a physics engine
  104629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104630. */
  104631. export interface IPhysicsEngine {
  104632. /**
  104633. * Gets the gravity vector used by the simulation
  104634. */
  104635. gravity: Vector3;
  104636. /**
  104637. * Sets the gravity vector used by the simulation
  104638. * @param gravity defines the gravity vector to use
  104639. */
  104640. setGravity(gravity: Vector3): void;
  104641. /**
  104642. * Set the time step of the physics engine.
  104643. * Default is 1/60.
  104644. * To slow it down, enter 1/600 for example.
  104645. * To speed it up, 1/30
  104646. * @param newTimeStep the new timestep to apply to this world.
  104647. */
  104648. setTimeStep(newTimeStep: number): void;
  104649. /**
  104650. * Get the time step of the physics engine.
  104651. * @returns the current time step
  104652. */
  104653. getTimeStep(): number;
  104654. /**
  104655. * Set the sub time step of the physics engine.
  104656. * Default is 0 meaning there is no sub steps
  104657. * To increase physics resolution precision, set a small value (like 1 ms)
  104658. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104659. */
  104660. setSubTimeStep(subTimeStep: number): void;
  104661. /**
  104662. * Get the sub time step of the physics engine.
  104663. * @returns the current sub time step
  104664. */
  104665. getSubTimeStep(): number;
  104666. /**
  104667. * Release all resources
  104668. */
  104669. dispose(): void;
  104670. /**
  104671. * Gets the name of the current physics plugin
  104672. * @returns the name of the plugin
  104673. */
  104674. getPhysicsPluginName(): string;
  104675. /**
  104676. * Adding a new impostor for the impostor tracking.
  104677. * This will be done by the impostor itself.
  104678. * @param impostor the impostor to add
  104679. */
  104680. addImpostor(impostor: PhysicsImpostor): void;
  104681. /**
  104682. * Remove an impostor from the engine.
  104683. * This impostor and its mesh will not longer be updated by the physics engine.
  104684. * @param impostor the impostor to remove
  104685. */
  104686. removeImpostor(impostor: PhysicsImpostor): void;
  104687. /**
  104688. * Add a joint to the physics engine
  104689. * @param mainImpostor defines the main impostor to which the joint is added.
  104690. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104691. * @param joint defines the joint that will connect both impostors.
  104692. */
  104693. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104694. /**
  104695. * Removes a joint from the simulation
  104696. * @param mainImpostor defines the impostor used with the joint
  104697. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104698. * @param joint defines the joint to remove
  104699. */
  104700. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104701. /**
  104702. * Gets the current plugin used to run the simulation
  104703. * @returns current plugin
  104704. */
  104705. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104706. /**
  104707. * Gets the list of physic impostors
  104708. * @returns an array of PhysicsImpostor
  104709. */
  104710. getImpostors(): Array<PhysicsImpostor>;
  104711. /**
  104712. * Gets the impostor for a physics enabled object
  104713. * @param object defines the object impersonated by the impostor
  104714. * @returns the PhysicsImpostor or null if not found
  104715. */
  104716. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104717. /**
  104718. * Gets the impostor for a physics body object
  104719. * @param body defines physics body used by the impostor
  104720. * @returns the PhysicsImpostor or null if not found
  104721. */
  104722. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104723. /**
  104724. * Does a raycast in the physics world
  104725. * @param from when should the ray start?
  104726. * @param to when should the ray end?
  104727. * @returns PhysicsRaycastResult
  104728. */
  104729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104730. /**
  104731. * Called by the scene. No need to call it.
  104732. * @param delta defines the timespam between frames
  104733. */
  104734. _step(delta: number): void;
  104735. }
  104736. }
  104737. declare module BABYLON {
  104738. /**
  104739. * The interface for the physics imposter parameters
  104740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104741. */
  104742. export interface PhysicsImpostorParameters {
  104743. /**
  104744. * The mass of the physics imposter
  104745. */
  104746. mass: number;
  104747. /**
  104748. * The friction of the physics imposter
  104749. */
  104750. friction?: number;
  104751. /**
  104752. * The coefficient of restitution of the physics imposter
  104753. */
  104754. restitution?: number;
  104755. /**
  104756. * The native options of the physics imposter
  104757. */
  104758. nativeOptions?: any;
  104759. /**
  104760. * Specifies if the parent should be ignored
  104761. */
  104762. ignoreParent?: boolean;
  104763. /**
  104764. * Specifies if bi-directional transformations should be disabled
  104765. */
  104766. disableBidirectionalTransformation?: boolean;
  104767. /**
  104768. * The pressure inside the physics imposter, soft object only
  104769. */
  104770. pressure?: number;
  104771. /**
  104772. * The stiffness the physics imposter, soft object only
  104773. */
  104774. stiffness?: number;
  104775. /**
  104776. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104777. */
  104778. velocityIterations?: number;
  104779. /**
  104780. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104781. */
  104782. positionIterations?: number;
  104783. /**
  104784. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104785. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104786. * Add to fix multiple points
  104787. */
  104788. fixedPoints?: number;
  104789. /**
  104790. * The collision margin around a soft object
  104791. */
  104792. margin?: number;
  104793. /**
  104794. * The collision margin around a soft object
  104795. */
  104796. damping?: number;
  104797. /**
  104798. * The path for a rope based on an extrusion
  104799. */
  104800. path?: any;
  104801. /**
  104802. * The shape of an extrusion used for a rope based on an extrusion
  104803. */
  104804. shape?: any;
  104805. }
  104806. /**
  104807. * Interface for a physics-enabled object
  104808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104809. */
  104810. export interface IPhysicsEnabledObject {
  104811. /**
  104812. * The position of the physics-enabled object
  104813. */
  104814. position: Vector3;
  104815. /**
  104816. * The rotation of the physics-enabled object
  104817. */
  104818. rotationQuaternion: Nullable<Quaternion>;
  104819. /**
  104820. * The scale of the physics-enabled object
  104821. */
  104822. scaling: Vector3;
  104823. /**
  104824. * The rotation of the physics-enabled object
  104825. */
  104826. rotation?: Vector3;
  104827. /**
  104828. * The parent of the physics-enabled object
  104829. */
  104830. parent?: any;
  104831. /**
  104832. * The bounding info of the physics-enabled object
  104833. * @returns The bounding info of the physics-enabled object
  104834. */
  104835. getBoundingInfo(): BoundingInfo;
  104836. /**
  104837. * Computes the world matrix
  104838. * @param force Specifies if the world matrix should be computed by force
  104839. * @returns A world matrix
  104840. */
  104841. computeWorldMatrix(force: boolean): Matrix;
  104842. /**
  104843. * Gets the world matrix
  104844. * @returns A world matrix
  104845. */
  104846. getWorldMatrix?(): Matrix;
  104847. /**
  104848. * Gets the child meshes
  104849. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104850. * @returns An array of abstract meshes
  104851. */
  104852. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104853. /**
  104854. * Gets the vertex data
  104855. * @param kind The type of vertex data
  104856. * @returns A nullable array of numbers, or a float32 array
  104857. */
  104858. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104859. /**
  104860. * Gets the indices from the mesh
  104861. * @returns A nullable array of index arrays
  104862. */
  104863. getIndices?(): Nullable<IndicesArray>;
  104864. /**
  104865. * Gets the scene from the mesh
  104866. * @returns the indices array or null
  104867. */
  104868. getScene?(): Scene;
  104869. /**
  104870. * Gets the absolute position from the mesh
  104871. * @returns the absolute position
  104872. */
  104873. getAbsolutePosition(): Vector3;
  104874. /**
  104875. * Gets the absolute pivot point from the mesh
  104876. * @returns the absolute pivot point
  104877. */
  104878. getAbsolutePivotPoint(): Vector3;
  104879. /**
  104880. * Rotates the mesh
  104881. * @param axis The axis of rotation
  104882. * @param amount The amount of rotation
  104883. * @param space The space of the rotation
  104884. * @returns The rotation transform node
  104885. */
  104886. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104887. /**
  104888. * Translates the mesh
  104889. * @param axis The axis of translation
  104890. * @param distance The distance of translation
  104891. * @param space The space of the translation
  104892. * @returns The transform node
  104893. */
  104894. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104895. /**
  104896. * Sets the absolute position of the mesh
  104897. * @param absolutePosition The absolute position of the mesh
  104898. * @returns The transform node
  104899. */
  104900. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104901. /**
  104902. * Gets the class name of the mesh
  104903. * @returns The class name
  104904. */
  104905. getClassName(): string;
  104906. }
  104907. /**
  104908. * Represents a physics imposter
  104909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104910. */
  104911. export class PhysicsImpostor {
  104912. /**
  104913. * The physics-enabled object used as the physics imposter
  104914. */
  104915. object: IPhysicsEnabledObject;
  104916. /**
  104917. * The type of the physics imposter
  104918. */
  104919. type: number;
  104920. private _options;
  104921. private _scene?;
  104922. /**
  104923. * The default object size of the imposter
  104924. */
  104925. static DEFAULT_OBJECT_SIZE: Vector3;
  104926. /**
  104927. * The identity quaternion of the imposter
  104928. */
  104929. static IDENTITY_QUATERNION: Quaternion;
  104930. /** @hidden */
  104931. _pluginData: any;
  104932. private _physicsEngine;
  104933. private _physicsBody;
  104934. private _bodyUpdateRequired;
  104935. private _onBeforePhysicsStepCallbacks;
  104936. private _onAfterPhysicsStepCallbacks;
  104937. /** @hidden */
  104938. _onPhysicsCollideCallbacks: Array<{
  104939. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104940. otherImpostors: Array<PhysicsImpostor>;
  104941. }>;
  104942. private _deltaPosition;
  104943. private _deltaRotation;
  104944. private _deltaRotationConjugated;
  104945. /** @hidden */
  104946. _isFromLine: boolean;
  104947. private _parent;
  104948. private _isDisposed;
  104949. private static _tmpVecs;
  104950. private static _tmpQuat;
  104951. /**
  104952. * Specifies if the physics imposter is disposed
  104953. */
  104954. get isDisposed(): boolean;
  104955. /**
  104956. * Gets the mass of the physics imposter
  104957. */
  104958. get mass(): number;
  104959. set mass(value: number);
  104960. /**
  104961. * Gets the coefficient of friction
  104962. */
  104963. get friction(): number;
  104964. /**
  104965. * Sets the coefficient of friction
  104966. */
  104967. set friction(value: number);
  104968. /**
  104969. * Gets the coefficient of restitution
  104970. */
  104971. get restitution(): number;
  104972. /**
  104973. * Sets the coefficient of restitution
  104974. */
  104975. set restitution(value: number);
  104976. /**
  104977. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104978. */
  104979. get pressure(): number;
  104980. /**
  104981. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104982. */
  104983. set pressure(value: number);
  104984. /**
  104985. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104986. */
  104987. get stiffness(): number;
  104988. /**
  104989. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104990. */
  104991. set stiffness(value: number);
  104992. /**
  104993. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104994. */
  104995. get velocityIterations(): number;
  104996. /**
  104997. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104998. */
  104999. set velocityIterations(value: number);
  105000. /**
  105001. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105002. */
  105003. get positionIterations(): number;
  105004. /**
  105005. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105006. */
  105007. set positionIterations(value: number);
  105008. /**
  105009. * The unique id of the physics imposter
  105010. * set by the physics engine when adding this impostor to the array
  105011. */
  105012. uniqueId: number;
  105013. /**
  105014. * @hidden
  105015. */
  105016. soft: boolean;
  105017. /**
  105018. * @hidden
  105019. */
  105020. segments: number;
  105021. private _joints;
  105022. /**
  105023. * Initializes the physics imposter
  105024. * @param object The physics-enabled object used as the physics imposter
  105025. * @param type The type of the physics imposter
  105026. * @param _options The options for the physics imposter
  105027. * @param _scene The Babylon scene
  105028. */
  105029. constructor(
  105030. /**
  105031. * The physics-enabled object used as the physics imposter
  105032. */
  105033. object: IPhysicsEnabledObject,
  105034. /**
  105035. * The type of the physics imposter
  105036. */
  105037. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105038. /**
  105039. * This function will completly initialize this impostor.
  105040. * It will create a new body - but only if this mesh has no parent.
  105041. * If it has, this impostor will not be used other than to define the impostor
  105042. * of the child mesh.
  105043. * @hidden
  105044. */
  105045. _init(): void;
  105046. private _getPhysicsParent;
  105047. /**
  105048. * Should a new body be generated.
  105049. * @returns boolean specifying if body initialization is required
  105050. */
  105051. isBodyInitRequired(): boolean;
  105052. /**
  105053. * Sets the updated scaling
  105054. * @param updated Specifies if the scaling is updated
  105055. */
  105056. setScalingUpdated(): void;
  105057. /**
  105058. * Force a regeneration of this or the parent's impostor's body.
  105059. * Use under cautious - This will remove all joints already implemented.
  105060. */
  105061. forceUpdate(): void;
  105062. /**
  105063. * Gets the body that holds this impostor. Either its own, or its parent.
  105064. */
  105065. get physicsBody(): any;
  105066. /**
  105067. * Get the parent of the physics imposter
  105068. * @returns Physics imposter or null
  105069. */
  105070. get parent(): Nullable<PhysicsImpostor>;
  105071. /**
  105072. * Sets the parent of the physics imposter
  105073. */
  105074. set parent(value: Nullable<PhysicsImpostor>);
  105075. /**
  105076. * Set the physics body. Used mainly by the physics engine/plugin
  105077. */
  105078. set physicsBody(physicsBody: any);
  105079. /**
  105080. * Resets the update flags
  105081. */
  105082. resetUpdateFlags(): void;
  105083. /**
  105084. * Gets the object extend size
  105085. * @returns the object extend size
  105086. */
  105087. getObjectExtendSize(): Vector3;
  105088. /**
  105089. * Gets the object center
  105090. * @returns The object center
  105091. */
  105092. getObjectCenter(): Vector3;
  105093. /**
  105094. * Get a specific parameter from the options parameters
  105095. * @param paramName The object parameter name
  105096. * @returns The object parameter
  105097. */
  105098. getParam(paramName: string): any;
  105099. /**
  105100. * Sets a specific parameter in the options given to the physics plugin
  105101. * @param paramName The parameter name
  105102. * @param value The value of the parameter
  105103. */
  105104. setParam(paramName: string, value: number): void;
  105105. /**
  105106. * Specifically change the body's mass option. Won't recreate the physics body object
  105107. * @param mass The mass of the physics imposter
  105108. */
  105109. setMass(mass: number): void;
  105110. /**
  105111. * Gets the linear velocity
  105112. * @returns linear velocity or null
  105113. */
  105114. getLinearVelocity(): Nullable<Vector3>;
  105115. /**
  105116. * Sets the linear velocity
  105117. * @param velocity linear velocity or null
  105118. */
  105119. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105120. /**
  105121. * Gets the angular velocity
  105122. * @returns angular velocity or null
  105123. */
  105124. getAngularVelocity(): Nullable<Vector3>;
  105125. /**
  105126. * Sets the angular velocity
  105127. * @param velocity The velocity or null
  105128. */
  105129. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105130. /**
  105131. * Execute a function with the physics plugin native code
  105132. * Provide a function the will have two variables - the world object and the physics body object
  105133. * @param func The function to execute with the physics plugin native code
  105134. */
  105135. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105136. /**
  105137. * Register a function that will be executed before the physics world is stepping forward
  105138. * @param func The function to execute before the physics world is stepped forward
  105139. */
  105140. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105141. /**
  105142. * Unregister a function that will be executed before the physics world is stepping forward
  105143. * @param func The function to execute before the physics world is stepped forward
  105144. */
  105145. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105146. /**
  105147. * Register a function that will be executed after the physics step
  105148. * @param func The function to execute after physics step
  105149. */
  105150. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105151. /**
  105152. * Unregisters a function that will be executed after the physics step
  105153. * @param func The function to execute after physics step
  105154. */
  105155. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105156. /**
  105157. * register a function that will be executed when this impostor collides against a different body
  105158. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105159. * @param func Callback that is executed on collision
  105160. */
  105161. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105162. /**
  105163. * Unregisters the physics imposter on contact
  105164. * @param collideAgainst The physics object to collide against
  105165. * @param func Callback to execute on collision
  105166. */
  105167. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105168. private _tmpQuat;
  105169. private _tmpQuat2;
  105170. /**
  105171. * Get the parent rotation
  105172. * @returns The parent rotation
  105173. */
  105174. getParentsRotation(): Quaternion;
  105175. /**
  105176. * this function is executed by the physics engine.
  105177. */
  105178. beforeStep: () => void;
  105179. /**
  105180. * this function is executed by the physics engine
  105181. */
  105182. afterStep: () => void;
  105183. /**
  105184. * Legacy collision detection event support
  105185. */
  105186. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105187. /**
  105188. * event and body object due to cannon's event-based architecture.
  105189. */
  105190. onCollide: (e: {
  105191. body: any;
  105192. }) => void;
  105193. /**
  105194. * Apply a force
  105195. * @param force The force to apply
  105196. * @param contactPoint The contact point for the force
  105197. * @returns The physics imposter
  105198. */
  105199. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105200. /**
  105201. * Apply an impulse
  105202. * @param force The impulse force
  105203. * @param contactPoint The contact point for the impulse force
  105204. * @returns The physics imposter
  105205. */
  105206. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105207. /**
  105208. * A help function to create a joint
  105209. * @param otherImpostor A physics imposter used to create a joint
  105210. * @param jointType The type of joint
  105211. * @param jointData The data for the joint
  105212. * @returns The physics imposter
  105213. */
  105214. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105215. /**
  105216. * Add a joint to this impostor with a different impostor
  105217. * @param otherImpostor A physics imposter used to add a joint
  105218. * @param joint The joint to add
  105219. * @returns The physics imposter
  105220. */
  105221. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105222. /**
  105223. * Add an anchor to a cloth impostor
  105224. * @param otherImpostor rigid impostor to anchor to
  105225. * @param width ratio across width from 0 to 1
  105226. * @param height ratio up height from 0 to 1
  105227. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105228. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105229. * @returns impostor the soft imposter
  105230. */
  105231. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105232. /**
  105233. * Add a hook to a rope impostor
  105234. * @param otherImpostor rigid impostor to anchor to
  105235. * @param length ratio across rope from 0 to 1
  105236. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105237. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105238. * @returns impostor the rope imposter
  105239. */
  105240. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105241. /**
  105242. * Will keep this body still, in a sleep mode.
  105243. * @returns the physics imposter
  105244. */
  105245. sleep(): PhysicsImpostor;
  105246. /**
  105247. * Wake the body up.
  105248. * @returns The physics imposter
  105249. */
  105250. wakeUp(): PhysicsImpostor;
  105251. /**
  105252. * Clones the physics imposter
  105253. * @param newObject The physics imposter clones to this physics-enabled object
  105254. * @returns A nullable physics imposter
  105255. */
  105256. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105257. /**
  105258. * Disposes the physics imposter
  105259. */
  105260. dispose(): void;
  105261. /**
  105262. * Sets the delta position
  105263. * @param position The delta position amount
  105264. */
  105265. setDeltaPosition(position: Vector3): void;
  105266. /**
  105267. * Sets the delta rotation
  105268. * @param rotation The delta rotation amount
  105269. */
  105270. setDeltaRotation(rotation: Quaternion): void;
  105271. /**
  105272. * Gets the box size of the physics imposter and stores the result in the input parameter
  105273. * @param result Stores the box size
  105274. * @returns The physics imposter
  105275. */
  105276. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105277. /**
  105278. * Gets the radius of the physics imposter
  105279. * @returns Radius of the physics imposter
  105280. */
  105281. getRadius(): number;
  105282. /**
  105283. * Sync a bone with this impostor
  105284. * @param bone The bone to sync to the impostor.
  105285. * @param boneMesh The mesh that the bone is influencing.
  105286. * @param jointPivot The pivot of the joint / bone in local space.
  105287. * @param distToJoint Optional distance from the impostor to the joint.
  105288. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105289. */
  105290. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105291. /**
  105292. * Sync impostor to a bone
  105293. * @param bone The bone that the impostor will be synced to.
  105294. * @param boneMesh The mesh that the bone is influencing.
  105295. * @param jointPivot The pivot of the joint / bone in local space.
  105296. * @param distToJoint Optional distance from the impostor to the joint.
  105297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105298. * @param boneAxis Optional vector3 axis the bone is aligned with
  105299. */
  105300. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105301. /**
  105302. * No-Imposter type
  105303. */
  105304. static NoImpostor: number;
  105305. /**
  105306. * Sphere-Imposter type
  105307. */
  105308. static SphereImpostor: number;
  105309. /**
  105310. * Box-Imposter type
  105311. */
  105312. static BoxImpostor: number;
  105313. /**
  105314. * Plane-Imposter type
  105315. */
  105316. static PlaneImpostor: number;
  105317. /**
  105318. * Mesh-imposter type
  105319. */
  105320. static MeshImpostor: number;
  105321. /**
  105322. * Capsule-Impostor type (Ammo.js plugin only)
  105323. */
  105324. static CapsuleImpostor: number;
  105325. /**
  105326. * Cylinder-Imposter type
  105327. */
  105328. static CylinderImpostor: number;
  105329. /**
  105330. * Particle-Imposter type
  105331. */
  105332. static ParticleImpostor: number;
  105333. /**
  105334. * Heightmap-Imposter type
  105335. */
  105336. static HeightmapImpostor: number;
  105337. /**
  105338. * ConvexHull-Impostor type (Ammo.js plugin only)
  105339. */
  105340. static ConvexHullImpostor: number;
  105341. /**
  105342. * Custom-Imposter type (Ammo.js plugin only)
  105343. */
  105344. static CustomImpostor: number;
  105345. /**
  105346. * Rope-Imposter type
  105347. */
  105348. static RopeImpostor: number;
  105349. /**
  105350. * Cloth-Imposter type
  105351. */
  105352. static ClothImpostor: number;
  105353. /**
  105354. * Softbody-Imposter type
  105355. */
  105356. static SoftbodyImpostor: number;
  105357. }
  105358. }
  105359. declare module BABYLON {
  105360. /**
  105361. * @hidden
  105362. **/
  105363. export class _CreationDataStorage {
  105364. closePath?: boolean;
  105365. closeArray?: boolean;
  105366. idx: number[];
  105367. dashSize: number;
  105368. gapSize: number;
  105369. path3D: Path3D;
  105370. pathArray: Vector3[][];
  105371. arc: number;
  105372. radius: number;
  105373. cap: number;
  105374. tessellation: number;
  105375. }
  105376. /**
  105377. * @hidden
  105378. **/
  105379. class _InstanceDataStorage {
  105380. visibleInstances: any;
  105381. batchCache: _InstancesBatch;
  105382. instancesBufferSize: number;
  105383. instancesBuffer: Nullable<Buffer>;
  105384. instancesData: Float32Array;
  105385. overridenInstanceCount: number;
  105386. isFrozen: boolean;
  105387. previousBatch: Nullable<_InstancesBatch>;
  105388. hardwareInstancedRendering: boolean;
  105389. sideOrientation: number;
  105390. manualUpdate: boolean;
  105391. }
  105392. /**
  105393. * @hidden
  105394. **/
  105395. export class _InstancesBatch {
  105396. mustReturn: boolean;
  105397. visibleInstances: Nullable<InstancedMesh[]>[];
  105398. renderSelf: boolean[];
  105399. hardwareInstancedRendering: boolean[];
  105400. }
  105401. /**
  105402. * @hidden
  105403. **/
  105404. class _ThinInstanceDataStorage {
  105405. instancesCount: number;
  105406. matrixBuffer: Nullable<Buffer>;
  105407. matrixBufferSize: number;
  105408. matrixData: Nullable<Float32Array>;
  105409. boundingVectors: Array<Vector3>;
  105410. }
  105411. /**
  105412. * Class used to represent renderable models
  105413. */
  105414. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105415. /**
  105416. * Mesh side orientation : usually the external or front surface
  105417. */
  105418. static readonly FRONTSIDE: number;
  105419. /**
  105420. * Mesh side orientation : usually the internal or back surface
  105421. */
  105422. static readonly BACKSIDE: number;
  105423. /**
  105424. * Mesh side orientation : both internal and external or front and back surfaces
  105425. */
  105426. static readonly DOUBLESIDE: number;
  105427. /**
  105428. * Mesh side orientation : by default, `FRONTSIDE`
  105429. */
  105430. static readonly DEFAULTSIDE: number;
  105431. /**
  105432. * Mesh cap setting : no cap
  105433. */
  105434. static readonly NO_CAP: number;
  105435. /**
  105436. * Mesh cap setting : one cap at the beginning of the mesh
  105437. */
  105438. static readonly CAP_START: number;
  105439. /**
  105440. * Mesh cap setting : one cap at the end of the mesh
  105441. */
  105442. static readonly CAP_END: number;
  105443. /**
  105444. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105445. */
  105446. static readonly CAP_ALL: number;
  105447. /**
  105448. * Mesh pattern setting : no flip or rotate
  105449. */
  105450. static readonly NO_FLIP: number;
  105451. /**
  105452. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105453. */
  105454. static readonly FLIP_TILE: number;
  105455. /**
  105456. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105457. */
  105458. static readonly ROTATE_TILE: number;
  105459. /**
  105460. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105461. */
  105462. static readonly FLIP_ROW: number;
  105463. /**
  105464. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105465. */
  105466. static readonly ROTATE_ROW: number;
  105467. /**
  105468. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105469. */
  105470. static readonly FLIP_N_ROTATE_TILE: number;
  105471. /**
  105472. * Mesh pattern setting : rotate pattern and rotate
  105473. */
  105474. static readonly FLIP_N_ROTATE_ROW: number;
  105475. /**
  105476. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105477. */
  105478. static readonly CENTER: number;
  105479. /**
  105480. * Mesh tile positioning : part tiles on left
  105481. */
  105482. static readonly LEFT: number;
  105483. /**
  105484. * Mesh tile positioning : part tiles on right
  105485. */
  105486. static readonly RIGHT: number;
  105487. /**
  105488. * Mesh tile positioning : part tiles on top
  105489. */
  105490. static readonly TOP: number;
  105491. /**
  105492. * Mesh tile positioning : part tiles on bottom
  105493. */
  105494. static readonly BOTTOM: number;
  105495. /**
  105496. * Gets the default side orientation.
  105497. * @param orientation the orientation to value to attempt to get
  105498. * @returns the default orientation
  105499. * @hidden
  105500. */
  105501. static _GetDefaultSideOrientation(orientation?: number): number;
  105502. private _internalMeshDataInfo;
  105503. /**
  105504. * An event triggered before rendering the mesh
  105505. */
  105506. get onBeforeRenderObservable(): Observable<Mesh>;
  105507. /**
  105508. * An event triggered before binding the mesh
  105509. */
  105510. get onBeforeBindObservable(): Observable<Mesh>;
  105511. /**
  105512. * An event triggered after rendering the mesh
  105513. */
  105514. get onAfterRenderObservable(): Observable<Mesh>;
  105515. /**
  105516. * An event triggered before drawing the mesh
  105517. */
  105518. get onBeforeDrawObservable(): Observable<Mesh>;
  105519. private _onBeforeDrawObserver;
  105520. /**
  105521. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105522. */
  105523. set onBeforeDraw(callback: () => void);
  105524. get hasInstances(): boolean;
  105525. get hasThinInstances(): boolean;
  105526. /**
  105527. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105528. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105529. */
  105530. delayLoadState: number;
  105531. /**
  105532. * Gets the list of instances created from this mesh
  105533. * it is not supposed to be modified manually.
  105534. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105535. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105536. */
  105537. instances: InstancedMesh[];
  105538. /**
  105539. * Gets the file containing delay loading data for this mesh
  105540. */
  105541. delayLoadingFile: string;
  105542. /** @hidden */
  105543. _binaryInfo: any;
  105544. /**
  105545. * User defined function used to change how LOD level selection is done
  105546. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105547. */
  105548. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105549. /**
  105550. * Gets or sets the morph target manager
  105551. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105552. */
  105553. get morphTargetManager(): Nullable<MorphTargetManager>;
  105554. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105555. /** @hidden */
  105556. _creationDataStorage: Nullable<_CreationDataStorage>;
  105557. /** @hidden */
  105558. _geometry: Nullable<Geometry>;
  105559. /** @hidden */
  105560. _delayInfo: Array<string>;
  105561. /** @hidden */
  105562. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105563. /** @hidden */
  105564. _instanceDataStorage: _InstanceDataStorage;
  105565. /** @hidden */
  105566. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105567. private _effectiveMaterial;
  105568. /** @hidden */
  105569. _shouldGenerateFlatShading: boolean;
  105570. /** @hidden */
  105571. _originalBuilderSideOrientation: number;
  105572. /**
  105573. * Use this property to change the original side orientation defined at construction time
  105574. */
  105575. overrideMaterialSideOrientation: Nullable<number>;
  105576. /**
  105577. * Gets the source mesh (the one used to clone this one from)
  105578. */
  105579. get source(): Nullable<Mesh>;
  105580. /**
  105581. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105582. */
  105583. get isUnIndexed(): boolean;
  105584. set isUnIndexed(value: boolean);
  105585. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105586. get worldMatrixInstancedBuffer(): Float32Array;
  105587. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105588. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105589. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105590. /**
  105591. * @constructor
  105592. * @param name The value used by scene.getMeshByName() to do a lookup.
  105593. * @param scene The scene to add this mesh to.
  105594. * @param parent The parent of this mesh, if it has one
  105595. * @param source An optional Mesh from which geometry is shared, cloned.
  105596. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105597. * When false, achieved by calling a clone(), also passing False.
  105598. * This will make creation of children, recursive.
  105599. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105600. */
  105601. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105602. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105603. doNotInstantiate: boolean;
  105604. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105605. /**
  105606. * Gets the class name
  105607. * @returns the string "Mesh".
  105608. */
  105609. getClassName(): string;
  105610. /** @hidden */
  105611. get _isMesh(): boolean;
  105612. /**
  105613. * Returns a description of this mesh
  105614. * @param fullDetails define if full details about this mesh must be used
  105615. * @returns a descriptive string representing this mesh
  105616. */
  105617. toString(fullDetails?: boolean): string;
  105618. /** @hidden */
  105619. _unBindEffect(): void;
  105620. /**
  105621. * Gets a boolean indicating if this mesh has LOD
  105622. */
  105623. get hasLODLevels(): boolean;
  105624. /**
  105625. * Gets the list of MeshLODLevel associated with the current mesh
  105626. * @returns an array of MeshLODLevel
  105627. */
  105628. getLODLevels(): MeshLODLevel[];
  105629. private _sortLODLevels;
  105630. /**
  105631. * Add a mesh as LOD level triggered at the given distance.
  105632. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105633. * @param distance The distance from the center of the object to show this level
  105634. * @param mesh The mesh to be added as LOD level (can be null)
  105635. * @return This mesh (for chaining)
  105636. */
  105637. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105638. /**
  105639. * Returns the LOD level mesh at the passed distance or null if not found.
  105640. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105641. * @param distance The distance from the center of the object to show this level
  105642. * @returns a Mesh or `null`
  105643. */
  105644. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105645. /**
  105646. * Remove a mesh from the LOD array
  105647. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105648. * @param mesh defines the mesh to be removed
  105649. * @return This mesh (for chaining)
  105650. */
  105651. removeLODLevel(mesh: Mesh): Mesh;
  105652. /**
  105653. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105654. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105655. * @param camera defines the camera to use to compute distance
  105656. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105657. * @return This mesh (for chaining)
  105658. */
  105659. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105660. /**
  105661. * Gets the mesh internal Geometry object
  105662. */
  105663. get geometry(): Nullable<Geometry>;
  105664. /**
  105665. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105666. * @returns the total number of vertices
  105667. */
  105668. getTotalVertices(): number;
  105669. /**
  105670. * Returns the content of an associated vertex buffer
  105671. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105672. * - VertexBuffer.PositionKind
  105673. * - VertexBuffer.UVKind
  105674. * - VertexBuffer.UV2Kind
  105675. * - VertexBuffer.UV3Kind
  105676. * - VertexBuffer.UV4Kind
  105677. * - VertexBuffer.UV5Kind
  105678. * - VertexBuffer.UV6Kind
  105679. * - VertexBuffer.ColorKind
  105680. * - VertexBuffer.MatricesIndicesKind
  105681. * - VertexBuffer.MatricesIndicesExtraKind
  105682. * - VertexBuffer.MatricesWeightsKind
  105683. * - VertexBuffer.MatricesWeightsExtraKind
  105684. * @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
  105685. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105686. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105687. */
  105688. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105689. /**
  105690. * Returns the mesh VertexBuffer object from the requested `kind`
  105691. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105692. * - VertexBuffer.PositionKind
  105693. * - VertexBuffer.NormalKind
  105694. * - VertexBuffer.UVKind
  105695. * - VertexBuffer.UV2Kind
  105696. * - VertexBuffer.UV3Kind
  105697. * - VertexBuffer.UV4Kind
  105698. * - VertexBuffer.UV5Kind
  105699. * - VertexBuffer.UV6Kind
  105700. * - VertexBuffer.ColorKind
  105701. * - VertexBuffer.MatricesIndicesKind
  105702. * - VertexBuffer.MatricesIndicesExtraKind
  105703. * - VertexBuffer.MatricesWeightsKind
  105704. * - VertexBuffer.MatricesWeightsExtraKind
  105705. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105706. */
  105707. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105708. /**
  105709. * Tests if a specific vertex buffer is associated with this mesh
  105710. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105711. * - VertexBuffer.PositionKind
  105712. * - VertexBuffer.NormalKind
  105713. * - VertexBuffer.UVKind
  105714. * - VertexBuffer.UV2Kind
  105715. * - VertexBuffer.UV3Kind
  105716. * - VertexBuffer.UV4Kind
  105717. * - VertexBuffer.UV5Kind
  105718. * - VertexBuffer.UV6Kind
  105719. * - VertexBuffer.ColorKind
  105720. * - VertexBuffer.MatricesIndicesKind
  105721. * - VertexBuffer.MatricesIndicesExtraKind
  105722. * - VertexBuffer.MatricesWeightsKind
  105723. * - VertexBuffer.MatricesWeightsExtraKind
  105724. * @returns a boolean
  105725. */
  105726. isVerticesDataPresent(kind: string): boolean;
  105727. /**
  105728. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105729. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105730. * - VertexBuffer.PositionKind
  105731. * - VertexBuffer.UVKind
  105732. * - VertexBuffer.UV2Kind
  105733. * - VertexBuffer.UV3Kind
  105734. * - VertexBuffer.UV4Kind
  105735. * - VertexBuffer.UV5Kind
  105736. * - VertexBuffer.UV6Kind
  105737. * - VertexBuffer.ColorKind
  105738. * - VertexBuffer.MatricesIndicesKind
  105739. * - VertexBuffer.MatricesIndicesExtraKind
  105740. * - VertexBuffer.MatricesWeightsKind
  105741. * - VertexBuffer.MatricesWeightsExtraKind
  105742. * @returns a boolean
  105743. */
  105744. isVertexBufferUpdatable(kind: string): boolean;
  105745. /**
  105746. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105747. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105748. * - VertexBuffer.PositionKind
  105749. * - VertexBuffer.NormalKind
  105750. * - VertexBuffer.UVKind
  105751. * - VertexBuffer.UV2Kind
  105752. * - VertexBuffer.UV3Kind
  105753. * - VertexBuffer.UV4Kind
  105754. * - VertexBuffer.UV5Kind
  105755. * - VertexBuffer.UV6Kind
  105756. * - VertexBuffer.ColorKind
  105757. * - VertexBuffer.MatricesIndicesKind
  105758. * - VertexBuffer.MatricesIndicesExtraKind
  105759. * - VertexBuffer.MatricesWeightsKind
  105760. * - VertexBuffer.MatricesWeightsExtraKind
  105761. * @returns an array of strings
  105762. */
  105763. getVerticesDataKinds(): string[];
  105764. /**
  105765. * Returns a positive integer : the total number of indices in this mesh geometry.
  105766. * @returns the numner of indices or zero if the mesh has no geometry.
  105767. */
  105768. getTotalIndices(): number;
  105769. /**
  105770. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105771. * @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.
  105772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105773. * @returns the indices array or an empty array if the mesh has no geometry
  105774. */
  105775. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105776. get isBlocked(): boolean;
  105777. /**
  105778. * Determine if the current mesh is ready to be rendered
  105779. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105780. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105781. * @returns true if all associated assets are ready (material, textures, shaders)
  105782. */
  105783. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105784. /**
  105785. * 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.
  105786. */
  105787. get areNormalsFrozen(): boolean;
  105788. /**
  105789. * 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.
  105790. * @returns the current mesh
  105791. */
  105792. freezeNormals(): Mesh;
  105793. /**
  105794. * 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
  105795. * @returns the current mesh
  105796. */
  105797. unfreezeNormals(): Mesh;
  105798. /**
  105799. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105800. */
  105801. set overridenInstanceCount(count: number);
  105802. /** @hidden */
  105803. _preActivate(): Mesh;
  105804. /** @hidden */
  105805. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105806. /** @hidden */
  105807. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105808. protected _afterComputeWorldMatrix(): void;
  105809. /** @hidden */
  105810. _postActivate(): void;
  105811. /**
  105812. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105813. * This means the mesh underlying bounding box and sphere are recomputed.
  105814. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105815. * @returns the current mesh
  105816. */
  105817. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105818. /** @hidden */
  105819. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105820. /**
  105821. * This function will subdivide the mesh into multiple submeshes
  105822. * @param count defines the expected number of submeshes
  105823. */
  105824. subdivide(count: number): void;
  105825. /**
  105826. * Copy a FloatArray into a specific associated vertex buffer
  105827. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105828. * - VertexBuffer.PositionKind
  105829. * - VertexBuffer.UVKind
  105830. * - VertexBuffer.UV2Kind
  105831. * - VertexBuffer.UV3Kind
  105832. * - VertexBuffer.UV4Kind
  105833. * - VertexBuffer.UV5Kind
  105834. * - VertexBuffer.UV6Kind
  105835. * - VertexBuffer.ColorKind
  105836. * - VertexBuffer.MatricesIndicesKind
  105837. * - VertexBuffer.MatricesIndicesExtraKind
  105838. * - VertexBuffer.MatricesWeightsKind
  105839. * - VertexBuffer.MatricesWeightsExtraKind
  105840. * @param data defines the data source
  105841. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105842. * @param stride defines the data stride size (can be null)
  105843. * @returns the current mesh
  105844. */
  105845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105846. /**
  105847. * Delete a vertex buffer associated with this mesh
  105848. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105849. * - VertexBuffer.PositionKind
  105850. * - VertexBuffer.UVKind
  105851. * - VertexBuffer.UV2Kind
  105852. * - VertexBuffer.UV3Kind
  105853. * - VertexBuffer.UV4Kind
  105854. * - VertexBuffer.UV5Kind
  105855. * - VertexBuffer.UV6Kind
  105856. * - VertexBuffer.ColorKind
  105857. * - VertexBuffer.MatricesIndicesKind
  105858. * - VertexBuffer.MatricesIndicesExtraKind
  105859. * - VertexBuffer.MatricesWeightsKind
  105860. * - VertexBuffer.MatricesWeightsExtraKind
  105861. */
  105862. removeVerticesData(kind: string): void;
  105863. /**
  105864. * Flags an associated vertex buffer as updatable
  105865. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105866. * - VertexBuffer.PositionKind
  105867. * - VertexBuffer.UVKind
  105868. * - VertexBuffer.UV2Kind
  105869. * - VertexBuffer.UV3Kind
  105870. * - VertexBuffer.UV4Kind
  105871. * - VertexBuffer.UV5Kind
  105872. * - VertexBuffer.UV6Kind
  105873. * - VertexBuffer.ColorKind
  105874. * - VertexBuffer.MatricesIndicesKind
  105875. * - VertexBuffer.MatricesIndicesExtraKind
  105876. * - VertexBuffer.MatricesWeightsKind
  105877. * - VertexBuffer.MatricesWeightsExtraKind
  105878. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105879. */
  105880. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105881. /**
  105882. * Sets the mesh global Vertex Buffer
  105883. * @param buffer defines the buffer to use
  105884. * @returns the current mesh
  105885. */
  105886. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105887. /**
  105888. * Update a specific associated vertex buffer
  105889. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105890. * - VertexBuffer.PositionKind
  105891. * - VertexBuffer.UVKind
  105892. * - VertexBuffer.UV2Kind
  105893. * - VertexBuffer.UV3Kind
  105894. * - VertexBuffer.UV4Kind
  105895. * - VertexBuffer.UV5Kind
  105896. * - VertexBuffer.UV6Kind
  105897. * - VertexBuffer.ColorKind
  105898. * - VertexBuffer.MatricesIndicesKind
  105899. * - VertexBuffer.MatricesIndicesExtraKind
  105900. * - VertexBuffer.MatricesWeightsKind
  105901. * - VertexBuffer.MatricesWeightsExtraKind
  105902. * @param data defines the data source
  105903. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105904. * @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)
  105905. * @returns the current mesh
  105906. */
  105907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105908. /**
  105909. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105910. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105911. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105912. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105913. * @returns the current mesh
  105914. */
  105915. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105916. /**
  105917. * Creates a un-shared specific occurence of the geometry for the mesh.
  105918. * @returns the current mesh
  105919. */
  105920. makeGeometryUnique(): Mesh;
  105921. /**
  105922. * Set the index buffer of this mesh
  105923. * @param indices defines the source data
  105924. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105925. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105926. * @returns the current mesh
  105927. */
  105928. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105929. /**
  105930. * Update the current index buffer
  105931. * @param indices defines the source data
  105932. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105933. * @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)
  105934. * @returns the current mesh
  105935. */
  105936. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105937. /**
  105938. * Invert the geometry to move from a right handed system to a left handed one.
  105939. * @returns the current mesh
  105940. */
  105941. toLeftHanded(): Mesh;
  105942. /** @hidden */
  105943. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105944. /** @hidden */
  105945. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105946. /**
  105947. * Registers for this mesh a javascript function called just before the rendering process
  105948. * @param func defines the function to call before rendering this mesh
  105949. * @returns the current mesh
  105950. */
  105951. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105952. /**
  105953. * Disposes a previously registered javascript function called before the rendering
  105954. * @param func defines the function to remove
  105955. * @returns the current mesh
  105956. */
  105957. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105958. /**
  105959. * Registers for this mesh a javascript function called just after the rendering is complete
  105960. * @param func defines the function to call after rendering this mesh
  105961. * @returns the current mesh
  105962. */
  105963. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105964. /**
  105965. * Disposes a previously registered javascript function called after the rendering.
  105966. * @param func defines the function to remove
  105967. * @returns the current mesh
  105968. */
  105969. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105970. /** @hidden */
  105971. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105972. /** @hidden */
  105973. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105974. /** @hidden */
  105975. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105976. /** @hidden */
  105977. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105978. /** @hidden */
  105979. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105980. /** @hidden */
  105981. _rebuild(): void;
  105982. /** @hidden */
  105983. _freeze(): void;
  105984. /** @hidden */
  105985. _unFreeze(): void;
  105986. /**
  105987. * 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
  105988. * @param subMesh defines the subMesh to render
  105989. * @param enableAlphaMode defines if alpha mode can be changed
  105990. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105991. * @returns the current mesh
  105992. */
  105993. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105994. private _onBeforeDraw;
  105995. /**
  105996. * Renormalize the mesh and patch it up if there are no weights
  105997. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105998. * However in the case of zero weights then we set just a single influence to 1.
  105999. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  106000. */
  106001. cleanMatrixWeights(): void;
  106002. private normalizeSkinFourWeights;
  106003. private normalizeSkinWeightsAndExtra;
  106004. /**
  106005. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106006. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106007. * the user know there was an issue with importing the mesh
  106008. * @returns a validation object with skinned, valid and report string
  106009. */
  106010. validateSkinning(): {
  106011. skinned: boolean;
  106012. valid: boolean;
  106013. report: string;
  106014. };
  106015. /** @hidden */
  106016. _checkDelayState(): Mesh;
  106017. private _queueLoad;
  106018. /**
  106019. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106020. * A mesh is in the frustum if its bounding box intersects the frustum
  106021. * @param frustumPlanes defines the frustum to test
  106022. * @returns true if the mesh is in the frustum planes
  106023. */
  106024. isInFrustum(frustumPlanes: Plane[]): boolean;
  106025. /**
  106026. * Sets the mesh material by the material or multiMaterial `id` property
  106027. * @param id is a string identifying the material or the multiMaterial
  106028. * @returns the current mesh
  106029. */
  106030. setMaterialByID(id: string): Mesh;
  106031. /**
  106032. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106033. * @returns an array of IAnimatable
  106034. */
  106035. getAnimatables(): IAnimatable[];
  106036. /**
  106037. * Modifies the mesh geometry according to the passed transformation matrix.
  106038. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106039. * The mesh normals are modified using the same transformation.
  106040. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106041. * @param transform defines the transform matrix to use
  106042. * @see https://doc.babylonjs.com/resources/baking_transformations
  106043. * @returns the current mesh
  106044. */
  106045. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106046. /**
  106047. * Modifies the mesh geometry according to its own current World Matrix.
  106048. * The mesh World Matrix is then reset.
  106049. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106050. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106051. * @see https://doc.babylonjs.com/resources/baking_transformations
  106052. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106053. * @returns the current mesh
  106054. */
  106055. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106056. /** @hidden */
  106057. get _positions(): Nullable<Vector3[]>;
  106058. /** @hidden */
  106059. _resetPointsArrayCache(): Mesh;
  106060. /** @hidden */
  106061. _generatePointsArray(): boolean;
  106062. /**
  106063. * Returns a new Mesh object generated from the current mesh properties.
  106064. * This method must not get confused with createInstance()
  106065. * @param name is a string, the name given to the new mesh
  106066. * @param newParent can be any Node object (default `null`)
  106067. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106068. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106069. * @returns a new mesh
  106070. */
  106071. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106072. /**
  106073. * Releases resources associated with this mesh.
  106074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106076. */
  106077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106078. /** @hidden */
  106079. _disposeInstanceSpecificData(): void;
  106080. /** @hidden */
  106081. _disposeThinInstanceSpecificData(): void;
  106082. /**
  106083. * Modifies the mesh geometry according to a displacement map.
  106084. * 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.
  106085. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106086. * @param url is a string, the URL from the image file is to be downloaded.
  106087. * @param minHeight is the lower limit of the displacement.
  106088. * @param maxHeight is the upper limit of the displacement.
  106089. * @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.
  106090. * @param uvOffset is an optional vector2 used to offset UV.
  106091. * @param uvScale is an optional vector2 used to scale UV.
  106092. * @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.
  106093. * @returns the Mesh.
  106094. */
  106095. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106096. /**
  106097. * Modifies the mesh geometry according to a displacementMap buffer.
  106098. * 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.
  106099. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106100. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106101. * @param heightMapWidth is the width of the buffer image.
  106102. * @param heightMapHeight is the height of the buffer image.
  106103. * @param minHeight is the lower limit of the displacement.
  106104. * @param maxHeight is the upper limit of the displacement.
  106105. * @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.
  106106. * @param uvOffset is an optional vector2 used to offset UV.
  106107. * @param uvScale is an optional vector2 used to scale UV.
  106108. * @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.
  106109. * @returns the Mesh.
  106110. */
  106111. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106112. /**
  106113. * Modify the mesh to get a flat shading rendering.
  106114. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106115. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106116. * @returns current mesh
  106117. */
  106118. convertToFlatShadedMesh(): Mesh;
  106119. /**
  106120. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106121. * In other words, more vertices, no more indices and a single bigger VBO.
  106122. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106123. * @returns current mesh
  106124. */
  106125. convertToUnIndexedMesh(): Mesh;
  106126. /**
  106127. * Inverses facet orientations.
  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. * @param flipNormals will also inverts the normals
  106130. * @returns current mesh
  106131. */
  106132. flipFaces(flipNormals?: boolean): Mesh;
  106133. /**
  106134. * Increase the number of facets and hence vertices in a mesh
  106135. * Vertex normals are interpolated from existing vertex normals
  106136. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106137. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106138. */
  106139. increaseVertices(numberPerEdge: number): void;
  106140. /**
  106141. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106142. * This will undo any application of covertToFlatShadedMesh
  106143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106144. */
  106145. forceSharedVertices(): void;
  106146. /** @hidden */
  106147. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106148. /** @hidden */
  106149. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106150. /**
  106151. * Creates a new InstancedMesh object from the mesh model.
  106152. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106153. * @param name defines the name of the new instance
  106154. * @returns a new InstancedMesh
  106155. */
  106156. createInstance(name: string): InstancedMesh;
  106157. /**
  106158. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106159. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106160. * @returns the current mesh
  106161. */
  106162. synchronizeInstances(): Mesh;
  106163. /**
  106164. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106165. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106166. * This should be used together with the simplification to avoid disappearing triangles.
  106167. * @param successCallback an optional success callback to be called after the optimization finished.
  106168. * @returns the current mesh
  106169. */
  106170. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106171. /**
  106172. * Serialize current mesh
  106173. * @param serializationObject defines the object which will receive the serialization data
  106174. */
  106175. serialize(serializationObject: any): void;
  106176. /** @hidden */
  106177. _syncGeometryWithMorphTargetManager(): void;
  106178. /** @hidden */
  106179. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106180. /**
  106181. * Returns a new Mesh object parsed from the source provided.
  106182. * @param parsedMesh is the source
  106183. * @param scene defines the hosting scene
  106184. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106185. * @returns a new Mesh
  106186. */
  106187. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106188. /**
  106189. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106191. * @param name defines the name of the mesh to create
  106192. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106193. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106194. * @param closePath creates a seam between the first and the last points of each path of the path array
  106195. * @param offset is taken in account only if the `pathArray` is containing a single path
  106196. * @param scene defines the hosting scene
  106197. * @param updatable defines if the mesh must be flagged as updatable
  106198. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106199. * @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)
  106200. * @returns a new Mesh
  106201. */
  106202. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106203. /**
  106204. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106205. * @param name defines the name of the mesh to create
  106206. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106207. * @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
  106208. * @param scene defines the hosting scene
  106209. * @param updatable defines if the mesh must be flagged as updatable
  106210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106211. * @returns a new Mesh
  106212. */
  106213. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106214. /**
  106215. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106216. * @param name defines the name of the mesh to create
  106217. * @param size sets the size (float) of each box side (default 1)
  106218. * @param scene defines the hosting scene
  106219. * @param updatable defines if the mesh must be flagged as updatable
  106220. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106221. * @returns a new Mesh
  106222. */
  106223. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106224. /**
  106225. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106226. * @param name defines the name of the mesh to create
  106227. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106228. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106229. * @param scene defines the hosting scene
  106230. * @param updatable defines if the mesh must be flagged as updatable
  106231. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106232. * @returns a new Mesh
  106233. */
  106234. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106235. /**
  106236. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106237. * @param name defines the name of the mesh to create
  106238. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106239. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106240. * @param scene defines the hosting scene
  106241. * @returns a new Mesh
  106242. */
  106243. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106244. /**
  106245. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106246. * @param name defines the name of the mesh to create
  106247. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106248. * @param diameterTop set the top cap diameter (floats, default 1)
  106249. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106250. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106251. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106252. * @param scene defines the hosting scene
  106253. * @param updatable defines if the mesh must be flagged as updatable
  106254. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106255. * @returns a new Mesh
  106256. */
  106257. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106258. /**
  106259. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106260. * @param name defines the name of the mesh to create
  106261. * @param diameter sets the diameter size (float) of the torus (default 1)
  106262. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106263. * @param tessellation sets the number of torus sides (postive integer, default 16)
  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 CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106270. /**
  106271. * Creates a torus knot 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 radius sets the global radius size (float) of the torus knot (default 2)
  106274. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106275. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106276. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106277. * @param p the number of windings on X axis (positive integers, default 2)
  106278. * @param q the number of windings on Y axis (positive integers, default 3)
  106279. * @param scene defines the hosting scene
  106280. * @param updatable defines if the mesh must be flagged as updatable
  106281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106282. * @returns a new Mesh
  106283. */
  106284. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106285. /**
  106286. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106287. * @param name defines the name of the mesh to create
  106288. * @param points is an array successive Vector3
  106289. * @param scene defines the hosting scene
  106290. * @param updatable defines if the mesh must be flagged as updatable
  106291. * @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).
  106292. * @returns a new Mesh
  106293. */
  106294. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106295. /**
  106296. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106297. * @param name defines the name of the mesh to create
  106298. * @param points is an array successive Vector3
  106299. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106300. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106301. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106302. * @param scene defines the hosting scene
  106303. * @param updatable defines if the mesh must be flagged as updatable
  106304. * @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)
  106305. * @returns a new Mesh
  106306. */
  106307. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106308. /**
  106309. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106310. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106311. * 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.
  106312. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106313. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106314. * Remember you can only change the shape positions, not their number when updating a polygon.
  106315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106316. * @param name defines the name of the mesh to create
  106317. * @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
  106318. * @param scene defines the hosting scene
  106319. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106320. * @param updatable defines if the mesh must be flagged as updatable
  106321. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106322. * @param earcutInjection can be used to inject your own earcut reference
  106323. * @returns a new Mesh
  106324. */
  106325. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106326. /**
  106327. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106329. * @param name defines the name of the mesh to create
  106330. * @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
  106331. * @param depth defines the height of extrusion
  106332. * @param scene defines the hosting scene
  106333. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106334. * @param updatable defines if the mesh must be flagged as updatable
  106335. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106336. * @param earcutInjection can be used to inject your own earcut reference
  106337. * @returns a new Mesh
  106338. */
  106339. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106340. /**
  106341. * Creates an extruded shape mesh.
  106342. * 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
  106343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106345. * @param name defines the name of the mesh to create
  106346. * @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
  106347. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106348. * @param scale is the value to scale the shape
  106349. * @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
  106350. * @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
  106351. * @param scene defines the hosting scene
  106352. * @param updatable defines if the mesh must be flagged as updatable
  106353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106354. * @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)
  106355. * @returns a new Mesh
  106356. */
  106357. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106358. /**
  106359. * Creates an custom extruded shape mesh.
  106360. * The custom extrusion is a parametric shape.
  106361. * It has no predefined shape. Its final shape will depend on the input parameters.
  106362. * Please consider using the same method from the MeshBuilder class instead
  106363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106364. * @param name defines the name of the mesh to create
  106365. * @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
  106366. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106367. * @param scaleFunction is a custom Javascript function called on each path point
  106368. * @param rotationFunction is a custom Javascript function called on each path point
  106369. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106370. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106371. * @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
  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. * @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)
  106376. * @returns a new Mesh
  106377. */
  106378. 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;
  106379. /**
  106380. * Creates lathe mesh.
  106381. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106382. * Please consider using the same method from the MeshBuilder class instead
  106383. * @param name defines the name of the mesh to create
  106384. * @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
  106385. * @param radius is the radius value of the lathe
  106386. * @param tessellation is the side number of the lathe.
  106387. * @param scene defines the hosting scene
  106388. * @param updatable defines if the mesh must be flagged as updatable
  106389. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106390. * @returns a new Mesh
  106391. */
  106392. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106393. /**
  106394. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106395. * @param name defines the name of the mesh to create
  106396. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106397. * @param scene defines the hosting scene
  106398. * @param updatable defines if the mesh must be flagged as updatable
  106399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106400. * @returns a new Mesh
  106401. */
  106402. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106403. /**
  106404. * Creates a ground mesh.
  106405. * Please consider using the same method from the MeshBuilder class instead
  106406. * @param name defines the name of the mesh to create
  106407. * @param width set the width of the ground
  106408. * @param height set the height of the ground
  106409. * @param subdivisions sets the number of subdivisions per side
  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 CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106415. /**
  106416. * Creates a tiled ground mesh.
  106417. * Please consider using the same method from the MeshBuilder class instead
  106418. * @param name defines the name of the mesh to create
  106419. * @param xmin set the ground minimum X coordinate
  106420. * @param zmin set the ground minimum Y coordinate
  106421. * @param xmax set the ground maximum X coordinate
  106422. * @param zmax set the ground maximum Z coordinate
  106423. * @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
  106424. * @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
  106425. * @param scene defines the hosting scene
  106426. * @param updatable defines if the mesh must be flagged as updatable
  106427. * @returns a new Mesh
  106428. */
  106429. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106430. w: number;
  106431. h: number;
  106432. }, precision: {
  106433. w: number;
  106434. h: number;
  106435. }, scene: Scene, updatable?: boolean): Mesh;
  106436. /**
  106437. * Creates a ground mesh from a height map.
  106438. * Please consider using the same method from the MeshBuilder class instead
  106439. * @see https://doc.babylonjs.com/babylon101/height_map
  106440. * @param name defines the name of the mesh to create
  106441. * @param url sets the URL of the height map image resource
  106442. * @param width set the ground width size
  106443. * @param height set the ground height size
  106444. * @param subdivisions sets the number of subdivision per side
  106445. * @param minHeight is the minimum altitude on the ground
  106446. * @param maxHeight is the maximum altitude on the ground
  106447. * @param scene defines the hosting scene
  106448. * @param updatable defines if the mesh must be flagged as updatable
  106449. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106450. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106451. * @returns a new Mesh
  106452. */
  106453. 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;
  106454. /**
  106455. * Creates a tube mesh.
  106456. * The tube is a parametric shape.
  106457. * It has no predefined shape. Its final shape will depend on the input parameters.
  106458. * Please consider using the same method from the MeshBuilder class instead
  106459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106460. * @param name defines the name of the mesh to create
  106461. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106462. * @param radius sets the tube radius size
  106463. * @param tessellation is the number of sides on the tubular surface
  106464. * @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
  106465. * @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
  106466. * @param scene defines the hosting scene
  106467. * @param updatable defines if the mesh must be flagged as updatable
  106468. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106469. * @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)
  106470. * @returns a new Mesh
  106471. */
  106472. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106473. (i: number, distance: number): number;
  106474. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106475. /**
  106476. * Creates a polyhedron mesh.
  106477. * Please consider using the same method from the MeshBuilder class instead.
  106478. * * 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
  106479. * * The parameter `size` (positive float, default 1) sets the polygon size
  106480. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106481. * * 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`
  106482. * * 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
  106483. * * 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)`)
  106484. * * 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
  106485. * * 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
  106486. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106487. * * 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
  106488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106489. * @param name defines the name of the mesh to create
  106490. * @param options defines the options used to create the mesh
  106491. * @param scene defines the hosting scene
  106492. * @returns a new Mesh
  106493. */
  106494. static CreatePolyhedron(name: string, options: {
  106495. type?: number;
  106496. size?: number;
  106497. sizeX?: number;
  106498. sizeY?: number;
  106499. sizeZ?: number;
  106500. custom?: any;
  106501. faceUV?: Vector4[];
  106502. faceColors?: Color4[];
  106503. updatable?: boolean;
  106504. sideOrientation?: number;
  106505. }, scene: Scene): Mesh;
  106506. /**
  106507. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106508. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106509. * * 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`)
  106510. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106511. * * 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
  106512. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106513. * * 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
  106514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106515. * @param name defines the name of the mesh
  106516. * @param options defines the options used to create the mesh
  106517. * @param scene defines the hosting scene
  106518. * @returns a new Mesh
  106519. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106520. */
  106521. static CreateIcoSphere(name: string, options: {
  106522. radius?: number;
  106523. flat?: boolean;
  106524. subdivisions?: number;
  106525. sideOrientation?: number;
  106526. updatable?: boolean;
  106527. }, scene: Scene): Mesh;
  106528. /**
  106529. * Creates a decal mesh.
  106530. * Please consider using the same method from the MeshBuilder class instead.
  106531. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106532. * @param name defines the name of the mesh
  106533. * @param sourceMesh defines the mesh receiving the decal
  106534. * @param position sets the position of the decal in world coordinates
  106535. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106536. * @param size sets the decal scaling
  106537. * @param angle sets the angle to rotate the decal
  106538. * @returns a new Mesh
  106539. */
  106540. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106541. /**
  106542. * Prepare internal position array for software CPU skinning
  106543. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106544. */
  106545. setPositionsForCPUSkinning(): Float32Array;
  106546. /**
  106547. * Prepare internal normal array for software CPU skinning
  106548. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106549. */
  106550. setNormalsForCPUSkinning(): Float32Array;
  106551. /**
  106552. * Updates the vertex buffer by applying transformation from the bones
  106553. * @param skeleton defines the skeleton to apply to current mesh
  106554. * @returns the current mesh
  106555. */
  106556. applySkeleton(skeleton: Skeleton): Mesh;
  106557. /**
  106558. * 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
  106559. * @param meshes defines the list of meshes to scan
  106560. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106561. */
  106562. static MinMax(meshes: AbstractMesh[]): {
  106563. min: Vector3;
  106564. max: Vector3;
  106565. };
  106566. /**
  106567. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106568. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106569. * @returns a vector3
  106570. */
  106571. static Center(meshesOrMinMaxVector: {
  106572. min: Vector3;
  106573. max: Vector3;
  106574. } | AbstractMesh[]): Vector3;
  106575. /**
  106576. * Merge the array of meshes into a single mesh for performance reasons.
  106577. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106578. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106579. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106580. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106581. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106582. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106583. * @returns a new mesh
  106584. */
  106585. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106586. /** @hidden */
  106587. addInstance(instance: InstancedMesh): void;
  106588. /** @hidden */
  106589. removeInstance(instance: InstancedMesh): void;
  106590. }
  106591. }
  106592. declare module BABYLON {
  106593. /**
  106594. * This is the base class of all the camera used in the application.
  106595. * @see https://doc.babylonjs.com/features/cameras
  106596. */
  106597. export class Camera extends Node {
  106598. /** @hidden */
  106599. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106600. /**
  106601. * This is the default projection mode used by the cameras.
  106602. * It helps recreating a feeling of perspective and better appreciate depth.
  106603. * This is the best way to simulate real life cameras.
  106604. */
  106605. static readonly PERSPECTIVE_CAMERA: number;
  106606. /**
  106607. * This helps creating camera with an orthographic mode.
  106608. * 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.
  106609. */
  106610. static readonly ORTHOGRAPHIC_CAMERA: number;
  106611. /**
  106612. * This is the default FOV mode for perspective cameras.
  106613. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106614. */
  106615. static readonly FOVMODE_VERTICAL_FIXED: number;
  106616. /**
  106617. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106618. */
  106619. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106620. /**
  106621. * This specifies ther is no need for a camera rig.
  106622. * Basically only one eye is rendered corresponding to the camera.
  106623. */
  106624. static readonly RIG_MODE_NONE: number;
  106625. /**
  106626. * Simulates a camera Rig with one blue eye and one red eye.
  106627. * This can be use with 3d blue and red glasses.
  106628. */
  106629. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106630. /**
  106631. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106632. */
  106633. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106634. /**
  106635. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106636. */
  106637. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106638. /**
  106639. * Defines that both eyes of the camera will be rendered over under each other.
  106640. */
  106641. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106642. /**
  106643. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106644. */
  106645. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106646. /**
  106647. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106648. */
  106649. static readonly RIG_MODE_VR: number;
  106650. /**
  106651. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106652. */
  106653. static readonly RIG_MODE_WEBVR: number;
  106654. /**
  106655. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106656. */
  106657. static readonly RIG_MODE_CUSTOM: number;
  106658. /**
  106659. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106660. */
  106661. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106662. /**
  106663. * Define the input manager associated with the camera.
  106664. */
  106665. inputs: CameraInputsManager<Camera>;
  106666. /** @hidden */
  106667. _position: Vector3;
  106668. /**
  106669. * Define the current local position of the camera in the scene
  106670. */
  106671. get position(): Vector3;
  106672. set position(newPosition: Vector3);
  106673. /**
  106674. * The vector the camera should consider as up.
  106675. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106676. */
  106677. upVector: Vector3;
  106678. /**
  106679. * Define the current limit on the left side for an orthographic camera
  106680. * In scene unit
  106681. */
  106682. orthoLeft: Nullable<number>;
  106683. /**
  106684. * Define the current limit on the right side for an orthographic camera
  106685. * In scene unit
  106686. */
  106687. orthoRight: Nullable<number>;
  106688. /**
  106689. * Define the current limit on the bottom side for an orthographic camera
  106690. * In scene unit
  106691. */
  106692. orthoBottom: Nullable<number>;
  106693. /**
  106694. * Define the current limit on the top side for an orthographic camera
  106695. * In scene unit
  106696. */
  106697. orthoTop: Nullable<number>;
  106698. /**
  106699. * Field Of View is set in Radians. (default is 0.8)
  106700. */
  106701. fov: number;
  106702. /**
  106703. * Define the minimum distance the camera can see from.
  106704. * This is important to note that the depth buffer are not infinite and the closer it starts
  106705. * the more your scene might encounter depth fighting issue.
  106706. */
  106707. minZ: number;
  106708. /**
  106709. * Define the maximum distance the camera can see to.
  106710. * This is important to note that the depth buffer are not infinite and the further it end
  106711. * the more your scene might encounter depth fighting issue.
  106712. */
  106713. maxZ: number;
  106714. /**
  106715. * Define the default inertia of the camera.
  106716. * This helps giving a smooth feeling to the camera movement.
  106717. */
  106718. inertia: number;
  106719. /**
  106720. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106721. */
  106722. mode: number;
  106723. /**
  106724. * Define whether the camera is intermediate.
  106725. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106726. */
  106727. isIntermediate: boolean;
  106728. /**
  106729. * Define the viewport of the camera.
  106730. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106731. */
  106732. viewport: Viewport;
  106733. /**
  106734. * Restricts the camera to viewing objects with the same layerMask.
  106735. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106736. */
  106737. layerMask: number;
  106738. /**
  106739. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106740. */
  106741. fovMode: number;
  106742. /**
  106743. * Rig mode of the camera.
  106744. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106745. * This is normally controlled byt the camera themselves as internal use.
  106746. */
  106747. cameraRigMode: number;
  106748. /**
  106749. * Defines the distance between both "eyes" in case of a RIG
  106750. */
  106751. interaxialDistance: number;
  106752. /**
  106753. * Defines if stereoscopic rendering is done side by side or over under.
  106754. */
  106755. isStereoscopicSideBySide: boolean;
  106756. /**
  106757. * 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
  106758. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106759. * else in the scene. (Eg. security camera)
  106760. *
  106761. * 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)
  106762. */
  106763. customRenderTargets: RenderTargetTexture[];
  106764. /**
  106765. * When set, the camera will render to this render target instead of the default canvas
  106766. *
  106767. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106768. */
  106769. outputRenderTarget: Nullable<RenderTargetTexture>;
  106770. /**
  106771. * Observable triggered when the camera view matrix has changed.
  106772. */
  106773. onViewMatrixChangedObservable: Observable<Camera>;
  106774. /**
  106775. * Observable triggered when the camera Projection matrix has changed.
  106776. */
  106777. onProjectionMatrixChangedObservable: Observable<Camera>;
  106778. /**
  106779. * Observable triggered when the inputs have been processed.
  106780. */
  106781. onAfterCheckInputsObservable: Observable<Camera>;
  106782. /**
  106783. * Observable triggered when reset has been called and applied to the camera.
  106784. */
  106785. onRestoreStateObservable: Observable<Camera>;
  106786. /**
  106787. * Is this camera a part of a rig system?
  106788. */
  106789. isRigCamera: boolean;
  106790. /**
  106791. * If isRigCamera set to true this will be set with the parent camera.
  106792. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106793. */
  106794. rigParent?: Camera;
  106795. /** @hidden */
  106796. _cameraRigParams: any;
  106797. /** @hidden */
  106798. _rigCameras: Camera[];
  106799. /** @hidden */
  106800. _rigPostProcess: Nullable<PostProcess>;
  106801. protected _webvrViewMatrix: Matrix;
  106802. /** @hidden */
  106803. _skipRendering: boolean;
  106804. /** @hidden */
  106805. _projectionMatrix: Matrix;
  106806. /** @hidden */
  106807. _postProcesses: Nullable<PostProcess>[];
  106808. /** @hidden */
  106809. _activeMeshes: SmartArray<AbstractMesh>;
  106810. protected _globalPosition: Vector3;
  106811. /** @hidden */
  106812. _computedViewMatrix: Matrix;
  106813. private _doNotComputeProjectionMatrix;
  106814. private _transformMatrix;
  106815. private _frustumPlanes;
  106816. private _refreshFrustumPlanes;
  106817. private _storedFov;
  106818. private _stateStored;
  106819. /**
  106820. * Instantiates a new camera object.
  106821. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106822. * @see https://doc.babylonjs.com/features/cameras
  106823. * @param name Defines the name of the camera in the scene
  106824. * @param position Defines the position of the camera
  106825. * @param scene Defines the scene the camera belongs too
  106826. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106827. */
  106828. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106829. /**
  106830. * Store current camera state (fov, position, etc..)
  106831. * @returns the camera
  106832. */
  106833. storeState(): Camera;
  106834. /**
  106835. * Restores the camera state values if it has been stored. You must call storeState() first
  106836. */
  106837. protected _restoreStateValues(): boolean;
  106838. /**
  106839. * Restored camera state. You must call storeState() first.
  106840. * @returns true if restored and false otherwise
  106841. */
  106842. restoreState(): boolean;
  106843. /**
  106844. * Gets the class name of the camera.
  106845. * @returns the class name
  106846. */
  106847. getClassName(): string;
  106848. /** @hidden */
  106849. readonly _isCamera: boolean;
  106850. /**
  106851. * Gets a string representation of the camera useful for debug purpose.
  106852. * @param fullDetails Defines that a more verboe level of logging is required
  106853. * @returns the string representation
  106854. */
  106855. toString(fullDetails?: boolean): string;
  106856. /**
  106857. * Gets the current world space position of the camera.
  106858. */
  106859. get globalPosition(): Vector3;
  106860. /**
  106861. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106862. * @returns the active meshe list
  106863. */
  106864. getActiveMeshes(): SmartArray<AbstractMesh>;
  106865. /**
  106866. * Check whether a mesh is part of the current active mesh list of the camera
  106867. * @param mesh Defines the mesh to check
  106868. * @returns true if active, false otherwise
  106869. */
  106870. isActiveMesh(mesh: Mesh): boolean;
  106871. /**
  106872. * Is this camera ready to be used/rendered
  106873. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106874. * @return true if the camera is ready
  106875. */
  106876. isReady(completeCheck?: boolean): boolean;
  106877. /** @hidden */
  106878. _initCache(): void;
  106879. /** @hidden */
  106880. _updateCache(ignoreParentClass?: boolean): void;
  106881. /** @hidden */
  106882. _isSynchronized(): boolean;
  106883. /** @hidden */
  106884. _isSynchronizedViewMatrix(): boolean;
  106885. /** @hidden */
  106886. _isSynchronizedProjectionMatrix(): boolean;
  106887. /**
  106888. * Attach the input controls to a specific dom element to get the input from.
  106889. * @param element Defines the element the controls should be listened from
  106890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106891. */
  106892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106893. /**
  106894. * Detach the current controls from the specified dom element.
  106895. * @param element Defines the element to stop listening the inputs from
  106896. */
  106897. detachControl(element: HTMLElement): void;
  106898. /**
  106899. * Update the camera state according to the different inputs gathered during the frame.
  106900. */
  106901. update(): void;
  106902. /** @hidden */
  106903. _checkInputs(): void;
  106904. /** @hidden */
  106905. get rigCameras(): Camera[];
  106906. /**
  106907. * Gets the post process used by the rig cameras
  106908. */
  106909. get rigPostProcess(): Nullable<PostProcess>;
  106910. /**
  106911. * Internal, gets the first post proces.
  106912. * @returns the first post process to be run on this camera.
  106913. */
  106914. _getFirstPostProcess(): Nullable<PostProcess>;
  106915. private _cascadePostProcessesToRigCams;
  106916. /**
  106917. * Attach a post process to the camera.
  106918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106919. * @param postProcess The post process to attach to the camera
  106920. * @param insertAt The position of the post process in case several of them are in use in the scene
  106921. * @returns the position the post process has been inserted at
  106922. */
  106923. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106924. /**
  106925. * Detach a post process to the camera.
  106926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106927. * @param postProcess The post process to detach from the camera
  106928. */
  106929. detachPostProcess(postProcess: PostProcess): void;
  106930. /**
  106931. * Gets the current world matrix of the camera
  106932. */
  106933. getWorldMatrix(): Matrix;
  106934. /** @hidden */
  106935. _getViewMatrix(): Matrix;
  106936. /**
  106937. * Gets the current view matrix of the camera.
  106938. * @param force forces the camera to recompute the matrix without looking at the cached state
  106939. * @returns the view matrix
  106940. */
  106941. getViewMatrix(force?: boolean): Matrix;
  106942. /**
  106943. * Freeze the projection matrix.
  106944. * It will prevent the cache check of the camera projection compute and can speed up perf
  106945. * if no parameter of the camera are meant to change
  106946. * @param projection Defines manually a projection if necessary
  106947. */
  106948. freezeProjectionMatrix(projection?: Matrix): void;
  106949. /**
  106950. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106951. */
  106952. unfreezeProjectionMatrix(): void;
  106953. /**
  106954. * Gets the current projection matrix of the camera.
  106955. * @param force forces the camera to recompute the matrix without looking at the cached state
  106956. * @returns the projection matrix
  106957. */
  106958. getProjectionMatrix(force?: boolean): Matrix;
  106959. /**
  106960. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106961. * @returns a Matrix
  106962. */
  106963. getTransformationMatrix(): Matrix;
  106964. private _updateFrustumPlanes;
  106965. /**
  106966. * Checks if a cullable object (mesh...) is in the camera frustum
  106967. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106968. * @param target The object to check
  106969. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106970. * @returns true if the object is in frustum otherwise false
  106971. */
  106972. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106973. /**
  106974. * Checks if a cullable object (mesh...) is in the camera frustum
  106975. * Unlike isInFrustum this cheks the full bounding box
  106976. * @param target The object to check
  106977. * @returns true if the object is in frustum otherwise false
  106978. */
  106979. isCompletelyInFrustum(target: ICullable): boolean;
  106980. /**
  106981. * Gets a ray in the forward direction from the camera.
  106982. * @param length Defines the length of the ray to create
  106983. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106984. * @param origin Defines the start point of the ray which defaults to the camera position
  106985. * @returns the forward ray
  106986. */
  106987. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106988. /**
  106989. * Releases resources associated with this node.
  106990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106992. */
  106993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106994. /** @hidden */
  106995. _isLeftCamera: boolean;
  106996. /**
  106997. * Gets the left camera of a rig setup in case of Rigged Camera
  106998. */
  106999. get isLeftCamera(): boolean;
  107000. /** @hidden */
  107001. _isRightCamera: boolean;
  107002. /**
  107003. * Gets the right camera of a rig setup in case of Rigged Camera
  107004. */
  107005. get isRightCamera(): boolean;
  107006. /**
  107007. * Gets the left camera of a rig setup in case of Rigged Camera
  107008. */
  107009. get leftCamera(): Nullable<FreeCamera>;
  107010. /**
  107011. * Gets the right camera of a rig setup in case of Rigged Camera
  107012. */
  107013. get rightCamera(): Nullable<FreeCamera>;
  107014. /**
  107015. * Gets the left camera target of a rig setup in case of Rigged Camera
  107016. * @returns the target position
  107017. */
  107018. getLeftTarget(): Nullable<Vector3>;
  107019. /**
  107020. * Gets the right camera target of a rig setup in case of Rigged Camera
  107021. * @returns the target position
  107022. */
  107023. getRightTarget(): Nullable<Vector3>;
  107024. /**
  107025. * @hidden
  107026. */
  107027. setCameraRigMode(mode: number, rigParams: any): void;
  107028. /** @hidden */
  107029. static _setStereoscopicRigMode(camera: Camera): void;
  107030. /** @hidden */
  107031. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107032. /** @hidden */
  107033. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107034. /** @hidden */
  107035. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107036. /** @hidden */
  107037. _getVRProjectionMatrix(): Matrix;
  107038. protected _updateCameraRotationMatrix(): void;
  107039. protected _updateWebVRCameraRotationMatrix(): void;
  107040. /**
  107041. * This function MUST be overwritten by the different WebVR cameras available.
  107042. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107043. * @hidden
  107044. */
  107045. _getWebVRProjectionMatrix(): Matrix;
  107046. /**
  107047. * This function MUST be overwritten by the different WebVR cameras available.
  107048. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107049. * @hidden
  107050. */
  107051. _getWebVRViewMatrix(): Matrix;
  107052. /** @hidden */
  107053. setCameraRigParameter(name: string, value: any): void;
  107054. /**
  107055. * needs to be overridden by children so sub has required properties to be copied
  107056. * @hidden
  107057. */
  107058. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107059. /**
  107060. * May need to be overridden by children
  107061. * @hidden
  107062. */
  107063. _updateRigCameras(): void;
  107064. /** @hidden */
  107065. _setupInputs(): void;
  107066. /**
  107067. * Serialiaze the camera setup to a json represention
  107068. * @returns the JSON representation
  107069. */
  107070. serialize(): any;
  107071. /**
  107072. * Clones the current camera.
  107073. * @param name The cloned camera name
  107074. * @returns the cloned camera
  107075. */
  107076. clone(name: string): Camera;
  107077. /**
  107078. * Gets the direction of the camera relative to a given local axis.
  107079. * @param localAxis Defines the reference axis to provide a relative direction.
  107080. * @return the direction
  107081. */
  107082. getDirection(localAxis: Vector3): Vector3;
  107083. /**
  107084. * Returns the current camera absolute rotation
  107085. */
  107086. get absoluteRotation(): Quaternion;
  107087. /**
  107088. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107089. * @param localAxis Defines the reference axis to provide a relative direction.
  107090. * @param result Defines the vector to store the result in
  107091. */
  107092. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107093. /**
  107094. * Gets a camera constructor for a given camera type
  107095. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107096. * @param name The name of the camera the result will be able to instantiate
  107097. * @param scene The scene the result will construct the camera in
  107098. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107099. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107100. * @returns a factory method to construc the camera
  107101. */
  107102. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107103. /**
  107104. * Compute the world matrix of the camera.
  107105. * @returns the camera world matrix
  107106. */
  107107. computeWorldMatrix(): Matrix;
  107108. /**
  107109. * Parse a JSON and creates the camera from the parsed information
  107110. * @param parsedCamera The JSON to parse
  107111. * @param scene The scene to instantiate the camera in
  107112. * @returns the newly constructed camera
  107113. */
  107114. static Parse(parsedCamera: any, scene: Scene): Camera;
  107115. }
  107116. }
  107117. declare module BABYLON {
  107118. /**
  107119. * Class containing static functions to help procedurally build meshes
  107120. */
  107121. export class DiscBuilder {
  107122. /**
  107123. * Creates a plane polygonal mesh. By default, this is a disc
  107124. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107125. * * 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
  107126. * * 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
  107127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107128. * * 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
  107129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107130. * @param name defines the name of the mesh
  107131. * @param options defines the options used to create the mesh
  107132. * @param scene defines the hosting scene
  107133. * @returns the plane polygonal mesh
  107134. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107135. */
  107136. static CreateDisc(name: string, options: {
  107137. radius?: number;
  107138. tessellation?: number;
  107139. arc?: number;
  107140. updatable?: boolean;
  107141. sideOrientation?: number;
  107142. frontUVs?: Vector4;
  107143. backUVs?: Vector4;
  107144. }, scene?: Nullable<Scene>): Mesh;
  107145. }
  107146. }
  107147. declare module BABYLON {
  107148. /**
  107149. * Options to be used when creating a FresnelParameters.
  107150. */
  107151. export type IFresnelParametersCreationOptions = {
  107152. /**
  107153. * Define the color used on edges (grazing angle)
  107154. */
  107155. leftColor?: Color3;
  107156. /**
  107157. * Define the color used on center
  107158. */
  107159. rightColor?: Color3;
  107160. /**
  107161. * Define bias applied to computed fresnel term
  107162. */
  107163. bias?: number;
  107164. /**
  107165. * Defined the power exponent applied to fresnel term
  107166. */
  107167. power?: number;
  107168. /**
  107169. * Define if the fresnel effect is enable or not.
  107170. */
  107171. isEnabled?: boolean;
  107172. };
  107173. /**
  107174. * Serialized format for FresnelParameters.
  107175. */
  107176. export type IFresnelParametersSerialized = {
  107177. /**
  107178. * Define the color used on edges (grazing angle) [as an array]
  107179. */
  107180. leftColor: number[];
  107181. /**
  107182. * Define the color used on center [as an array]
  107183. */
  107184. rightColor: number[];
  107185. /**
  107186. * Define bias applied to computed fresnel term
  107187. */
  107188. bias: number;
  107189. /**
  107190. * Defined the power exponent applied to fresnel term
  107191. */
  107192. power?: number;
  107193. /**
  107194. * Define if the fresnel effect is enable or not.
  107195. */
  107196. isEnabled: boolean;
  107197. };
  107198. /**
  107199. * This represents all the required information to add a fresnel effect on a material:
  107200. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107201. */
  107202. export class FresnelParameters {
  107203. private _isEnabled;
  107204. /**
  107205. * Define if the fresnel effect is enable or not.
  107206. */
  107207. get isEnabled(): boolean;
  107208. set isEnabled(value: boolean);
  107209. /**
  107210. * Define the color used on edges (grazing angle)
  107211. */
  107212. leftColor: Color3;
  107213. /**
  107214. * Define the color used on center
  107215. */
  107216. rightColor: Color3;
  107217. /**
  107218. * Define bias applied to computed fresnel term
  107219. */
  107220. bias: number;
  107221. /**
  107222. * Defined the power exponent applied to fresnel term
  107223. */
  107224. power: number;
  107225. /**
  107226. * Creates a new FresnelParameters object.
  107227. *
  107228. * @param options provide your own settings to optionally to override defaults
  107229. */
  107230. constructor(options?: IFresnelParametersCreationOptions);
  107231. /**
  107232. * Clones the current fresnel and its valuues
  107233. * @returns a clone fresnel configuration
  107234. */
  107235. clone(): FresnelParameters;
  107236. /**
  107237. * Determines equality between FresnelParameters objects
  107238. * @param otherFresnelParameters defines the second operand
  107239. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107240. */
  107241. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107242. /**
  107243. * Serializes the current fresnel parameters to a JSON representation.
  107244. * @return the JSON serialization
  107245. */
  107246. serialize(): IFresnelParametersSerialized;
  107247. /**
  107248. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107249. * @param parsedFresnelParameters Define the JSON representation
  107250. * @returns the parsed parameters
  107251. */
  107252. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107253. }
  107254. }
  107255. declare module BABYLON {
  107256. /**
  107257. * This groups all the flags used to control the materials channel.
  107258. */
  107259. export class MaterialFlags {
  107260. private static _DiffuseTextureEnabled;
  107261. /**
  107262. * Are diffuse textures enabled in the application.
  107263. */
  107264. static get DiffuseTextureEnabled(): boolean;
  107265. static set DiffuseTextureEnabled(value: boolean);
  107266. private static _DetailTextureEnabled;
  107267. /**
  107268. * Are detail textures enabled in the application.
  107269. */
  107270. static get DetailTextureEnabled(): boolean;
  107271. static set DetailTextureEnabled(value: boolean);
  107272. private static _AmbientTextureEnabled;
  107273. /**
  107274. * Are ambient textures enabled in the application.
  107275. */
  107276. static get AmbientTextureEnabled(): boolean;
  107277. static set AmbientTextureEnabled(value: boolean);
  107278. private static _OpacityTextureEnabled;
  107279. /**
  107280. * Are opacity textures enabled in the application.
  107281. */
  107282. static get OpacityTextureEnabled(): boolean;
  107283. static set OpacityTextureEnabled(value: boolean);
  107284. private static _ReflectionTextureEnabled;
  107285. /**
  107286. * Are reflection textures enabled in the application.
  107287. */
  107288. static get ReflectionTextureEnabled(): boolean;
  107289. static set ReflectionTextureEnabled(value: boolean);
  107290. private static _EmissiveTextureEnabled;
  107291. /**
  107292. * Are emissive textures enabled in the application.
  107293. */
  107294. static get EmissiveTextureEnabled(): boolean;
  107295. static set EmissiveTextureEnabled(value: boolean);
  107296. private static _SpecularTextureEnabled;
  107297. /**
  107298. * Are specular textures enabled in the application.
  107299. */
  107300. static get SpecularTextureEnabled(): boolean;
  107301. static set SpecularTextureEnabled(value: boolean);
  107302. private static _BumpTextureEnabled;
  107303. /**
  107304. * Are bump textures enabled in the application.
  107305. */
  107306. static get BumpTextureEnabled(): boolean;
  107307. static set BumpTextureEnabled(value: boolean);
  107308. private static _LightmapTextureEnabled;
  107309. /**
  107310. * Are lightmap textures enabled in the application.
  107311. */
  107312. static get LightmapTextureEnabled(): boolean;
  107313. static set LightmapTextureEnabled(value: boolean);
  107314. private static _RefractionTextureEnabled;
  107315. /**
  107316. * Are refraction textures enabled in the application.
  107317. */
  107318. static get RefractionTextureEnabled(): boolean;
  107319. static set RefractionTextureEnabled(value: boolean);
  107320. private static _ColorGradingTextureEnabled;
  107321. /**
  107322. * Are color grading textures enabled in the application.
  107323. */
  107324. static get ColorGradingTextureEnabled(): boolean;
  107325. static set ColorGradingTextureEnabled(value: boolean);
  107326. private static _FresnelEnabled;
  107327. /**
  107328. * Are fresnels enabled in the application.
  107329. */
  107330. static get FresnelEnabled(): boolean;
  107331. static set FresnelEnabled(value: boolean);
  107332. private static _ClearCoatTextureEnabled;
  107333. /**
  107334. * Are clear coat textures enabled in the application.
  107335. */
  107336. static get ClearCoatTextureEnabled(): boolean;
  107337. static set ClearCoatTextureEnabled(value: boolean);
  107338. private static _ClearCoatBumpTextureEnabled;
  107339. /**
  107340. * Are clear coat bump textures enabled in the application.
  107341. */
  107342. static get ClearCoatBumpTextureEnabled(): boolean;
  107343. static set ClearCoatBumpTextureEnabled(value: boolean);
  107344. private static _ClearCoatTintTextureEnabled;
  107345. /**
  107346. * Are clear coat tint textures enabled in the application.
  107347. */
  107348. static get ClearCoatTintTextureEnabled(): boolean;
  107349. static set ClearCoatTintTextureEnabled(value: boolean);
  107350. private static _SheenTextureEnabled;
  107351. /**
  107352. * Are sheen textures enabled in the application.
  107353. */
  107354. static get SheenTextureEnabled(): boolean;
  107355. static set SheenTextureEnabled(value: boolean);
  107356. private static _AnisotropicTextureEnabled;
  107357. /**
  107358. * Are anisotropic textures enabled in the application.
  107359. */
  107360. static get AnisotropicTextureEnabled(): boolean;
  107361. static set AnisotropicTextureEnabled(value: boolean);
  107362. private static _ThicknessTextureEnabled;
  107363. /**
  107364. * Are thickness textures enabled in the application.
  107365. */
  107366. static get ThicknessTextureEnabled(): boolean;
  107367. static set ThicknessTextureEnabled(value: boolean);
  107368. }
  107369. }
  107370. declare module BABYLON {
  107371. /** @hidden */
  107372. export var defaultFragmentDeclaration: {
  107373. name: string;
  107374. shader: string;
  107375. };
  107376. }
  107377. declare module BABYLON {
  107378. /** @hidden */
  107379. export var defaultUboDeclaration: {
  107380. name: string;
  107381. shader: string;
  107382. };
  107383. }
  107384. declare module BABYLON {
  107385. /** @hidden */
  107386. export var lightFragmentDeclaration: {
  107387. name: string;
  107388. shader: string;
  107389. };
  107390. }
  107391. declare module BABYLON {
  107392. /** @hidden */
  107393. export var lightUboDeclaration: {
  107394. name: string;
  107395. shader: string;
  107396. };
  107397. }
  107398. declare module BABYLON {
  107399. /** @hidden */
  107400. export var lightsFragmentFunctions: {
  107401. name: string;
  107402. shader: string;
  107403. };
  107404. }
  107405. declare module BABYLON {
  107406. /** @hidden */
  107407. export var shadowsFragmentFunctions: {
  107408. name: string;
  107409. shader: string;
  107410. };
  107411. }
  107412. declare module BABYLON {
  107413. /** @hidden */
  107414. export var fresnelFunction: {
  107415. name: string;
  107416. shader: string;
  107417. };
  107418. }
  107419. declare module BABYLON {
  107420. /** @hidden */
  107421. export var bumpFragmentMainFunctions: {
  107422. name: string;
  107423. shader: string;
  107424. };
  107425. }
  107426. declare module BABYLON {
  107427. /** @hidden */
  107428. export var bumpFragmentFunctions: {
  107429. name: string;
  107430. shader: string;
  107431. };
  107432. }
  107433. declare module BABYLON {
  107434. /** @hidden */
  107435. export var logDepthDeclaration: {
  107436. name: string;
  107437. shader: string;
  107438. };
  107439. }
  107440. declare module BABYLON {
  107441. /** @hidden */
  107442. export var bumpFragment: {
  107443. name: string;
  107444. shader: string;
  107445. };
  107446. }
  107447. declare module BABYLON {
  107448. /** @hidden */
  107449. export var depthPrePass: {
  107450. name: string;
  107451. shader: string;
  107452. };
  107453. }
  107454. declare module BABYLON {
  107455. /** @hidden */
  107456. export var lightFragment: {
  107457. name: string;
  107458. shader: string;
  107459. };
  107460. }
  107461. declare module BABYLON {
  107462. /** @hidden */
  107463. export var logDepthFragment: {
  107464. name: string;
  107465. shader: string;
  107466. };
  107467. }
  107468. declare module BABYLON {
  107469. /** @hidden */
  107470. export var defaultPixelShader: {
  107471. name: string;
  107472. shader: string;
  107473. };
  107474. }
  107475. declare module BABYLON {
  107476. /** @hidden */
  107477. export var defaultVertexDeclaration: {
  107478. name: string;
  107479. shader: string;
  107480. };
  107481. }
  107482. declare module BABYLON {
  107483. /** @hidden */
  107484. export var bumpVertexDeclaration: {
  107485. name: string;
  107486. shader: string;
  107487. };
  107488. }
  107489. declare module BABYLON {
  107490. /** @hidden */
  107491. export var bumpVertex: {
  107492. name: string;
  107493. shader: string;
  107494. };
  107495. }
  107496. declare module BABYLON {
  107497. /** @hidden */
  107498. export var fogVertex: {
  107499. name: string;
  107500. shader: string;
  107501. };
  107502. }
  107503. declare module BABYLON {
  107504. /** @hidden */
  107505. export var shadowsVertex: {
  107506. name: string;
  107507. shader: string;
  107508. };
  107509. }
  107510. declare module BABYLON {
  107511. /** @hidden */
  107512. export var pointCloudVertex: {
  107513. name: string;
  107514. shader: string;
  107515. };
  107516. }
  107517. declare module BABYLON {
  107518. /** @hidden */
  107519. export var logDepthVertex: {
  107520. name: string;
  107521. shader: string;
  107522. };
  107523. }
  107524. declare module BABYLON {
  107525. /** @hidden */
  107526. export var defaultVertexShader: {
  107527. name: string;
  107528. shader: string;
  107529. };
  107530. }
  107531. declare module BABYLON {
  107532. /**
  107533. * @hidden
  107534. */
  107535. export interface IMaterialDetailMapDefines {
  107536. DETAIL: boolean;
  107537. DETAILDIRECTUV: number;
  107538. DETAIL_NORMALBLENDMETHOD: number;
  107539. /** @hidden */
  107540. _areTexturesDirty: boolean;
  107541. }
  107542. /**
  107543. * Define the code related to the detail map parameters of a material
  107544. *
  107545. * Inspired from:
  107546. * 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
  107547. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107548. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107549. */
  107550. export class DetailMapConfiguration {
  107551. private _texture;
  107552. /**
  107553. * The detail texture of the material.
  107554. */
  107555. texture: Nullable<BaseTexture>;
  107556. /**
  107557. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107558. * Bigger values mean stronger blending
  107559. */
  107560. diffuseBlendLevel: number;
  107561. /**
  107562. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107563. * Bigger values mean stronger blending. Only used with PBR materials
  107564. */
  107565. roughnessBlendLevel: number;
  107566. /**
  107567. * Defines how strong the bump effect from the detail map is
  107568. * Bigger values mean stronger effect
  107569. */
  107570. bumpLevel: number;
  107571. private _normalBlendMethod;
  107572. /**
  107573. * The method used to blend the bump and detail normals together
  107574. */
  107575. normalBlendMethod: number;
  107576. private _isEnabled;
  107577. /**
  107578. * Enable or disable the detail map on this material
  107579. */
  107580. isEnabled: boolean;
  107581. /** @hidden */
  107582. private _internalMarkAllSubMeshesAsTexturesDirty;
  107583. /** @hidden */
  107584. _markAllSubMeshesAsTexturesDirty(): void;
  107585. /**
  107586. * Instantiate a new detail map
  107587. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107588. */
  107589. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107590. /**
  107591. * Gets whether the submesh is ready to be used or not.
  107592. * @param defines the list of "defines" to update.
  107593. * @param scene defines the scene the material belongs to.
  107594. * @returns - boolean indicating that the submesh is ready or not.
  107595. */
  107596. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107597. /**
  107598. * Update the defines for detail map usage
  107599. * @param defines the list of "defines" to update.
  107600. * @param scene defines the scene the material belongs to.
  107601. */
  107602. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107603. /**
  107604. * Binds the material data.
  107605. * @param uniformBuffer defines the Uniform buffer to fill in.
  107606. * @param scene defines the scene the material belongs to.
  107607. * @param isFrozen defines whether the material is frozen or not.
  107608. */
  107609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107610. /**
  107611. * Checks to see if a texture is used in the material.
  107612. * @param texture - Base texture to use.
  107613. * @returns - Boolean specifying if a texture is used in the material.
  107614. */
  107615. hasTexture(texture: BaseTexture): boolean;
  107616. /**
  107617. * Returns an array of the actively used textures.
  107618. * @param activeTextures Array of BaseTextures
  107619. */
  107620. getActiveTextures(activeTextures: BaseTexture[]): void;
  107621. /**
  107622. * Returns the animatable textures.
  107623. * @param animatables Array of animatable textures.
  107624. */
  107625. getAnimatables(animatables: IAnimatable[]): void;
  107626. /**
  107627. * Disposes the resources of the material.
  107628. * @param forceDisposeTextures - Forces the disposal of all textures.
  107629. */
  107630. dispose(forceDisposeTextures?: boolean): void;
  107631. /**
  107632. * Get the current class name useful for serialization or dynamic coding.
  107633. * @returns "DetailMap"
  107634. */
  107635. getClassName(): string;
  107636. /**
  107637. * Add the required uniforms to the current list.
  107638. * @param uniforms defines the current uniform list.
  107639. */
  107640. static AddUniforms(uniforms: string[]): void;
  107641. /**
  107642. * Add the required samplers to the current list.
  107643. * @param samplers defines the current sampler list.
  107644. */
  107645. static AddSamplers(samplers: string[]): void;
  107646. /**
  107647. * Add the required uniforms to the current buffer.
  107648. * @param uniformBuffer defines the current uniform buffer.
  107649. */
  107650. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107651. /**
  107652. * Makes a duplicate of the current instance into another one.
  107653. * @param detailMap define the instance where to copy the info
  107654. */
  107655. copyTo(detailMap: DetailMapConfiguration): void;
  107656. /**
  107657. * Serializes this detail map instance
  107658. * @returns - An object with the serialized instance.
  107659. */
  107660. serialize(): any;
  107661. /**
  107662. * Parses a detail map setting from a serialized object.
  107663. * @param source - Serialized object.
  107664. * @param scene Defines the scene we are parsing for
  107665. * @param rootUrl Defines the rootUrl to load from
  107666. */
  107667. parse(source: any, scene: Scene, rootUrl: string): void;
  107668. }
  107669. }
  107670. declare module BABYLON {
  107671. /** @hidden */
  107672. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107673. MAINUV1: boolean;
  107674. MAINUV2: boolean;
  107675. DIFFUSE: boolean;
  107676. DIFFUSEDIRECTUV: number;
  107677. DETAIL: boolean;
  107678. DETAILDIRECTUV: number;
  107679. DETAIL_NORMALBLENDMETHOD: number;
  107680. AMBIENT: boolean;
  107681. AMBIENTDIRECTUV: number;
  107682. OPACITY: boolean;
  107683. OPACITYDIRECTUV: number;
  107684. OPACITYRGB: boolean;
  107685. REFLECTION: boolean;
  107686. EMISSIVE: boolean;
  107687. EMISSIVEDIRECTUV: number;
  107688. SPECULAR: boolean;
  107689. SPECULARDIRECTUV: number;
  107690. BUMP: boolean;
  107691. BUMPDIRECTUV: number;
  107692. PARALLAX: boolean;
  107693. PARALLAXOCCLUSION: boolean;
  107694. SPECULAROVERALPHA: boolean;
  107695. CLIPPLANE: boolean;
  107696. CLIPPLANE2: boolean;
  107697. CLIPPLANE3: boolean;
  107698. CLIPPLANE4: boolean;
  107699. CLIPPLANE5: boolean;
  107700. CLIPPLANE6: boolean;
  107701. ALPHATEST: boolean;
  107702. DEPTHPREPASS: boolean;
  107703. ALPHAFROMDIFFUSE: boolean;
  107704. POINTSIZE: boolean;
  107705. FOG: boolean;
  107706. SPECULARTERM: boolean;
  107707. DIFFUSEFRESNEL: boolean;
  107708. OPACITYFRESNEL: boolean;
  107709. REFLECTIONFRESNEL: boolean;
  107710. REFRACTIONFRESNEL: boolean;
  107711. EMISSIVEFRESNEL: boolean;
  107712. FRESNEL: boolean;
  107713. NORMAL: boolean;
  107714. UV1: boolean;
  107715. UV2: boolean;
  107716. VERTEXCOLOR: boolean;
  107717. VERTEXALPHA: boolean;
  107718. NUM_BONE_INFLUENCERS: number;
  107719. BonesPerMesh: number;
  107720. BONETEXTURE: boolean;
  107721. INSTANCES: boolean;
  107722. THIN_INSTANCES: boolean;
  107723. GLOSSINESS: boolean;
  107724. ROUGHNESS: boolean;
  107725. EMISSIVEASILLUMINATION: boolean;
  107726. LINKEMISSIVEWITHDIFFUSE: boolean;
  107727. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107728. LIGHTMAP: boolean;
  107729. LIGHTMAPDIRECTUV: number;
  107730. OBJECTSPACE_NORMALMAP: boolean;
  107731. USELIGHTMAPASSHADOWMAP: boolean;
  107732. REFLECTIONMAP_3D: boolean;
  107733. REFLECTIONMAP_SPHERICAL: boolean;
  107734. REFLECTIONMAP_PLANAR: boolean;
  107735. REFLECTIONMAP_CUBIC: boolean;
  107736. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107737. REFLECTIONMAP_PROJECTION: boolean;
  107738. REFLECTIONMAP_SKYBOX: boolean;
  107739. REFLECTIONMAP_EXPLICIT: boolean;
  107740. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107741. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107742. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107743. INVERTCUBICMAP: boolean;
  107744. LOGARITHMICDEPTH: boolean;
  107745. REFRACTION: boolean;
  107746. REFRACTIONMAP_3D: boolean;
  107747. REFLECTIONOVERALPHA: boolean;
  107748. TWOSIDEDLIGHTING: boolean;
  107749. SHADOWFLOAT: boolean;
  107750. MORPHTARGETS: boolean;
  107751. MORPHTARGETS_NORMAL: boolean;
  107752. MORPHTARGETS_TANGENT: boolean;
  107753. MORPHTARGETS_UV: boolean;
  107754. NUM_MORPH_INFLUENCERS: number;
  107755. NONUNIFORMSCALING: boolean;
  107756. PREMULTIPLYALPHA: boolean;
  107757. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107758. ALPHABLEND: boolean;
  107759. PREPASS: boolean;
  107760. SCENE_MRT_COUNT: number;
  107761. RGBDLIGHTMAP: boolean;
  107762. RGBDREFLECTION: boolean;
  107763. RGBDREFRACTION: boolean;
  107764. IMAGEPROCESSING: boolean;
  107765. VIGNETTE: boolean;
  107766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107767. VIGNETTEBLENDMODEOPAQUE: boolean;
  107768. TONEMAPPING: boolean;
  107769. TONEMAPPING_ACES: boolean;
  107770. CONTRAST: boolean;
  107771. COLORCURVES: boolean;
  107772. COLORGRADING: boolean;
  107773. COLORGRADING3D: boolean;
  107774. SAMPLER3DGREENDEPTH: boolean;
  107775. SAMPLER3DBGRMAP: boolean;
  107776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107777. MULTIVIEW: boolean;
  107778. /**
  107779. * If the reflection texture on this material is in linear color space
  107780. * @hidden
  107781. */
  107782. IS_REFLECTION_LINEAR: boolean;
  107783. /**
  107784. * If the refraction texture on this material is in linear color space
  107785. * @hidden
  107786. */
  107787. IS_REFRACTION_LINEAR: boolean;
  107788. EXPOSURE: boolean;
  107789. constructor();
  107790. setReflectionMode(modeToEnable: string): void;
  107791. }
  107792. /**
  107793. * This is the default material used in Babylon. It is the best trade off between quality
  107794. * and performances.
  107795. * @see https://doc.babylonjs.com/babylon101/materials
  107796. */
  107797. export class StandardMaterial extends PushMaterial {
  107798. private _diffuseTexture;
  107799. /**
  107800. * The basic texture of the material as viewed under a light.
  107801. */
  107802. diffuseTexture: Nullable<BaseTexture>;
  107803. private _ambientTexture;
  107804. /**
  107805. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107806. */
  107807. ambientTexture: Nullable<BaseTexture>;
  107808. private _opacityTexture;
  107809. /**
  107810. * Define the transparency of the material from a texture.
  107811. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107812. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107813. */
  107814. opacityTexture: Nullable<BaseTexture>;
  107815. private _reflectionTexture;
  107816. /**
  107817. * Define the texture used to display the reflection.
  107818. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107819. */
  107820. reflectionTexture: Nullable<BaseTexture>;
  107821. private _emissiveTexture;
  107822. /**
  107823. * Define texture of the material as if self lit.
  107824. * This will be mixed in the final result even in the absence of light.
  107825. */
  107826. emissiveTexture: Nullable<BaseTexture>;
  107827. private _specularTexture;
  107828. /**
  107829. * Define how the color and intensity of the highlight given by the light in the material.
  107830. */
  107831. specularTexture: Nullable<BaseTexture>;
  107832. private _bumpTexture;
  107833. /**
  107834. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107835. * 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.
  107836. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  107837. */
  107838. bumpTexture: Nullable<BaseTexture>;
  107839. private _lightmapTexture;
  107840. /**
  107841. * Complex lighting can be computationally expensive to compute at runtime.
  107842. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107843. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  107844. */
  107845. lightmapTexture: Nullable<BaseTexture>;
  107846. private _refractionTexture;
  107847. /**
  107848. * Define the texture used to display the refraction.
  107849. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107850. */
  107851. refractionTexture: Nullable<BaseTexture>;
  107852. /**
  107853. * The color of the material lit by the environmental background lighting.
  107854. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107855. */
  107856. ambientColor: Color3;
  107857. /**
  107858. * The basic color of the material as viewed under a light.
  107859. */
  107860. diffuseColor: Color3;
  107861. /**
  107862. * Define how the color and intensity of the highlight given by the light in the material.
  107863. */
  107864. specularColor: Color3;
  107865. /**
  107866. * Define the color of the material as if self lit.
  107867. * This will be mixed in the final result even in the absence of light.
  107868. */
  107869. emissiveColor: Color3;
  107870. /**
  107871. * Defines how sharp are the highlights in the material.
  107872. * The bigger the value the sharper giving a more glossy feeling to the result.
  107873. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107874. */
  107875. specularPower: number;
  107876. private _useAlphaFromDiffuseTexture;
  107877. /**
  107878. * Does the transparency come from the diffuse texture alpha channel.
  107879. */
  107880. useAlphaFromDiffuseTexture: boolean;
  107881. private _useEmissiveAsIllumination;
  107882. /**
  107883. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107884. */
  107885. useEmissiveAsIllumination: boolean;
  107886. private _linkEmissiveWithDiffuse;
  107887. /**
  107888. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107889. * the emissive level when the final color is close to one.
  107890. */
  107891. linkEmissiveWithDiffuse: boolean;
  107892. private _useSpecularOverAlpha;
  107893. /**
  107894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107896. */
  107897. useSpecularOverAlpha: boolean;
  107898. private _useReflectionOverAlpha;
  107899. /**
  107900. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107901. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107902. */
  107903. useReflectionOverAlpha: boolean;
  107904. private _disableLighting;
  107905. /**
  107906. * Does lights from the scene impacts this material.
  107907. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107908. */
  107909. disableLighting: boolean;
  107910. private _useObjectSpaceNormalMap;
  107911. /**
  107912. * Allows using an object space normal map (instead of tangent space).
  107913. */
  107914. useObjectSpaceNormalMap: boolean;
  107915. private _useParallax;
  107916. /**
  107917. * Is parallax enabled or not.
  107918. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107919. */
  107920. useParallax: boolean;
  107921. private _useParallaxOcclusion;
  107922. /**
  107923. * Is parallax occlusion enabled or not.
  107924. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107925. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  107926. */
  107927. useParallaxOcclusion: boolean;
  107928. /**
  107929. * 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.
  107930. */
  107931. parallaxScaleBias: number;
  107932. private _roughness;
  107933. /**
  107934. * Helps to define how blurry the reflections should appears in the material.
  107935. */
  107936. roughness: number;
  107937. /**
  107938. * In case of refraction, define the value of the index of refraction.
  107939. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107940. */
  107941. indexOfRefraction: number;
  107942. /**
  107943. * Invert the refraction texture alongside the y axis.
  107944. * It can be useful with procedural textures or probe for instance.
  107945. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107946. */
  107947. invertRefractionY: boolean;
  107948. /**
  107949. * Defines the alpha limits in alpha test mode.
  107950. */
  107951. alphaCutOff: number;
  107952. private _useLightmapAsShadowmap;
  107953. /**
  107954. * In case of light mapping, define whether the map contains light or shadow informations.
  107955. */
  107956. useLightmapAsShadowmap: boolean;
  107957. private _diffuseFresnelParameters;
  107958. /**
  107959. * Define the diffuse fresnel parameters of the material.
  107960. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107961. */
  107962. diffuseFresnelParameters: FresnelParameters;
  107963. private _opacityFresnelParameters;
  107964. /**
  107965. * Define the opacity fresnel parameters of the material.
  107966. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107967. */
  107968. opacityFresnelParameters: FresnelParameters;
  107969. private _reflectionFresnelParameters;
  107970. /**
  107971. * Define the reflection fresnel parameters of the material.
  107972. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107973. */
  107974. reflectionFresnelParameters: FresnelParameters;
  107975. private _refractionFresnelParameters;
  107976. /**
  107977. * Define the refraction fresnel parameters of the material.
  107978. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107979. */
  107980. refractionFresnelParameters: FresnelParameters;
  107981. private _emissiveFresnelParameters;
  107982. /**
  107983. * Define the emissive fresnel parameters of the material.
  107984. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107985. */
  107986. emissiveFresnelParameters: FresnelParameters;
  107987. private _useReflectionFresnelFromSpecular;
  107988. /**
  107989. * If true automatically deducts the fresnels values from the material specularity.
  107990. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107991. */
  107992. useReflectionFresnelFromSpecular: boolean;
  107993. private _useGlossinessFromSpecularMapAlpha;
  107994. /**
  107995. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107996. */
  107997. useGlossinessFromSpecularMapAlpha: boolean;
  107998. private _maxSimultaneousLights;
  107999. /**
  108000. * Defines the maximum number of lights that can be used in the material
  108001. */
  108002. maxSimultaneousLights: number;
  108003. private _invertNormalMapX;
  108004. /**
  108005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108006. */
  108007. invertNormalMapX: boolean;
  108008. private _invertNormalMapY;
  108009. /**
  108010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108011. */
  108012. invertNormalMapY: boolean;
  108013. private _twoSidedLighting;
  108014. /**
  108015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108016. */
  108017. twoSidedLighting: boolean;
  108018. /**
  108019. * Default configuration related to image processing available in the standard Material.
  108020. */
  108021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108022. /**
  108023. * Gets the image processing configuration used either in this material.
  108024. */
  108025. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108026. /**
  108027. * Sets the Default image processing configuration used either in the this material.
  108028. *
  108029. * If sets to null, the scene one is in use.
  108030. */
  108031. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108032. /**
  108033. * Keep track of the image processing observer to allow dispose and replace.
  108034. */
  108035. private _imageProcessingObserver;
  108036. /**
  108037. * Attaches a new image processing configuration to the Standard Material.
  108038. * @param configuration
  108039. */
  108040. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108041. /**
  108042. * Gets wether the color curves effect is enabled.
  108043. */
  108044. get cameraColorCurvesEnabled(): boolean;
  108045. /**
  108046. * Sets wether the color curves effect is enabled.
  108047. */
  108048. set cameraColorCurvesEnabled(value: boolean);
  108049. /**
  108050. * Gets wether the color grading effect is enabled.
  108051. */
  108052. get cameraColorGradingEnabled(): boolean;
  108053. /**
  108054. * Gets wether the color grading effect is enabled.
  108055. */
  108056. set cameraColorGradingEnabled(value: boolean);
  108057. /**
  108058. * Gets wether tonemapping is enabled or not.
  108059. */
  108060. get cameraToneMappingEnabled(): boolean;
  108061. /**
  108062. * Sets wether tonemapping is enabled or not
  108063. */
  108064. set cameraToneMappingEnabled(value: boolean);
  108065. /**
  108066. * The camera exposure used on this material.
  108067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108068. * This corresponds to a photographic exposure.
  108069. */
  108070. get cameraExposure(): number;
  108071. /**
  108072. * The camera exposure used on this material.
  108073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108074. * This corresponds to a photographic exposure.
  108075. */
  108076. set cameraExposure(value: number);
  108077. /**
  108078. * Gets The camera contrast used on this material.
  108079. */
  108080. get cameraContrast(): number;
  108081. /**
  108082. * Sets The camera contrast used on this material.
  108083. */
  108084. set cameraContrast(value: number);
  108085. /**
  108086. * Gets the Color Grading 2D Lookup Texture.
  108087. */
  108088. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108089. /**
  108090. * Sets the Color Grading 2D Lookup Texture.
  108091. */
  108092. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108093. /**
  108094. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108095. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108096. * 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;
  108097. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108098. */
  108099. get cameraColorCurves(): Nullable<ColorCurves>;
  108100. /**
  108101. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108102. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108103. * 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;
  108104. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108105. */
  108106. set cameraColorCurves(value: Nullable<ColorCurves>);
  108107. /**
  108108. * Defines the detail map parameters for the material.
  108109. */
  108110. readonly detailMap: DetailMapConfiguration;
  108111. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108112. protected _worldViewProjectionMatrix: Matrix;
  108113. protected _globalAmbientColor: Color3;
  108114. protected _useLogarithmicDepth: boolean;
  108115. protected _rebuildInParallel: boolean;
  108116. /**
  108117. * Instantiates a new standard material.
  108118. * This is the default material used in Babylon. It is the best trade off between quality
  108119. * and performances.
  108120. * @see https://doc.babylonjs.com/babylon101/materials
  108121. * @param name Define the name of the material in the scene
  108122. * @param scene Define the scene the material belong to
  108123. */
  108124. constructor(name: string, scene: Scene);
  108125. /**
  108126. * Gets a boolean indicating that current material needs to register RTT
  108127. */
  108128. get hasRenderTargetTextures(): boolean;
  108129. /**
  108130. * Gets the current class name of the material e.g. "StandardMaterial"
  108131. * Mainly use in serialization.
  108132. * @returns the class name
  108133. */
  108134. getClassName(): string;
  108135. /**
  108136. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108137. * You can try switching to logarithmic depth.
  108138. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108139. */
  108140. get useLogarithmicDepth(): boolean;
  108141. set useLogarithmicDepth(value: boolean);
  108142. /**
  108143. * Specifies if the material will require alpha blending
  108144. * @returns a boolean specifying if alpha blending is needed
  108145. */
  108146. needAlphaBlending(): boolean;
  108147. /**
  108148. * Specifies if this material should be rendered in alpha test mode
  108149. * @returns a boolean specifying if an alpha test is needed.
  108150. */
  108151. needAlphaTesting(): boolean;
  108152. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108153. /**
  108154. * Get the texture used for alpha test purpose.
  108155. * @returns the diffuse texture in case of the standard material.
  108156. */
  108157. getAlphaTestTexture(): Nullable<BaseTexture>;
  108158. /**
  108159. * Get if the submesh is ready to be used and all its information available.
  108160. * Child classes can use it to update shaders
  108161. * @param mesh defines the mesh to check
  108162. * @param subMesh defines which submesh to check
  108163. * @param useInstances specifies that instances should be used
  108164. * @returns a boolean indicating that the submesh is ready or not
  108165. */
  108166. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108167. /**
  108168. * Builds the material UBO layouts.
  108169. * Used internally during the effect preparation.
  108170. */
  108171. buildUniformLayout(): void;
  108172. /**
  108173. * Unbinds the material from the mesh
  108174. */
  108175. unbind(): void;
  108176. /**
  108177. * Binds the submesh to this material by preparing the effect and shader to draw
  108178. * @param world defines the world transformation matrix
  108179. * @param mesh defines the mesh containing the submesh
  108180. * @param subMesh defines the submesh to bind the material to
  108181. */
  108182. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108183. /**
  108184. * Get the list of animatables in the material.
  108185. * @returns the list of animatables object used in the material
  108186. */
  108187. getAnimatables(): IAnimatable[];
  108188. /**
  108189. * Gets the active textures from the material
  108190. * @returns an array of textures
  108191. */
  108192. getActiveTextures(): BaseTexture[];
  108193. /**
  108194. * Specifies if the material uses a texture
  108195. * @param texture defines the texture to check against the material
  108196. * @returns a boolean specifying if the material uses the texture
  108197. */
  108198. hasTexture(texture: BaseTexture): boolean;
  108199. /**
  108200. * Disposes the material
  108201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108203. */
  108204. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108205. /**
  108206. * Makes a duplicate of the material, and gives it a new name
  108207. * @param name defines the new name for the duplicated material
  108208. * @returns the cloned material
  108209. */
  108210. clone(name: string): StandardMaterial;
  108211. /**
  108212. * Serializes this material in a JSON representation
  108213. * @returns the serialized material object
  108214. */
  108215. serialize(): any;
  108216. /**
  108217. * Creates a standard material from parsed material data
  108218. * @param source defines the JSON representation of the material
  108219. * @param scene defines the hosting scene
  108220. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108221. * @returns a new standard material
  108222. */
  108223. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108224. /**
  108225. * Are diffuse textures enabled in the application.
  108226. */
  108227. static get DiffuseTextureEnabled(): boolean;
  108228. static set DiffuseTextureEnabled(value: boolean);
  108229. /**
  108230. * Are detail textures enabled in the application.
  108231. */
  108232. static get DetailTextureEnabled(): boolean;
  108233. static set DetailTextureEnabled(value: boolean);
  108234. /**
  108235. * Are ambient textures enabled in the application.
  108236. */
  108237. static get AmbientTextureEnabled(): boolean;
  108238. static set AmbientTextureEnabled(value: boolean);
  108239. /**
  108240. * Are opacity textures enabled in the application.
  108241. */
  108242. static get OpacityTextureEnabled(): boolean;
  108243. static set OpacityTextureEnabled(value: boolean);
  108244. /**
  108245. * Are reflection textures enabled in the application.
  108246. */
  108247. static get ReflectionTextureEnabled(): boolean;
  108248. static set ReflectionTextureEnabled(value: boolean);
  108249. /**
  108250. * Are emissive textures enabled in the application.
  108251. */
  108252. static get EmissiveTextureEnabled(): boolean;
  108253. static set EmissiveTextureEnabled(value: boolean);
  108254. /**
  108255. * Are specular textures enabled in the application.
  108256. */
  108257. static get SpecularTextureEnabled(): boolean;
  108258. static set SpecularTextureEnabled(value: boolean);
  108259. /**
  108260. * Are bump textures enabled in the application.
  108261. */
  108262. static get BumpTextureEnabled(): boolean;
  108263. static set BumpTextureEnabled(value: boolean);
  108264. /**
  108265. * Are lightmap textures enabled in the application.
  108266. */
  108267. static get LightmapTextureEnabled(): boolean;
  108268. static set LightmapTextureEnabled(value: boolean);
  108269. /**
  108270. * Are refraction textures enabled in the application.
  108271. */
  108272. static get RefractionTextureEnabled(): boolean;
  108273. static set RefractionTextureEnabled(value: boolean);
  108274. /**
  108275. * Are color grading textures enabled in the application.
  108276. */
  108277. static get ColorGradingTextureEnabled(): boolean;
  108278. static set ColorGradingTextureEnabled(value: boolean);
  108279. /**
  108280. * Are fresnels enabled in the application.
  108281. */
  108282. static get FresnelEnabled(): boolean;
  108283. static set FresnelEnabled(value: boolean);
  108284. }
  108285. }
  108286. declare module BABYLON {
  108287. /**
  108288. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108289. *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.
  108290. * The SPS is also a particle system. It provides some methods to manage the particles.
  108291. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108292. *
  108293. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108294. */
  108295. export class SolidParticleSystem implements IDisposable {
  108296. /**
  108297. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108298. * Example : var p = SPS.particles[i];
  108299. */
  108300. particles: SolidParticle[];
  108301. /**
  108302. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108303. */
  108304. nbParticles: number;
  108305. /**
  108306. * If the particles must ever face the camera (default false). Useful for planar particles.
  108307. */
  108308. billboard: boolean;
  108309. /**
  108310. * Recompute normals when adding a shape
  108311. */
  108312. recomputeNormals: boolean;
  108313. /**
  108314. * This a counter ofr your own usage. It's not set by any SPS functions.
  108315. */
  108316. counter: number;
  108317. /**
  108318. * The SPS name. This name is also given to the underlying mesh.
  108319. */
  108320. name: string;
  108321. /**
  108322. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108323. */
  108324. mesh: Mesh;
  108325. /**
  108326. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108327. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108328. */
  108329. vars: any;
  108330. /**
  108331. * This array is populated when the SPS is set as 'pickable'.
  108332. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108333. * Each element of this array is an object `{idx: int, faceId: int}`.
  108334. * `idx` is the picked particle index in the `SPS.particles` array
  108335. * `faceId` is the picked face index counted within this particle.
  108336. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108337. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108338. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108339. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108340. */
  108341. pickedParticles: {
  108342. idx: number;
  108343. faceId: number;
  108344. }[];
  108345. /**
  108346. * This array is populated when the SPS is set as 'pickable'
  108347. * Each key of this array is a submesh index.
  108348. * Each element of this array is a second array defined like this :
  108349. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108350. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108351. * `idx` is the picked particle index in the `SPS.particles` array
  108352. * `faceId` is the picked face index counted within this particle.
  108353. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108354. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108355. */
  108356. pickedBySubMesh: {
  108357. idx: number;
  108358. faceId: number;
  108359. }[][];
  108360. /**
  108361. * This array is populated when `enableDepthSort` is set to true.
  108362. * Each element of this array is an instance of the class DepthSortedParticle.
  108363. */
  108364. depthSortedParticles: DepthSortedParticle[];
  108365. /**
  108366. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108367. * @hidden
  108368. */
  108369. _bSphereOnly: boolean;
  108370. /**
  108371. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108372. * @hidden
  108373. */
  108374. _bSphereRadiusFactor: number;
  108375. private _scene;
  108376. private _positions;
  108377. private _indices;
  108378. private _normals;
  108379. private _colors;
  108380. private _uvs;
  108381. private _indices32;
  108382. private _positions32;
  108383. private _normals32;
  108384. private _fixedNormal32;
  108385. private _colors32;
  108386. private _uvs32;
  108387. private _index;
  108388. private _updatable;
  108389. private _pickable;
  108390. private _isVisibilityBoxLocked;
  108391. private _alwaysVisible;
  108392. private _depthSort;
  108393. private _expandable;
  108394. private _shapeCounter;
  108395. private _copy;
  108396. private _color;
  108397. private _computeParticleColor;
  108398. private _computeParticleTexture;
  108399. private _computeParticleRotation;
  108400. private _computeParticleVertex;
  108401. private _computeBoundingBox;
  108402. private _depthSortParticles;
  108403. private _camera;
  108404. private _mustUnrotateFixedNormals;
  108405. private _particlesIntersect;
  108406. private _needs32Bits;
  108407. private _isNotBuilt;
  108408. private _lastParticleId;
  108409. private _idxOfId;
  108410. private _multimaterialEnabled;
  108411. private _useModelMaterial;
  108412. private _indicesByMaterial;
  108413. private _materialIndexes;
  108414. private _depthSortFunction;
  108415. private _materialSortFunction;
  108416. private _materials;
  108417. private _multimaterial;
  108418. private _materialIndexesById;
  108419. private _defaultMaterial;
  108420. private _autoUpdateSubMeshes;
  108421. private _tmpVertex;
  108422. /**
  108423. * Creates a SPS (Solid Particle System) object.
  108424. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108425. * @param scene (Scene) is the scene in which the SPS is added.
  108426. * @param options defines the options of the sps e.g.
  108427. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108428. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108429. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108430. * * 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.
  108431. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108432. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108433. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108434. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108435. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108436. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108437. */
  108438. constructor(name: string, scene: Scene, options?: {
  108439. updatable?: boolean;
  108440. isPickable?: boolean;
  108441. enableDepthSort?: boolean;
  108442. particleIntersection?: boolean;
  108443. boundingSphereOnly?: boolean;
  108444. bSphereRadiusFactor?: number;
  108445. expandable?: boolean;
  108446. useModelMaterial?: boolean;
  108447. enableMultiMaterial?: boolean;
  108448. });
  108449. /**
  108450. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108451. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108452. * @returns the created mesh
  108453. */
  108454. buildMesh(): Mesh;
  108455. /**
  108456. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108457. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108458. * Thus the particles generated from `digest()` have their property `position` set yet.
  108459. * @param mesh ( Mesh ) is the mesh to be digested
  108460. * @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
  108461. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108462. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108463. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108464. * @returns the current SPS
  108465. */
  108466. digest(mesh: Mesh, options?: {
  108467. facetNb?: number;
  108468. number?: number;
  108469. delta?: number;
  108470. storage?: [];
  108471. }): SolidParticleSystem;
  108472. /**
  108473. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108474. * @hidden
  108475. */
  108476. private _unrotateFixedNormals;
  108477. /**
  108478. * Resets the temporary working copy particle
  108479. * @hidden
  108480. */
  108481. private _resetCopy;
  108482. /**
  108483. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108484. * @param p the current index in the positions array to be updated
  108485. * @param ind the current index in the indices array
  108486. * @param shape a Vector3 array, the shape geometry
  108487. * @param positions the positions array to be updated
  108488. * @param meshInd the shape indices array
  108489. * @param indices the indices array to be updated
  108490. * @param meshUV the shape uv array
  108491. * @param uvs the uv array to be updated
  108492. * @param meshCol the shape color array
  108493. * @param colors the color array to be updated
  108494. * @param meshNor the shape normals array
  108495. * @param normals the normals array to be updated
  108496. * @param idx the particle index
  108497. * @param idxInShape the particle index in its shape
  108498. * @param options the addShape() method passed options
  108499. * @model the particle model
  108500. * @hidden
  108501. */
  108502. private _meshBuilder;
  108503. /**
  108504. * Returns a shape Vector3 array from positions float array
  108505. * @param positions float array
  108506. * @returns a vector3 array
  108507. * @hidden
  108508. */
  108509. private _posToShape;
  108510. /**
  108511. * Returns a shapeUV array from a float uvs (array deep copy)
  108512. * @param uvs as a float array
  108513. * @returns a shapeUV array
  108514. * @hidden
  108515. */
  108516. private _uvsToShapeUV;
  108517. /**
  108518. * Adds a new particle object in the particles array
  108519. * @param idx particle index in particles array
  108520. * @param id particle id
  108521. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108522. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108523. * @param model particle ModelShape object
  108524. * @param shapeId model shape identifier
  108525. * @param idxInShape index of the particle in the current model
  108526. * @param bInfo model bounding info object
  108527. * @param storage target storage array, if any
  108528. * @hidden
  108529. */
  108530. private _addParticle;
  108531. /**
  108532. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108533. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108534. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108535. * @param nb (positive integer) the number of particles to be created from this model
  108536. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108537. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108538. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108539. * @returns the number of shapes in the system
  108540. */
  108541. addShape(mesh: Mesh, nb: number, options?: {
  108542. positionFunction?: any;
  108543. vertexFunction?: any;
  108544. storage?: [];
  108545. }): number;
  108546. /**
  108547. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108548. * @hidden
  108549. */
  108550. private _rebuildParticle;
  108551. /**
  108552. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108553. * @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.
  108554. * @returns the SPS.
  108555. */
  108556. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108557. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108558. * Returns an array with the removed particles.
  108559. * 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.
  108560. * The SPS can't be empty so at least one particle needs to remain in place.
  108561. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108562. * @param start index of the first particle to remove
  108563. * @param end index of the last particle to remove (included)
  108564. * @returns an array populated with the removed particles
  108565. */
  108566. removeParticles(start: number, end: number): SolidParticle[];
  108567. /**
  108568. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108569. * @param solidParticleArray an array populated with Solid Particles objects
  108570. * @returns the SPS
  108571. */
  108572. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108573. /**
  108574. * Creates a new particle and modifies the SPS mesh geometry :
  108575. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108576. * - calls _addParticle() to populate the particle array
  108577. * factorized code from addShape() and insertParticlesFromArray()
  108578. * @param idx particle index in the particles array
  108579. * @param i particle index in its shape
  108580. * @param modelShape particle ModelShape object
  108581. * @param shape shape vertex array
  108582. * @param meshInd shape indices array
  108583. * @param meshUV shape uv array
  108584. * @param meshCol shape color array
  108585. * @param meshNor shape normals array
  108586. * @param bbInfo shape bounding info
  108587. * @param storage target particle storage
  108588. * @options addShape() passed options
  108589. * @hidden
  108590. */
  108591. private _insertNewParticle;
  108592. /**
  108593. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108594. * This method calls `updateParticle()` for each particle of the SPS.
  108595. * For an animated SPS, it is usually called within the render loop.
  108596. * 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.
  108597. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108598. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108599. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108600. * @returns the SPS.
  108601. */
  108602. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108603. /**
  108604. * Disposes the SPS.
  108605. */
  108606. dispose(): void;
  108607. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108608. * idx is the particle index in the SPS
  108609. * faceId is the picked face index counted within this particle.
  108610. * Returns null if the pickInfo can't identify a picked particle.
  108611. * @param pickingInfo (PickingInfo object)
  108612. * @returns {idx: number, faceId: number} or null
  108613. */
  108614. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108615. idx: number;
  108616. faceId: number;
  108617. }>;
  108618. /**
  108619. * Returns a SolidParticle object from its identifier : particle.id
  108620. * @param id (integer) the particle Id
  108621. * @returns the searched particle or null if not found in the SPS.
  108622. */
  108623. getParticleById(id: number): Nullable<SolidParticle>;
  108624. /**
  108625. * Returns a new array populated with the particles having the passed shapeId.
  108626. * @param shapeId (integer) the shape identifier
  108627. * @returns a new solid particle array
  108628. */
  108629. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108630. /**
  108631. * Populates the passed array "ref" with the particles having the passed shapeId.
  108632. * @param shapeId the shape identifier
  108633. * @returns the SPS
  108634. * @param ref
  108635. */
  108636. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108637. /**
  108638. * Computes the required SubMeshes according the materials assigned to the particles.
  108639. * @returns the solid particle system.
  108640. * Does nothing if called before the SPS mesh is built.
  108641. */
  108642. computeSubMeshes(): SolidParticleSystem;
  108643. /**
  108644. * Sorts the solid particles by material when MultiMaterial is enabled.
  108645. * Updates the indices32 array.
  108646. * Updates the indicesByMaterial array.
  108647. * Updates the mesh indices array.
  108648. * @returns the SPS
  108649. * @hidden
  108650. */
  108651. private _sortParticlesByMaterial;
  108652. /**
  108653. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108654. * @hidden
  108655. */
  108656. private _setMaterialIndexesById;
  108657. /**
  108658. * Returns an array with unique values of Materials from the passed array
  108659. * @param array the material array to be checked and filtered
  108660. * @hidden
  108661. */
  108662. private _filterUniqueMaterialId;
  108663. /**
  108664. * Sets a new Standard Material as _defaultMaterial if not already set.
  108665. * @hidden
  108666. */
  108667. private _setDefaultMaterial;
  108668. /**
  108669. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108670. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108671. * @returns the SPS.
  108672. */
  108673. refreshVisibleSize(): SolidParticleSystem;
  108674. /**
  108675. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108676. * @param size the size (float) of the visibility box
  108677. * note : this doesn't lock the SPS mesh bounding box.
  108678. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108679. */
  108680. setVisibilityBox(size: number): void;
  108681. /**
  108682. * Gets whether the SPS as always visible or not
  108683. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108684. */
  108685. get isAlwaysVisible(): boolean;
  108686. /**
  108687. * Sets the SPS as always visible or not
  108688. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108689. */
  108690. set isAlwaysVisible(val: boolean);
  108691. /**
  108692. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108693. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108694. */
  108695. set isVisibilityBoxLocked(val: boolean);
  108696. /**
  108697. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108698. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108699. */
  108700. get isVisibilityBoxLocked(): boolean;
  108701. /**
  108702. * Tells to `setParticles()` to compute the particle rotations or not.
  108703. * Default value : true. The SPS is faster when it's set to false.
  108704. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108705. */
  108706. set computeParticleRotation(val: boolean);
  108707. /**
  108708. * Tells to `setParticles()` to compute the particle colors or not.
  108709. * Default value : true. The SPS is faster when it's set to false.
  108710. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108711. */
  108712. set computeParticleColor(val: boolean);
  108713. set computeParticleTexture(val: boolean);
  108714. /**
  108715. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108716. * Default value : false. The SPS is faster when it's set to false.
  108717. * Note : the particle custom vertex positions aren't stored values.
  108718. */
  108719. set computeParticleVertex(val: boolean);
  108720. /**
  108721. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108722. */
  108723. set computeBoundingBox(val: boolean);
  108724. /**
  108725. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108726. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108727. * Default : `true`
  108728. */
  108729. set depthSortParticles(val: boolean);
  108730. /**
  108731. * Gets if `setParticles()` computes the particle rotations or not.
  108732. * Default value : true. The SPS is faster when it's set to false.
  108733. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108734. */
  108735. get computeParticleRotation(): boolean;
  108736. /**
  108737. * Gets if `setParticles()` computes the particle colors or not.
  108738. * Default value : true. The SPS is faster when it's set to false.
  108739. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108740. */
  108741. get computeParticleColor(): boolean;
  108742. /**
  108743. * Gets if `setParticles()` computes the particle textures or not.
  108744. * Default value : true. The SPS is faster when it's set to false.
  108745. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108746. */
  108747. get computeParticleTexture(): boolean;
  108748. /**
  108749. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108750. * Default value : false. The SPS is faster when it's set to false.
  108751. * Note : the particle custom vertex positions aren't stored values.
  108752. */
  108753. get computeParticleVertex(): boolean;
  108754. /**
  108755. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108756. */
  108757. get computeBoundingBox(): boolean;
  108758. /**
  108759. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108760. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108761. * Default : `true`
  108762. */
  108763. get depthSortParticles(): boolean;
  108764. /**
  108765. * Gets if the SPS is created as expandable at construction time.
  108766. * Default : `false`
  108767. */
  108768. get expandable(): boolean;
  108769. /**
  108770. * Gets if the SPS supports the Multi Materials
  108771. */
  108772. get multimaterialEnabled(): boolean;
  108773. /**
  108774. * Gets if the SPS uses the model materials for its own multimaterial.
  108775. */
  108776. get useModelMaterial(): boolean;
  108777. /**
  108778. * The SPS used material array.
  108779. */
  108780. get materials(): Material[];
  108781. /**
  108782. * Sets the SPS MultiMaterial from the passed materials.
  108783. * Note : the passed array is internally copied and not used then by reference.
  108784. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108785. */
  108786. setMultiMaterial(materials: Material[]): void;
  108787. /**
  108788. * The SPS computed multimaterial object
  108789. */
  108790. get multimaterial(): MultiMaterial;
  108791. set multimaterial(mm: MultiMaterial);
  108792. /**
  108793. * If the subMeshes must be updated on the next call to setParticles()
  108794. */
  108795. get autoUpdateSubMeshes(): boolean;
  108796. set autoUpdateSubMeshes(val: boolean);
  108797. /**
  108798. * This function does nothing. It may be overwritten to set all the particle first values.
  108799. * The SPS doesn't call this function, you may have to call it by your own.
  108800. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108801. */
  108802. initParticles(): void;
  108803. /**
  108804. * This function does nothing. It may be overwritten to recycle a particle.
  108805. * The SPS doesn't call this function, you may have to call it by your own.
  108806. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108807. * @param particle The particle to recycle
  108808. * @returns the recycled particle
  108809. */
  108810. recycleParticle(particle: SolidParticle): SolidParticle;
  108811. /**
  108812. * Updates a particle : this function should be overwritten by the user.
  108813. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108814. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108815. * @example : just set a particle position or velocity and recycle conditions
  108816. * @param particle The particle to update
  108817. * @returns the updated particle
  108818. */
  108819. updateParticle(particle: SolidParticle): SolidParticle;
  108820. /**
  108821. * Updates a vertex of a particle : it can be overwritten by the user.
  108822. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108823. * @param particle the current particle
  108824. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108825. * @param pt the index of the current vertex in the particle shape
  108826. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108827. * @example : just set a vertex particle position or color
  108828. * @returns the sps
  108829. */
  108830. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108831. /**
  108832. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108833. * This does nothing and may be overwritten by the user.
  108834. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108835. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108836. * @param update the boolean update value actually passed to setParticles()
  108837. */
  108838. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108839. /**
  108840. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108841. * This will be passed three parameters.
  108842. * This does nothing and may be overwritten by the user.
  108843. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108844. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108845. * @param update the boolean update value actually passed to setParticles()
  108846. */
  108847. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108848. }
  108849. }
  108850. declare module BABYLON {
  108851. /**
  108852. * Represents one particle of a solid particle system.
  108853. */
  108854. export class SolidParticle {
  108855. /**
  108856. * particle global index
  108857. */
  108858. idx: number;
  108859. /**
  108860. * particle identifier
  108861. */
  108862. id: number;
  108863. /**
  108864. * The color of the particle
  108865. */
  108866. color: Nullable<Color4>;
  108867. /**
  108868. * The world space position of the particle.
  108869. */
  108870. position: Vector3;
  108871. /**
  108872. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108873. */
  108874. rotation: Vector3;
  108875. /**
  108876. * The world space rotation quaternion of the particle.
  108877. */
  108878. rotationQuaternion: Nullable<Quaternion>;
  108879. /**
  108880. * The scaling of the particle.
  108881. */
  108882. scaling: Vector3;
  108883. /**
  108884. * The uvs of the particle.
  108885. */
  108886. uvs: Vector4;
  108887. /**
  108888. * The current speed of the particle.
  108889. */
  108890. velocity: Vector3;
  108891. /**
  108892. * The pivot point in the particle local space.
  108893. */
  108894. pivot: Vector3;
  108895. /**
  108896. * Must the particle be translated from its pivot point in its local space ?
  108897. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108898. * Default : false
  108899. */
  108900. translateFromPivot: boolean;
  108901. /**
  108902. * Is the particle active or not ?
  108903. */
  108904. alive: boolean;
  108905. /**
  108906. * Is the particle visible or not ?
  108907. */
  108908. isVisible: boolean;
  108909. /**
  108910. * Index of this particle in the global "positions" array (Internal use)
  108911. * @hidden
  108912. */
  108913. _pos: number;
  108914. /**
  108915. * @hidden Index of this particle in the global "indices" array (Internal use)
  108916. */
  108917. _ind: number;
  108918. /**
  108919. * @hidden ModelShape of this particle (Internal use)
  108920. */
  108921. _model: ModelShape;
  108922. /**
  108923. * ModelShape id of this particle
  108924. */
  108925. shapeId: number;
  108926. /**
  108927. * Index of the particle in its shape id
  108928. */
  108929. idxInShape: number;
  108930. /**
  108931. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108932. */
  108933. _modelBoundingInfo: BoundingInfo;
  108934. /**
  108935. * @hidden Particle BoundingInfo object (Internal use)
  108936. */
  108937. _boundingInfo: BoundingInfo;
  108938. /**
  108939. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108940. */
  108941. _sps: SolidParticleSystem;
  108942. /**
  108943. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108944. */
  108945. _stillInvisible: boolean;
  108946. /**
  108947. * @hidden Last computed particle rotation matrix
  108948. */
  108949. _rotationMatrix: number[];
  108950. /**
  108951. * Parent particle Id, if any.
  108952. * Default null.
  108953. */
  108954. parentId: Nullable<number>;
  108955. /**
  108956. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108957. */
  108958. materialIndex: Nullable<number>;
  108959. /**
  108960. * Custom object or properties.
  108961. */
  108962. props: Nullable<any>;
  108963. /**
  108964. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108965. * The possible values are :
  108966. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108967. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108968. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108970. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108971. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108972. * */
  108973. cullingStrategy: number;
  108974. /**
  108975. * @hidden Internal global position in the SPS.
  108976. */
  108977. _globalPosition: Vector3;
  108978. /**
  108979. * Creates a Solid Particle object.
  108980. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108981. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108982. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108983. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108984. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108985. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108986. * @param shapeId (integer) is the model shape identifier in the SPS.
  108987. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108988. * @param sps defines the sps it is associated to
  108989. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108990. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108991. */
  108992. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108993. /**
  108994. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108995. * @param target the particle target
  108996. * @returns the current particle
  108997. */
  108998. copyToRef(target: SolidParticle): SolidParticle;
  108999. /**
  109000. * Legacy support, changed scale to scaling
  109001. */
  109002. get scale(): Vector3;
  109003. /**
  109004. * Legacy support, changed scale to scaling
  109005. */
  109006. set scale(scale: Vector3);
  109007. /**
  109008. * Legacy support, changed quaternion to rotationQuaternion
  109009. */
  109010. get quaternion(): Nullable<Quaternion>;
  109011. /**
  109012. * Legacy support, changed quaternion to rotationQuaternion
  109013. */
  109014. set quaternion(q: Nullable<Quaternion>);
  109015. /**
  109016. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109017. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109018. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109019. * @returns true if it intersects
  109020. */
  109021. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109022. /**
  109023. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109024. * A particle is in the frustum if its bounding box intersects the frustum
  109025. * @param frustumPlanes defines the frustum to test
  109026. * @returns true if the particle is in the frustum planes
  109027. */
  109028. isInFrustum(frustumPlanes: Plane[]): boolean;
  109029. /**
  109030. * get the rotation matrix of the particle
  109031. * @hidden
  109032. */
  109033. getRotationMatrix(m: Matrix): void;
  109034. }
  109035. /**
  109036. * Represents the shape of the model used by one particle of a solid particle system.
  109037. * SPS internal tool, don't use it manually.
  109038. */
  109039. export class ModelShape {
  109040. /**
  109041. * The shape id
  109042. * @hidden
  109043. */
  109044. shapeID: number;
  109045. /**
  109046. * flat array of model positions (internal use)
  109047. * @hidden
  109048. */
  109049. _shape: Vector3[];
  109050. /**
  109051. * flat array of model UVs (internal use)
  109052. * @hidden
  109053. */
  109054. _shapeUV: number[];
  109055. /**
  109056. * color array of the model
  109057. * @hidden
  109058. */
  109059. _shapeColors: number[];
  109060. /**
  109061. * indices array of the model
  109062. * @hidden
  109063. */
  109064. _indices: number[];
  109065. /**
  109066. * normals array of the model
  109067. * @hidden
  109068. */
  109069. _normals: number[];
  109070. /**
  109071. * length of the shape in the model indices array (internal use)
  109072. * @hidden
  109073. */
  109074. _indicesLength: number;
  109075. /**
  109076. * Custom position function (internal use)
  109077. * @hidden
  109078. */
  109079. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109080. /**
  109081. * Custom vertex function (internal use)
  109082. * @hidden
  109083. */
  109084. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109085. /**
  109086. * Model material (internal use)
  109087. * @hidden
  109088. */
  109089. _material: Nullable<Material>;
  109090. /**
  109091. * 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.
  109092. * SPS internal tool, don't use it manually.
  109093. * @hidden
  109094. */
  109095. 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>);
  109096. }
  109097. /**
  109098. * Represents a Depth Sorted Particle in the solid particle system.
  109099. * @hidden
  109100. */
  109101. export class DepthSortedParticle {
  109102. /**
  109103. * Particle index
  109104. */
  109105. idx: number;
  109106. /**
  109107. * Index of the particle in the "indices" array
  109108. */
  109109. ind: number;
  109110. /**
  109111. * Length of the particle shape in the "indices" array
  109112. */
  109113. indicesLength: number;
  109114. /**
  109115. * Squared distance from the particle to the camera
  109116. */
  109117. sqDistance: number;
  109118. /**
  109119. * Material index when used with MultiMaterials
  109120. */
  109121. materialIndex: number;
  109122. /**
  109123. * Creates a new sorted particle
  109124. * @param materialIndex
  109125. */
  109126. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109127. }
  109128. /**
  109129. * Represents a solid particle vertex
  109130. */
  109131. export class SolidParticleVertex {
  109132. /**
  109133. * Vertex position
  109134. */
  109135. position: Vector3;
  109136. /**
  109137. * Vertex color
  109138. */
  109139. color: Color4;
  109140. /**
  109141. * Vertex UV
  109142. */
  109143. uv: Vector2;
  109144. /**
  109145. * Creates a new solid particle vertex
  109146. */
  109147. constructor();
  109148. /** Vertex x coordinate */
  109149. get x(): number;
  109150. set x(val: number);
  109151. /** Vertex y coordinate */
  109152. get y(): number;
  109153. set y(val: number);
  109154. /** Vertex z coordinate */
  109155. get z(): number;
  109156. set z(val: number);
  109157. }
  109158. }
  109159. declare module BABYLON {
  109160. /**
  109161. * @hidden
  109162. */
  109163. export class _MeshCollisionData {
  109164. _checkCollisions: boolean;
  109165. _collisionMask: number;
  109166. _collisionGroup: number;
  109167. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109168. _collider: Nullable<Collider>;
  109169. _oldPositionForCollisions: Vector3;
  109170. _diffPositionForCollisions: Vector3;
  109171. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109172. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109173. }
  109174. }
  109175. declare module BABYLON {
  109176. /** @hidden */
  109177. class _FacetDataStorage {
  109178. facetPositions: Vector3[];
  109179. facetNormals: Vector3[];
  109180. facetPartitioning: number[][];
  109181. facetNb: number;
  109182. partitioningSubdivisions: number;
  109183. partitioningBBoxRatio: number;
  109184. facetDataEnabled: boolean;
  109185. facetParameters: any;
  109186. bbSize: Vector3;
  109187. subDiv: {
  109188. max: number;
  109189. X: number;
  109190. Y: number;
  109191. Z: number;
  109192. };
  109193. facetDepthSort: boolean;
  109194. facetDepthSortEnabled: boolean;
  109195. depthSortedIndices: IndicesArray;
  109196. depthSortedFacets: {
  109197. ind: number;
  109198. sqDistance: number;
  109199. }[];
  109200. facetDepthSortFunction: (f1: {
  109201. ind: number;
  109202. sqDistance: number;
  109203. }, f2: {
  109204. ind: number;
  109205. sqDistance: number;
  109206. }) => number;
  109207. facetDepthSortFrom: Vector3;
  109208. facetDepthSortOrigin: Vector3;
  109209. invertedMatrix: Matrix;
  109210. }
  109211. /**
  109212. * @hidden
  109213. **/
  109214. class _InternalAbstractMeshDataInfo {
  109215. _hasVertexAlpha: boolean;
  109216. _useVertexColors: boolean;
  109217. _numBoneInfluencers: number;
  109218. _applyFog: boolean;
  109219. _receiveShadows: boolean;
  109220. _facetData: _FacetDataStorage;
  109221. _visibility: number;
  109222. _skeleton: Nullable<Skeleton>;
  109223. _layerMask: number;
  109224. _computeBonesUsingShaders: boolean;
  109225. _isActive: boolean;
  109226. _onlyForInstances: boolean;
  109227. _isActiveIntermediate: boolean;
  109228. _onlyForInstancesIntermediate: boolean;
  109229. _actAsRegularMesh: boolean;
  109230. }
  109231. /**
  109232. * Class used to store all common mesh properties
  109233. */
  109234. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109235. /** No occlusion */
  109236. static OCCLUSION_TYPE_NONE: number;
  109237. /** Occlusion set to optimisitic */
  109238. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109239. /** Occlusion set to strict */
  109240. static OCCLUSION_TYPE_STRICT: number;
  109241. /** Use an accurante occlusion algorithm */
  109242. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109243. /** Use a conservative occlusion algorithm */
  109244. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109245. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109246. * Test order :
  109247. * Is the bounding sphere outside the frustum ?
  109248. * If not, are the bounding box vertices outside the frustum ?
  109249. * It not, then the cullable object is in the frustum.
  109250. */
  109251. static readonly CULLINGSTRATEGY_STANDARD: number;
  109252. /** Culling strategy : Bounding Sphere Only.
  109253. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109254. * It's also less accurate than the standard because some not visible objects can still be selected.
  109255. * Test : is the bounding sphere outside the frustum ?
  109256. * If not, then the cullable object is in the frustum.
  109257. */
  109258. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109259. /** Culling strategy : Optimistic Inclusion.
  109260. * This in an inclusion test first, then the standard exclusion test.
  109261. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109262. * 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.
  109263. * Anyway, it's as accurate as the standard strategy.
  109264. * Test :
  109265. * Is the cullable object bounding sphere center in the frustum ?
  109266. * If not, apply the default culling strategy.
  109267. */
  109268. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109269. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109270. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109271. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109272. * 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.
  109273. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109274. * Test :
  109275. * Is the cullable object bounding sphere center in the frustum ?
  109276. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109277. */
  109278. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109279. /**
  109280. * No billboard
  109281. */
  109282. static get BILLBOARDMODE_NONE(): number;
  109283. /** Billboard on X axis */
  109284. static get BILLBOARDMODE_X(): number;
  109285. /** Billboard on Y axis */
  109286. static get BILLBOARDMODE_Y(): number;
  109287. /** Billboard on Z axis */
  109288. static get BILLBOARDMODE_Z(): number;
  109289. /** Billboard on all axes */
  109290. static get BILLBOARDMODE_ALL(): number;
  109291. /** Billboard on using position instead of orientation */
  109292. static get BILLBOARDMODE_USE_POSITION(): number;
  109293. /** @hidden */
  109294. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109295. /**
  109296. * The culling strategy to use to check whether the mesh must be rendered or not.
  109297. * This value can be changed at any time and will be used on the next render mesh selection.
  109298. * The possible values are :
  109299. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109300. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109301. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109302. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109303. * Please read each static variable documentation to get details about the culling process.
  109304. * */
  109305. cullingStrategy: number;
  109306. /**
  109307. * Gets the number of facets in the mesh
  109308. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109309. */
  109310. get facetNb(): number;
  109311. /**
  109312. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109313. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109314. */
  109315. get partitioningSubdivisions(): number;
  109316. set partitioningSubdivisions(nb: number);
  109317. /**
  109318. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109319. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109320. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109321. */
  109322. get partitioningBBoxRatio(): number;
  109323. set partitioningBBoxRatio(ratio: number);
  109324. /**
  109325. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109326. * Works only for updatable meshes.
  109327. * Doesn't work with multi-materials
  109328. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109329. */
  109330. get mustDepthSortFacets(): boolean;
  109331. set mustDepthSortFacets(sort: boolean);
  109332. /**
  109333. * The location (Vector3) where the facet depth sort must be computed from.
  109334. * By default, the active camera position.
  109335. * Used only when facet depth sort is enabled
  109336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109337. */
  109338. get facetDepthSortFrom(): Vector3;
  109339. set facetDepthSortFrom(location: Vector3);
  109340. /**
  109341. * gets a boolean indicating if facetData is enabled
  109342. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109343. */
  109344. get isFacetDataEnabled(): boolean;
  109345. /** @hidden */
  109346. _updateNonUniformScalingState(value: boolean): boolean;
  109347. /**
  109348. * An event triggered when this mesh collides with another one
  109349. */
  109350. onCollideObservable: Observable<AbstractMesh>;
  109351. /** Set a function to call when this mesh collides with another one */
  109352. set onCollide(callback: () => void);
  109353. /**
  109354. * An event triggered when the collision's position changes
  109355. */
  109356. onCollisionPositionChangeObservable: Observable<Vector3>;
  109357. /** Set a function to call when the collision's position changes */
  109358. set onCollisionPositionChange(callback: () => void);
  109359. /**
  109360. * An event triggered when material is changed
  109361. */
  109362. onMaterialChangedObservable: Observable<AbstractMesh>;
  109363. /**
  109364. * Gets or sets the orientation for POV movement & rotation
  109365. */
  109366. definedFacingForward: boolean;
  109367. /** @hidden */
  109368. _occlusionQuery: Nullable<WebGLQuery>;
  109369. /** @hidden */
  109370. _renderingGroup: Nullable<RenderingGroup>;
  109371. /**
  109372. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109373. */
  109374. get visibility(): number;
  109375. /**
  109376. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109377. */
  109378. set visibility(value: number);
  109379. /** Gets or sets the alpha index used to sort transparent meshes
  109380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109381. */
  109382. alphaIndex: number;
  109383. /**
  109384. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109385. */
  109386. isVisible: boolean;
  109387. /**
  109388. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109389. */
  109390. isPickable: boolean;
  109391. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109392. showSubMeshesBoundingBox: boolean;
  109393. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109394. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109395. */
  109396. isBlocker: boolean;
  109397. /**
  109398. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109399. */
  109400. enablePointerMoveEvents: boolean;
  109401. /**
  109402. * Specifies the rendering group id for this mesh (0 by default)
  109403. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109404. */
  109405. renderingGroupId: number;
  109406. private _material;
  109407. /** Gets or sets current material */
  109408. get material(): Nullable<Material>;
  109409. set material(value: Nullable<Material>);
  109410. /**
  109411. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109412. * @see https://doc.babylonjs.com/babylon101/shadows
  109413. */
  109414. get receiveShadows(): boolean;
  109415. set receiveShadows(value: boolean);
  109416. /** Defines color to use when rendering outline */
  109417. outlineColor: Color3;
  109418. /** Define width to use when rendering outline */
  109419. outlineWidth: number;
  109420. /** Defines color to use when rendering overlay */
  109421. overlayColor: Color3;
  109422. /** Defines alpha to use when rendering overlay */
  109423. overlayAlpha: number;
  109424. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109425. get hasVertexAlpha(): boolean;
  109426. set hasVertexAlpha(value: boolean);
  109427. /** 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) */
  109428. get useVertexColors(): boolean;
  109429. set useVertexColors(value: boolean);
  109430. /**
  109431. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109432. */
  109433. get computeBonesUsingShaders(): boolean;
  109434. set computeBonesUsingShaders(value: boolean);
  109435. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109436. get numBoneInfluencers(): number;
  109437. set numBoneInfluencers(value: number);
  109438. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109439. get applyFog(): boolean;
  109440. set applyFog(value: boolean);
  109441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109442. useOctreeForRenderingSelection: boolean;
  109443. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109444. useOctreeForPicking: boolean;
  109445. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109446. useOctreeForCollisions: boolean;
  109447. /**
  109448. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109449. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109450. */
  109451. get layerMask(): number;
  109452. set layerMask(value: number);
  109453. /**
  109454. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109455. */
  109456. alwaysSelectAsActiveMesh: boolean;
  109457. /**
  109458. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109459. */
  109460. doNotSyncBoundingInfo: boolean;
  109461. /**
  109462. * Gets or sets the current action manager
  109463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109464. */
  109465. actionManager: Nullable<AbstractActionManager>;
  109466. private _meshCollisionData;
  109467. /**
  109468. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109469. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109470. */
  109471. ellipsoid: Vector3;
  109472. /**
  109473. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109474. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109475. */
  109476. ellipsoidOffset: Vector3;
  109477. /**
  109478. * Gets or sets a collision mask used to mask collisions (default is -1).
  109479. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109480. */
  109481. get collisionMask(): number;
  109482. set collisionMask(mask: number);
  109483. /**
  109484. * Gets or sets the current collision group mask (-1 by default).
  109485. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109486. */
  109487. get collisionGroup(): number;
  109488. set collisionGroup(mask: number);
  109489. /**
  109490. * Gets or sets current surrounding meshes (null by default).
  109491. *
  109492. * By default collision detection is tested against every mesh in the scene.
  109493. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109494. * meshes will be tested for the collision.
  109495. *
  109496. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109497. */
  109498. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109499. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109500. /**
  109501. * Defines edge width used when edgesRenderer is enabled
  109502. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109503. */
  109504. edgesWidth: number;
  109505. /**
  109506. * Defines edge color used when edgesRenderer is enabled
  109507. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109508. */
  109509. edgesColor: Color4;
  109510. /** @hidden */
  109511. _edgesRenderer: Nullable<IEdgesRenderer>;
  109512. /** @hidden */
  109513. _masterMesh: Nullable<AbstractMesh>;
  109514. /** @hidden */
  109515. _boundingInfo: Nullable<BoundingInfo>;
  109516. /** @hidden */
  109517. _renderId: number;
  109518. /**
  109519. * Gets or sets the list of subMeshes
  109520. * @see https://doc.babylonjs.com/how_to/multi_materials
  109521. */
  109522. subMeshes: SubMesh[];
  109523. /** @hidden */
  109524. _intersectionsInProgress: AbstractMesh[];
  109525. /** @hidden */
  109526. _unIndexed: boolean;
  109527. /** @hidden */
  109528. _lightSources: Light[];
  109529. /** Gets the list of lights affecting that mesh */
  109530. get lightSources(): Light[];
  109531. /** @hidden */
  109532. get _positions(): Nullable<Vector3[]>;
  109533. /** @hidden */
  109534. _waitingData: {
  109535. lods: Nullable<any>;
  109536. actions: Nullable<any>;
  109537. freezeWorldMatrix: Nullable<boolean>;
  109538. };
  109539. /** @hidden */
  109540. _bonesTransformMatrices: Nullable<Float32Array>;
  109541. /** @hidden */
  109542. _transformMatrixTexture: Nullable<RawTexture>;
  109543. /**
  109544. * Gets or sets a skeleton to apply skining transformations
  109545. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109546. */
  109547. set skeleton(value: Nullable<Skeleton>);
  109548. get skeleton(): Nullable<Skeleton>;
  109549. /**
  109550. * An event triggered when the mesh is rebuilt.
  109551. */
  109552. onRebuildObservable: Observable<AbstractMesh>;
  109553. /**
  109554. * Creates a new AbstractMesh
  109555. * @param name defines the name of the mesh
  109556. * @param scene defines the hosting scene
  109557. */
  109558. constructor(name: string, scene?: Nullable<Scene>);
  109559. /**
  109560. * Returns the string "AbstractMesh"
  109561. * @returns "AbstractMesh"
  109562. */
  109563. getClassName(): string;
  109564. /**
  109565. * Gets a string representation of the current mesh
  109566. * @param fullDetails defines a boolean indicating if full details must be included
  109567. * @returns a string representation of the current mesh
  109568. */
  109569. toString(fullDetails?: boolean): string;
  109570. /**
  109571. * @hidden
  109572. */
  109573. protected _getEffectiveParent(): Nullable<Node>;
  109574. /** @hidden */
  109575. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109576. /** @hidden */
  109577. _rebuild(): void;
  109578. /** @hidden */
  109579. _resyncLightSources(): void;
  109580. /** @hidden */
  109581. _resyncLightSource(light: Light): void;
  109582. /** @hidden */
  109583. _unBindEffect(): void;
  109584. /** @hidden */
  109585. _removeLightSource(light: Light, dispose: boolean): void;
  109586. private _markSubMeshesAsDirty;
  109587. /** @hidden */
  109588. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109589. /** @hidden */
  109590. _markSubMeshesAsAttributesDirty(): void;
  109591. /** @hidden */
  109592. _markSubMeshesAsMiscDirty(): void;
  109593. /**
  109594. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109595. */
  109596. get scaling(): Vector3;
  109597. set scaling(newScaling: Vector3);
  109598. /**
  109599. * Returns true if the mesh is blocked. Implemented by child classes
  109600. */
  109601. get isBlocked(): boolean;
  109602. /**
  109603. * Returns the mesh itself by default. Implemented by child classes
  109604. * @param camera defines the camera to use to pick the right LOD level
  109605. * @returns the currentAbstractMesh
  109606. */
  109607. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109608. /**
  109609. * Returns 0 by default. Implemented by child classes
  109610. * @returns an integer
  109611. */
  109612. getTotalVertices(): number;
  109613. /**
  109614. * Returns a positive integer : the total number of indices in this mesh geometry.
  109615. * @returns the numner of indices or zero if the mesh has no geometry.
  109616. */
  109617. getTotalIndices(): number;
  109618. /**
  109619. * Returns null by default. Implemented by child classes
  109620. * @returns null
  109621. */
  109622. getIndices(): Nullable<IndicesArray>;
  109623. /**
  109624. * Returns the array of the requested vertex data kind. Implemented by child classes
  109625. * @param kind defines the vertex data kind to use
  109626. * @returns null
  109627. */
  109628. getVerticesData(kind: string): Nullable<FloatArray>;
  109629. /**
  109630. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109631. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109632. * Note that a new underlying VertexBuffer object is created each call.
  109633. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109634. * @param kind defines vertex data kind:
  109635. * * VertexBuffer.PositionKind
  109636. * * VertexBuffer.UVKind
  109637. * * VertexBuffer.UV2Kind
  109638. * * VertexBuffer.UV3Kind
  109639. * * VertexBuffer.UV4Kind
  109640. * * VertexBuffer.UV5Kind
  109641. * * VertexBuffer.UV6Kind
  109642. * * VertexBuffer.ColorKind
  109643. * * VertexBuffer.MatricesIndicesKind
  109644. * * VertexBuffer.MatricesIndicesExtraKind
  109645. * * VertexBuffer.MatricesWeightsKind
  109646. * * VertexBuffer.MatricesWeightsExtraKind
  109647. * @param data defines the data source
  109648. * @param updatable defines if the data must be flagged as updatable (or static)
  109649. * @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
  109650. * @returns the current mesh
  109651. */
  109652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109653. /**
  109654. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109655. * If the mesh has no geometry, it is simply returned as it is.
  109656. * @param kind defines vertex data kind:
  109657. * * VertexBuffer.PositionKind
  109658. * * VertexBuffer.UVKind
  109659. * * VertexBuffer.UV2Kind
  109660. * * VertexBuffer.UV3Kind
  109661. * * VertexBuffer.UV4Kind
  109662. * * VertexBuffer.UV5Kind
  109663. * * VertexBuffer.UV6Kind
  109664. * * VertexBuffer.ColorKind
  109665. * * VertexBuffer.MatricesIndicesKind
  109666. * * VertexBuffer.MatricesIndicesExtraKind
  109667. * * VertexBuffer.MatricesWeightsKind
  109668. * * VertexBuffer.MatricesWeightsExtraKind
  109669. * @param data defines the data source
  109670. * @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
  109671. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109672. * @returns the current mesh
  109673. */
  109674. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109675. /**
  109676. * Sets the mesh indices,
  109677. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109678. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109679. * @param totalVertices Defines the total number of vertices
  109680. * @returns the current mesh
  109681. */
  109682. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109683. /**
  109684. * Gets a boolean indicating if specific vertex data is present
  109685. * @param kind defines the vertex data kind to use
  109686. * @returns true is data kind is present
  109687. */
  109688. isVerticesDataPresent(kind: string): boolean;
  109689. /**
  109690. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109691. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109692. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109693. * @returns a BoundingInfo
  109694. */
  109695. getBoundingInfo(): BoundingInfo;
  109696. /**
  109697. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109698. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109699. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109700. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109701. * @returns the current mesh
  109702. */
  109703. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109704. /**
  109705. * Overwrite the current bounding info
  109706. * @param boundingInfo defines the new bounding info
  109707. * @returns the current mesh
  109708. */
  109709. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109710. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109711. get useBones(): boolean;
  109712. /** @hidden */
  109713. _preActivate(): void;
  109714. /** @hidden */
  109715. _preActivateForIntermediateRendering(renderId: number): void;
  109716. /** @hidden */
  109717. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109718. /** @hidden */
  109719. _postActivate(): void;
  109720. /** @hidden */
  109721. _freeze(): void;
  109722. /** @hidden */
  109723. _unFreeze(): void;
  109724. /**
  109725. * Gets the current world matrix
  109726. * @returns a Matrix
  109727. */
  109728. getWorldMatrix(): Matrix;
  109729. /** @hidden */
  109730. _getWorldMatrixDeterminant(): number;
  109731. /**
  109732. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109733. */
  109734. get isAnInstance(): boolean;
  109735. /**
  109736. * Gets a boolean indicating if this mesh has instances
  109737. */
  109738. get hasInstances(): boolean;
  109739. /**
  109740. * Gets a boolean indicating if this mesh has thin instances
  109741. */
  109742. get hasThinInstances(): boolean;
  109743. /**
  109744. * Perform relative position change from the point of view of behind the front of the mesh.
  109745. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109746. * Supports definition of mesh facing forward or backward
  109747. * @param amountRight defines the distance on the right axis
  109748. * @param amountUp defines the distance on the up axis
  109749. * @param amountForward defines the distance on the forward axis
  109750. * @returns the current mesh
  109751. */
  109752. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109753. /**
  109754. * Calculate relative position change from the point of view of behind the front of the mesh.
  109755. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109756. * Supports definition of mesh facing forward or backward
  109757. * @param amountRight defines the distance on the right axis
  109758. * @param amountUp defines the distance on the up axis
  109759. * @param amountForward defines the distance on the forward axis
  109760. * @returns the new displacement vector
  109761. */
  109762. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109763. /**
  109764. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109765. * Supports definition of mesh facing forward or backward
  109766. * @param flipBack defines the flip
  109767. * @param twirlClockwise defines the twirl
  109768. * @param tiltRight defines the tilt
  109769. * @returns the current mesh
  109770. */
  109771. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109772. /**
  109773. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109774. * Supports definition of mesh facing forward or backward.
  109775. * @param flipBack defines the flip
  109776. * @param twirlClockwise defines the twirl
  109777. * @param tiltRight defines the tilt
  109778. * @returns the new rotation vector
  109779. */
  109780. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109781. /**
  109782. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109783. * This means the mesh underlying bounding box and sphere are recomputed.
  109784. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109785. * @returns the current mesh
  109786. */
  109787. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109788. /** @hidden */
  109789. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109790. /** @hidden */
  109791. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109792. /** @hidden */
  109793. _updateBoundingInfo(): AbstractMesh;
  109794. /** @hidden */
  109795. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109796. /** @hidden */
  109797. protected _afterComputeWorldMatrix(): void;
  109798. /** @hidden */
  109799. get _effectiveMesh(): AbstractMesh;
  109800. /**
  109801. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109802. * A mesh is in the frustum if its bounding box intersects the frustum
  109803. * @param frustumPlanes defines the frustum to test
  109804. * @returns true if the mesh is in the frustum planes
  109805. */
  109806. isInFrustum(frustumPlanes: Plane[]): boolean;
  109807. /**
  109808. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109809. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109810. * @param frustumPlanes defines the frustum to test
  109811. * @returns true if the mesh is completely in the frustum planes
  109812. */
  109813. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109814. /**
  109815. * True if the mesh intersects another mesh or a SolidParticle object
  109816. * @param mesh defines a target mesh or SolidParticle to test
  109817. * @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)
  109818. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109819. * @returns true if there is an intersection
  109820. */
  109821. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109822. /**
  109823. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109824. * @param point defines the point to test
  109825. * @returns true if there is an intersection
  109826. */
  109827. intersectsPoint(point: Vector3): boolean;
  109828. /**
  109829. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109830. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109831. */
  109832. get checkCollisions(): boolean;
  109833. set checkCollisions(collisionEnabled: boolean);
  109834. /**
  109835. * Gets Collider object used to compute collisions (not physics)
  109836. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109837. */
  109838. get collider(): Nullable<Collider>;
  109839. /**
  109840. * Move the mesh using collision engine
  109841. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109842. * @param displacement defines the requested displacement vector
  109843. * @returns the current mesh
  109844. */
  109845. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109846. private _onCollisionPositionChange;
  109847. /** @hidden */
  109848. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109849. /** @hidden */
  109850. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109851. /** @hidden */
  109852. _checkCollision(collider: Collider): AbstractMesh;
  109853. /** @hidden */
  109854. _generatePointsArray(): boolean;
  109855. /**
  109856. * Checks if the passed Ray intersects with the mesh
  109857. * @param ray defines the ray to use
  109858. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109859. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109860. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109861. * @returns the picking info
  109862. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109863. */
  109864. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109865. /**
  109866. * Clones the current mesh
  109867. * @param name defines the mesh name
  109868. * @param newParent defines the new mesh parent
  109869. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109870. * @returns the new mesh
  109871. */
  109872. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109873. /**
  109874. * Disposes all the submeshes of the current meshnp
  109875. * @returns the current mesh
  109876. */
  109877. releaseSubMeshes(): AbstractMesh;
  109878. /**
  109879. * Releases resources associated with this abstract mesh.
  109880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109882. */
  109883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109884. /**
  109885. * Adds the passed mesh as a child to the current mesh
  109886. * @param mesh defines the child mesh
  109887. * @returns the current mesh
  109888. */
  109889. addChild(mesh: AbstractMesh): AbstractMesh;
  109890. /**
  109891. * Removes the passed mesh from the current mesh children list
  109892. * @param mesh defines the child mesh
  109893. * @returns the current mesh
  109894. */
  109895. removeChild(mesh: AbstractMesh): AbstractMesh;
  109896. /** @hidden */
  109897. private _initFacetData;
  109898. /**
  109899. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109900. * This method can be called within the render loop.
  109901. * 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
  109902. * @returns the current mesh
  109903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109904. */
  109905. updateFacetData(): AbstractMesh;
  109906. /**
  109907. * Returns the facetLocalNormals array.
  109908. * The normals are expressed in the mesh local spac
  109909. * @returns an array of Vector3
  109910. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109911. */
  109912. getFacetLocalNormals(): Vector3[];
  109913. /**
  109914. * Returns the facetLocalPositions array.
  109915. * The facet positions are expressed in the mesh local space
  109916. * @returns an array of Vector3
  109917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109918. */
  109919. getFacetLocalPositions(): Vector3[];
  109920. /**
  109921. * Returns the facetLocalPartioning array
  109922. * @returns an array of array of numbers
  109923. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109924. */
  109925. getFacetLocalPartitioning(): number[][];
  109926. /**
  109927. * Returns the i-th facet position in the world system.
  109928. * This method allocates a new Vector3 per call
  109929. * @param i defines the facet index
  109930. * @returns a new Vector3
  109931. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109932. */
  109933. getFacetPosition(i: number): Vector3;
  109934. /**
  109935. * Sets the reference Vector3 with the i-th facet position in the world system
  109936. * @param i defines the facet index
  109937. * @param ref defines the target vector
  109938. * @returns the current mesh
  109939. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109940. */
  109941. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109942. /**
  109943. * Returns the i-th facet normal in the world system.
  109944. * This method allocates a new Vector3 per call
  109945. * @param i defines the facet index
  109946. * @returns a new Vector3
  109947. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109948. */
  109949. getFacetNormal(i: number): Vector3;
  109950. /**
  109951. * Sets the reference Vector3 with the i-th facet normal in the world system
  109952. * @param i defines the facet index
  109953. * @param ref defines the target vector
  109954. * @returns the current mesh
  109955. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109956. */
  109957. getFacetNormalToRef(i: number, ref: Vector3): this;
  109958. /**
  109959. * 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)
  109960. * @param x defines x coordinate
  109961. * @param y defines y coordinate
  109962. * @param z defines z coordinate
  109963. * @returns the array of facet indexes
  109964. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109965. */
  109966. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109967. /**
  109968. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109969. * @param projected sets as the (x,y,z) world projection on the facet
  109970. * @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
  109971. * @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
  109972. * @param x defines x coordinate
  109973. * @param y defines y coordinate
  109974. * @param z defines z coordinate
  109975. * @returns the face index if found (or null instead)
  109976. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109977. */
  109978. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109979. /**
  109980. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109981. * @param projected sets as the (x,y,z) local projection on the facet
  109982. * @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
  109983. * @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
  109984. * @param x defines x coordinate
  109985. * @param y defines y coordinate
  109986. * @param z defines z coordinate
  109987. * @returns the face index if found (or null instead)
  109988. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109989. */
  109990. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109991. /**
  109992. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109993. * @returns the parameters
  109994. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  109995. */
  109996. getFacetDataParameters(): any;
  109997. /**
  109998. * Disables the feature FacetData and frees the related memory
  109999. * @returns the current mesh
  110000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110001. */
  110002. disableFacetData(): AbstractMesh;
  110003. /**
  110004. * Updates the AbstractMesh indices array
  110005. * @param indices defines the data source
  110006. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110007. * @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)
  110008. * @returns the current mesh
  110009. */
  110010. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110011. /**
  110012. * Creates new normals data for the mesh
  110013. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110014. * @returns the current mesh
  110015. */
  110016. createNormals(updatable: boolean): AbstractMesh;
  110017. /**
  110018. * Align the mesh with a normal
  110019. * @param normal defines the normal to use
  110020. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110021. * @returns the current mesh
  110022. */
  110023. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110024. /** @hidden */
  110025. _checkOcclusionQuery(): boolean;
  110026. /**
  110027. * Disables the mesh edge rendering mode
  110028. * @returns the currentAbstractMesh
  110029. */
  110030. disableEdgesRendering(): AbstractMesh;
  110031. /**
  110032. * Enables the edge rendering mode on the mesh.
  110033. * This mode makes the mesh edges visible
  110034. * @param epsilon defines the maximal distance between two angles to detect a face
  110035. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110036. * @returns the currentAbstractMesh
  110037. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110038. */
  110039. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110040. /**
  110041. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110042. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110043. */
  110044. getConnectedParticleSystems(): IParticleSystem[];
  110045. }
  110046. }
  110047. declare module BABYLON {
  110048. /**
  110049. * Interface used to define ActionEvent
  110050. */
  110051. export interface IActionEvent {
  110052. /** The mesh or sprite that triggered the action */
  110053. source: any;
  110054. /** The X mouse cursor position at the time of the event */
  110055. pointerX: number;
  110056. /** The Y mouse cursor position at the time of the event */
  110057. pointerY: number;
  110058. /** The mesh that is currently pointed at (can be null) */
  110059. meshUnderPointer: Nullable<AbstractMesh>;
  110060. /** the original (browser) event that triggered the ActionEvent */
  110061. sourceEvent?: any;
  110062. /** additional data for the event */
  110063. additionalData?: any;
  110064. }
  110065. /**
  110066. * ActionEvent is the event being sent when an action is triggered.
  110067. */
  110068. export class ActionEvent implements IActionEvent {
  110069. /** The mesh or sprite that triggered the action */
  110070. source: any;
  110071. /** The X mouse cursor position at the time of the event */
  110072. pointerX: number;
  110073. /** The Y mouse cursor position at the time of the event */
  110074. pointerY: number;
  110075. /** The mesh that is currently pointed at (can be null) */
  110076. meshUnderPointer: Nullable<AbstractMesh>;
  110077. /** the original (browser) event that triggered the ActionEvent */
  110078. sourceEvent?: any;
  110079. /** additional data for the event */
  110080. additionalData?: any;
  110081. /**
  110082. * Creates a new ActionEvent
  110083. * @param source The mesh or sprite that triggered the action
  110084. * @param pointerX The X mouse cursor position at the time of the event
  110085. * @param pointerY The Y mouse cursor position at the time of the event
  110086. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110087. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110088. * @param additionalData additional data for the event
  110089. */
  110090. constructor(
  110091. /** The mesh or sprite that triggered the action */
  110092. source: any,
  110093. /** The X mouse cursor position at the time of the event */
  110094. pointerX: number,
  110095. /** The Y mouse cursor position at the time of the event */
  110096. pointerY: number,
  110097. /** The mesh that is currently pointed at (can be null) */
  110098. meshUnderPointer: Nullable<AbstractMesh>,
  110099. /** the original (browser) event that triggered the ActionEvent */
  110100. sourceEvent?: any,
  110101. /** additional data for the event */
  110102. additionalData?: any);
  110103. /**
  110104. * Helper function to auto-create an ActionEvent from a source mesh.
  110105. * @param source The source mesh that triggered the event
  110106. * @param evt The original (browser) event
  110107. * @param additionalData additional data for the event
  110108. * @returns the new ActionEvent
  110109. */
  110110. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110111. /**
  110112. * Helper function to auto-create an ActionEvent from a source sprite
  110113. * @param source The source sprite that triggered the event
  110114. * @param scene Scene associated with the sprite
  110115. * @param evt The original (browser) event
  110116. * @param additionalData additional data for the event
  110117. * @returns the new ActionEvent
  110118. */
  110119. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110120. /**
  110121. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110122. * @param scene the scene where the event occurred
  110123. * @param evt The original (browser) event
  110124. * @returns the new ActionEvent
  110125. */
  110126. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110127. /**
  110128. * Helper function to auto-create an ActionEvent from a primitive
  110129. * @param prim defines the target primitive
  110130. * @param pointerPos defines the pointer position
  110131. * @param evt The original (browser) event
  110132. * @param additionalData additional data for the event
  110133. * @returns the new ActionEvent
  110134. */
  110135. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110136. }
  110137. }
  110138. declare module BABYLON {
  110139. /**
  110140. * Abstract class used to decouple action Manager from scene and meshes.
  110141. * Do not instantiate.
  110142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110143. */
  110144. export abstract class AbstractActionManager implements IDisposable {
  110145. /** Gets the list of active triggers */
  110146. static Triggers: {
  110147. [key: string]: number;
  110148. };
  110149. /** Gets the cursor to use when hovering items */
  110150. hoverCursor: string;
  110151. /** Gets the list of actions */
  110152. actions: IAction[];
  110153. /**
  110154. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110155. */
  110156. isRecursive: boolean;
  110157. /**
  110158. * Releases all associated resources
  110159. */
  110160. abstract dispose(): void;
  110161. /**
  110162. * Does this action manager has pointer triggers
  110163. */
  110164. abstract get hasPointerTriggers(): boolean;
  110165. /**
  110166. * Does this action manager has pick triggers
  110167. */
  110168. abstract get hasPickTriggers(): boolean;
  110169. /**
  110170. * Process a specific trigger
  110171. * @param trigger defines the trigger to process
  110172. * @param evt defines the event details to be processed
  110173. */
  110174. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110175. /**
  110176. * Does this action manager handles actions of any of the given triggers
  110177. * @param triggers defines the triggers to be tested
  110178. * @return a boolean indicating whether one (or more) of the triggers is handled
  110179. */
  110180. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110181. /**
  110182. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110183. * speed.
  110184. * @param triggerA defines the trigger to be tested
  110185. * @param triggerB defines the trigger to be tested
  110186. * @return a boolean indicating whether one (or more) of the triggers is handled
  110187. */
  110188. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110189. /**
  110190. * Does this action manager handles actions of a given trigger
  110191. * @param trigger defines the trigger to be tested
  110192. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110193. * @return whether the trigger is handled
  110194. */
  110195. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110196. /**
  110197. * Serialize this manager to a JSON object
  110198. * @param name defines the property name to store this manager
  110199. * @returns a JSON representation of this manager
  110200. */
  110201. abstract serialize(name: string): any;
  110202. /**
  110203. * Registers an action to this action manager
  110204. * @param action defines the action to be registered
  110205. * @return the action amended (prepared) after registration
  110206. */
  110207. abstract registerAction(action: IAction): Nullable<IAction>;
  110208. /**
  110209. * Unregisters an action to this action manager
  110210. * @param action defines the action to be unregistered
  110211. * @return a boolean indicating whether the action has been unregistered
  110212. */
  110213. abstract unregisterAction(action: IAction): Boolean;
  110214. /**
  110215. * Does exist one action manager with at least one trigger
  110216. **/
  110217. static get HasTriggers(): boolean;
  110218. /**
  110219. * Does exist one action manager with at least one pick trigger
  110220. **/
  110221. static get HasPickTriggers(): boolean;
  110222. /**
  110223. * Does exist one action manager that handles actions of a given trigger
  110224. * @param trigger defines the trigger to be tested
  110225. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110226. **/
  110227. static HasSpecificTrigger(trigger: number): boolean;
  110228. }
  110229. }
  110230. declare module BABYLON {
  110231. /**
  110232. * Defines how a node can be built from a string name.
  110233. */
  110234. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110235. /**
  110236. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110237. */
  110238. export class Node implements IBehaviorAware<Node> {
  110239. /** @hidden */
  110240. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110241. private static _NodeConstructors;
  110242. /**
  110243. * Add a new node constructor
  110244. * @param type defines the type name of the node to construct
  110245. * @param constructorFunc defines the constructor function
  110246. */
  110247. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110248. /**
  110249. * Returns a node constructor based on type name
  110250. * @param type defines the type name
  110251. * @param name defines the new node name
  110252. * @param scene defines the hosting scene
  110253. * @param options defines optional options to transmit to constructors
  110254. * @returns the new constructor or null
  110255. */
  110256. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110257. /**
  110258. * Gets or sets the name of the node
  110259. */
  110260. name: string;
  110261. /**
  110262. * Gets or sets the id of the node
  110263. */
  110264. id: string;
  110265. /**
  110266. * Gets or sets the unique id of the node
  110267. */
  110268. uniqueId: number;
  110269. /**
  110270. * Gets or sets a string used to store user defined state for the node
  110271. */
  110272. state: string;
  110273. /**
  110274. * Gets or sets an object used to store user defined information for the node
  110275. */
  110276. metadata: any;
  110277. /**
  110278. * For internal use only. Please do not use.
  110279. */
  110280. reservedDataStore: any;
  110281. /**
  110282. * List of inspectable custom properties (used by the Inspector)
  110283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110284. */
  110285. inspectableCustomProperties: IInspectable[];
  110286. private _doNotSerialize;
  110287. /**
  110288. * Gets or sets a boolean used to define if the node must be serialized
  110289. */
  110290. get doNotSerialize(): boolean;
  110291. set doNotSerialize(value: boolean);
  110292. /** @hidden */
  110293. _isDisposed: boolean;
  110294. /**
  110295. * Gets a list of Animations associated with the node
  110296. */
  110297. animations: Animation[];
  110298. protected _ranges: {
  110299. [name: string]: Nullable<AnimationRange>;
  110300. };
  110301. /**
  110302. * Callback raised when the node is ready to be used
  110303. */
  110304. onReady: Nullable<(node: Node) => void>;
  110305. private _isEnabled;
  110306. private _isParentEnabled;
  110307. private _isReady;
  110308. /** @hidden */
  110309. _currentRenderId: number;
  110310. private _parentUpdateId;
  110311. /** @hidden */
  110312. _childUpdateId: number;
  110313. /** @hidden */
  110314. _waitingParentId: Nullable<string>;
  110315. /** @hidden */
  110316. _scene: Scene;
  110317. /** @hidden */
  110318. _cache: any;
  110319. private _parentNode;
  110320. private _children;
  110321. /** @hidden */
  110322. _worldMatrix: Matrix;
  110323. /** @hidden */
  110324. _worldMatrixDeterminant: number;
  110325. /** @hidden */
  110326. _worldMatrixDeterminantIsDirty: boolean;
  110327. /** @hidden */
  110328. private _sceneRootNodesIndex;
  110329. /**
  110330. * Gets a boolean indicating if the node has been disposed
  110331. * @returns true if the node was disposed
  110332. */
  110333. isDisposed(): boolean;
  110334. /**
  110335. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110336. * @see https://doc.babylonjs.com/how_to/parenting
  110337. */
  110338. set parent(parent: Nullable<Node>);
  110339. get parent(): Nullable<Node>;
  110340. /** @hidden */
  110341. _addToSceneRootNodes(): void;
  110342. /** @hidden */
  110343. _removeFromSceneRootNodes(): void;
  110344. private _animationPropertiesOverride;
  110345. /**
  110346. * Gets or sets the animation properties override
  110347. */
  110348. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110349. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110350. /**
  110351. * Gets a string idenfifying the name of the class
  110352. * @returns "Node" string
  110353. */
  110354. getClassName(): string;
  110355. /** @hidden */
  110356. readonly _isNode: boolean;
  110357. /**
  110358. * An event triggered when the mesh is disposed
  110359. */
  110360. onDisposeObservable: Observable<Node>;
  110361. private _onDisposeObserver;
  110362. /**
  110363. * Sets a callback that will be raised when the node will be disposed
  110364. */
  110365. set onDispose(callback: () => void);
  110366. /**
  110367. * Creates a new Node
  110368. * @param name the name and id to be given to this node
  110369. * @param scene the scene this node will be added to
  110370. */
  110371. constructor(name: string, scene?: Nullable<Scene>);
  110372. /**
  110373. * Gets the scene of the node
  110374. * @returns a scene
  110375. */
  110376. getScene(): Scene;
  110377. /**
  110378. * Gets the engine of the node
  110379. * @returns a Engine
  110380. */
  110381. getEngine(): Engine;
  110382. private _behaviors;
  110383. /**
  110384. * Attach a behavior to the node
  110385. * @see https://doc.babylonjs.com/features/behaviour
  110386. * @param behavior defines the behavior to attach
  110387. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110388. * @returns the current Node
  110389. */
  110390. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110391. /**
  110392. * Remove an attached behavior
  110393. * @see https://doc.babylonjs.com/features/behaviour
  110394. * @param behavior defines the behavior to attach
  110395. * @returns the current Node
  110396. */
  110397. removeBehavior(behavior: Behavior<Node>): Node;
  110398. /**
  110399. * Gets the list of attached behaviors
  110400. * @see https://doc.babylonjs.com/features/behaviour
  110401. */
  110402. get behaviors(): Behavior<Node>[];
  110403. /**
  110404. * Gets an attached behavior by name
  110405. * @param name defines the name of the behavior to look for
  110406. * @see https://doc.babylonjs.com/features/behaviour
  110407. * @returns null if behavior was not found else the requested behavior
  110408. */
  110409. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110410. /**
  110411. * Returns the latest update of the World matrix
  110412. * @returns a Matrix
  110413. */
  110414. getWorldMatrix(): Matrix;
  110415. /** @hidden */
  110416. _getWorldMatrixDeterminant(): number;
  110417. /**
  110418. * Returns directly the latest state of the mesh World matrix.
  110419. * A Matrix is returned.
  110420. */
  110421. get worldMatrixFromCache(): Matrix;
  110422. /** @hidden */
  110423. _initCache(): void;
  110424. /** @hidden */
  110425. updateCache(force?: boolean): void;
  110426. /** @hidden */
  110427. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110428. /** @hidden */
  110429. _updateCache(ignoreParentClass?: boolean): void;
  110430. /** @hidden */
  110431. _isSynchronized(): boolean;
  110432. /** @hidden */
  110433. _markSyncedWithParent(): void;
  110434. /** @hidden */
  110435. isSynchronizedWithParent(): boolean;
  110436. /** @hidden */
  110437. isSynchronized(): boolean;
  110438. /**
  110439. * Is this node ready to be used/rendered
  110440. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110441. * @return true if the node is ready
  110442. */
  110443. isReady(completeCheck?: boolean): boolean;
  110444. /**
  110445. * Is this node enabled?
  110446. * 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
  110447. * @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
  110448. * @return whether this node (and its parent) is enabled
  110449. */
  110450. isEnabled(checkAncestors?: boolean): boolean;
  110451. /** @hidden */
  110452. protected _syncParentEnabledState(): void;
  110453. /**
  110454. * Set the enabled state of this node
  110455. * @param value defines the new enabled state
  110456. */
  110457. setEnabled(value: boolean): void;
  110458. /**
  110459. * Is this node a descendant of the given node?
  110460. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110461. * @param ancestor defines the parent node to inspect
  110462. * @returns a boolean indicating if this node is a descendant of the given node
  110463. */
  110464. isDescendantOf(ancestor: Node): boolean;
  110465. /** @hidden */
  110466. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110467. /**
  110468. * Will return all nodes that have this node as ascendant
  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
  110470. * @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
  110471. * @return all children nodes of all types
  110472. */
  110473. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110474. /**
  110475. * Get all child-meshes of this node
  110476. * @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)
  110477. * @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
  110478. * @returns an array of AbstractMesh
  110479. */
  110480. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110481. /**
  110482. * Get all direct children of this node
  110483. * @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
  110484. * @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)
  110485. * @returns an array of Node
  110486. */
  110487. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110488. /** @hidden */
  110489. _setReady(state: boolean): void;
  110490. /**
  110491. * Get an animation by name
  110492. * @param name defines the name of the animation to look for
  110493. * @returns null if not found else the requested animation
  110494. */
  110495. getAnimationByName(name: string): Nullable<Animation>;
  110496. /**
  110497. * Creates an animation range for this node
  110498. * @param name defines the name of the range
  110499. * @param from defines the starting key
  110500. * @param to defines the end key
  110501. */
  110502. createAnimationRange(name: string, from: number, to: number): void;
  110503. /**
  110504. * Delete a specific animation range
  110505. * @param name defines the name of the range to delete
  110506. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110507. */
  110508. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110509. /**
  110510. * Get an animation range by name
  110511. * @param name defines the name of the animation range to look for
  110512. * @returns null if not found else the requested animation range
  110513. */
  110514. getAnimationRange(name: string): Nullable<AnimationRange>;
  110515. /**
  110516. * Gets the list of all animation ranges defined on this node
  110517. * @returns an array
  110518. */
  110519. getAnimationRanges(): Nullable<AnimationRange>[];
  110520. /**
  110521. * Will start the animation sequence
  110522. * @param name defines the range frames for animation sequence
  110523. * @param loop defines if the animation should loop (false by default)
  110524. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110525. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110526. * @returns the object created for this animation. If range does not exist, it will return null
  110527. */
  110528. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110529. /**
  110530. * Serialize animation ranges into a JSON compatible object
  110531. * @returns serialization object
  110532. */
  110533. serializeAnimationRanges(): any;
  110534. /**
  110535. * Computes the world matrix of the node
  110536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110537. * @returns the world matrix
  110538. */
  110539. computeWorldMatrix(force?: boolean): Matrix;
  110540. /**
  110541. * Releases resources associated with this node.
  110542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110544. */
  110545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110546. /**
  110547. * Parse animation range data from a serialization object and store them into a given node
  110548. * @param node defines where to store the animation ranges
  110549. * @param parsedNode defines the serialization object to read data from
  110550. * @param scene defines the hosting scene
  110551. */
  110552. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110553. /**
  110554. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110555. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110556. * @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
  110557. * @returns the new bounding vectors
  110558. */
  110559. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110560. min: Vector3;
  110561. max: Vector3;
  110562. };
  110563. }
  110564. }
  110565. declare module BABYLON {
  110566. /**
  110567. * @hidden
  110568. */
  110569. export class _IAnimationState {
  110570. key: number;
  110571. repeatCount: number;
  110572. workValue?: any;
  110573. loopMode?: number;
  110574. offsetValue?: any;
  110575. highLimitValue?: any;
  110576. }
  110577. /**
  110578. * Class used to store any kind of animation
  110579. */
  110580. export class Animation {
  110581. /**Name of the animation */
  110582. name: string;
  110583. /**Property to animate */
  110584. targetProperty: string;
  110585. /**The frames per second of the animation */
  110586. framePerSecond: number;
  110587. /**The data type of the animation */
  110588. dataType: number;
  110589. /**The loop mode of the animation */
  110590. loopMode?: number | undefined;
  110591. /**Specifies if blending should be enabled */
  110592. enableBlending?: boolean | undefined;
  110593. /**
  110594. * Use matrix interpolation instead of using direct key value when animating matrices
  110595. */
  110596. static AllowMatricesInterpolation: boolean;
  110597. /**
  110598. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110599. */
  110600. static AllowMatrixDecomposeForInterpolation: boolean;
  110601. /** Define the Url to load snippets */
  110602. static SnippetUrl: string;
  110603. /** Snippet ID if the animation was created from the snippet server */
  110604. snippetId: string;
  110605. /**
  110606. * Stores the key frames of the animation
  110607. */
  110608. private _keys;
  110609. /**
  110610. * Stores the easing function of the animation
  110611. */
  110612. private _easingFunction;
  110613. /**
  110614. * @hidden Internal use only
  110615. */
  110616. _runtimeAnimations: RuntimeAnimation[];
  110617. /**
  110618. * The set of event that will be linked to this animation
  110619. */
  110620. private _events;
  110621. /**
  110622. * Stores an array of target property paths
  110623. */
  110624. targetPropertyPath: string[];
  110625. /**
  110626. * Stores the blending speed of the animation
  110627. */
  110628. blendingSpeed: number;
  110629. /**
  110630. * Stores the animation ranges for the animation
  110631. */
  110632. private _ranges;
  110633. /**
  110634. * @hidden Internal use
  110635. */
  110636. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110637. /**
  110638. * Sets up an animation
  110639. * @param property The property to animate
  110640. * @param animationType The animation type to apply
  110641. * @param framePerSecond The frames per second of the animation
  110642. * @param easingFunction The easing function used in the animation
  110643. * @returns The created animation
  110644. */
  110645. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110646. /**
  110647. * Create and start an animation on a node
  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 targetProperty defines property to animate
  110651. * @param framePerSecond defines the number of frame per second yo use
  110652. * @param totalFrame defines the number of frames in total
  110653. * @param from defines the initial value
  110654. * @param to defines the final value
  110655. * @param loopMode defines which loop mode you want to use (off by default)
  110656. * @param easingFunction defines the easing function to use (linear by default)
  110657. * @param onAnimationEnd defines the callback to call when animation end
  110658. * @returns the animatable created for this animation
  110659. */
  110660. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110661. /**
  110662. * Create and start an animation on a node and its descendants
  110663. * @param name defines the name of the global animation that will be run on all nodes
  110664. * @param node defines the root node where the animation will take place
  110665. * @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
  110666. * @param targetProperty defines property to animate
  110667. * @param framePerSecond defines the number of frame per second to use
  110668. * @param totalFrame defines the number of frames in total
  110669. * @param from defines the initial value
  110670. * @param to defines the final value
  110671. * @param loopMode defines which loop mode you want to use (off by default)
  110672. * @param easingFunction defines the easing function to use (linear by default)
  110673. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110674. * @returns the list of animatables created for all nodes
  110675. * @example https://www.babylonjs-playground.com/#MH0VLI
  110676. */
  110677. 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[]>;
  110678. /**
  110679. * Creates a new animation, merges it with the existing animations and starts it
  110680. * @param name Name of the animation
  110681. * @param node Node which contains the scene that begins the animations
  110682. * @param targetProperty Specifies which property to animate
  110683. * @param framePerSecond The frames per second of the animation
  110684. * @param totalFrame The total number of frames
  110685. * @param from The frame at the beginning of the animation
  110686. * @param to The frame at the end of the animation
  110687. * @param loopMode Specifies the loop mode of the animation
  110688. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110689. * @param onAnimationEnd Callback to run once the animation is complete
  110690. * @returns Nullable animation
  110691. */
  110692. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110693. /**
  110694. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110695. * @param sourceAnimation defines the Animation containing keyframes to convert
  110696. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110697. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110698. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110699. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110700. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110701. */
  110702. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110703. /**
  110704. * Transition property of an host to the target Value
  110705. * @param property The property to transition
  110706. * @param targetValue The target Value of the property
  110707. * @param host The object where the property to animate belongs
  110708. * @param scene Scene used to run the animation
  110709. * @param frameRate Framerate (in frame/s) to use
  110710. * @param transition The transition type we want to use
  110711. * @param duration The duration of the animation, in milliseconds
  110712. * @param onAnimationEnd Callback trigger at the end of the animation
  110713. * @returns Nullable animation
  110714. */
  110715. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110716. /**
  110717. * Return the array of runtime animations currently using this animation
  110718. */
  110719. get runtimeAnimations(): RuntimeAnimation[];
  110720. /**
  110721. * Specifies if any of the runtime animations are currently running
  110722. */
  110723. get hasRunningRuntimeAnimations(): boolean;
  110724. /**
  110725. * Initializes the animation
  110726. * @param name Name of the animation
  110727. * @param targetProperty Property to animate
  110728. * @param framePerSecond The frames per second of the animation
  110729. * @param dataType The data type of the animation
  110730. * @param loopMode The loop mode of the animation
  110731. * @param enableBlending Specifies if blending should be enabled
  110732. */
  110733. constructor(
  110734. /**Name of the animation */
  110735. name: string,
  110736. /**Property to animate */
  110737. targetProperty: string,
  110738. /**The frames per second of the animation */
  110739. framePerSecond: number,
  110740. /**The data type of the animation */
  110741. dataType: number,
  110742. /**The loop mode of the animation */
  110743. loopMode?: number | undefined,
  110744. /**Specifies if blending should be enabled */
  110745. enableBlending?: boolean | undefined);
  110746. /**
  110747. * Converts the animation to a string
  110748. * @param fullDetails support for multiple levels of logging within scene loading
  110749. * @returns String form of the animation
  110750. */
  110751. toString(fullDetails?: boolean): string;
  110752. /**
  110753. * Add an event to this animation
  110754. * @param event Event to add
  110755. */
  110756. addEvent(event: AnimationEvent): void;
  110757. /**
  110758. * Remove all events found at the given frame
  110759. * @param frame The frame to remove events from
  110760. */
  110761. removeEvents(frame: number): void;
  110762. /**
  110763. * Retrieves all the events from the animation
  110764. * @returns Events from the animation
  110765. */
  110766. getEvents(): AnimationEvent[];
  110767. /**
  110768. * Creates an animation range
  110769. * @param name Name of the animation range
  110770. * @param from Starting frame of the animation range
  110771. * @param to Ending frame of the animation
  110772. */
  110773. createRange(name: string, from: number, to: number): void;
  110774. /**
  110775. * Deletes an animation range by name
  110776. * @param name Name of the animation range to delete
  110777. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110778. */
  110779. deleteRange(name: string, deleteFrames?: boolean): void;
  110780. /**
  110781. * Gets the animation range by name, or null if not defined
  110782. * @param name Name of the animation range
  110783. * @returns Nullable animation range
  110784. */
  110785. getRange(name: string): Nullable<AnimationRange>;
  110786. /**
  110787. * Gets the key frames from the animation
  110788. * @returns The key frames of the animation
  110789. */
  110790. getKeys(): Array<IAnimationKey>;
  110791. /**
  110792. * Gets the highest frame rate of the animation
  110793. * @returns Highest frame rate of the animation
  110794. */
  110795. getHighestFrame(): number;
  110796. /**
  110797. * Gets the easing function of the animation
  110798. * @returns Easing function of the animation
  110799. */
  110800. getEasingFunction(): IEasingFunction;
  110801. /**
  110802. * Sets the easing function of the animation
  110803. * @param easingFunction A custom mathematical formula for animation
  110804. */
  110805. setEasingFunction(easingFunction: EasingFunction): void;
  110806. /**
  110807. * Interpolates a scalar linearly
  110808. * @param startValue Start value of the animation curve
  110809. * @param endValue End value of the animation curve
  110810. * @param gradient Scalar amount to interpolate
  110811. * @returns Interpolated scalar value
  110812. */
  110813. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110814. /**
  110815. * Interpolates a scalar cubically
  110816. * @param startValue Start value of the animation curve
  110817. * @param outTangent End tangent of the animation
  110818. * @param endValue End value of the animation curve
  110819. * @param inTangent Start tangent of the animation curve
  110820. * @param gradient Scalar amount to interpolate
  110821. * @returns Interpolated scalar value
  110822. */
  110823. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110824. /**
  110825. * Interpolates a quaternion using a spherical linear interpolation
  110826. * @param startValue Start value of the animation curve
  110827. * @param endValue End value of the animation curve
  110828. * @param gradient Scalar amount to interpolate
  110829. * @returns Interpolated quaternion value
  110830. */
  110831. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110832. /**
  110833. * Interpolates a quaternion cubically
  110834. * @param startValue Start value of the animation curve
  110835. * @param outTangent End tangent of the animation curve
  110836. * @param endValue End value of the animation curve
  110837. * @param inTangent Start tangent of the animation curve
  110838. * @param gradient Scalar amount to interpolate
  110839. * @returns Interpolated quaternion value
  110840. */
  110841. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110842. /**
  110843. * Interpolates a Vector3 linearl
  110844. * @param startValue Start value of the animation curve
  110845. * @param endValue End value of the animation curve
  110846. * @param gradient Scalar amount to interpolate
  110847. * @returns Interpolated scalar value
  110848. */
  110849. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110850. /**
  110851. * Interpolates a Vector3 cubically
  110852. * @param startValue Start value of the animation curve
  110853. * @param outTangent End tangent of the animation
  110854. * @param endValue End value of the animation curve
  110855. * @param inTangent Start tangent of the animation curve
  110856. * @param gradient Scalar amount to interpolate
  110857. * @returns InterpolatedVector3 value
  110858. */
  110859. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110860. /**
  110861. * Interpolates a Vector2 linearly
  110862. * @param startValue Start value of the animation curve
  110863. * @param endValue End value of the animation curve
  110864. * @param gradient Scalar amount to interpolate
  110865. * @returns Interpolated Vector2 value
  110866. */
  110867. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110868. /**
  110869. * Interpolates a Vector2 cubically
  110870. * @param startValue Start value of the animation curve
  110871. * @param outTangent End tangent of the animation
  110872. * @param endValue End value of the animation curve
  110873. * @param inTangent Start tangent of the animation curve
  110874. * @param gradient Scalar amount to interpolate
  110875. * @returns Interpolated Vector2 value
  110876. */
  110877. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110878. /**
  110879. * Interpolates a size linearly
  110880. * @param startValue Start value of the animation curve
  110881. * @param endValue End value of the animation curve
  110882. * @param gradient Scalar amount to interpolate
  110883. * @returns Interpolated Size value
  110884. */
  110885. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110886. /**
  110887. * Interpolates a Color3 linearly
  110888. * @param startValue Start value of the animation curve
  110889. * @param endValue End value of the animation curve
  110890. * @param gradient Scalar amount to interpolate
  110891. * @returns Interpolated Color3 value
  110892. */
  110893. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110894. /**
  110895. * Interpolates a Color4 linearly
  110896. * @param startValue Start value of the animation curve
  110897. * @param endValue End value of the animation curve
  110898. * @param gradient Scalar amount to interpolate
  110899. * @returns Interpolated Color3 value
  110900. */
  110901. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110902. /**
  110903. * @hidden Internal use only
  110904. */
  110905. _getKeyValue(value: any): any;
  110906. /**
  110907. * @hidden Internal use only
  110908. */
  110909. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110910. /**
  110911. * Defines the function to use to interpolate matrices
  110912. * @param startValue defines the start matrix
  110913. * @param endValue defines the end matrix
  110914. * @param gradient defines the gradient between both matrices
  110915. * @param result defines an optional target matrix where to store the interpolation
  110916. * @returns the interpolated matrix
  110917. */
  110918. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110919. /**
  110920. * Makes a copy of the animation
  110921. * @returns Cloned animation
  110922. */
  110923. clone(): Animation;
  110924. /**
  110925. * Sets the key frames of the animation
  110926. * @param values The animation key frames to set
  110927. */
  110928. setKeys(values: Array<IAnimationKey>): void;
  110929. /**
  110930. * Serializes the animation to an object
  110931. * @returns Serialized object
  110932. */
  110933. serialize(): any;
  110934. /**
  110935. * Float animation type
  110936. */
  110937. static readonly ANIMATIONTYPE_FLOAT: number;
  110938. /**
  110939. * Vector3 animation type
  110940. */
  110941. static readonly ANIMATIONTYPE_VECTOR3: number;
  110942. /**
  110943. * Quaternion animation type
  110944. */
  110945. static readonly ANIMATIONTYPE_QUATERNION: number;
  110946. /**
  110947. * Matrix animation type
  110948. */
  110949. static readonly ANIMATIONTYPE_MATRIX: number;
  110950. /**
  110951. * Color3 animation type
  110952. */
  110953. static readonly ANIMATIONTYPE_COLOR3: number;
  110954. /**
  110955. * Color3 animation type
  110956. */
  110957. static readonly ANIMATIONTYPE_COLOR4: number;
  110958. /**
  110959. * Vector2 animation type
  110960. */
  110961. static readonly ANIMATIONTYPE_VECTOR2: number;
  110962. /**
  110963. * Size animation type
  110964. */
  110965. static readonly ANIMATIONTYPE_SIZE: number;
  110966. /**
  110967. * Relative Loop Mode
  110968. */
  110969. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110970. /**
  110971. * Cycle Loop Mode
  110972. */
  110973. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110974. /**
  110975. * Constant Loop Mode
  110976. */
  110977. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110978. /** @hidden */
  110979. static _UniversalLerp(left: any, right: any, amount: number): any;
  110980. /**
  110981. * Parses an animation object and creates an animation
  110982. * @param parsedAnimation Parsed animation object
  110983. * @returns Animation object
  110984. */
  110985. static Parse(parsedAnimation: any): Animation;
  110986. /**
  110987. * Appends the serialized animations from the source animations
  110988. * @param source Source containing the animations
  110989. * @param destination Target to store the animations
  110990. */
  110991. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110992. /**
  110993. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110994. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110995. * @param url defines the url to load from
  110996. * @returns a promise that will resolve to the new animation or an array of animations
  110997. */
  110998. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110999. /**
  111000. * Creates an animation or an array of animations from a snippet saved by the Inspector
  111001. * @param snippetId defines the snippet to load
  111002. * @returns a promise that will resolve to the new animation or a new array of animations
  111003. */
  111004. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111005. }
  111006. }
  111007. declare module BABYLON {
  111008. /**
  111009. * Interface containing an array of animations
  111010. */
  111011. export interface IAnimatable {
  111012. /**
  111013. * Array of animations
  111014. */
  111015. animations: Nullable<Array<Animation>>;
  111016. }
  111017. }
  111018. declare module BABYLON {
  111019. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111020. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111021. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111022. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111023. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111024. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111025. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111026. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111027. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111028. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111029. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111030. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111031. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111032. /**
  111033. * Decorator used to define property that can be serialized as reference to a camera
  111034. * @param sourceName defines the name of the property to decorate
  111035. */
  111036. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111037. /**
  111038. * Class used to help serialization objects
  111039. */
  111040. export class SerializationHelper {
  111041. /** @hidden */
  111042. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111043. /** @hidden */
  111044. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111045. /** @hidden */
  111046. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111047. /** @hidden */
  111048. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111049. /**
  111050. * Appends the serialized animations from the source animations
  111051. * @param source Source containing the animations
  111052. * @param destination Target to store the animations
  111053. */
  111054. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111055. /**
  111056. * Static function used to serialized a specific entity
  111057. * @param entity defines the entity to serialize
  111058. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111059. * @returns a JSON compatible object representing the serialization of the entity
  111060. */
  111061. static Serialize<T>(entity: T, serializationObject?: any): any;
  111062. /**
  111063. * Creates a new entity from a serialization data object
  111064. * @param creationFunction defines a function used to instanciated the new entity
  111065. * @param source defines the source serialization data
  111066. * @param scene defines the hosting scene
  111067. * @param rootUrl defines the root url for resources
  111068. * @returns a new entity
  111069. */
  111070. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111071. /**
  111072. * Clones an object
  111073. * @param creationFunction defines the function used to instanciate the new object
  111074. * @param source defines the source object
  111075. * @returns the cloned object
  111076. */
  111077. static Clone<T>(creationFunction: () => T, source: T): T;
  111078. /**
  111079. * Instanciates a new object based on a source one (some data will be shared between both object)
  111080. * @param creationFunction defines the function used to instanciate the new object
  111081. * @param source defines the source object
  111082. * @returns the new object
  111083. */
  111084. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111085. }
  111086. }
  111087. declare module BABYLON {
  111088. /**
  111089. * Base class of all the textures in babylon.
  111090. * It groups all the common properties the materials, post process, lights... might need
  111091. * in order to make a correct use of the texture.
  111092. */
  111093. export class BaseTexture implements IAnimatable {
  111094. /**
  111095. * Default anisotropic filtering level for the application.
  111096. * It is set to 4 as a good tradeoff between perf and quality.
  111097. */
  111098. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111099. /**
  111100. * Gets or sets the unique id of the texture
  111101. */
  111102. uniqueId: number;
  111103. /**
  111104. * Define the name of the texture.
  111105. */
  111106. name: string;
  111107. /**
  111108. * Gets or sets an object used to store user defined information.
  111109. */
  111110. metadata: any;
  111111. /**
  111112. * For internal use only. Please do not use.
  111113. */
  111114. reservedDataStore: any;
  111115. private _hasAlpha;
  111116. /**
  111117. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111118. */
  111119. set hasAlpha(value: boolean);
  111120. get hasAlpha(): boolean;
  111121. /**
  111122. * Defines if the alpha value should be determined via the rgb values.
  111123. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111124. */
  111125. getAlphaFromRGB: boolean;
  111126. /**
  111127. * Intensity or strength of the texture.
  111128. * It is commonly used by materials to fine tune the intensity of the texture
  111129. */
  111130. level: number;
  111131. /**
  111132. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111133. * This is part of the texture as textures usually maps to one uv set.
  111134. */
  111135. coordinatesIndex: number;
  111136. private _coordinatesMode;
  111137. /**
  111138. * How a texture is mapped.
  111139. *
  111140. * | Value | Type | Description |
  111141. * | ----- | ----------------------------------- | ----------- |
  111142. * | 0 | EXPLICIT_MODE | |
  111143. * | 1 | SPHERICAL_MODE | |
  111144. * | 2 | PLANAR_MODE | |
  111145. * | 3 | CUBIC_MODE | |
  111146. * | 4 | PROJECTION_MODE | |
  111147. * | 5 | SKYBOX_MODE | |
  111148. * | 6 | INVCUBIC_MODE | |
  111149. * | 7 | EQUIRECTANGULAR_MODE | |
  111150. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111151. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111152. */
  111153. set coordinatesMode(value: number);
  111154. get coordinatesMode(): number;
  111155. /**
  111156. * | Value | Type | Description |
  111157. * | ----- | ------------------ | ----------- |
  111158. * | 0 | CLAMP_ADDRESSMODE | |
  111159. * | 1 | WRAP_ADDRESSMODE | |
  111160. * | 2 | MIRROR_ADDRESSMODE | |
  111161. */
  111162. wrapU: number;
  111163. /**
  111164. * | Value | Type | Description |
  111165. * | ----- | ------------------ | ----------- |
  111166. * | 0 | CLAMP_ADDRESSMODE | |
  111167. * | 1 | WRAP_ADDRESSMODE | |
  111168. * | 2 | MIRROR_ADDRESSMODE | |
  111169. */
  111170. wrapV: number;
  111171. /**
  111172. * | Value | Type | Description |
  111173. * | ----- | ------------------ | ----------- |
  111174. * | 0 | CLAMP_ADDRESSMODE | |
  111175. * | 1 | WRAP_ADDRESSMODE | |
  111176. * | 2 | MIRROR_ADDRESSMODE | |
  111177. */
  111178. wrapR: number;
  111179. /**
  111180. * With compliant hardware and browser (supporting anisotropic filtering)
  111181. * this defines the level of anisotropic filtering in the texture.
  111182. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111183. */
  111184. anisotropicFilteringLevel: number;
  111185. /**
  111186. * Define if the texture is a cube texture or if false a 2d texture.
  111187. */
  111188. get isCube(): boolean;
  111189. set isCube(value: boolean);
  111190. /**
  111191. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111192. */
  111193. get is3D(): boolean;
  111194. set is3D(value: boolean);
  111195. /**
  111196. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111197. */
  111198. get is2DArray(): boolean;
  111199. set is2DArray(value: boolean);
  111200. /**
  111201. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111202. * HDR texture are usually stored in linear space.
  111203. * This only impacts the PBR and Background materials
  111204. */
  111205. gammaSpace: boolean;
  111206. /**
  111207. * Gets or sets whether or not the texture contains RGBD data.
  111208. */
  111209. get isRGBD(): boolean;
  111210. set isRGBD(value: boolean);
  111211. /**
  111212. * Is Z inverted in the texture (useful in a cube texture).
  111213. */
  111214. invertZ: boolean;
  111215. /**
  111216. * Are mip maps generated for this texture or not.
  111217. */
  111218. get noMipmap(): boolean;
  111219. /**
  111220. * @hidden
  111221. */
  111222. lodLevelInAlpha: boolean;
  111223. /**
  111224. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111225. */
  111226. get lodGenerationOffset(): number;
  111227. set lodGenerationOffset(value: number);
  111228. /**
  111229. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111230. */
  111231. get lodGenerationScale(): number;
  111232. set lodGenerationScale(value: number);
  111233. /**
  111234. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111235. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111236. * average roughness values.
  111237. */
  111238. get linearSpecularLOD(): boolean;
  111239. set linearSpecularLOD(value: boolean);
  111240. /**
  111241. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111242. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111243. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111244. */
  111245. get irradianceTexture(): Nullable<BaseTexture>;
  111246. set irradianceTexture(value: Nullable<BaseTexture>);
  111247. /**
  111248. * Define if the texture is a render target.
  111249. */
  111250. isRenderTarget: boolean;
  111251. /**
  111252. * Define the unique id of the texture in the scene.
  111253. */
  111254. get uid(): string;
  111255. /** @hidden */
  111256. _prefiltered: boolean;
  111257. /**
  111258. * Return a string representation of the texture.
  111259. * @returns the texture as a string
  111260. */
  111261. toString(): string;
  111262. /**
  111263. * Get the class name of the texture.
  111264. * @returns "BaseTexture"
  111265. */
  111266. getClassName(): string;
  111267. /**
  111268. * Define the list of animation attached to the texture.
  111269. */
  111270. animations: Animation[];
  111271. /**
  111272. * An event triggered when the texture is disposed.
  111273. */
  111274. onDisposeObservable: Observable<BaseTexture>;
  111275. private _onDisposeObserver;
  111276. /**
  111277. * Callback triggered when the texture has been disposed.
  111278. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111279. */
  111280. set onDispose(callback: () => void);
  111281. /**
  111282. * Define the current state of the loading sequence when in delayed load mode.
  111283. */
  111284. delayLoadState: number;
  111285. private _scene;
  111286. private _engine;
  111287. /** @hidden */
  111288. _texture: Nullable<InternalTexture>;
  111289. private _uid;
  111290. /**
  111291. * Define if the texture is preventinga material to render or not.
  111292. * If not and the texture is not ready, the engine will use a default black texture instead.
  111293. */
  111294. get isBlocking(): boolean;
  111295. /**
  111296. * Instantiates a new BaseTexture.
  111297. * Base class of all the textures in babylon.
  111298. * It groups all the common properties the materials, post process, lights... might need
  111299. * in order to make a correct use of the texture.
  111300. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111301. */
  111302. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111303. /**
  111304. * Get the scene the texture belongs to.
  111305. * @returns the scene or null if undefined
  111306. */
  111307. getScene(): Nullable<Scene>;
  111308. /** @hidden */
  111309. protected _getEngine(): Nullable<ThinEngine>;
  111310. /**
  111311. * Get the texture transform matrix used to offset tile the texture for istance.
  111312. * @returns the transformation matrix
  111313. */
  111314. getTextureMatrix(): Matrix;
  111315. /**
  111316. * Get the texture reflection matrix used to rotate/transform the reflection.
  111317. * @returns the reflection matrix
  111318. */
  111319. getReflectionTextureMatrix(): Matrix;
  111320. /**
  111321. * Get the underlying lower level texture from Babylon.
  111322. * @returns the insternal texture
  111323. */
  111324. getInternalTexture(): Nullable<InternalTexture>;
  111325. /**
  111326. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111327. * @returns true if ready or not blocking
  111328. */
  111329. isReadyOrNotBlocking(): boolean;
  111330. /**
  111331. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111332. * @returns true if fully ready
  111333. */
  111334. isReady(): boolean;
  111335. private _cachedSize;
  111336. /**
  111337. * Get the size of the texture.
  111338. * @returns the texture size.
  111339. */
  111340. getSize(): ISize;
  111341. /**
  111342. * Get the base size of the texture.
  111343. * It can be different from the size if the texture has been resized for POT for instance
  111344. * @returns the base size
  111345. */
  111346. getBaseSize(): ISize;
  111347. /**
  111348. * Update the sampling mode of the texture.
  111349. * Default is Trilinear mode.
  111350. *
  111351. * | Value | Type | Description |
  111352. * | ----- | ------------------ | ----------- |
  111353. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111354. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111355. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111356. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111357. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111358. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111359. * | 7 | NEAREST_LINEAR | |
  111360. * | 8 | NEAREST_NEAREST | |
  111361. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111362. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111363. * | 11 | LINEAR_LINEAR | |
  111364. * | 12 | LINEAR_NEAREST | |
  111365. *
  111366. * > _mag_: magnification filter (close to the viewer)
  111367. * > _min_: minification filter (far from the viewer)
  111368. * > _mip_: filter used between mip map levels
  111369. *@param samplingMode Define the new sampling mode of the texture
  111370. */
  111371. updateSamplingMode(samplingMode: number): void;
  111372. /**
  111373. * Scales the texture if is `canRescale()`
  111374. * @param ratio the resize factor we want to use to rescale
  111375. */
  111376. scale(ratio: number): void;
  111377. /**
  111378. * Get if the texture can rescale.
  111379. */
  111380. get canRescale(): boolean;
  111381. /** @hidden */
  111382. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111383. /** @hidden */
  111384. _rebuild(): void;
  111385. /**
  111386. * Triggers the load sequence in delayed load mode.
  111387. */
  111388. delayLoad(): void;
  111389. /**
  111390. * Clones the texture.
  111391. * @returns the cloned texture
  111392. */
  111393. clone(): Nullable<BaseTexture>;
  111394. /**
  111395. * Get the texture underlying type (INT, FLOAT...)
  111396. */
  111397. get textureType(): number;
  111398. /**
  111399. * Get the texture underlying format (RGB, RGBA...)
  111400. */
  111401. get textureFormat(): number;
  111402. /**
  111403. * Indicates that textures need to be re-calculated for all materials
  111404. */
  111405. protected _markAllSubMeshesAsTexturesDirty(): void;
  111406. /**
  111407. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111408. * This will returns an RGBA array buffer containing either in values (0-255) or
  111409. * float values (0-1) depending of the underlying buffer type.
  111410. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111411. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111412. * @param buffer defines a user defined buffer to fill with data (can be null)
  111413. * @returns The Array buffer containing the pixels data.
  111414. */
  111415. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111416. /**
  111417. * Release and destroy the underlying lower level texture aka internalTexture.
  111418. */
  111419. releaseInternalTexture(): void;
  111420. /** @hidden */
  111421. get _lodTextureHigh(): Nullable<BaseTexture>;
  111422. /** @hidden */
  111423. get _lodTextureMid(): Nullable<BaseTexture>;
  111424. /** @hidden */
  111425. get _lodTextureLow(): Nullable<BaseTexture>;
  111426. /**
  111427. * Dispose the texture and release its associated resources.
  111428. */
  111429. dispose(): void;
  111430. /**
  111431. * Serialize the texture into a JSON representation that can be parsed later on.
  111432. * @returns the JSON representation of the texture
  111433. */
  111434. serialize(): any;
  111435. /**
  111436. * Helper function to be called back once a list of texture contains only ready textures.
  111437. * @param textures Define the list of textures to wait for
  111438. * @param callback Define the callback triggered once the entire list will be ready
  111439. */
  111440. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111441. private static _isScene;
  111442. }
  111443. }
  111444. declare module BABYLON {
  111445. /**
  111446. * Options to be used when creating an effect.
  111447. */
  111448. export interface IEffectCreationOptions {
  111449. /**
  111450. * Atrributes that will be used in the shader.
  111451. */
  111452. attributes: string[];
  111453. /**
  111454. * Uniform varible names that will be set in the shader.
  111455. */
  111456. uniformsNames: string[];
  111457. /**
  111458. * Uniform buffer variable names that will be set in the shader.
  111459. */
  111460. uniformBuffersNames: string[];
  111461. /**
  111462. * Sampler texture variable names that will be set in the shader.
  111463. */
  111464. samplers: string[];
  111465. /**
  111466. * Define statements that will be set in the shader.
  111467. */
  111468. defines: any;
  111469. /**
  111470. * Possible fallbacks for this effect to improve performance when needed.
  111471. */
  111472. fallbacks: Nullable<IEffectFallbacks>;
  111473. /**
  111474. * Callback that will be called when the shader is compiled.
  111475. */
  111476. onCompiled: Nullable<(effect: Effect) => void>;
  111477. /**
  111478. * Callback that will be called if an error occurs during shader compilation.
  111479. */
  111480. onError: Nullable<(effect: Effect, errors: string) => void>;
  111481. /**
  111482. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111483. */
  111484. indexParameters?: any;
  111485. /**
  111486. * Max number of lights that can be used in the shader.
  111487. */
  111488. maxSimultaneousLights?: number;
  111489. /**
  111490. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111491. */
  111492. transformFeedbackVaryings?: Nullable<string[]>;
  111493. /**
  111494. * 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
  111495. */
  111496. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111497. /**
  111498. * Is this effect rendering to several color attachments ?
  111499. */
  111500. multiTarget?: boolean;
  111501. }
  111502. /**
  111503. * Effect containing vertex and fragment shader that can be executed on an object.
  111504. */
  111505. export class Effect implements IDisposable {
  111506. /**
  111507. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111508. */
  111509. static ShadersRepository: string;
  111510. /**
  111511. * Enable logging of the shader code when a compilation error occurs
  111512. */
  111513. static LogShaderCodeOnCompilationError: boolean;
  111514. /**
  111515. * Name of the effect.
  111516. */
  111517. name: any;
  111518. /**
  111519. * String container all the define statements that should be set on the shader.
  111520. */
  111521. defines: string;
  111522. /**
  111523. * Callback that will be called when the shader is compiled.
  111524. */
  111525. onCompiled: Nullable<(effect: Effect) => void>;
  111526. /**
  111527. * Callback that will be called if an error occurs during shader compilation.
  111528. */
  111529. onError: Nullable<(effect: Effect, errors: string) => void>;
  111530. /**
  111531. * Callback that will be called when effect is bound.
  111532. */
  111533. onBind: Nullable<(effect: Effect) => void>;
  111534. /**
  111535. * Unique ID of the effect.
  111536. */
  111537. uniqueId: number;
  111538. /**
  111539. * Observable that will be called when the shader is compiled.
  111540. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111541. */
  111542. onCompileObservable: Observable<Effect>;
  111543. /**
  111544. * Observable that will be called if an error occurs during shader compilation.
  111545. */
  111546. onErrorObservable: Observable<Effect>;
  111547. /** @hidden */
  111548. _onBindObservable: Nullable<Observable<Effect>>;
  111549. /**
  111550. * @hidden
  111551. * Specifies if the effect was previously ready
  111552. */
  111553. _wasPreviouslyReady: boolean;
  111554. /**
  111555. * Observable that will be called when effect is bound.
  111556. */
  111557. get onBindObservable(): Observable<Effect>;
  111558. /** @hidden */
  111559. _bonesComputationForcedToCPU: boolean;
  111560. /** @hidden */
  111561. _multiTarget: boolean;
  111562. private static _uniqueIdSeed;
  111563. private _engine;
  111564. private _uniformBuffersNames;
  111565. private _uniformBuffersNamesList;
  111566. private _uniformsNames;
  111567. private _samplerList;
  111568. private _samplers;
  111569. private _isReady;
  111570. private _compilationError;
  111571. private _allFallbacksProcessed;
  111572. private _attributesNames;
  111573. private _attributes;
  111574. private _attributeLocationByName;
  111575. private _uniforms;
  111576. /**
  111577. * Key for the effect.
  111578. * @hidden
  111579. */
  111580. _key: string;
  111581. private _indexParameters;
  111582. private _fallbacks;
  111583. private _vertexSourceCode;
  111584. private _fragmentSourceCode;
  111585. private _vertexSourceCodeOverride;
  111586. private _fragmentSourceCodeOverride;
  111587. private _transformFeedbackVaryings;
  111588. /**
  111589. * Compiled shader to webGL program.
  111590. * @hidden
  111591. */
  111592. _pipelineContext: Nullable<IPipelineContext>;
  111593. private _valueCache;
  111594. private static _baseCache;
  111595. /**
  111596. * Instantiates an effect.
  111597. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111598. * @param baseName Name of the effect.
  111599. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111600. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111601. * @param samplers List of sampler variables that will be passed to the shader.
  111602. * @param engine Engine to be used to render the effect
  111603. * @param defines Define statements to be added to the shader.
  111604. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111605. * @param onCompiled Callback that will be called when the shader is compiled.
  111606. * @param onError Callback that will be called if an error occurs during shader compilation.
  111607. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111608. */
  111609. 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);
  111610. private _useFinalCode;
  111611. /**
  111612. * Unique key for this effect
  111613. */
  111614. get key(): string;
  111615. /**
  111616. * If the effect has been compiled and prepared.
  111617. * @returns if the effect is compiled and prepared.
  111618. */
  111619. isReady(): boolean;
  111620. private _isReadyInternal;
  111621. /**
  111622. * The engine the effect was initialized with.
  111623. * @returns the engine.
  111624. */
  111625. getEngine(): Engine;
  111626. /**
  111627. * The pipeline context for this effect
  111628. * @returns the associated pipeline context
  111629. */
  111630. getPipelineContext(): Nullable<IPipelineContext>;
  111631. /**
  111632. * The set of names of attribute variables for the shader.
  111633. * @returns An array of attribute names.
  111634. */
  111635. getAttributesNames(): string[];
  111636. /**
  111637. * Returns the attribute at the given index.
  111638. * @param index The index of the attribute.
  111639. * @returns The location of the attribute.
  111640. */
  111641. getAttributeLocation(index: number): number;
  111642. /**
  111643. * Returns the attribute based on the name of the variable.
  111644. * @param name of the attribute to look up.
  111645. * @returns the attribute location.
  111646. */
  111647. getAttributeLocationByName(name: string): number;
  111648. /**
  111649. * The number of attributes.
  111650. * @returns the numnber of attributes.
  111651. */
  111652. getAttributesCount(): number;
  111653. /**
  111654. * Gets the index of a uniform variable.
  111655. * @param uniformName of the uniform to look up.
  111656. * @returns the index.
  111657. */
  111658. getUniformIndex(uniformName: string): number;
  111659. /**
  111660. * Returns the attribute based on the name of the variable.
  111661. * @param uniformName of the uniform to look up.
  111662. * @returns the location of the uniform.
  111663. */
  111664. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111665. /**
  111666. * Returns an array of sampler variable names
  111667. * @returns The array of sampler variable names.
  111668. */
  111669. getSamplers(): string[];
  111670. /**
  111671. * Returns an array of uniform variable names
  111672. * @returns The array of uniform variable names.
  111673. */
  111674. getUniformNames(): string[];
  111675. /**
  111676. * Returns an array of uniform buffer variable names
  111677. * @returns The array of uniform buffer variable names.
  111678. */
  111679. getUniformBuffersNames(): string[];
  111680. /**
  111681. * Returns the index parameters used to create the effect
  111682. * @returns The index parameters object
  111683. */
  111684. getIndexParameters(): any;
  111685. /**
  111686. * The error from the last compilation.
  111687. * @returns the error string.
  111688. */
  111689. getCompilationError(): string;
  111690. /**
  111691. * Gets a boolean indicating that all fallbacks were used during compilation
  111692. * @returns true if all fallbacks were used
  111693. */
  111694. allFallbacksProcessed(): boolean;
  111695. /**
  111696. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111697. * @param func The callback to be used.
  111698. */
  111699. executeWhenCompiled(func: (effect: Effect) => void): void;
  111700. private _checkIsReady;
  111701. private _loadShader;
  111702. /**
  111703. * Gets the vertex shader source code of this effect
  111704. */
  111705. get vertexSourceCode(): string;
  111706. /**
  111707. * Gets the fragment shader source code of this effect
  111708. */
  111709. get fragmentSourceCode(): string;
  111710. /**
  111711. * Recompiles the webGL program
  111712. * @param vertexSourceCode The source code for the vertex shader.
  111713. * @param fragmentSourceCode The source code for the fragment shader.
  111714. * @param onCompiled Callback called when completed.
  111715. * @param onError Callback called on error.
  111716. * @hidden
  111717. */
  111718. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111719. /**
  111720. * Prepares the effect
  111721. * @hidden
  111722. */
  111723. _prepareEffect(): void;
  111724. private _getShaderCodeAndErrorLine;
  111725. private _processCompilationErrors;
  111726. /**
  111727. * Checks if the effect is supported. (Must be called after compilation)
  111728. */
  111729. get isSupported(): boolean;
  111730. /**
  111731. * Binds a texture to the engine to be used as output of the shader.
  111732. * @param channel Name of the output variable.
  111733. * @param texture Texture to bind.
  111734. * @hidden
  111735. */
  111736. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111737. /**
  111738. * Sets a texture on the engine to be used in the shader.
  111739. * @param channel Name of the sampler variable.
  111740. * @param texture Texture to set.
  111741. */
  111742. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111743. /**
  111744. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111745. * @param channel Name of the sampler variable.
  111746. * @param texture Texture to set.
  111747. */
  111748. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111749. /**
  111750. * Sets an array of textures on the engine to be used in the shader.
  111751. * @param channel Name of the variable.
  111752. * @param textures Textures to set.
  111753. */
  111754. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111755. /**
  111756. * 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)
  111757. * @param channel Name of the sampler variable.
  111758. * @param postProcess Post process to get the input texture from.
  111759. */
  111760. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111761. /**
  111762. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111763. * 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)
  111764. * @param channel Name of the sampler variable.
  111765. * @param postProcess Post process to get the output texture from.
  111766. */
  111767. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111768. /** @hidden */
  111769. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111770. /** @hidden */
  111771. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111772. /** @hidden */
  111773. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111774. /** @hidden */
  111775. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111776. /**
  111777. * Binds a buffer to a uniform.
  111778. * @param buffer Buffer to bind.
  111779. * @param name Name of the uniform variable to bind to.
  111780. */
  111781. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111782. /**
  111783. * Binds block to a uniform.
  111784. * @param blockName Name of the block to bind.
  111785. * @param index Index to bind.
  111786. */
  111787. bindUniformBlock(blockName: string, index: number): void;
  111788. /**
  111789. * Sets an interger value on a uniform variable.
  111790. * @param uniformName Name of the variable.
  111791. * @param value Value to be set.
  111792. * @returns this effect.
  111793. */
  111794. setInt(uniformName: string, value: number): Effect;
  111795. /**
  111796. * Sets an int array on a uniform variable.
  111797. * @param uniformName Name of the variable.
  111798. * @param array array to be set.
  111799. * @returns this effect.
  111800. */
  111801. setIntArray(uniformName: string, array: Int32Array): Effect;
  111802. /**
  111803. * 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)
  111804. * @param uniformName Name of the variable.
  111805. * @param array array to be set.
  111806. * @returns this effect.
  111807. */
  111808. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111809. /**
  111810. * 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)
  111811. * @param uniformName Name of the variable.
  111812. * @param array array to be set.
  111813. * @returns this effect.
  111814. */
  111815. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111816. /**
  111817. * 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)
  111818. * @param uniformName Name of the variable.
  111819. * @param array array to be set.
  111820. * @returns this effect.
  111821. */
  111822. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111823. /**
  111824. * Sets an float array on a uniform variable.
  111825. * @param uniformName Name of the variable.
  111826. * @param array array to be set.
  111827. * @returns this effect.
  111828. */
  111829. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111830. /**
  111831. * 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)
  111832. * @param uniformName Name of the variable.
  111833. * @param array array to be set.
  111834. * @returns this effect.
  111835. */
  111836. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111837. /**
  111838. * 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)
  111839. * @param uniformName Name of the variable.
  111840. * @param array array to be set.
  111841. * @returns this effect.
  111842. */
  111843. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111844. /**
  111845. * 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)
  111846. * @param uniformName Name of the variable.
  111847. * @param array array to be set.
  111848. * @returns this effect.
  111849. */
  111850. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111851. /**
  111852. * Sets an array on a uniform variable.
  111853. * @param uniformName Name of the variable.
  111854. * @param array array to be set.
  111855. * @returns this effect.
  111856. */
  111857. setArray(uniformName: string, array: number[]): Effect;
  111858. /**
  111859. * 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)
  111860. * @param uniformName Name of the variable.
  111861. * @param array array to be set.
  111862. * @returns this effect.
  111863. */
  111864. setArray2(uniformName: string, array: number[]): Effect;
  111865. /**
  111866. * 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)
  111867. * @param uniformName Name of the variable.
  111868. * @param array array to be set.
  111869. * @returns this effect.
  111870. */
  111871. setArray3(uniformName: string, array: number[]): Effect;
  111872. /**
  111873. * 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)
  111874. * @param uniformName Name of the variable.
  111875. * @param array array to be set.
  111876. * @returns this effect.
  111877. */
  111878. setArray4(uniformName: string, array: number[]): Effect;
  111879. /**
  111880. * Sets matrices on a uniform variable.
  111881. * @param uniformName Name of the variable.
  111882. * @param matrices matrices to be set.
  111883. * @returns this effect.
  111884. */
  111885. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111886. /**
  111887. * Sets matrix on a uniform variable.
  111888. * @param uniformName Name of the variable.
  111889. * @param matrix matrix to be set.
  111890. * @returns this effect.
  111891. */
  111892. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111893. /**
  111894. * 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)
  111895. * @param uniformName Name of the variable.
  111896. * @param matrix matrix to be set.
  111897. * @returns this effect.
  111898. */
  111899. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111900. /**
  111901. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111902. * @param uniformName Name of the variable.
  111903. * @param matrix matrix to be set.
  111904. * @returns this effect.
  111905. */
  111906. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111907. /**
  111908. * Sets a float on a uniform variable.
  111909. * @param uniformName Name of the variable.
  111910. * @param value value to be set.
  111911. * @returns this effect.
  111912. */
  111913. setFloat(uniformName: string, value: number): Effect;
  111914. /**
  111915. * Sets a boolean on a uniform variable.
  111916. * @param uniformName Name of the variable.
  111917. * @param bool value to be set.
  111918. * @returns this effect.
  111919. */
  111920. setBool(uniformName: string, bool: boolean): Effect;
  111921. /**
  111922. * Sets a Vector2 on a uniform variable.
  111923. * @param uniformName Name of the variable.
  111924. * @param vector2 vector2 to be set.
  111925. * @returns this effect.
  111926. */
  111927. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111928. /**
  111929. * Sets a float2 on a uniform variable.
  111930. * @param uniformName Name of the variable.
  111931. * @param x First float in float2.
  111932. * @param y Second float in float2.
  111933. * @returns this effect.
  111934. */
  111935. setFloat2(uniformName: string, x: number, y: number): Effect;
  111936. /**
  111937. * Sets a Vector3 on a uniform variable.
  111938. * @param uniformName Name of the variable.
  111939. * @param vector3 Value to be set.
  111940. * @returns this effect.
  111941. */
  111942. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111943. /**
  111944. * Sets a float3 on a uniform variable.
  111945. * @param uniformName Name of the variable.
  111946. * @param x First float in float3.
  111947. * @param y Second float in float3.
  111948. * @param z Third float in float3.
  111949. * @returns this effect.
  111950. */
  111951. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111952. /**
  111953. * Sets a Vector4 on a uniform variable.
  111954. * @param uniformName Name of the variable.
  111955. * @param vector4 Value to be set.
  111956. * @returns this effect.
  111957. */
  111958. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111959. /**
  111960. * Sets a float4 on a uniform variable.
  111961. * @param uniformName Name of the variable.
  111962. * @param x First float in float4.
  111963. * @param y Second float in float4.
  111964. * @param z Third float in float4.
  111965. * @param w Fourth float in float4.
  111966. * @returns this effect.
  111967. */
  111968. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111969. /**
  111970. * Sets a Color3 on a uniform variable.
  111971. * @param uniformName Name of the variable.
  111972. * @param color3 Value to be set.
  111973. * @returns this effect.
  111974. */
  111975. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111976. /**
  111977. * Sets a Color4 on a uniform variable.
  111978. * @param uniformName Name of the variable.
  111979. * @param color3 Value to be set.
  111980. * @param alpha Alpha value to be set.
  111981. * @returns this effect.
  111982. */
  111983. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111984. /**
  111985. * Sets a Color4 on a uniform variable
  111986. * @param uniformName defines the name of the variable
  111987. * @param color4 defines the value to be set
  111988. * @returns this effect.
  111989. */
  111990. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111991. /** Release all associated resources */
  111992. dispose(): void;
  111993. /**
  111994. * This function will add a new shader to the shader store
  111995. * @param name the name of the shader
  111996. * @param pixelShader optional pixel shader content
  111997. * @param vertexShader optional vertex shader content
  111998. */
  111999. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  112000. /**
  112001. * Store of each shader (The can be looked up using effect.key)
  112002. */
  112003. static ShadersStore: {
  112004. [key: string]: string;
  112005. };
  112006. /**
  112007. * Store of each included file for a shader (The can be looked up using effect.key)
  112008. */
  112009. static IncludesShadersStore: {
  112010. [key: string]: string;
  112011. };
  112012. /**
  112013. * Resets the cache of effects.
  112014. */
  112015. static ResetCache(): void;
  112016. }
  112017. }
  112018. declare module BABYLON {
  112019. /**
  112020. * Interface used to describe the capabilities of the engine relatively to the current browser
  112021. */
  112022. export interface EngineCapabilities {
  112023. /** Maximum textures units per fragment shader */
  112024. maxTexturesImageUnits: number;
  112025. /** Maximum texture units per vertex shader */
  112026. maxVertexTextureImageUnits: number;
  112027. /** Maximum textures units in the entire pipeline */
  112028. maxCombinedTexturesImageUnits: number;
  112029. /** Maximum texture size */
  112030. maxTextureSize: number;
  112031. /** Maximum texture samples */
  112032. maxSamples?: number;
  112033. /** Maximum cube texture size */
  112034. maxCubemapTextureSize: number;
  112035. /** Maximum render texture size */
  112036. maxRenderTextureSize: number;
  112037. /** Maximum number of vertex attributes */
  112038. maxVertexAttribs: number;
  112039. /** Maximum number of varyings */
  112040. maxVaryingVectors: number;
  112041. /** Maximum number of uniforms per vertex shader */
  112042. maxVertexUniformVectors: number;
  112043. /** Maximum number of uniforms per fragment shader */
  112044. maxFragmentUniformVectors: number;
  112045. /** Defines if standard derivates (dx/dy) are supported */
  112046. standardDerivatives: boolean;
  112047. /** Defines if s3tc texture compression is supported */
  112048. s3tc?: WEBGL_compressed_texture_s3tc;
  112049. /** Defines if pvrtc texture compression is supported */
  112050. pvrtc: any;
  112051. /** Defines if etc1 texture compression is supported */
  112052. etc1: any;
  112053. /** Defines if etc2 texture compression is supported */
  112054. etc2: any;
  112055. /** Defines if astc texture compression is supported */
  112056. astc: any;
  112057. /** Defines if float textures are supported */
  112058. textureFloat: boolean;
  112059. /** Defines if vertex array objects are supported */
  112060. vertexArrayObject: boolean;
  112061. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112062. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112063. /** Gets the maximum level of anisotropy supported */
  112064. maxAnisotropy: number;
  112065. /** Defines if instancing is supported */
  112066. instancedArrays: boolean;
  112067. /** Defines if 32 bits indices are supported */
  112068. uintIndices: boolean;
  112069. /** Defines if high precision shaders are supported */
  112070. highPrecisionShaderSupported: boolean;
  112071. /** Defines if depth reading in the fragment shader is supported */
  112072. fragmentDepthSupported: boolean;
  112073. /** Defines if float texture linear filtering is supported*/
  112074. textureFloatLinearFiltering: boolean;
  112075. /** Defines if rendering to float textures is supported */
  112076. textureFloatRender: boolean;
  112077. /** Defines if half float textures are supported*/
  112078. textureHalfFloat: boolean;
  112079. /** Defines if half float texture linear filtering is supported*/
  112080. textureHalfFloatLinearFiltering: boolean;
  112081. /** Defines if rendering to half float textures is supported */
  112082. textureHalfFloatRender: boolean;
  112083. /** Defines if textureLOD shader command is supported */
  112084. textureLOD: boolean;
  112085. /** Defines if draw buffers extension is supported */
  112086. drawBuffersExtension: boolean;
  112087. /** Defines if depth textures are supported */
  112088. depthTextureExtension: boolean;
  112089. /** Defines if float color buffer are supported */
  112090. colorBufferFloat: boolean;
  112091. /** Gets disjoint timer query extension (null if not supported) */
  112092. timerQuery?: EXT_disjoint_timer_query;
  112093. /** Defines if timestamp can be used with timer query */
  112094. canUseTimestampForTimerQuery: boolean;
  112095. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112096. multiview?: any;
  112097. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112098. oculusMultiview?: any;
  112099. /** Function used to let the system compiles shaders in background */
  112100. parallelShaderCompile?: {
  112101. COMPLETION_STATUS_KHR: number;
  112102. };
  112103. /** Max number of texture samples for MSAA */
  112104. maxMSAASamples: number;
  112105. /** Defines if the blend min max extension is supported */
  112106. blendMinMax: boolean;
  112107. }
  112108. }
  112109. declare module BABYLON {
  112110. /**
  112111. * @hidden
  112112. **/
  112113. export class DepthCullingState {
  112114. private _isDepthTestDirty;
  112115. private _isDepthMaskDirty;
  112116. private _isDepthFuncDirty;
  112117. private _isCullFaceDirty;
  112118. private _isCullDirty;
  112119. private _isZOffsetDirty;
  112120. private _isFrontFaceDirty;
  112121. private _depthTest;
  112122. private _depthMask;
  112123. private _depthFunc;
  112124. private _cull;
  112125. private _cullFace;
  112126. private _zOffset;
  112127. private _frontFace;
  112128. /**
  112129. * Initializes the state.
  112130. */
  112131. constructor();
  112132. get isDirty(): boolean;
  112133. get zOffset(): number;
  112134. set zOffset(value: number);
  112135. get cullFace(): Nullable<number>;
  112136. set cullFace(value: Nullable<number>);
  112137. get cull(): Nullable<boolean>;
  112138. set cull(value: Nullable<boolean>);
  112139. get depthFunc(): Nullable<number>;
  112140. set depthFunc(value: Nullable<number>);
  112141. get depthMask(): boolean;
  112142. set depthMask(value: boolean);
  112143. get depthTest(): boolean;
  112144. set depthTest(value: boolean);
  112145. get frontFace(): Nullable<number>;
  112146. set frontFace(value: Nullable<number>);
  112147. reset(): void;
  112148. apply(gl: WebGLRenderingContext): void;
  112149. }
  112150. }
  112151. declare module BABYLON {
  112152. /**
  112153. * @hidden
  112154. **/
  112155. export class StencilState {
  112156. /** 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 */
  112157. static readonly ALWAYS: number;
  112158. /** Passed to stencilOperation to specify that stencil value must be kept */
  112159. static readonly KEEP: number;
  112160. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112161. static readonly REPLACE: number;
  112162. private _isStencilTestDirty;
  112163. private _isStencilMaskDirty;
  112164. private _isStencilFuncDirty;
  112165. private _isStencilOpDirty;
  112166. private _stencilTest;
  112167. private _stencilMask;
  112168. private _stencilFunc;
  112169. private _stencilFuncRef;
  112170. private _stencilFuncMask;
  112171. private _stencilOpStencilFail;
  112172. private _stencilOpDepthFail;
  112173. private _stencilOpStencilDepthPass;
  112174. get isDirty(): boolean;
  112175. get stencilFunc(): number;
  112176. set stencilFunc(value: number);
  112177. get stencilFuncRef(): number;
  112178. set stencilFuncRef(value: number);
  112179. get stencilFuncMask(): number;
  112180. set stencilFuncMask(value: number);
  112181. get stencilOpStencilFail(): number;
  112182. set stencilOpStencilFail(value: number);
  112183. get stencilOpDepthFail(): number;
  112184. set stencilOpDepthFail(value: number);
  112185. get stencilOpStencilDepthPass(): number;
  112186. set stencilOpStencilDepthPass(value: number);
  112187. get stencilMask(): number;
  112188. set stencilMask(value: number);
  112189. get stencilTest(): boolean;
  112190. set stencilTest(value: boolean);
  112191. constructor();
  112192. reset(): void;
  112193. apply(gl: WebGLRenderingContext): void;
  112194. }
  112195. }
  112196. declare module BABYLON {
  112197. /**
  112198. * @hidden
  112199. **/
  112200. export class AlphaState {
  112201. private _isAlphaBlendDirty;
  112202. private _isBlendFunctionParametersDirty;
  112203. private _isBlendEquationParametersDirty;
  112204. private _isBlendConstantsDirty;
  112205. private _alphaBlend;
  112206. private _blendFunctionParameters;
  112207. private _blendEquationParameters;
  112208. private _blendConstants;
  112209. /**
  112210. * Initializes the state.
  112211. */
  112212. constructor();
  112213. get isDirty(): boolean;
  112214. get alphaBlend(): boolean;
  112215. set alphaBlend(value: boolean);
  112216. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112217. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112218. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112219. reset(): void;
  112220. apply(gl: WebGLRenderingContext): void;
  112221. }
  112222. }
  112223. declare module BABYLON {
  112224. /** @hidden */
  112225. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112226. attributeProcessor(attribute: string): string;
  112227. varyingProcessor(varying: string, isFragment: boolean): string;
  112228. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112229. }
  112230. }
  112231. declare module BABYLON {
  112232. /**
  112233. * Interface for attribute information associated with buffer instanciation
  112234. */
  112235. export interface InstancingAttributeInfo {
  112236. /**
  112237. * Name of the GLSL attribute
  112238. * if attribute index is not specified, this is used to retrieve the index from the effect
  112239. */
  112240. attributeName: string;
  112241. /**
  112242. * Index/offset of the attribute in the vertex shader
  112243. * if not specified, this will be computes from the name.
  112244. */
  112245. index?: number;
  112246. /**
  112247. * size of the attribute, 1, 2, 3 or 4
  112248. */
  112249. attributeSize: number;
  112250. /**
  112251. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112252. */
  112253. offset: number;
  112254. /**
  112255. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112256. * default to 1
  112257. */
  112258. divisor?: number;
  112259. /**
  112260. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112261. * default is FLOAT
  112262. */
  112263. attributeType?: number;
  112264. /**
  112265. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112266. */
  112267. normalized?: boolean;
  112268. }
  112269. }
  112270. declare module BABYLON {
  112271. interface ThinEngine {
  112272. /**
  112273. * Update a video texture
  112274. * @param texture defines the texture to update
  112275. * @param video defines the video element to use
  112276. * @param invertY defines if data must be stored with Y axis inverted
  112277. */
  112278. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112279. }
  112280. }
  112281. declare module BABYLON {
  112282. interface ThinEngine {
  112283. /**
  112284. * Creates a dynamic texture
  112285. * @param width defines the width of the texture
  112286. * @param height defines the height of the texture
  112287. * @param generateMipMaps defines if the engine should generate the mip levels
  112288. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112289. * @returns the dynamic texture inside an InternalTexture
  112290. */
  112291. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112292. /**
  112293. * Update the content of a dynamic texture
  112294. * @param texture defines the texture to update
  112295. * @param canvas defines the canvas containing the source
  112296. * @param invertY defines if data must be stored with Y axis inverted
  112297. * @param premulAlpha defines if alpha is stored as premultiplied
  112298. * @param format defines the format of the data
  112299. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112300. */
  112301. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112302. }
  112303. }
  112304. declare module BABYLON {
  112305. /**
  112306. * Settings for finer control over video usage
  112307. */
  112308. export interface VideoTextureSettings {
  112309. /**
  112310. * Applies `autoplay` to video, if specified
  112311. */
  112312. autoPlay?: boolean;
  112313. /**
  112314. * Applies `loop` to video, if specified
  112315. */
  112316. loop?: boolean;
  112317. /**
  112318. * Automatically updates internal texture from video at every frame in the render loop
  112319. */
  112320. autoUpdateTexture: boolean;
  112321. /**
  112322. * Image src displayed during the video loading or until the user interacts with the video.
  112323. */
  112324. poster?: string;
  112325. }
  112326. /**
  112327. * If you want to display a video in your scene, this is the special texture for that.
  112328. * This special texture works similar to other textures, with the exception of a few parameters.
  112329. * @see https://doc.babylonjs.com/how_to/video_texture
  112330. */
  112331. export class VideoTexture extends Texture {
  112332. /**
  112333. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112334. */
  112335. readonly autoUpdateTexture: boolean;
  112336. /**
  112337. * The video instance used by the texture internally
  112338. */
  112339. readonly video: HTMLVideoElement;
  112340. private _onUserActionRequestedObservable;
  112341. /**
  112342. * Event triggerd when a dom action is required by the user to play the video.
  112343. * This happens due to recent changes in browser policies preventing video to auto start.
  112344. */
  112345. get onUserActionRequestedObservable(): Observable<Texture>;
  112346. private _generateMipMaps;
  112347. private _stillImageCaptured;
  112348. private _displayingPosterTexture;
  112349. private _settings;
  112350. private _createInternalTextureOnEvent;
  112351. private _frameId;
  112352. private _currentSrc;
  112353. /**
  112354. * Creates a video texture.
  112355. * If you want to display a video in your scene, this is the special texture for that.
  112356. * This special texture works similar to other textures, with the exception of a few parameters.
  112357. * @see https://doc.babylonjs.com/how_to/video_texture
  112358. * @param name optional name, will detect from video source, if not defined
  112359. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112360. * @param scene is obviously the current scene.
  112361. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112362. * @param invertY is false by default but can be used to invert video on Y axis
  112363. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112364. * @param settings allows finer control over video usage
  112365. */
  112366. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112367. private _getName;
  112368. private _getVideo;
  112369. private _createInternalTexture;
  112370. private reset;
  112371. /**
  112372. * @hidden Internal method to initiate `update`.
  112373. */
  112374. _rebuild(): void;
  112375. /**
  112376. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112377. */
  112378. update(): void;
  112379. /**
  112380. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112381. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112382. */
  112383. updateTexture(isVisible: boolean): void;
  112384. protected _updateInternalTexture: () => void;
  112385. /**
  112386. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112387. * @param url New url.
  112388. */
  112389. updateURL(url: string): void;
  112390. /**
  112391. * Clones the texture.
  112392. * @returns the cloned texture
  112393. */
  112394. clone(): VideoTexture;
  112395. /**
  112396. * Dispose the texture and release its associated resources.
  112397. */
  112398. dispose(): void;
  112399. /**
  112400. * Creates a video texture straight from a stream.
  112401. * @param scene Define the scene the texture should be created in
  112402. * @param stream Define the stream the texture should be created from
  112403. * @returns The created video texture as a promise
  112404. */
  112405. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112406. /**
  112407. * Creates a video texture straight from your WebCam video feed.
  112408. * @param scene Define the scene the texture should be created in
  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. * @returns The created video texture as a promise
  112412. */
  112413. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112414. minWidth: number;
  112415. maxWidth: number;
  112416. minHeight: number;
  112417. maxHeight: number;
  112418. deviceId: string;
  112419. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112420. /**
  112421. * Creates a video texture straight from your WebCam video feed.
  112422. * @param scene Define the scene the texture should be created in
  112423. * @param onReady Define a callback to triggered once the texture will be ready
  112424. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112425. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112426. */
  112427. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112428. minWidth: number;
  112429. maxWidth: number;
  112430. minHeight: number;
  112431. maxHeight: number;
  112432. deviceId: string;
  112433. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112434. }
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * Defines the interface used by objects working like Scene
  112439. * @hidden
  112440. */
  112441. export interface ISceneLike {
  112442. _addPendingData(data: any): void;
  112443. _removePendingData(data: any): void;
  112444. offlineProvider: IOfflineProvider;
  112445. }
  112446. /** Interface defining initialization parameters for Engine class */
  112447. export interface EngineOptions extends WebGLContextAttributes {
  112448. /**
  112449. * Defines if the engine should no exceed a specified device ratio
  112450. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112451. */
  112452. limitDeviceRatio?: number;
  112453. /**
  112454. * Defines if webvr should be enabled automatically
  112455. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112456. */
  112457. autoEnableWebVR?: boolean;
  112458. /**
  112459. * Defines if webgl2 should be turned off even if supported
  112460. * @see https://doc.babylonjs.com/features/webgl2
  112461. */
  112462. disableWebGL2Support?: boolean;
  112463. /**
  112464. * Defines if webaudio should be initialized as well
  112465. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112466. */
  112467. audioEngine?: boolean;
  112468. /**
  112469. * Defines if animations should run using a deterministic lock step
  112470. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112471. */
  112472. deterministicLockstep?: boolean;
  112473. /** Defines the maximum steps to use with deterministic lock step mode */
  112474. lockstepMaxSteps?: number;
  112475. /** Defines the seconds between each deterministic lock step */
  112476. timeStep?: number;
  112477. /**
  112478. * Defines that engine should ignore context lost events
  112479. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112480. */
  112481. doNotHandleContextLost?: boolean;
  112482. /**
  112483. * Defines that engine should ignore modifying touch action attribute and style
  112484. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112485. */
  112486. doNotHandleTouchAction?: boolean;
  112487. /**
  112488. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112489. */
  112490. useHighPrecisionFloats?: boolean;
  112491. /**
  112492. * Make the canvas XR Compatible for XR sessions
  112493. */
  112494. xrCompatible?: boolean;
  112495. }
  112496. /**
  112497. * The base engine class (root of all engines)
  112498. */
  112499. export class ThinEngine {
  112500. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112501. static ExceptionList: ({
  112502. key: string;
  112503. capture: string;
  112504. captureConstraint: number;
  112505. targets: string[];
  112506. } | {
  112507. key: string;
  112508. capture: null;
  112509. captureConstraint: null;
  112510. targets: string[];
  112511. })[];
  112512. /** @hidden */
  112513. static _TextureLoaders: IInternalTextureLoader[];
  112514. /**
  112515. * Returns the current npm package of the sdk
  112516. */
  112517. static get NpmPackage(): string;
  112518. /**
  112519. * Returns the current version of the framework
  112520. */
  112521. static get Version(): string;
  112522. /**
  112523. * Returns a string describing the current engine
  112524. */
  112525. get description(): string;
  112526. /**
  112527. * Gets or sets the epsilon value used by collision engine
  112528. */
  112529. static CollisionsEpsilon: number;
  112530. /**
  112531. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112532. */
  112533. static get ShadersRepository(): string;
  112534. static set ShadersRepository(value: string);
  112535. /** @hidden */
  112536. _shaderProcessor: IShaderProcessor;
  112537. /**
  112538. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112539. */
  112540. forcePOTTextures: boolean;
  112541. /**
  112542. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112543. */
  112544. isFullscreen: boolean;
  112545. /**
  112546. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112547. */
  112548. cullBackFaces: boolean;
  112549. /**
  112550. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112551. */
  112552. renderEvenInBackground: boolean;
  112553. /**
  112554. * Gets or sets a boolean indicating that cache can be kept between frames
  112555. */
  112556. preventCacheWipeBetweenFrames: boolean;
  112557. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112558. validateShaderPrograms: boolean;
  112559. /**
  112560. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112561. * This can provide greater z depth for distant objects.
  112562. */
  112563. useReverseDepthBuffer: boolean;
  112564. /**
  112565. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112566. */
  112567. disableUniformBuffers: boolean;
  112568. /** @hidden */
  112569. _uniformBuffers: UniformBuffer[];
  112570. /**
  112571. * Gets a boolean indicating that the engine supports uniform buffers
  112572. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112573. */
  112574. get supportsUniformBuffers(): boolean;
  112575. /** @hidden */
  112576. _gl: WebGLRenderingContext;
  112577. /** @hidden */
  112578. _webGLVersion: number;
  112579. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112580. protected _windowIsBackground: boolean;
  112581. protected _creationOptions: EngineOptions;
  112582. protected _highPrecisionShadersAllowed: boolean;
  112583. /** @hidden */
  112584. get _shouldUseHighPrecisionShader(): boolean;
  112585. /**
  112586. * Gets a boolean indicating that only power of 2 textures are supported
  112587. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112588. */
  112589. get needPOTTextures(): boolean;
  112590. /** @hidden */
  112591. _badOS: boolean;
  112592. /** @hidden */
  112593. _badDesktopOS: boolean;
  112594. private _hardwareScalingLevel;
  112595. /** @hidden */
  112596. _caps: EngineCapabilities;
  112597. private _isStencilEnable;
  112598. private _glVersion;
  112599. private _glRenderer;
  112600. private _glVendor;
  112601. /** @hidden */
  112602. _videoTextureSupported: boolean;
  112603. protected _renderingQueueLaunched: boolean;
  112604. protected _activeRenderLoops: (() => void)[];
  112605. /**
  112606. * Observable signaled when a context lost event is raised
  112607. */
  112608. onContextLostObservable: Observable<ThinEngine>;
  112609. /**
  112610. * Observable signaled when a context restored event is raised
  112611. */
  112612. onContextRestoredObservable: Observable<ThinEngine>;
  112613. private _onContextLost;
  112614. private _onContextRestored;
  112615. protected _contextWasLost: boolean;
  112616. /** @hidden */
  112617. _doNotHandleContextLost: boolean;
  112618. /**
  112619. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112620. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112621. */
  112622. get doNotHandleContextLost(): boolean;
  112623. set doNotHandleContextLost(value: boolean);
  112624. /**
  112625. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112626. */
  112627. disableVertexArrayObjects: boolean;
  112628. /** @hidden */
  112629. protected _colorWrite: boolean;
  112630. /** @hidden */
  112631. protected _colorWriteChanged: boolean;
  112632. /** @hidden */
  112633. protected _depthCullingState: DepthCullingState;
  112634. /** @hidden */
  112635. protected _stencilState: StencilState;
  112636. /** @hidden */
  112637. _alphaState: AlphaState;
  112638. /** @hidden */
  112639. _alphaMode: number;
  112640. /** @hidden */
  112641. _alphaEquation: number;
  112642. /** @hidden */
  112643. _internalTexturesCache: InternalTexture[];
  112644. /** @hidden */
  112645. protected _activeChannel: number;
  112646. private _currentTextureChannel;
  112647. /** @hidden */
  112648. protected _boundTexturesCache: {
  112649. [key: string]: Nullable<InternalTexture>;
  112650. };
  112651. /** @hidden */
  112652. protected _currentEffect: Nullable<Effect>;
  112653. /** @hidden */
  112654. protected _currentProgram: Nullable<WebGLProgram>;
  112655. private _compiledEffects;
  112656. private _vertexAttribArraysEnabled;
  112657. /** @hidden */
  112658. protected _cachedViewport: Nullable<IViewportLike>;
  112659. private _cachedVertexArrayObject;
  112660. /** @hidden */
  112661. protected _cachedVertexBuffers: any;
  112662. /** @hidden */
  112663. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112664. /** @hidden */
  112665. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112666. /** @hidden */
  112667. _currentRenderTarget: Nullable<InternalTexture>;
  112668. private _uintIndicesCurrentlySet;
  112669. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112670. /** @hidden */
  112671. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112672. /** @hidden */
  112673. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112674. private _currentBufferPointers;
  112675. private _currentInstanceLocations;
  112676. private _currentInstanceBuffers;
  112677. private _textureUnits;
  112678. /** @hidden */
  112679. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112680. /** @hidden */
  112681. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112682. /** @hidden */
  112683. _boundRenderFunction: any;
  112684. private _vaoRecordInProgress;
  112685. private _mustWipeVertexAttributes;
  112686. private _emptyTexture;
  112687. private _emptyCubeTexture;
  112688. private _emptyTexture3D;
  112689. private _emptyTexture2DArray;
  112690. /** @hidden */
  112691. _frameHandler: number;
  112692. private _nextFreeTextureSlots;
  112693. private _maxSimultaneousTextures;
  112694. private _activeRequests;
  112695. /** @hidden */
  112696. _transformTextureUrl: Nullable<(url: string) => string>;
  112697. protected get _supportsHardwareTextureRescaling(): boolean;
  112698. private _framebufferDimensionsObject;
  112699. /**
  112700. * sets the object from which width and height will be taken from when getting render width and height
  112701. * Will fallback to the gl object
  112702. * @param dimensions the framebuffer width and height that will be used.
  112703. */
  112704. set framebufferDimensionsObject(dimensions: Nullable<{
  112705. framebufferWidth: number;
  112706. framebufferHeight: number;
  112707. }>);
  112708. /**
  112709. * Gets the current viewport
  112710. */
  112711. get currentViewport(): Nullable<IViewportLike>;
  112712. /**
  112713. * Gets the default empty texture
  112714. */
  112715. get emptyTexture(): InternalTexture;
  112716. /**
  112717. * Gets the default empty 3D texture
  112718. */
  112719. get emptyTexture3D(): InternalTexture;
  112720. /**
  112721. * Gets the default empty 2D array texture
  112722. */
  112723. get emptyTexture2DArray(): InternalTexture;
  112724. /**
  112725. * Gets the default empty cube texture
  112726. */
  112727. get emptyCubeTexture(): InternalTexture;
  112728. /**
  112729. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112730. */
  112731. readonly premultipliedAlpha: boolean;
  112732. /**
  112733. * Observable event triggered before each texture is initialized
  112734. */
  112735. onBeforeTextureInitObservable: Observable<Texture>;
  112736. /**
  112737. * Creates a new engine
  112738. * @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
  112739. * @param antialias defines enable antialiasing (default: false)
  112740. * @param options defines further options to be sent to the getContext() function
  112741. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112742. */
  112743. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112744. private _rebuildInternalTextures;
  112745. private _rebuildEffects;
  112746. /**
  112747. * Gets a boolean indicating if all created effects are ready
  112748. * @returns true if all effects are ready
  112749. */
  112750. areAllEffectsReady(): boolean;
  112751. protected _rebuildBuffers(): void;
  112752. protected _initGLContext(): void;
  112753. /**
  112754. * Gets version of the current webGL context
  112755. */
  112756. get webGLVersion(): number;
  112757. /**
  112758. * Gets a string idenfifying the name of the class
  112759. * @returns "Engine" string
  112760. */
  112761. getClassName(): string;
  112762. /**
  112763. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112764. */
  112765. get isStencilEnable(): boolean;
  112766. /** @hidden */
  112767. _prepareWorkingCanvas(): void;
  112768. /**
  112769. * Reset the texture cache to empty state
  112770. */
  112771. resetTextureCache(): void;
  112772. /**
  112773. * Gets an object containing information about the current webGL context
  112774. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112775. */
  112776. getGlInfo(): {
  112777. vendor: string;
  112778. renderer: string;
  112779. version: string;
  112780. };
  112781. /**
  112782. * Defines the hardware scaling level.
  112783. * By default the hardware scaling level is computed from the window device ratio.
  112784. * 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.
  112785. * @param level defines the level to use
  112786. */
  112787. setHardwareScalingLevel(level: number): void;
  112788. /**
  112789. * Gets the current hardware scaling level.
  112790. * By default the hardware scaling level is computed from the window device ratio.
  112791. * 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.
  112792. * @returns a number indicating the current hardware scaling level
  112793. */
  112794. getHardwareScalingLevel(): number;
  112795. /**
  112796. * Gets the list of loaded textures
  112797. * @returns an array containing all loaded textures
  112798. */
  112799. getLoadedTexturesCache(): InternalTexture[];
  112800. /**
  112801. * Gets the object containing all engine capabilities
  112802. * @returns the EngineCapabilities object
  112803. */
  112804. getCaps(): EngineCapabilities;
  112805. /**
  112806. * stop executing a render loop function and remove it from the execution array
  112807. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112808. */
  112809. stopRenderLoop(renderFunction?: () => void): void;
  112810. /** @hidden */
  112811. _renderLoop(): void;
  112812. /**
  112813. * Gets the HTML canvas attached with the current webGL context
  112814. * @returns a HTML canvas
  112815. */
  112816. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112817. /**
  112818. * Gets host window
  112819. * @returns the host window object
  112820. */
  112821. getHostWindow(): Nullable<Window>;
  112822. /**
  112823. * Gets the current render width
  112824. * @param useScreen defines if screen size must be used (or the current render target if any)
  112825. * @returns a number defining the current render width
  112826. */
  112827. getRenderWidth(useScreen?: boolean): number;
  112828. /**
  112829. * Gets the current render height
  112830. * @param useScreen defines if screen size must be used (or the current render target if any)
  112831. * @returns a number defining the current render height
  112832. */
  112833. getRenderHeight(useScreen?: boolean): number;
  112834. /**
  112835. * Can be used to override the current requestAnimationFrame requester.
  112836. * @hidden
  112837. */
  112838. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112839. /**
  112840. * Register and execute a render loop. The engine can have more than one render function
  112841. * @param renderFunction defines the function to continuously execute
  112842. */
  112843. runRenderLoop(renderFunction: () => void): void;
  112844. /**
  112845. * Clear the current render buffer or the current render target (if any is set up)
  112846. * @param color defines the color to use
  112847. * @param backBuffer defines if the back buffer must be cleared
  112848. * @param depth defines if the depth buffer must be cleared
  112849. * @param stencil defines if the stencil buffer must be cleared
  112850. */
  112851. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112852. private _viewportCached;
  112853. /** @hidden */
  112854. _viewport(x: number, y: number, width: number, height: number): void;
  112855. /**
  112856. * Set the WebGL's viewport
  112857. * @param viewport defines the viewport element to be used
  112858. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112859. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112860. */
  112861. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112862. /**
  112863. * Begin a new frame
  112864. */
  112865. beginFrame(): void;
  112866. /**
  112867. * Enf the current frame
  112868. */
  112869. endFrame(): void;
  112870. /**
  112871. * Resize the view according to the canvas' size
  112872. */
  112873. resize(): void;
  112874. /**
  112875. * Force a specific size of the canvas
  112876. * @param width defines the new canvas' width
  112877. * @param height defines the new canvas' height
  112878. * @returns true if the size was changed
  112879. */
  112880. setSize(width: number, height: number): boolean;
  112881. /**
  112882. * Binds the frame buffer to the specified texture.
  112883. * @param texture The texture to render to or null for the default canvas
  112884. * @param faceIndex The face of the texture to render to in case of cube texture
  112885. * @param requiredWidth The width of the target to render to
  112886. * @param requiredHeight The height of the target to render to
  112887. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112888. * @param lodLevel defines the lod level to bind to the frame buffer
  112889. * @param layer defines the 2d array index to bind to frame buffer to
  112890. */
  112891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112892. /** @hidden */
  112893. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112894. /**
  112895. * Unbind the current render target texture from the webGL context
  112896. * @param texture defines the render target texture to unbind
  112897. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112898. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112899. */
  112900. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112901. /**
  112902. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112903. */
  112904. flushFramebuffer(): void;
  112905. /**
  112906. * Unbind the current render target and bind the default framebuffer
  112907. */
  112908. restoreDefaultFramebuffer(): void;
  112909. /** @hidden */
  112910. protected _resetVertexBufferBinding(): void;
  112911. /**
  112912. * Creates a vertex buffer
  112913. * @param data the data for the vertex buffer
  112914. * @returns the new WebGL static buffer
  112915. */
  112916. createVertexBuffer(data: DataArray): DataBuffer;
  112917. private _createVertexBuffer;
  112918. /**
  112919. * Creates a dynamic vertex buffer
  112920. * @param data the data for the dynamic vertex buffer
  112921. * @returns the new WebGL dynamic buffer
  112922. */
  112923. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112924. protected _resetIndexBufferBinding(): void;
  112925. /**
  112926. * Creates a new index buffer
  112927. * @param indices defines the content of the index buffer
  112928. * @param updatable defines if the index buffer must be updatable
  112929. * @returns a new webGL buffer
  112930. */
  112931. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112932. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112933. /**
  112934. * Bind a webGL buffer to the webGL context
  112935. * @param buffer defines the buffer to bind
  112936. */
  112937. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112938. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112939. private bindBuffer;
  112940. /**
  112941. * update the bound buffer with the given data
  112942. * @param data defines the data to update
  112943. */
  112944. updateArrayBuffer(data: Float32Array): void;
  112945. private _vertexAttribPointer;
  112946. /** @hidden */
  112947. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112948. private _bindVertexBuffersAttributes;
  112949. /**
  112950. * Records a vertex array object
  112951. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112952. * @param vertexBuffers defines the list of vertex buffers to store
  112953. * @param indexBuffer defines the index buffer to store
  112954. * @param effect defines the effect to store
  112955. * @returns the new vertex array object
  112956. */
  112957. recordVertexArrayObject(vertexBuffers: {
  112958. [key: string]: VertexBuffer;
  112959. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112960. /**
  112961. * Bind a specific vertex array object
  112962. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112963. * @param vertexArrayObject defines the vertex array object to bind
  112964. * @param indexBuffer defines the index buffer to bind
  112965. */
  112966. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112967. /**
  112968. * Bind webGl buffers directly to the webGL context
  112969. * @param vertexBuffer defines the vertex buffer to bind
  112970. * @param indexBuffer defines the index buffer to bind
  112971. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112972. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112973. * @param effect defines the effect associated with the vertex buffer
  112974. */
  112975. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112976. private _unbindVertexArrayObject;
  112977. /**
  112978. * Bind a list of vertex buffers to the webGL context
  112979. * @param vertexBuffers defines the list of vertex buffers to bind
  112980. * @param indexBuffer defines the index buffer to bind
  112981. * @param effect defines the effect associated with the vertex buffers
  112982. */
  112983. bindBuffers(vertexBuffers: {
  112984. [key: string]: Nullable<VertexBuffer>;
  112985. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112986. /**
  112987. * Unbind all instance attributes
  112988. */
  112989. unbindInstanceAttributes(): void;
  112990. /**
  112991. * Release and free the memory of a vertex array object
  112992. * @param vao defines the vertex array object to delete
  112993. */
  112994. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112995. /** @hidden */
  112996. _releaseBuffer(buffer: DataBuffer): boolean;
  112997. protected _deleteBuffer(buffer: DataBuffer): void;
  112998. /**
  112999. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  113000. * @param instancesBuffer defines the webGL buffer to update and bind
  113001. * @param data defines the data to store in the buffer
  113002. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  113003. */
  113004. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113005. /**
  113006. * Bind the content of a webGL buffer used with instantiation
  113007. * @param instancesBuffer defines the webGL buffer to bind
  113008. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113009. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113010. */
  113011. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113012. /**
  113013. * Disable the instance attribute corresponding to the name in parameter
  113014. * @param name defines the name of the attribute to disable
  113015. */
  113016. disableInstanceAttributeByName(name: string): void;
  113017. /**
  113018. * Disable the instance attribute corresponding to the location in parameter
  113019. * @param attributeLocation defines the attribute location of the attribute to disable
  113020. */
  113021. disableInstanceAttribute(attributeLocation: number): void;
  113022. /**
  113023. * Disable the attribute corresponding to the location in parameter
  113024. * @param attributeLocation defines the attribute location of the attribute to disable
  113025. */
  113026. disableAttributeByIndex(attributeLocation: number): void;
  113027. /**
  113028. * Send a draw order
  113029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113030. * @param indexStart defines the starting index
  113031. * @param indexCount defines the number of index to draw
  113032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113033. */
  113034. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113035. /**
  113036. * Draw a list of points
  113037. * @param verticesStart defines the index of first vertex to draw
  113038. * @param verticesCount defines the count of vertices to draw
  113039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113040. */
  113041. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113042. /**
  113043. * Draw a list of unindexed primitives
  113044. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113045. * @param verticesStart defines the index of first vertex to draw
  113046. * @param verticesCount defines the count of vertices to draw
  113047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113048. */
  113049. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113050. /**
  113051. * Draw a list of indexed primitives
  113052. * @param fillMode defines the primitive to use
  113053. * @param indexStart defines the starting index
  113054. * @param indexCount defines the number of index to draw
  113055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113056. */
  113057. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113058. /**
  113059. * Draw a list of unindexed primitives
  113060. * @param fillMode defines the primitive to use
  113061. * @param verticesStart defines the index of first vertex to draw
  113062. * @param verticesCount defines the count of vertices to draw
  113063. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113064. */
  113065. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113066. private _drawMode;
  113067. /** @hidden */
  113068. protected _reportDrawCall(): void;
  113069. /** @hidden */
  113070. _releaseEffect(effect: Effect): void;
  113071. /** @hidden */
  113072. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113073. /**
  113074. * Create a new effect (used to store vertex/fragment shaders)
  113075. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113076. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113077. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113078. * @param samplers defines an array of string used to represent textures
  113079. * @param defines defines the string containing the defines to use to compile the shaders
  113080. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113081. * @param onCompiled defines a function to call when the effect creation is successful
  113082. * @param onError defines a function to call when the effect creation has failed
  113083. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113084. * @returns the new Effect
  113085. */
  113086. 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;
  113087. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113088. private _compileShader;
  113089. private _compileRawShader;
  113090. /** @hidden */
  113091. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113092. /**
  113093. * Directly creates a webGL program
  113094. * @param pipelineContext defines the pipeline context to attach to
  113095. * @param vertexCode defines the vertex shader code to use
  113096. * @param fragmentCode defines the fragment shader code to use
  113097. * @param context defines the webGL context to use (if not set, the current one will be used)
  113098. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113099. * @returns the new webGL program
  113100. */
  113101. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113102. /**
  113103. * Creates a webGL program
  113104. * @param pipelineContext defines the pipeline context to attach to
  113105. * @param vertexCode defines the vertex shader code to use
  113106. * @param fragmentCode defines the fragment shader code to use
  113107. * @param defines defines the string containing the defines to use to compile the shaders
  113108. * @param context defines the webGL context to use (if not set, the current one will be used)
  113109. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113110. * @returns the new webGL program
  113111. */
  113112. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113113. /**
  113114. * Creates a new pipeline context
  113115. * @returns the new pipeline
  113116. */
  113117. createPipelineContext(): IPipelineContext;
  113118. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113119. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113120. /** @hidden */
  113121. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113122. /** @hidden */
  113123. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113124. /** @hidden */
  113125. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113126. /**
  113127. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113128. * @param pipelineContext defines the pipeline context to use
  113129. * @param uniformsNames defines the list of uniform names
  113130. * @returns an array of webGL uniform locations
  113131. */
  113132. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113133. /**
  113134. * Gets the lsit of active attributes for a given webGL program
  113135. * @param pipelineContext defines the pipeline context to use
  113136. * @param attributesNames defines the list of attribute names to get
  113137. * @returns an array of indices indicating the offset of each attribute
  113138. */
  113139. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113140. /**
  113141. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113142. * @param effect defines the effect to activate
  113143. */
  113144. enableEffect(effect: Nullable<Effect>): void;
  113145. /**
  113146. * Set the value of an uniform to a number (int)
  113147. * @param uniform defines the webGL uniform location where to store the value
  113148. * @param value defines the int number to store
  113149. */
  113150. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113151. /**
  113152. * Set the value of an uniform to an array of int32
  113153. * @param uniform defines the webGL uniform location where to store the value
  113154. * @param array defines the array of int32 to store
  113155. */
  113156. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113157. /**
  113158. * Set the value of an uniform to an array of int32 (stored as vec2)
  113159. * @param uniform defines the webGL uniform location where to store the value
  113160. * @param array defines the array of int32 to store
  113161. */
  113162. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113163. /**
  113164. * Set the value of an uniform to an array of int32 (stored as vec3)
  113165. * @param uniform defines the webGL uniform location where to store the value
  113166. * @param array defines the array of int32 to store
  113167. */
  113168. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113169. /**
  113170. * Set the value of an uniform to an array of int32 (stored as vec4)
  113171. * @param uniform defines the webGL uniform location where to store the value
  113172. * @param array defines the array of int32 to store
  113173. */
  113174. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113175. /**
  113176. * Set the value of an uniform to an array of number
  113177. * @param uniform defines the webGL uniform location where to store the value
  113178. * @param array defines the array of number to store
  113179. */
  113180. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113181. /**
  113182. * Set the value of an uniform to an array of number (stored as vec2)
  113183. * @param uniform defines the webGL uniform location where to store the value
  113184. * @param array defines the array of number to store
  113185. */
  113186. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113187. /**
  113188. * Set the value of an uniform to an array of number (stored as vec3)
  113189. * @param uniform defines the webGL uniform location where to store the value
  113190. * @param array defines the array of number to store
  113191. */
  113192. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113193. /**
  113194. * Set the value of an uniform to an array of number (stored as vec4)
  113195. * @param uniform defines the webGL uniform location where to store the value
  113196. * @param array defines the array of number to store
  113197. */
  113198. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113199. /**
  113200. * Set the value of an uniform to an array of float32 (stored as matrices)
  113201. * @param uniform defines the webGL uniform location where to store the value
  113202. * @param matrices defines the array of float32 to store
  113203. */
  113204. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113205. /**
  113206. * Set the value of an uniform to a matrix (3x3)
  113207. * @param uniform defines the webGL uniform location where to store the value
  113208. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113209. */
  113210. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113211. /**
  113212. * Set the value of an uniform to a matrix (2x2)
  113213. * @param uniform defines the webGL uniform location where to store the value
  113214. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113215. */
  113216. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113217. /**
  113218. * Set the value of an uniform to a number (float)
  113219. * @param uniform defines the webGL uniform location where to store the value
  113220. * @param value defines the float number to store
  113221. */
  113222. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113223. /**
  113224. * Set the value of an uniform to a vec2
  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. */
  113229. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113230. /**
  113231. * Set the value of an uniform to a vec3
  113232. * @param uniform defines the webGL uniform location where to store the value
  113233. * @param x defines the 1st component of the value
  113234. * @param y defines the 2nd component of the value
  113235. * @param z defines the 3rd component of the value
  113236. */
  113237. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113238. /**
  113239. * Set the value of an uniform to a vec4
  113240. * @param uniform defines the webGL uniform location where to store the value
  113241. * @param x defines the 1st component of the value
  113242. * @param y defines the 2nd component of the value
  113243. * @param z defines the 3rd component of the value
  113244. * @param w defines the 4th component of the value
  113245. */
  113246. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113247. /**
  113248. * Apply all cached states (depth, culling, stencil and alpha)
  113249. */
  113250. applyStates(): void;
  113251. /**
  113252. * Enable or disable color writing
  113253. * @param enable defines the state to set
  113254. */
  113255. setColorWrite(enable: boolean): void;
  113256. /**
  113257. * Gets a boolean indicating if color writing is enabled
  113258. * @returns the current color writing state
  113259. */
  113260. getColorWrite(): boolean;
  113261. /**
  113262. * Gets the depth culling state manager
  113263. */
  113264. get depthCullingState(): DepthCullingState;
  113265. /**
  113266. * Gets the alpha state manager
  113267. */
  113268. get alphaState(): AlphaState;
  113269. /**
  113270. * Gets the stencil state manager
  113271. */
  113272. get stencilState(): StencilState;
  113273. /**
  113274. * Clears the list of texture accessible through engine.
  113275. * This can help preventing texture load conflict due to name collision.
  113276. */
  113277. clearInternalTexturesCache(): void;
  113278. /**
  113279. * Force the entire cache to be cleared
  113280. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113281. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113282. */
  113283. wipeCaches(bruteForce?: boolean): void;
  113284. /** @hidden */
  113285. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113286. min: number;
  113287. mag: number;
  113288. };
  113289. /** @hidden */
  113290. _createTexture(): WebGLTexture;
  113291. /**
  113292. * Usually called from Texture.ts.
  113293. * Passed information to create a WebGLTexture
  113294. * @param url defines a value which contains one of the following:
  113295. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113296. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113297. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113298. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113299. * @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)
  113300. * @param scene needed for loading to the correct scene
  113301. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113302. * @param onLoad optional callback to be called upon successful completion
  113303. * @param onError optional callback to be called upon failure
  113304. * @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
  113305. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113306. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113307. * @param forcedExtension defines the extension to use to pick the right loader
  113308. * @param mimeType defines an optional mime type
  113309. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113310. */
  113311. 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;
  113312. /**
  113313. * Loads an image as an HTMLImageElement.
  113314. * @param input url string, ArrayBuffer, or Blob to load
  113315. * @param onLoad callback called when the image successfully loads
  113316. * @param onError callback called when the image fails to load
  113317. * @param offlineProvider offline provider for caching
  113318. * @param mimeType optional mime type
  113319. * @returns the HTMLImageElement of the loaded image
  113320. * @hidden
  113321. */
  113322. 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>;
  113323. /**
  113324. * @hidden
  113325. */
  113326. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113327. private _unpackFlipYCached;
  113328. /**
  113329. * In case you are sharing the context with other applications, it might
  113330. * be interested to not cache the unpack flip y state to ensure a consistent
  113331. * value would be set.
  113332. */
  113333. enableUnpackFlipYCached: boolean;
  113334. /** @hidden */
  113335. _unpackFlipY(value: boolean): void;
  113336. /** @hidden */
  113337. _getUnpackAlignement(): number;
  113338. private _getTextureTarget;
  113339. /**
  113340. * Update the sampling mode of a given texture
  113341. * @param samplingMode defines the required sampling mode
  113342. * @param texture defines the texture to update
  113343. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113344. */
  113345. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113346. /**
  113347. * Update the sampling mode of a given texture
  113348. * @param texture defines the texture to update
  113349. * @param wrapU defines the texture wrap mode of the u coordinates
  113350. * @param wrapV defines the texture wrap mode of the v coordinates
  113351. * @param wrapR defines the texture wrap mode of the r coordinates
  113352. */
  113353. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113354. /** @hidden */
  113355. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113356. width: number;
  113357. height: number;
  113358. layers?: number;
  113359. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113360. /** @hidden */
  113361. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113362. /** @hidden */
  113363. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113364. /**
  113365. * Update a portion of an internal texture
  113366. * @param texture defines the texture to update
  113367. * @param imageData defines the data to store into the texture
  113368. * @param xOffset defines the x coordinates of the update rectangle
  113369. * @param yOffset defines the y coordinates of the update rectangle
  113370. * @param width defines the width of the update rectangle
  113371. * @param height defines the height of the update rectangle
  113372. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113373. * @param lod defines the lod level to update (0 by default)
  113374. */
  113375. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113376. /** @hidden */
  113377. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113378. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113379. private _prepareWebGLTexture;
  113380. /** @hidden */
  113381. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113382. private _getDepthStencilBuffer;
  113383. /** @hidden */
  113384. _releaseFramebufferObjects(texture: InternalTexture): void;
  113385. /** @hidden */
  113386. _releaseTexture(texture: InternalTexture): void;
  113387. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113388. protected _setProgram(program: WebGLProgram): void;
  113389. protected _boundUniforms: {
  113390. [key: number]: WebGLUniformLocation;
  113391. };
  113392. /**
  113393. * Binds an effect to the webGL context
  113394. * @param effect defines the effect to bind
  113395. */
  113396. bindSamplers(effect: Effect): void;
  113397. private _activateCurrentTexture;
  113398. /** @hidden */
  113399. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113400. /** @hidden */
  113401. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113402. /**
  113403. * Unbind all textures from the webGL context
  113404. */
  113405. unbindAllTextures(): void;
  113406. /**
  113407. * Sets a texture to the according uniform.
  113408. * @param channel The texture channel
  113409. * @param uniform The uniform to set
  113410. * @param texture The texture to apply
  113411. */
  113412. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113413. private _bindSamplerUniformToChannel;
  113414. private _getTextureWrapMode;
  113415. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113416. /**
  113417. * Sets an array of texture to the webGL context
  113418. * @param channel defines the channel where the texture array must be set
  113419. * @param uniform defines the associated uniform location
  113420. * @param textures defines the array of textures to bind
  113421. */
  113422. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113423. /** @hidden */
  113424. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113425. private _setTextureParameterFloat;
  113426. private _setTextureParameterInteger;
  113427. /**
  113428. * Unbind all vertex attributes from the webGL context
  113429. */
  113430. unbindAllAttributes(): void;
  113431. /**
  113432. * 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
  113433. */
  113434. releaseEffects(): void;
  113435. /**
  113436. * Dispose and release all associated resources
  113437. */
  113438. dispose(): void;
  113439. /**
  113440. * Attach a new callback raised when context lost event is fired
  113441. * @param callback defines the callback to call
  113442. */
  113443. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113444. /**
  113445. * Attach a new callback raised when context restored event is fired
  113446. * @param callback defines the callback to call
  113447. */
  113448. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113449. /**
  113450. * Get the current error code of the webGL context
  113451. * @returns the error code
  113452. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113453. */
  113454. getError(): number;
  113455. private _canRenderToFloatFramebuffer;
  113456. private _canRenderToHalfFloatFramebuffer;
  113457. private _canRenderToFramebuffer;
  113458. /** @hidden */
  113459. _getWebGLTextureType(type: number): number;
  113460. /** @hidden */
  113461. _getInternalFormat(format: number): number;
  113462. /** @hidden */
  113463. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113464. /** @hidden */
  113465. _getRGBAMultiSampleBufferFormat(type: number): number;
  113466. /** @hidden */
  113467. _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;
  113468. /**
  113469. * Loads a file from a url
  113470. * @param url url to load
  113471. * @param onSuccess callback called when the file successfully loads
  113472. * @param onProgress callback called while file is loading (if the server supports this mode)
  113473. * @param offlineProvider defines the offline provider for caching
  113474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113475. * @param onError callback called when the file fails to load
  113476. * @returns a file request object
  113477. * @hidden
  113478. */
  113479. 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;
  113480. /**
  113481. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113482. * @param x defines the x coordinate of the rectangle where pixels must be read
  113483. * @param y defines the y coordinate of the rectangle where pixels must be read
  113484. * @param width defines the width of the rectangle where pixels must be read
  113485. * @param height defines the height of the rectangle where pixels must be read
  113486. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113487. * @returns a Uint8Array containing RGBA colors
  113488. */
  113489. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113490. private static _isSupported;
  113491. /**
  113492. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113493. * @returns true if the engine can be created
  113494. * @ignorenaming
  113495. */
  113496. static isSupported(): boolean;
  113497. /**
  113498. * Find the next highest power of two.
  113499. * @param x Number to start search from.
  113500. * @return Next highest power of two.
  113501. */
  113502. static CeilingPOT(x: number): number;
  113503. /**
  113504. * Find the next lowest power of two.
  113505. * @param x Number to start search from.
  113506. * @return Next lowest power of two.
  113507. */
  113508. static FloorPOT(x: number): number;
  113509. /**
  113510. * Find the nearest power of two.
  113511. * @param x Number to start search from.
  113512. * @return Next nearest power of two.
  113513. */
  113514. static NearestPOT(x: number): number;
  113515. /**
  113516. * Get the closest exponent of two
  113517. * @param value defines the value to approximate
  113518. * @param max defines the maximum value to return
  113519. * @param mode defines how to define the closest value
  113520. * @returns closest exponent of two of the given value
  113521. */
  113522. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113523. /**
  113524. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113525. * @param func - the function to be called
  113526. * @param requester - the object that will request the next frame. Falls back to window.
  113527. * @returns frame number
  113528. */
  113529. static QueueNewFrame(func: () => void, requester?: any): number;
  113530. /**
  113531. * Gets host document
  113532. * @returns the host document object
  113533. */
  113534. getHostDocument(): Nullable<Document>;
  113535. }
  113536. }
  113537. declare module BABYLON {
  113538. /**
  113539. * Class representing spherical harmonics coefficients to the 3rd degree
  113540. */
  113541. export class SphericalHarmonics {
  113542. /**
  113543. * Defines whether or not the harmonics have been prescaled for rendering.
  113544. */
  113545. preScaled: boolean;
  113546. /**
  113547. * The l0,0 coefficients of the spherical harmonics
  113548. */
  113549. l00: Vector3;
  113550. /**
  113551. * The l1,-1 coefficients of the spherical harmonics
  113552. */
  113553. l1_1: Vector3;
  113554. /**
  113555. * The l1,0 coefficients of the spherical harmonics
  113556. */
  113557. l10: Vector3;
  113558. /**
  113559. * The l1,1 coefficients of the spherical harmonics
  113560. */
  113561. l11: Vector3;
  113562. /**
  113563. * The l2,-2 coefficients of the spherical harmonics
  113564. */
  113565. l2_2: Vector3;
  113566. /**
  113567. * The l2,-1 coefficients of the spherical harmonics
  113568. */
  113569. l2_1: Vector3;
  113570. /**
  113571. * The l2,0 coefficients of the spherical harmonics
  113572. */
  113573. l20: Vector3;
  113574. /**
  113575. * The l2,1 coefficients of the spherical harmonics
  113576. */
  113577. l21: Vector3;
  113578. /**
  113579. * The l2,2 coefficients of the spherical harmonics
  113580. */
  113581. l22: Vector3;
  113582. /**
  113583. * Adds a light to the spherical harmonics
  113584. * @param direction the direction of the light
  113585. * @param color the color of the light
  113586. * @param deltaSolidAngle the delta solid angle of the light
  113587. */
  113588. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113589. /**
  113590. * Scales the spherical harmonics by the given amount
  113591. * @param scale the amount to scale
  113592. */
  113593. scaleInPlace(scale: number): void;
  113594. /**
  113595. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113596. *
  113597. * ```
  113598. * E_lm = A_l * L_lm
  113599. * ```
  113600. *
  113601. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113602. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113603. * the scaling factors are given in equation 9.
  113604. */
  113605. convertIncidentRadianceToIrradiance(): void;
  113606. /**
  113607. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113608. *
  113609. * ```
  113610. * L = (1/pi) * E * rho
  113611. * ```
  113612. *
  113613. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113614. */
  113615. convertIrradianceToLambertianRadiance(): void;
  113616. /**
  113617. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113618. * required operations at run time.
  113619. *
  113620. * This is simply done by scaling back the SH with Ylm constants parameter.
  113621. * The trigonometric part being applied by the shader at run time.
  113622. */
  113623. preScaleForRendering(): void;
  113624. /**
  113625. * Constructs a spherical harmonics from an array.
  113626. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113627. * @returns the spherical harmonics
  113628. */
  113629. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113630. /**
  113631. * Gets the spherical harmonics from polynomial
  113632. * @param polynomial the spherical polynomial
  113633. * @returns the spherical harmonics
  113634. */
  113635. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113636. }
  113637. /**
  113638. * Class representing spherical polynomial coefficients to the 3rd degree
  113639. */
  113640. export class SphericalPolynomial {
  113641. private _harmonics;
  113642. /**
  113643. * The spherical harmonics used to create the polynomials.
  113644. */
  113645. get preScaledHarmonics(): SphericalHarmonics;
  113646. /**
  113647. * The x coefficients of the spherical polynomial
  113648. */
  113649. x: Vector3;
  113650. /**
  113651. * The y coefficients of the spherical polynomial
  113652. */
  113653. y: Vector3;
  113654. /**
  113655. * The z coefficients of the spherical polynomial
  113656. */
  113657. z: Vector3;
  113658. /**
  113659. * The xx coefficients of the spherical polynomial
  113660. */
  113661. xx: Vector3;
  113662. /**
  113663. * The yy coefficients of the spherical polynomial
  113664. */
  113665. yy: Vector3;
  113666. /**
  113667. * The zz coefficients of the spherical polynomial
  113668. */
  113669. zz: Vector3;
  113670. /**
  113671. * The xy coefficients of the spherical polynomial
  113672. */
  113673. xy: Vector3;
  113674. /**
  113675. * The yz coefficients of the spherical polynomial
  113676. */
  113677. yz: Vector3;
  113678. /**
  113679. * The zx coefficients of the spherical polynomial
  113680. */
  113681. zx: Vector3;
  113682. /**
  113683. * Adds an ambient color to the spherical polynomial
  113684. * @param color the color to add
  113685. */
  113686. addAmbient(color: Color3): void;
  113687. /**
  113688. * Scales the spherical polynomial by the given amount
  113689. * @param scale the amount to scale
  113690. */
  113691. scaleInPlace(scale: number): void;
  113692. /**
  113693. * Gets the spherical polynomial from harmonics
  113694. * @param harmonics the spherical harmonics
  113695. * @returns the spherical polynomial
  113696. */
  113697. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113698. /**
  113699. * Constructs a spherical polynomial from an array.
  113700. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113701. * @returns the spherical polynomial
  113702. */
  113703. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113704. }
  113705. }
  113706. declare module BABYLON {
  113707. /**
  113708. * Defines the source of the internal texture
  113709. */
  113710. export enum InternalTextureSource {
  113711. /**
  113712. * The source of the texture data is unknown
  113713. */
  113714. Unknown = 0,
  113715. /**
  113716. * Texture data comes from an URL
  113717. */
  113718. Url = 1,
  113719. /**
  113720. * Texture data is only used for temporary storage
  113721. */
  113722. Temp = 2,
  113723. /**
  113724. * Texture data comes from raw data (ArrayBuffer)
  113725. */
  113726. Raw = 3,
  113727. /**
  113728. * Texture content is dynamic (video or dynamic texture)
  113729. */
  113730. Dynamic = 4,
  113731. /**
  113732. * Texture content is generated by rendering to it
  113733. */
  113734. RenderTarget = 5,
  113735. /**
  113736. * Texture content is part of a multi render target process
  113737. */
  113738. MultiRenderTarget = 6,
  113739. /**
  113740. * Texture data comes from a cube data file
  113741. */
  113742. Cube = 7,
  113743. /**
  113744. * Texture data comes from a raw cube data
  113745. */
  113746. CubeRaw = 8,
  113747. /**
  113748. * Texture data come from a prefiltered cube data file
  113749. */
  113750. CubePrefiltered = 9,
  113751. /**
  113752. * Texture content is raw 3D data
  113753. */
  113754. Raw3D = 10,
  113755. /**
  113756. * Texture content is raw 2D array data
  113757. */
  113758. Raw2DArray = 11,
  113759. /**
  113760. * Texture content is a depth texture
  113761. */
  113762. Depth = 12,
  113763. /**
  113764. * Texture data comes from a raw cube data encoded with RGBD
  113765. */
  113766. CubeRawRGBD = 13
  113767. }
  113768. /**
  113769. * Class used to store data associated with WebGL texture data for the engine
  113770. * This class should not be used directly
  113771. */
  113772. export class InternalTexture {
  113773. /** @hidden */
  113774. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113775. /**
  113776. * Defines if the texture is ready
  113777. */
  113778. isReady: boolean;
  113779. /**
  113780. * Defines if the texture is a cube texture
  113781. */
  113782. isCube: boolean;
  113783. /**
  113784. * Defines if the texture contains 3D data
  113785. */
  113786. is3D: boolean;
  113787. /**
  113788. * Defines if the texture contains 2D array data
  113789. */
  113790. is2DArray: boolean;
  113791. /**
  113792. * Defines if the texture contains multiview data
  113793. */
  113794. isMultiview: boolean;
  113795. /**
  113796. * Gets the URL used to load this texture
  113797. */
  113798. url: string;
  113799. /**
  113800. * Gets the sampling mode of the texture
  113801. */
  113802. samplingMode: number;
  113803. /**
  113804. * Gets a boolean indicating if the texture needs mipmaps generation
  113805. */
  113806. generateMipMaps: boolean;
  113807. /**
  113808. * Gets the number of samples used by the texture (WebGL2+ only)
  113809. */
  113810. samples: number;
  113811. /**
  113812. * Gets the type of the texture (int, float...)
  113813. */
  113814. type: number;
  113815. /**
  113816. * Gets the format of the texture (RGB, RGBA...)
  113817. */
  113818. format: number;
  113819. /**
  113820. * Observable called when the texture is loaded
  113821. */
  113822. onLoadedObservable: Observable<InternalTexture>;
  113823. /**
  113824. * Gets the width of the texture
  113825. */
  113826. width: number;
  113827. /**
  113828. * Gets the height of the texture
  113829. */
  113830. height: number;
  113831. /**
  113832. * Gets the depth of the texture
  113833. */
  113834. depth: number;
  113835. /**
  113836. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113837. */
  113838. baseWidth: number;
  113839. /**
  113840. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113841. */
  113842. baseHeight: number;
  113843. /**
  113844. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113845. */
  113846. baseDepth: number;
  113847. /**
  113848. * Gets a boolean indicating if the texture is inverted on Y axis
  113849. */
  113850. invertY: boolean;
  113851. /** @hidden */
  113852. _invertVScale: boolean;
  113853. /** @hidden */
  113854. _associatedChannel: number;
  113855. /** @hidden */
  113856. _source: InternalTextureSource;
  113857. /** @hidden */
  113858. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113859. /** @hidden */
  113860. _bufferView: Nullable<ArrayBufferView>;
  113861. /** @hidden */
  113862. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113863. /** @hidden */
  113864. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113865. /** @hidden */
  113866. _size: number;
  113867. /** @hidden */
  113868. _extension: string;
  113869. /** @hidden */
  113870. _files: Nullable<string[]>;
  113871. /** @hidden */
  113872. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113873. /** @hidden */
  113874. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113875. /** @hidden */
  113876. _framebuffer: Nullable<WebGLFramebuffer>;
  113877. /** @hidden */
  113878. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113879. /** @hidden */
  113880. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113881. /** @hidden */
  113882. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113883. /** @hidden */
  113884. _attachments: Nullable<number[]>;
  113885. /** @hidden */
  113886. _textureArray: Nullable<InternalTexture[]>;
  113887. /** @hidden */
  113888. _cachedCoordinatesMode: Nullable<number>;
  113889. /** @hidden */
  113890. _cachedWrapU: Nullable<number>;
  113891. /** @hidden */
  113892. _cachedWrapV: Nullable<number>;
  113893. /** @hidden */
  113894. _cachedWrapR: Nullable<number>;
  113895. /** @hidden */
  113896. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113897. /** @hidden */
  113898. _isDisabled: boolean;
  113899. /** @hidden */
  113900. _compression: Nullable<string>;
  113901. /** @hidden */
  113902. _generateStencilBuffer: boolean;
  113903. /** @hidden */
  113904. _generateDepthBuffer: boolean;
  113905. /** @hidden */
  113906. _comparisonFunction: number;
  113907. /** @hidden */
  113908. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113909. /** @hidden */
  113910. _lodGenerationScale: number;
  113911. /** @hidden */
  113912. _lodGenerationOffset: number;
  113913. /** @hidden */
  113914. _depthStencilTexture: Nullable<InternalTexture>;
  113915. /** @hidden */
  113916. _colorTextureArray: Nullable<WebGLTexture>;
  113917. /** @hidden */
  113918. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113919. /** @hidden */
  113920. _lodTextureHigh: Nullable<BaseTexture>;
  113921. /** @hidden */
  113922. _lodTextureMid: Nullable<BaseTexture>;
  113923. /** @hidden */
  113924. _lodTextureLow: Nullable<BaseTexture>;
  113925. /** @hidden */
  113926. _isRGBD: boolean;
  113927. /** @hidden */
  113928. _linearSpecularLOD: boolean;
  113929. /** @hidden */
  113930. _irradianceTexture: Nullable<BaseTexture>;
  113931. /** @hidden */
  113932. _webGLTexture: Nullable<WebGLTexture>;
  113933. /** @hidden */
  113934. _references: number;
  113935. private _engine;
  113936. /**
  113937. * Gets the Engine the texture belongs to.
  113938. * @returns The babylon engine
  113939. */
  113940. getEngine(): ThinEngine;
  113941. /**
  113942. * Gets the data source type of the texture
  113943. */
  113944. get source(): InternalTextureSource;
  113945. /**
  113946. * Creates a new InternalTexture
  113947. * @param engine defines the engine to use
  113948. * @param source defines the type of data that will be used
  113949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113950. */
  113951. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113952. /**
  113953. * Increments the number of references (ie. the number of Texture that point to it)
  113954. */
  113955. incrementReferences(): void;
  113956. /**
  113957. * Change the size of the texture (not the size of the content)
  113958. * @param width defines the new width
  113959. * @param height defines the new height
  113960. * @param depth defines the new depth (1 by default)
  113961. */
  113962. updateSize(width: int, height: int, depth?: int): void;
  113963. /** @hidden */
  113964. _rebuild(): void;
  113965. /** @hidden */
  113966. _swapAndDie(target: InternalTexture): void;
  113967. /**
  113968. * Dispose the current allocated resources
  113969. */
  113970. dispose(): void;
  113971. }
  113972. }
  113973. declare module BABYLON {
  113974. /**
  113975. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113976. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113977. */
  113978. export class Analyser {
  113979. /**
  113980. * Gets or sets the smoothing
  113981. * @ignorenaming
  113982. */
  113983. SMOOTHING: number;
  113984. /**
  113985. * Gets or sets the FFT table size
  113986. * @ignorenaming
  113987. */
  113988. FFT_SIZE: number;
  113989. /**
  113990. * Gets or sets the bar graph amplitude
  113991. * @ignorenaming
  113992. */
  113993. BARGRAPHAMPLITUDE: number;
  113994. /**
  113995. * Gets or sets the position of the debug canvas
  113996. * @ignorenaming
  113997. */
  113998. DEBUGCANVASPOS: {
  113999. x: number;
  114000. y: number;
  114001. };
  114002. /**
  114003. * Gets or sets the debug canvas size
  114004. * @ignorenaming
  114005. */
  114006. DEBUGCANVASSIZE: {
  114007. width: number;
  114008. height: number;
  114009. };
  114010. private _byteFreqs;
  114011. private _byteTime;
  114012. private _floatFreqs;
  114013. private _webAudioAnalyser;
  114014. private _debugCanvas;
  114015. private _debugCanvasContext;
  114016. private _scene;
  114017. private _registerFunc;
  114018. private _audioEngine;
  114019. /**
  114020. * Creates a new analyser
  114021. * @param scene defines hosting scene
  114022. */
  114023. constructor(scene: Scene);
  114024. /**
  114025. * Get the number of data values you will have to play with for the visualization
  114026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114027. * @returns a number
  114028. */
  114029. getFrequencyBinCount(): number;
  114030. /**
  114031. * Gets the current frequency data as a byte array
  114032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114033. * @returns a Uint8Array
  114034. */
  114035. getByteFrequencyData(): Uint8Array;
  114036. /**
  114037. * Gets the current waveform as a byte array
  114038. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114039. * @returns a Uint8Array
  114040. */
  114041. getByteTimeDomainData(): Uint8Array;
  114042. /**
  114043. * Gets the current frequency data as a float array
  114044. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114045. * @returns a Float32Array
  114046. */
  114047. getFloatFrequencyData(): Float32Array;
  114048. /**
  114049. * Renders the debug canvas
  114050. */
  114051. drawDebugCanvas(): void;
  114052. /**
  114053. * Stops rendering the debug canvas and removes it
  114054. */
  114055. stopDebugCanvas(): void;
  114056. /**
  114057. * Connects two audio nodes
  114058. * @param inputAudioNode defines first node to connect
  114059. * @param outputAudioNode defines second node to connect
  114060. */
  114061. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114062. /**
  114063. * Releases all associated resources
  114064. */
  114065. dispose(): void;
  114066. }
  114067. }
  114068. declare module BABYLON {
  114069. /**
  114070. * This represents an audio engine and it is responsible
  114071. * to play, synchronize and analyse sounds throughout the application.
  114072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114073. */
  114074. export interface IAudioEngine extends IDisposable {
  114075. /**
  114076. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114077. */
  114078. readonly canUseWebAudio: boolean;
  114079. /**
  114080. * Gets the current AudioContext if available.
  114081. */
  114082. readonly audioContext: Nullable<AudioContext>;
  114083. /**
  114084. * The master gain node defines the global audio volume of your audio engine.
  114085. */
  114086. readonly masterGain: GainNode;
  114087. /**
  114088. * Gets whether or not mp3 are supported by your browser.
  114089. */
  114090. readonly isMP3supported: boolean;
  114091. /**
  114092. * Gets whether or not ogg are supported by your browser.
  114093. */
  114094. readonly isOGGsupported: boolean;
  114095. /**
  114096. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114097. * @ignoreNaming
  114098. */
  114099. WarnedWebAudioUnsupported: boolean;
  114100. /**
  114101. * Defines if the audio engine relies on a custom unlocked button.
  114102. * In this case, the embedded button will not be displayed.
  114103. */
  114104. useCustomUnlockedButton: boolean;
  114105. /**
  114106. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114107. */
  114108. readonly unlocked: boolean;
  114109. /**
  114110. * Event raised when audio has been unlocked on the browser.
  114111. */
  114112. onAudioUnlockedObservable: Observable<AudioEngine>;
  114113. /**
  114114. * Event raised when audio has been locked on the browser.
  114115. */
  114116. onAudioLockedObservable: Observable<AudioEngine>;
  114117. /**
  114118. * Flags the audio engine in Locked state.
  114119. * This happens due to new browser policies preventing audio to autoplay.
  114120. */
  114121. lock(): void;
  114122. /**
  114123. * Unlocks the audio engine once a user action has been done on the dom.
  114124. * This is helpful to resume play once browser policies have been satisfied.
  114125. */
  114126. unlock(): void;
  114127. /**
  114128. * Gets the global volume sets on the master gain.
  114129. * @returns the global volume if set or -1 otherwise
  114130. */
  114131. getGlobalVolume(): number;
  114132. /**
  114133. * Sets the global volume of your experience (sets on the master gain).
  114134. * @param newVolume Defines the new global volume of the application
  114135. */
  114136. setGlobalVolume(newVolume: number): void;
  114137. /**
  114138. * Connect the audio engine to an audio analyser allowing some amazing
  114139. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114141. * @param analyser The analyser to connect to the engine
  114142. */
  114143. connectToAnalyser(analyser: Analyser): void;
  114144. }
  114145. /**
  114146. * This represents the default audio engine used in babylon.
  114147. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114149. */
  114150. export class AudioEngine implements IAudioEngine {
  114151. private _audioContext;
  114152. private _audioContextInitialized;
  114153. private _muteButton;
  114154. private _hostElement;
  114155. /**
  114156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114157. */
  114158. canUseWebAudio: boolean;
  114159. /**
  114160. * The master gain node defines the global audio volume of your audio engine.
  114161. */
  114162. masterGain: GainNode;
  114163. /**
  114164. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114165. * @ignoreNaming
  114166. */
  114167. WarnedWebAudioUnsupported: boolean;
  114168. /**
  114169. * Gets whether or not mp3 are supported by your browser.
  114170. */
  114171. isMP3supported: boolean;
  114172. /**
  114173. * Gets whether or not ogg are supported by your browser.
  114174. */
  114175. isOGGsupported: boolean;
  114176. /**
  114177. * Gets whether audio has been unlocked on the device.
  114178. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114179. * a user interaction has happened.
  114180. */
  114181. unlocked: boolean;
  114182. /**
  114183. * Defines if the audio engine relies on a custom unlocked button.
  114184. * In this case, the embedded button will not be displayed.
  114185. */
  114186. useCustomUnlockedButton: boolean;
  114187. /**
  114188. * Event raised when audio has been unlocked on the browser.
  114189. */
  114190. onAudioUnlockedObservable: Observable<AudioEngine>;
  114191. /**
  114192. * Event raised when audio has been locked on the browser.
  114193. */
  114194. onAudioLockedObservable: Observable<AudioEngine>;
  114195. /**
  114196. * Gets the current AudioContext if available.
  114197. */
  114198. get audioContext(): Nullable<AudioContext>;
  114199. private _connectedAnalyser;
  114200. /**
  114201. * Instantiates a new audio engine.
  114202. *
  114203. * There should be only one per page as some browsers restrict the number
  114204. * of audio contexts you can create.
  114205. * @param hostElement defines the host element where to display the mute icon if necessary
  114206. */
  114207. constructor(hostElement?: Nullable<HTMLElement>);
  114208. /**
  114209. * Flags the audio engine in Locked state.
  114210. * This happens due to new browser policies preventing audio to autoplay.
  114211. */
  114212. lock(): void;
  114213. /**
  114214. * Unlocks the audio engine once a user action has been done on the dom.
  114215. * This is helpful to resume play once browser policies have been satisfied.
  114216. */
  114217. unlock(): void;
  114218. private _resumeAudioContext;
  114219. private _initializeAudioContext;
  114220. private _tryToRun;
  114221. private _triggerRunningState;
  114222. private _triggerSuspendedState;
  114223. private _displayMuteButton;
  114224. private _moveButtonToTopLeft;
  114225. private _onResize;
  114226. private _hideMuteButton;
  114227. /**
  114228. * Destroy and release the resources associated with the audio ccontext.
  114229. */
  114230. dispose(): void;
  114231. /**
  114232. * Gets the global volume sets on the master gain.
  114233. * @returns the global volume if set or -1 otherwise
  114234. */
  114235. getGlobalVolume(): number;
  114236. /**
  114237. * Sets the global volume of your experience (sets on the master gain).
  114238. * @param newVolume Defines the new global volume of the application
  114239. */
  114240. setGlobalVolume(newVolume: number): void;
  114241. /**
  114242. * Connect the audio engine to an audio analyser allowing some amazing
  114243. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114245. * @param analyser The analyser to connect to the engine
  114246. */
  114247. connectToAnalyser(analyser: Analyser): void;
  114248. }
  114249. }
  114250. declare module BABYLON {
  114251. /**
  114252. * Interface used to present a loading screen while loading a scene
  114253. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114254. */
  114255. export interface ILoadingScreen {
  114256. /**
  114257. * Function called to display the loading screen
  114258. */
  114259. displayLoadingUI: () => void;
  114260. /**
  114261. * Function called to hide the loading screen
  114262. */
  114263. hideLoadingUI: () => void;
  114264. /**
  114265. * Gets or sets the color to use for the background
  114266. */
  114267. loadingUIBackgroundColor: string;
  114268. /**
  114269. * Gets or sets the text to display while loading
  114270. */
  114271. loadingUIText: string;
  114272. }
  114273. /**
  114274. * Class used for the default loading screen
  114275. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114276. */
  114277. export class DefaultLoadingScreen implements ILoadingScreen {
  114278. private _renderingCanvas;
  114279. private _loadingText;
  114280. private _loadingDivBackgroundColor;
  114281. private _loadingDiv;
  114282. private _loadingTextDiv;
  114283. /** Gets or sets the logo url to use for the default loading screen */
  114284. static DefaultLogoUrl: string;
  114285. /** Gets or sets the spinner url to use for the default loading screen */
  114286. static DefaultSpinnerUrl: string;
  114287. /**
  114288. * Creates a new default loading screen
  114289. * @param _renderingCanvas defines the canvas used to render the scene
  114290. * @param _loadingText defines the default text to display
  114291. * @param _loadingDivBackgroundColor defines the default background color
  114292. */
  114293. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114294. /**
  114295. * Function called to display the loading screen
  114296. */
  114297. displayLoadingUI(): void;
  114298. /**
  114299. * Function called to hide the loading screen
  114300. */
  114301. hideLoadingUI(): void;
  114302. /**
  114303. * Gets or sets the text to display while loading
  114304. */
  114305. set loadingUIText(text: string);
  114306. get loadingUIText(): string;
  114307. /**
  114308. * Gets or sets the color to use for the background
  114309. */
  114310. get loadingUIBackgroundColor(): string;
  114311. set loadingUIBackgroundColor(color: string);
  114312. private _resizeLoadingUI;
  114313. }
  114314. }
  114315. declare module BABYLON {
  114316. /**
  114317. * Interface for any object that can request an animation frame
  114318. */
  114319. export interface ICustomAnimationFrameRequester {
  114320. /**
  114321. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114322. */
  114323. renderFunction?: Function;
  114324. /**
  114325. * Called to request the next frame to render to
  114326. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114327. */
  114328. requestAnimationFrame: Function;
  114329. /**
  114330. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114331. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114332. */
  114333. requestID?: number;
  114334. }
  114335. }
  114336. declare module BABYLON {
  114337. /**
  114338. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114339. */
  114340. export class PerformanceMonitor {
  114341. private _enabled;
  114342. private _rollingFrameTime;
  114343. private _lastFrameTimeMs;
  114344. /**
  114345. * constructor
  114346. * @param frameSampleSize The number of samples required to saturate the sliding window
  114347. */
  114348. constructor(frameSampleSize?: number);
  114349. /**
  114350. * Samples current frame
  114351. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114352. */
  114353. sampleFrame(timeMs?: number): void;
  114354. /**
  114355. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114356. */
  114357. get averageFrameTime(): number;
  114358. /**
  114359. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114360. */
  114361. get averageFrameTimeVariance(): number;
  114362. /**
  114363. * Returns the frame time of the most recent frame
  114364. */
  114365. get instantaneousFrameTime(): number;
  114366. /**
  114367. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114368. */
  114369. get averageFPS(): number;
  114370. /**
  114371. * Returns the average framerate in frames per second using the most recent frame time
  114372. */
  114373. get instantaneousFPS(): number;
  114374. /**
  114375. * Returns true if enough samples have been taken to completely fill the sliding window
  114376. */
  114377. get isSaturated(): boolean;
  114378. /**
  114379. * Enables contributions to the sliding window sample set
  114380. */
  114381. enable(): void;
  114382. /**
  114383. * Disables contributions to the sliding window sample set
  114384. * Samples will not be interpolated over the disabled period
  114385. */
  114386. disable(): void;
  114387. /**
  114388. * Returns true if sampling is enabled
  114389. */
  114390. get isEnabled(): boolean;
  114391. /**
  114392. * Resets performance monitor
  114393. */
  114394. reset(): void;
  114395. }
  114396. /**
  114397. * RollingAverage
  114398. *
  114399. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114400. */
  114401. export class RollingAverage {
  114402. /**
  114403. * Current average
  114404. */
  114405. average: number;
  114406. /**
  114407. * Current variance
  114408. */
  114409. variance: number;
  114410. protected _samples: Array<number>;
  114411. protected _sampleCount: number;
  114412. protected _pos: number;
  114413. protected _m2: number;
  114414. /**
  114415. * constructor
  114416. * @param length The number of samples required to saturate the sliding window
  114417. */
  114418. constructor(length: number);
  114419. /**
  114420. * Adds a sample to the sample set
  114421. * @param v The sample value
  114422. */
  114423. add(v: number): void;
  114424. /**
  114425. * Returns previously added values or null if outside of history or outside the sliding window domain
  114426. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114427. * @return Value previously recorded with add() or null if outside of range
  114428. */
  114429. history(i: number): number;
  114430. /**
  114431. * Returns true if enough samples have been taken to completely fill the sliding window
  114432. * @return true if sample-set saturated
  114433. */
  114434. isSaturated(): boolean;
  114435. /**
  114436. * Resets the rolling average (equivalent to 0 samples taken so far)
  114437. */
  114438. reset(): void;
  114439. /**
  114440. * Wraps a value around the sample range boundaries
  114441. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114442. * @return Wrapped position in sample range
  114443. */
  114444. protected _wrapPosition(i: number): number;
  114445. }
  114446. }
  114447. declare module BABYLON {
  114448. /**
  114449. * This class is used to track a performance counter which is number based.
  114450. * The user has access to many properties which give statistics of different nature.
  114451. *
  114452. * The implementer can track two kinds of Performance Counter: time and count.
  114453. * 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.
  114454. * 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.
  114455. */
  114456. export class PerfCounter {
  114457. /**
  114458. * Gets or sets a global boolean to turn on and off all the counters
  114459. */
  114460. static Enabled: boolean;
  114461. /**
  114462. * Returns the smallest value ever
  114463. */
  114464. get min(): number;
  114465. /**
  114466. * Returns the biggest value ever
  114467. */
  114468. get max(): number;
  114469. /**
  114470. * Returns the average value since the performance counter is running
  114471. */
  114472. get average(): number;
  114473. /**
  114474. * Returns the average value of the last second the counter was monitored
  114475. */
  114476. get lastSecAverage(): number;
  114477. /**
  114478. * Returns the current value
  114479. */
  114480. get current(): number;
  114481. /**
  114482. * Gets the accumulated total
  114483. */
  114484. get total(): number;
  114485. /**
  114486. * Gets the total value count
  114487. */
  114488. get count(): number;
  114489. /**
  114490. * Creates a new counter
  114491. */
  114492. constructor();
  114493. /**
  114494. * Call this method to start monitoring a new frame.
  114495. * 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.
  114496. */
  114497. fetchNewFrame(): void;
  114498. /**
  114499. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114500. * @param newCount the count value to add to the monitored count
  114501. * @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.
  114502. */
  114503. addCount(newCount: number, fetchResult: boolean): void;
  114504. /**
  114505. * Start monitoring this performance counter
  114506. */
  114507. beginMonitoring(): void;
  114508. /**
  114509. * Compute the time lapsed since the previous beginMonitoring() call.
  114510. * @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
  114511. */
  114512. endMonitoring(newFrame?: boolean): void;
  114513. private _fetchResult;
  114514. private _startMonitoringTime;
  114515. private _min;
  114516. private _max;
  114517. private _average;
  114518. private _current;
  114519. private _totalValueCount;
  114520. private _totalAccumulated;
  114521. private _lastSecAverage;
  114522. private _lastSecAccumulated;
  114523. private _lastSecTime;
  114524. private _lastSecValueCount;
  114525. }
  114526. }
  114527. declare module BABYLON {
  114528. interface ThinEngine {
  114529. /**
  114530. * Sets alpha constants used by some alpha blending modes
  114531. * @param r defines the red component
  114532. * @param g defines the green component
  114533. * @param b defines the blue component
  114534. * @param a defines the alpha component
  114535. */
  114536. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114537. /**
  114538. * Sets the current alpha mode
  114539. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114540. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114541. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114542. */
  114543. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114544. /**
  114545. * Gets the current alpha mode
  114546. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114547. * @returns the current alpha mode
  114548. */
  114549. getAlphaMode(): number;
  114550. /**
  114551. * Sets the current alpha equation
  114552. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114553. */
  114554. setAlphaEquation(equation: number): void;
  114555. /**
  114556. * Gets the current alpha equation.
  114557. * @returns the current alpha equation
  114558. */
  114559. getAlphaEquation(): number;
  114560. }
  114561. }
  114562. declare module BABYLON {
  114563. interface ThinEngine {
  114564. /** @hidden */
  114565. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114566. }
  114567. }
  114568. declare module BABYLON {
  114569. /**
  114570. * Defines the interface used by display changed events
  114571. */
  114572. export interface IDisplayChangedEventArgs {
  114573. /** Gets the vrDisplay object (if any) */
  114574. vrDisplay: Nullable<any>;
  114575. /** Gets a boolean indicating if webVR is supported */
  114576. vrSupported: boolean;
  114577. }
  114578. /**
  114579. * Defines the interface used by objects containing a viewport (like a camera)
  114580. */
  114581. interface IViewportOwnerLike {
  114582. /**
  114583. * Gets or sets the viewport
  114584. */
  114585. viewport: IViewportLike;
  114586. }
  114587. /**
  114588. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114589. */
  114590. export class Engine extends ThinEngine {
  114591. /** Defines that alpha blending is disabled */
  114592. static readonly ALPHA_DISABLE: number;
  114593. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114594. static readonly ALPHA_ADD: number;
  114595. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114596. static readonly ALPHA_COMBINE: number;
  114597. /** Defines that alpha blending to DEST - SRC * DEST */
  114598. static readonly ALPHA_SUBTRACT: number;
  114599. /** Defines that alpha blending to SRC * DEST */
  114600. static readonly ALPHA_MULTIPLY: number;
  114601. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114602. static readonly ALPHA_MAXIMIZED: number;
  114603. /** Defines that alpha blending to SRC + DEST */
  114604. static readonly ALPHA_ONEONE: number;
  114605. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114606. static readonly ALPHA_PREMULTIPLIED: number;
  114607. /**
  114608. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114610. */
  114611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114612. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114613. static readonly ALPHA_INTERPOLATE: number;
  114614. /**
  114615. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114617. */
  114618. static readonly ALPHA_SCREENMODE: number;
  114619. /** Defines that the ressource is not delayed*/
  114620. static readonly DELAYLOADSTATE_NONE: number;
  114621. /** Defines that the ressource was successfully delay loaded */
  114622. static readonly DELAYLOADSTATE_LOADED: number;
  114623. /** Defines that the ressource is currently delay loading */
  114624. static readonly DELAYLOADSTATE_LOADING: number;
  114625. /** Defines that the ressource is delayed and has not started loading */
  114626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114628. static readonly NEVER: number;
  114629. /** 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 */
  114630. static readonly ALWAYS: number;
  114631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114632. static readonly LESS: number;
  114633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114634. static readonly EQUAL: number;
  114635. /** 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 */
  114636. static readonly LEQUAL: number;
  114637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114638. static readonly GREATER: number;
  114639. /** 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 */
  114640. static readonly GEQUAL: number;
  114641. /** 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 */
  114642. static readonly NOTEQUAL: number;
  114643. /** Passed to stencilOperation to specify that stencil value must be kept */
  114644. static readonly KEEP: number;
  114645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114646. static readonly REPLACE: number;
  114647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114648. static readonly INCR: number;
  114649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114650. static readonly DECR: number;
  114651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114652. static readonly INVERT: number;
  114653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114654. static readonly INCR_WRAP: number;
  114655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114656. static readonly DECR_WRAP: number;
  114657. /** Texture is not repeating outside of 0..1 UVs */
  114658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114659. /** Texture is repeating outside of 0..1 UVs */
  114660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114661. /** Texture is repeating and mirrored */
  114662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114663. /** ALPHA */
  114664. static readonly TEXTUREFORMAT_ALPHA: number;
  114665. /** LUMINANCE */
  114666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114667. /** LUMINANCE_ALPHA */
  114668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114669. /** RGB */
  114670. static readonly TEXTUREFORMAT_RGB: number;
  114671. /** RGBA */
  114672. static readonly TEXTUREFORMAT_RGBA: number;
  114673. /** RED */
  114674. static readonly TEXTUREFORMAT_RED: number;
  114675. /** RED (2nd reference) */
  114676. static readonly TEXTUREFORMAT_R: number;
  114677. /** RG */
  114678. static readonly TEXTUREFORMAT_RG: number;
  114679. /** RED_INTEGER */
  114680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114681. /** RED_INTEGER (2nd reference) */
  114682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114683. /** RG_INTEGER */
  114684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114685. /** RGB_INTEGER */
  114686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114687. /** RGBA_INTEGER */
  114688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114689. /** UNSIGNED_BYTE */
  114690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114691. /** UNSIGNED_BYTE (2nd reference) */
  114692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114693. /** FLOAT */
  114694. static readonly TEXTURETYPE_FLOAT: number;
  114695. /** HALF_FLOAT */
  114696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114697. /** BYTE */
  114698. static readonly TEXTURETYPE_BYTE: number;
  114699. /** SHORT */
  114700. static readonly TEXTURETYPE_SHORT: number;
  114701. /** UNSIGNED_SHORT */
  114702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114703. /** INT */
  114704. static readonly TEXTURETYPE_INT: number;
  114705. /** UNSIGNED_INT */
  114706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114707. /** UNSIGNED_SHORT_4_4_4_4 */
  114708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114709. /** UNSIGNED_SHORT_5_5_5_1 */
  114710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114711. /** UNSIGNED_SHORT_5_6_5 */
  114712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114713. /** UNSIGNED_INT_2_10_10_10_REV */
  114714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114715. /** UNSIGNED_INT_24_8 */
  114716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114717. /** UNSIGNED_INT_10F_11F_11F_REV */
  114718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114719. /** UNSIGNED_INT_5_9_9_9_REV */
  114720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114723. /** nearest is mag = nearest and min = nearest and mip = linear */
  114724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114727. /** Trilinear is mag = linear and min = linear and mip = linear */
  114728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114729. /** nearest is mag = nearest and min = nearest and mip = linear */
  114730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114733. /** Trilinear is mag = linear and min = linear and mip = linear */
  114734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114735. /** mag = nearest and min = nearest and mip = nearest */
  114736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114737. /** mag = nearest and min = linear and mip = nearest */
  114738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114739. /** mag = nearest and min = linear and mip = linear */
  114740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114741. /** mag = nearest and min = linear and mip = none */
  114742. static readonly TEXTURE_NEAREST_LINEAR: number;
  114743. /** mag = nearest and min = nearest and mip = none */
  114744. static readonly TEXTURE_NEAREST_NEAREST: number;
  114745. /** mag = linear and min = nearest and mip = nearest */
  114746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114747. /** mag = linear and min = nearest and mip = linear */
  114748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114749. /** mag = linear and min = linear and mip = none */
  114750. static readonly TEXTURE_LINEAR_LINEAR: number;
  114751. /** mag = linear and min = nearest and mip = none */
  114752. static readonly TEXTURE_LINEAR_NEAREST: number;
  114753. /** Explicit coordinates mode */
  114754. static readonly TEXTURE_EXPLICIT_MODE: number;
  114755. /** Spherical coordinates mode */
  114756. static readonly TEXTURE_SPHERICAL_MODE: number;
  114757. /** Planar coordinates mode */
  114758. static readonly TEXTURE_PLANAR_MODE: number;
  114759. /** Cubic coordinates mode */
  114760. static readonly TEXTURE_CUBIC_MODE: number;
  114761. /** Projection coordinates mode */
  114762. static readonly TEXTURE_PROJECTION_MODE: number;
  114763. /** Skybox coordinates mode */
  114764. static readonly TEXTURE_SKYBOX_MODE: number;
  114765. /** Inverse Cubic coordinates mode */
  114766. static readonly TEXTURE_INVCUBIC_MODE: number;
  114767. /** Equirectangular coordinates mode */
  114768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114769. /** Equirectangular Fixed coordinates mode */
  114770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114771. /** Equirectangular Fixed Mirrored coordinates mode */
  114772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114774. static readonly SCALEMODE_FLOOR: number;
  114775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114776. static readonly SCALEMODE_NEAREST: number;
  114777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114778. static readonly SCALEMODE_CEILING: number;
  114779. /**
  114780. * Returns the current npm package of the sdk
  114781. */
  114782. static get NpmPackage(): string;
  114783. /**
  114784. * Returns the current version of the framework
  114785. */
  114786. static get Version(): string;
  114787. /** Gets the list of created engines */
  114788. static get Instances(): Engine[];
  114789. /**
  114790. * Gets the latest created engine
  114791. */
  114792. static get LastCreatedEngine(): Nullable<Engine>;
  114793. /**
  114794. * Gets the latest created scene
  114795. */
  114796. static get LastCreatedScene(): Nullable<Scene>;
  114797. /**
  114798. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114799. * @param flag defines which part of the materials must be marked as dirty
  114800. * @param predicate defines a predicate used to filter which materials should be affected
  114801. */
  114802. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114803. /**
  114804. * Method called to create the default loading screen.
  114805. * This can be overriden in your own app.
  114806. * @param canvas The rendering canvas element
  114807. * @returns The loading screen
  114808. */
  114809. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114810. /**
  114811. * Method called to create the default rescale post process on each engine.
  114812. */
  114813. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114814. /**
  114815. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114816. **/
  114817. enableOfflineSupport: boolean;
  114818. /**
  114819. * 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)
  114820. **/
  114821. disableManifestCheck: boolean;
  114822. /**
  114823. * Gets the list of created scenes
  114824. */
  114825. scenes: Scene[];
  114826. /**
  114827. * Event raised when a new scene is created
  114828. */
  114829. onNewSceneAddedObservable: Observable<Scene>;
  114830. /**
  114831. * Gets the list of created postprocesses
  114832. */
  114833. postProcesses: PostProcess[];
  114834. /**
  114835. * Gets a boolean indicating if the pointer is currently locked
  114836. */
  114837. isPointerLock: boolean;
  114838. /**
  114839. * Observable event triggered each time the rendering canvas is resized
  114840. */
  114841. onResizeObservable: Observable<Engine>;
  114842. /**
  114843. * Observable event triggered each time the canvas loses focus
  114844. */
  114845. onCanvasBlurObservable: Observable<Engine>;
  114846. /**
  114847. * Observable event triggered each time the canvas gains focus
  114848. */
  114849. onCanvasFocusObservable: Observable<Engine>;
  114850. /**
  114851. * Observable event triggered each time the canvas receives pointerout event
  114852. */
  114853. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114854. /**
  114855. * Observable raised when the engine begins a new frame
  114856. */
  114857. onBeginFrameObservable: Observable<Engine>;
  114858. /**
  114859. * If set, will be used to request the next animation frame for the render loop
  114860. */
  114861. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114862. /**
  114863. * Observable raised when the engine ends the current frame
  114864. */
  114865. onEndFrameObservable: Observable<Engine>;
  114866. /**
  114867. * Observable raised when the engine is about to compile a shader
  114868. */
  114869. onBeforeShaderCompilationObservable: Observable<Engine>;
  114870. /**
  114871. * Observable raised when the engine has jsut compiled a shader
  114872. */
  114873. onAfterShaderCompilationObservable: Observable<Engine>;
  114874. /**
  114875. * Gets the audio engine
  114876. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114877. * @ignorenaming
  114878. */
  114879. static audioEngine: IAudioEngine;
  114880. /**
  114881. * Default AudioEngine factory responsible of creating the Audio Engine.
  114882. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114883. */
  114884. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114885. /**
  114886. * Default offline support factory responsible of creating a tool used to store data locally.
  114887. * By default, this will create a Database object if the workload has been embedded.
  114888. */
  114889. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114890. private _loadingScreen;
  114891. private _pointerLockRequested;
  114892. private _rescalePostProcess;
  114893. private _deterministicLockstep;
  114894. private _lockstepMaxSteps;
  114895. private _timeStep;
  114896. protected get _supportsHardwareTextureRescaling(): boolean;
  114897. private _fps;
  114898. private _deltaTime;
  114899. /** @hidden */
  114900. _drawCalls: PerfCounter;
  114901. /** 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 */
  114902. canvasTabIndex: number;
  114903. /**
  114904. * Turn this value on if you want to pause FPS computation when in background
  114905. */
  114906. disablePerformanceMonitorInBackground: boolean;
  114907. private _performanceMonitor;
  114908. /**
  114909. * Gets the performance monitor attached to this engine
  114910. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114911. */
  114912. get performanceMonitor(): PerformanceMonitor;
  114913. private _onFocus;
  114914. private _onBlur;
  114915. private _onCanvasPointerOut;
  114916. private _onCanvasBlur;
  114917. private _onCanvasFocus;
  114918. private _onFullscreenChange;
  114919. private _onPointerLockChange;
  114920. /**
  114921. * Gets the HTML element used to attach event listeners
  114922. * @returns a HTML element
  114923. */
  114924. getInputElement(): Nullable<HTMLElement>;
  114925. /**
  114926. * Creates a new engine
  114927. * @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
  114928. * @param antialias defines enable antialiasing (default: false)
  114929. * @param options defines further options to be sent to the getContext() function
  114930. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114931. */
  114932. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114933. /**
  114934. * Gets current aspect ratio
  114935. * @param viewportOwner defines the camera to use to get the aspect ratio
  114936. * @param useScreen defines if screen size must be used (or the current render target if any)
  114937. * @returns a number defining the aspect ratio
  114938. */
  114939. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114940. /**
  114941. * Gets current screen aspect ratio
  114942. * @returns a number defining the aspect ratio
  114943. */
  114944. getScreenAspectRatio(): number;
  114945. /**
  114946. * Gets the client rect of the HTML canvas attached with the current webGL context
  114947. * @returns a client rectanglee
  114948. */
  114949. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114950. /**
  114951. * Gets the client rect of the HTML element used for events
  114952. * @returns a client rectanglee
  114953. */
  114954. getInputElementClientRect(): Nullable<ClientRect>;
  114955. /**
  114956. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114957. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114958. * @returns true if engine is in deterministic lock step mode
  114959. */
  114960. isDeterministicLockStep(): boolean;
  114961. /**
  114962. * Gets the max steps when engine is running in deterministic lock step
  114963. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114964. * @returns the max steps
  114965. */
  114966. getLockstepMaxSteps(): number;
  114967. /**
  114968. * Returns the time in ms between steps when using deterministic lock step.
  114969. * @returns time step in (ms)
  114970. */
  114971. getTimeStep(): number;
  114972. /**
  114973. * Force the mipmap generation for the given render target texture
  114974. * @param texture defines the render target texture to use
  114975. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114976. */
  114977. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114978. /** States */
  114979. /**
  114980. * Set various states to the webGL context
  114981. * @param culling defines backface culling state
  114982. * @param zOffset defines the value to apply to zOffset (0 by default)
  114983. * @param force defines if states must be applied even if cache is up to date
  114984. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114985. */
  114986. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114987. /**
  114988. * Set the z offset to apply to current rendering
  114989. * @param value defines the offset to apply
  114990. */
  114991. setZOffset(value: number): void;
  114992. /**
  114993. * Gets the current value of the zOffset
  114994. * @returns the current zOffset state
  114995. */
  114996. getZOffset(): number;
  114997. /**
  114998. * Enable or disable depth buffering
  114999. * @param enable defines the state to set
  115000. */
  115001. setDepthBuffer(enable: boolean): void;
  115002. /**
  115003. * Gets a boolean indicating if depth writing is enabled
  115004. * @returns the current depth writing state
  115005. */
  115006. getDepthWrite(): boolean;
  115007. /**
  115008. * Enable or disable depth writing
  115009. * @param enable defines the state to set
  115010. */
  115011. setDepthWrite(enable: boolean): void;
  115012. /**
  115013. * Gets a boolean indicating if stencil buffer is enabled
  115014. * @returns the current stencil buffer state
  115015. */
  115016. getStencilBuffer(): boolean;
  115017. /**
  115018. * Enable or disable the stencil buffer
  115019. * @param enable defines if the stencil buffer must be enabled or disabled
  115020. */
  115021. setStencilBuffer(enable: boolean): void;
  115022. /**
  115023. * Gets the current stencil mask
  115024. * @returns a number defining the new stencil mask to use
  115025. */
  115026. getStencilMask(): number;
  115027. /**
  115028. * Sets the current stencil mask
  115029. * @param mask defines the new stencil mask to use
  115030. */
  115031. setStencilMask(mask: number): void;
  115032. /**
  115033. * Gets the current stencil function
  115034. * @returns a number defining the stencil function to use
  115035. */
  115036. getStencilFunction(): number;
  115037. /**
  115038. * Gets the current stencil reference value
  115039. * @returns a number defining the stencil reference value to use
  115040. */
  115041. getStencilFunctionReference(): number;
  115042. /**
  115043. * Gets the current stencil mask
  115044. * @returns a number defining the stencil mask to use
  115045. */
  115046. getStencilFunctionMask(): number;
  115047. /**
  115048. * Sets the current stencil function
  115049. * @param stencilFunc defines the new stencil function to use
  115050. */
  115051. setStencilFunction(stencilFunc: number): void;
  115052. /**
  115053. * Sets the current stencil reference
  115054. * @param reference defines the new stencil reference to use
  115055. */
  115056. setStencilFunctionReference(reference: number): void;
  115057. /**
  115058. * Sets the current stencil mask
  115059. * @param mask defines the new stencil mask to use
  115060. */
  115061. setStencilFunctionMask(mask: number): void;
  115062. /**
  115063. * Gets the current stencil operation when stencil fails
  115064. * @returns a number defining stencil operation to use when stencil fails
  115065. */
  115066. getStencilOperationFail(): number;
  115067. /**
  115068. * Gets the current stencil operation when depth fails
  115069. * @returns a number defining stencil operation to use when depth fails
  115070. */
  115071. getStencilOperationDepthFail(): number;
  115072. /**
  115073. * Gets the current stencil operation when stencil passes
  115074. * @returns a number defining stencil operation to use when stencil passes
  115075. */
  115076. getStencilOperationPass(): number;
  115077. /**
  115078. * Sets the stencil operation to use when stencil fails
  115079. * @param operation defines the stencil operation to use when stencil fails
  115080. */
  115081. setStencilOperationFail(operation: number): void;
  115082. /**
  115083. * Sets the stencil operation to use when depth fails
  115084. * @param operation defines the stencil operation to use when depth fails
  115085. */
  115086. setStencilOperationDepthFail(operation: number): void;
  115087. /**
  115088. * Sets the stencil operation to use when stencil passes
  115089. * @param operation defines the stencil operation to use when stencil passes
  115090. */
  115091. setStencilOperationPass(operation: number): void;
  115092. /**
  115093. * Sets a boolean indicating if the dithering state is enabled or disabled
  115094. * @param value defines the dithering state
  115095. */
  115096. setDitheringState(value: boolean): void;
  115097. /**
  115098. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115099. * @param value defines the rasterizer state
  115100. */
  115101. setRasterizerState(value: boolean): void;
  115102. /**
  115103. * Gets the current depth function
  115104. * @returns a number defining the depth function
  115105. */
  115106. getDepthFunction(): Nullable<number>;
  115107. /**
  115108. * Sets the current depth function
  115109. * @param depthFunc defines the function to use
  115110. */
  115111. setDepthFunction(depthFunc: number): void;
  115112. /**
  115113. * Sets the current depth function to GREATER
  115114. */
  115115. setDepthFunctionToGreater(): void;
  115116. /**
  115117. * Sets the current depth function to GEQUAL
  115118. */
  115119. setDepthFunctionToGreaterOrEqual(): void;
  115120. /**
  115121. * Sets the current depth function to LESS
  115122. */
  115123. setDepthFunctionToLess(): void;
  115124. /**
  115125. * Sets the current depth function to LEQUAL
  115126. */
  115127. setDepthFunctionToLessOrEqual(): void;
  115128. private _cachedStencilBuffer;
  115129. private _cachedStencilFunction;
  115130. private _cachedStencilMask;
  115131. private _cachedStencilOperationPass;
  115132. private _cachedStencilOperationFail;
  115133. private _cachedStencilOperationDepthFail;
  115134. private _cachedStencilReference;
  115135. /**
  115136. * Caches the the state of the stencil buffer
  115137. */
  115138. cacheStencilState(): void;
  115139. /**
  115140. * Restores the state of the stencil buffer
  115141. */
  115142. restoreStencilState(): void;
  115143. /**
  115144. * Directly set the WebGL Viewport
  115145. * @param x defines the x coordinate of the viewport (in screen space)
  115146. * @param y defines the y coordinate of the viewport (in screen space)
  115147. * @param width defines the width of the viewport (in screen space)
  115148. * @param height defines the height of the viewport (in screen space)
  115149. * @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
  115150. */
  115151. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115152. /**
  115153. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115154. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115155. * @param y defines the y-coordinate of the corner of the clear rectangle
  115156. * @param width defines the width of the clear rectangle
  115157. * @param height defines the height of the clear rectangle
  115158. * @param clearColor defines the clear color
  115159. */
  115160. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115161. /**
  115162. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115163. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115164. * @param y defines the y-coordinate of the corner of the clear rectangle
  115165. * @param width defines the width of the clear rectangle
  115166. * @param height defines the height of the clear rectangle
  115167. */
  115168. enableScissor(x: number, y: number, width: number, height: number): void;
  115169. /**
  115170. * Disable previously set scissor test rectangle
  115171. */
  115172. disableScissor(): void;
  115173. protected _reportDrawCall(): void;
  115174. /**
  115175. * Initializes a webVR display and starts listening to display change events
  115176. * The onVRDisplayChangedObservable will be notified upon these changes
  115177. * @returns The onVRDisplayChangedObservable
  115178. */
  115179. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115180. /** @hidden */
  115181. _prepareVRComponent(): void;
  115182. /** @hidden */
  115183. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115184. /** @hidden */
  115185. _submitVRFrame(): void;
  115186. /**
  115187. * Call this function to leave webVR mode
  115188. * Will do nothing if webVR is not supported or if there is no webVR device
  115189. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115190. */
  115191. disableVR(): void;
  115192. /**
  115193. * Gets a boolean indicating that the system is in VR mode and is presenting
  115194. * @returns true if VR mode is engaged
  115195. */
  115196. isVRPresenting(): boolean;
  115197. /** @hidden */
  115198. _requestVRFrame(): void;
  115199. /** @hidden */
  115200. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115201. /**
  115202. * Gets the source code of the vertex shader associated with a specific webGL program
  115203. * @param program defines the program to use
  115204. * @returns a string containing the source code of the vertex shader associated with the program
  115205. */
  115206. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115207. /**
  115208. * Gets the source code of the fragment shader associated with a specific webGL program
  115209. * @param program defines the program to use
  115210. * @returns a string containing the source code of the fragment shader associated with the program
  115211. */
  115212. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115213. /**
  115214. * Sets a depth stencil texture from a render target to the according uniform.
  115215. * @param channel The texture channel
  115216. * @param uniform The uniform to set
  115217. * @param texture The render target texture containing the depth stencil texture to apply
  115218. */
  115219. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115220. /**
  115221. * Sets a texture to the webGL context from a postprocess
  115222. * @param channel defines the channel to use
  115223. * @param postProcess defines the source postprocess
  115224. */
  115225. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115226. /**
  115227. * Binds the output of the passed in post process to the texture channel specified
  115228. * @param channel The channel the texture should be bound to
  115229. * @param postProcess The post process which's output should be bound
  115230. */
  115231. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115232. protected _rebuildBuffers(): void;
  115233. /** @hidden */
  115234. _renderFrame(): void;
  115235. _renderLoop(): void;
  115236. /** @hidden */
  115237. _renderViews(): boolean;
  115238. /**
  115239. * Toggle full screen mode
  115240. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115241. */
  115242. switchFullscreen(requestPointerLock: boolean): void;
  115243. /**
  115244. * Enters full screen mode
  115245. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115246. */
  115247. enterFullscreen(requestPointerLock: boolean): void;
  115248. /**
  115249. * Exits full screen mode
  115250. */
  115251. exitFullscreen(): void;
  115252. /**
  115253. * Enters Pointerlock mode
  115254. */
  115255. enterPointerlock(): void;
  115256. /**
  115257. * Exits Pointerlock mode
  115258. */
  115259. exitPointerlock(): void;
  115260. /**
  115261. * Begin a new frame
  115262. */
  115263. beginFrame(): void;
  115264. /**
  115265. * Enf the current frame
  115266. */
  115267. endFrame(): void;
  115268. resize(): void;
  115269. /**
  115270. * Force a specific size of the canvas
  115271. * @param width defines the new canvas' width
  115272. * @param height defines the new canvas' height
  115273. * @returns true if the size was changed
  115274. */
  115275. setSize(width: number, height: number): boolean;
  115276. /**
  115277. * Updates a dynamic vertex buffer.
  115278. * @param vertexBuffer the vertex buffer to update
  115279. * @param data the data used to update the vertex buffer
  115280. * @param byteOffset the byte offset of the data
  115281. * @param byteLength the byte length of the data
  115282. */
  115283. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115284. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115285. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115286. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115287. _releaseTexture(texture: InternalTexture): void;
  115288. /**
  115289. * @hidden
  115290. * Rescales a texture
  115291. * @param source input texutre
  115292. * @param destination destination texture
  115293. * @param scene scene to use to render the resize
  115294. * @param internalFormat format to use when resizing
  115295. * @param onComplete callback to be called when resize has completed
  115296. */
  115297. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115298. /**
  115299. * Gets the current framerate
  115300. * @returns a number representing the framerate
  115301. */
  115302. getFps(): number;
  115303. /**
  115304. * Gets the time spent between current and previous frame
  115305. * @returns a number representing the delta time in ms
  115306. */
  115307. getDeltaTime(): number;
  115308. private _measureFps;
  115309. /** @hidden */
  115310. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115311. /**
  115312. * Update a dynamic index buffer
  115313. * @param indexBuffer defines the target index buffer
  115314. * @param indices defines the data to update
  115315. * @param offset defines the offset in the target index buffer where update should start
  115316. */
  115317. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115318. /**
  115319. * Updates the sample count of a render target texture
  115320. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115321. * @param texture defines the texture to update
  115322. * @param samples defines the sample count to set
  115323. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115324. */
  115325. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115326. /**
  115327. * Updates a depth texture Comparison Mode and Function.
  115328. * If the comparison Function is equal to 0, the mode will be set to none.
  115329. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115330. * @param texture The texture to set the comparison function for
  115331. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115332. */
  115333. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115334. /**
  115335. * Creates a webGL buffer to use with instanciation
  115336. * @param capacity defines the size of the buffer
  115337. * @returns the webGL buffer
  115338. */
  115339. createInstancesBuffer(capacity: number): DataBuffer;
  115340. /**
  115341. * Delete a webGL buffer used with instanciation
  115342. * @param buffer defines the webGL buffer to delete
  115343. */
  115344. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115345. private _clientWaitAsync;
  115346. /** @hidden */
  115347. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115348. dispose(): void;
  115349. private _disableTouchAction;
  115350. /**
  115351. * Display the loading screen
  115352. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115353. */
  115354. displayLoadingUI(): void;
  115355. /**
  115356. * Hide the loading screen
  115357. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115358. */
  115359. hideLoadingUI(): void;
  115360. /**
  115361. * Gets the current loading screen object
  115362. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115363. */
  115364. get loadingScreen(): ILoadingScreen;
  115365. /**
  115366. * Sets the current loading screen object
  115367. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115368. */
  115369. set loadingScreen(loadingScreen: ILoadingScreen);
  115370. /**
  115371. * Sets the current loading screen text
  115372. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115373. */
  115374. set loadingUIText(text: string);
  115375. /**
  115376. * Sets the current loading screen background color
  115377. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115378. */
  115379. set loadingUIBackgroundColor(color: string);
  115380. /** Pointerlock and fullscreen */
  115381. /**
  115382. * Ask the browser to promote the current element to pointerlock mode
  115383. * @param element defines the DOM element to promote
  115384. */
  115385. static _RequestPointerlock(element: HTMLElement): void;
  115386. /**
  115387. * Asks the browser to exit pointerlock mode
  115388. */
  115389. static _ExitPointerlock(): void;
  115390. /**
  115391. * Ask the browser to promote the current element to fullscreen rendering mode
  115392. * @param element defines the DOM element to promote
  115393. */
  115394. static _RequestFullscreen(element: HTMLElement): void;
  115395. /**
  115396. * Asks the browser to exit fullscreen mode
  115397. */
  115398. static _ExitFullscreen(): void;
  115399. }
  115400. }
  115401. declare module BABYLON {
  115402. /**
  115403. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115404. * during the life time of the application.
  115405. */
  115406. export class EngineStore {
  115407. /** Gets the list of created engines */
  115408. static Instances: Engine[];
  115409. /** @hidden */
  115410. static _LastCreatedScene: Nullable<Scene>;
  115411. /**
  115412. * Gets the latest created engine
  115413. */
  115414. static get LastCreatedEngine(): Nullable<Engine>;
  115415. /**
  115416. * Gets the latest created scene
  115417. */
  115418. static get LastCreatedScene(): Nullable<Scene>;
  115419. /**
  115420. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115421. * @ignorenaming
  115422. */
  115423. static UseFallbackTexture: boolean;
  115424. /**
  115425. * Texture content used if a texture cannot loaded
  115426. * @ignorenaming
  115427. */
  115428. static FallbackTexture: string;
  115429. }
  115430. }
  115431. declare module BABYLON {
  115432. /**
  115433. * Helper class that provides a small promise polyfill
  115434. */
  115435. export class PromisePolyfill {
  115436. /**
  115437. * Static function used to check if the polyfill is required
  115438. * If this is the case then the function will inject the polyfill to window.Promise
  115439. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115440. */
  115441. static Apply(force?: boolean): void;
  115442. }
  115443. }
  115444. declare module BABYLON {
  115445. /**
  115446. * Interface for screenshot methods with describe argument called `size` as object with options
  115447. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115448. */
  115449. export interface IScreenshotSize {
  115450. /**
  115451. * number in pixels for canvas height
  115452. */
  115453. height?: number;
  115454. /**
  115455. * multiplier allowing render at a higher or lower resolution
  115456. * If value is defined then height and width will be ignored and taken from camera
  115457. */
  115458. precision?: number;
  115459. /**
  115460. * number in pixels for canvas width
  115461. */
  115462. width?: number;
  115463. }
  115464. }
  115465. declare module BABYLON {
  115466. interface IColor4Like {
  115467. r: float;
  115468. g: float;
  115469. b: float;
  115470. a: float;
  115471. }
  115472. /**
  115473. * Class containing a set of static utilities functions
  115474. */
  115475. export class Tools {
  115476. /**
  115477. * Gets or sets the base URL to use to load assets
  115478. */
  115479. static get BaseUrl(): string;
  115480. static set BaseUrl(value: string);
  115481. /**
  115482. * Enable/Disable Custom HTTP Request Headers globally.
  115483. * default = false
  115484. * @see CustomRequestHeaders
  115485. */
  115486. static UseCustomRequestHeaders: boolean;
  115487. /**
  115488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115489. * i.e. when loading files, where the server/service expects an Authorization header
  115490. */
  115491. static CustomRequestHeaders: {
  115492. [key: string]: string;
  115493. };
  115494. /**
  115495. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115496. */
  115497. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115498. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115499. /**
  115500. * Default behaviour for cors in the application.
  115501. * It can be a string if the expected behavior is identical in the entire app.
  115502. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115503. */
  115504. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115505. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115506. /**
  115507. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115508. * @ignorenaming
  115509. */
  115510. static get UseFallbackTexture(): boolean;
  115511. static set UseFallbackTexture(value: boolean);
  115512. /**
  115513. * Use this object to register external classes like custom textures or material
  115514. * to allow the laoders to instantiate them
  115515. */
  115516. static get RegisteredExternalClasses(): {
  115517. [key: string]: Object;
  115518. };
  115519. static set RegisteredExternalClasses(classes: {
  115520. [key: string]: Object;
  115521. });
  115522. /**
  115523. * Texture content used if a texture cannot loaded
  115524. * @ignorenaming
  115525. */
  115526. static get fallbackTexture(): string;
  115527. static set fallbackTexture(value: string);
  115528. /**
  115529. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115530. * @param u defines the coordinate on X axis
  115531. * @param v defines the coordinate on Y axis
  115532. * @param width defines the width of the source data
  115533. * @param height defines the height of the source data
  115534. * @param pixels defines the source byte array
  115535. * @param color defines the output color
  115536. */
  115537. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115538. /**
  115539. * Interpolates between a and b via alpha
  115540. * @param a The lower value (returned when alpha = 0)
  115541. * @param b The upper value (returned when alpha = 1)
  115542. * @param alpha The interpolation-factor
  115543. * @return The mixed value
  115544. */
  115545. static Mix(a: number, b: number, alpha: number): number;
  115546. /**
  115547. * Tries to instantiate a new object from a given class name
  115548. * @param className defines the class name to instantiate
  115549. * @returns the new object or null if the system was not able to do the instantiation
  115550. */
  115551. static Instantiate(className: string): any;
  115552. /**
  115553. * Provides a slice function that will work even on IE
  115554. * @param data defines the array to slice
  115555. * @param start defines the start of the data (optional)
  115556. * @param end defines the end of the data (optional)
  115557. * @returns the new sliced array
  115558. */
  115559. static Slice<T>(data: T, start?: number, end?: number): T;
  115560. /**
  115561. * Polyfill for setImmediate
  115562. * @param action defines the action to execute after the current execution block
  115563. */
  115564. static SetImmediate(action: () => void): void;
  115565. /**
  115566. * Function indicating if a number is an exponent of 2
  115567. * @param value defines the value to test
  115568. * @returns true if the value is an exponent of 2
  115569. */
  115570. static IsExponentOfTwo(value: number): boolean;
  115571. private static _tmpFloatArray;
  115572. /**
  115573. * Returns the nearest 32-bit single precision float representation of a Number
  115574. * @param value A Number. If the parameter is of a different type, it will get converted
  115575. * to a number or to NaN if it cannot be converted
  115576. * @returns number
  115577. */
  115578. static FloatRound(value: number): number;
  115579. /**
  115580. * Extracts the filename from a path
  115581. * @param path defines the path to use
  115582. * @returns the filename
  115583. */
  115584. static GetFilename(path: string): string;
  115585. /**
  115586. * Extracts the "folder" part of a path (everything before the filename).
  115587. * @param uri The URI to extract the info from
  115588. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115589. * @returns The "folder" part of the path
  115590. */
  115591. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115592. /**
  115593. * Extracts text content from a DOM element hierarchy
  115594. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115595. */
  115596. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115597. /**
  115598. * Convert an angle in radians to degrees
  115599. * @param angle defines the angle to convert
  115600. * @returns the angle in degrees
  115601. */
  115602. static ToDegrees(angle: number): number;
  115603. /**
  115604. * Convert an angle in degrees to radians
  115605. * @param angle defines the angle to convert
  115606. * @returns the angle in radians
  115607. */
  115608. static ToRadians(angle: number): number;
  115609. /**
  115610. * Returns an array if obj is not an array
  115611. * @param obj defines the object to evaluate as an array
  115612. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115613. * @returns either obj directly if obj is an array or a new array containing obj
  115614. */
  115615. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115616. /**
  115617. * Gets the pointer prefix to use
  115618. * @param engine defines the engine we are finding the prefix for
  115619. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115620. */
  115621. static GetPointerPrefix(engine: Engine): string;
  115622. /**
  115623. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115624. * @param url define the url we are trying
  115625. * @param element define the dom element where to configure the cors policy
  115626. */
  115627. static SetCorsBehavior(url: string | string[], element: {
  115628. crossOrigin: string | null;
  115629. }): void;
  115630. /**
  115631. * Removes unwanted characters from an url
  115632. * @param url defines the url to clean
  115633. * @returns the cleaned url
  115634. */
  115635. static CleanUrl(url: string): string;
  115636. /**
  115637. * Gets or sets a function used to pre-process url before using them to load assets
  115638. */
  115639. static get PreprocessUrl(): (url: string) => string;
  115640. static set PreprocessUrl(processor: (url: string) => string);
  115641. /**
  115642. * Loads an image as an HTMLImageElement.
  115643. * @param input url string, ArrayBuffer, or Blob to load
  115644. * @param onLoad callback called when the image successfully loads
  115645. * @param onError callback called when the image fails to load
  115646. * @param offlineProvider offline provider for caching
  115647. * @param mimeType optional mime type
  115648. * @returns the HTMLImageElement of the loaded image
  115649. */
  115650. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115651. /**
  115652. * Loads a file from a url
  115653. * @param url url string, ArrayBuffer, or Blob to load
  115654. * @param onSuccess callback called when the file successfully loads
  115655. * @param onProgress callback called while file is loading (if the server supports this mode)
  115656. * @param offlineProvider defines the offline provider for caching
  115657. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115658. * @param onError callback called when the file fails to load
  115659. * @returns a file request object
  115660. */
  115661. 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;
  115662. /**
  115663. * Loads a file from a url
  115664. * @param url the file url to load
  115665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115666. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115667. */
  115668. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115669. /**
  115670. * Load a script (identified by an url). When the url returns, the
  115671. * content of this file is added into a new script element, attached to the DOM (body element)
  115672. * @param scriptUrl defines the url of the script to laod
  115673. * @param onSuccess defines the callback called when the script is loaded
  115674. * @param onError defines the callback to call if an error occurs
  115675. * @param scriptId defines the id of the script element
  115676. */
  115677. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115678. /**
  115679. * Load an asynchronous script (identified by an url). When the url returns, the
  115680. * content of this file is added into a new script element, attached to the DOM (body element)
  115681. * @param scriptUrl defines the url of the script to laod
  115682. * @param scriptId defines the id of the script element
  115683. * @returns a promise request object
  115684. */
  115685. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115686. /**
  115687. * Loads a file from a blob
  115688. * @param fileToLoad defines the blob to use
  115689. * @param callback defines the callback to call when data is loaded
  115690. * @param progressCallback defines the callback to call during loading process
  115691. * @returns a file request object
  115692. */
  115693. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115694. /**
  115695. * Reads a file from a File object
  115696. * @param file defines the file to load
  115697. * @param onSuccess defines the callback to call when data is loaded
  115698. * @param onProgress defines the callback to call during loading process
  115699. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115700. * @param onError defines the callback to call when an error occurs
  115701. * @returns a file request object
  115702. */
  115703. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115704. /**
  115705. * Creates a data url from a given string content
  115706. * @param content defines the content to convert
  115707. * @returns the new data url link
  115708. */
  115709. static FileAsURL(content: string): string;
  115710. /**
  115711. * Format the given number to a specific decimal format
  115712. * @param value defines the number to format
  115713. * @param decimals defines the number of decimals to use
  115714. * @returns the formatted string
  115715. */
  115716. static Format(value: number, decimals?: number): string;
  115717. /**
  115718. * Tries to copy an object by duplicating every property
  115719. * @param source defines the source object
  115720. * @param destination defines the target object
  115721. * @param doNotCopyList defines a list of properties to avoid
  115722. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115723. */
  115724. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115725. /**
  115726. * Gets a boolean indicating if the given object has no own property
  115727. * @param obj defines the object to test
  115728. * @returns true if object has no own property
  115729. */
  115730. static IsEmpty(obj: any): boolean;
  115731. /**
  115732. * Function used to register events at window level
  115733. * @param windowElement defines the Window object to use
  115734. * @param events defines the events to register
  115735. */
  115736. static RegisterTopRootEvents(windowElement: Window, events: {
  115737. name: string;
  115738. handler: Nullable<(e: FocusEvent) => any>;
  115739. }[]): void;
  115740. /**
  115741. * Function used to unregister events from window level
  115742. * @param windowElement defines the Window object to use
  115743. * @param events defines the events to unregister
  115744. */
  115745. static UnregisterTopRootEvents(windowElement: Window, events: {
  115746. name: string;
  115747. handler: Nullable<(e: FocusEvent) => any>;
  115748. }[]): void;
  115749. /**
  115750. * @ignore
  115751. */
  115752. static _ScreenshotCanvas: HTMLCanvasElement;
  115753. /**
  115754. * Dumps the current bound framebuffer
  115755. * @param width defines the rendering width
  115756. * @param height defines the rendering height
  115757. * @param engine defines the hosting engine
  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 the filename to download. If present, the result will automatically be downloaded
  115761. */
  115762. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115763. /**
  115764. * Converts the canvas data to blob.
  115765. * This acts as a polyfill for browsers not supporting the to blob function.
  115766. * @param canvas Defines the canvas to extract the data from
  115767. * @param successCallback Defines the callback triggered once the data are available
  115768. * @param mimeType Defines the mime type of the result
  115769. */
  115770. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115771. /**
  115772. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115773. * @param successCallback defines the callback triggered once the data are available
  115774. * @param mimeType defines the mime type of the result
  115775. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115776. */
  115777. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115778. /**
  115779. * Downloads a blob in the browser
  115780. * @param blob defines the blob to download
  115781. * @param fileName defines the name of the downloaded file
  115782. */
  115783. static Download(blob: Blob, fileName: string): void;
  115784. /**
  115785. * Captures a screenshot of the current rendering
  115786. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115787. * @param engine defines the rendering engine
  115788. * @param camera defines the source camera
  115789. * @param size This parameter can be set to a single number or to an object with the
  115790. * following (optional) properties: precision, width, height. If a single number is passed,
  115791. * it will be used for both width and height. If an object is passed, the screenshot size
  115792. * will be derived from the parameters. The precision property is a multiplier allowing
  115793. * rendering at a higher or lower resolution
  115794. * @param successCallback defines the callback receives a single parameter which contains the
  115795. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115796. * src parameter of an <img> to display it
  115797. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115798. * Check your browser for supported MIME types
  115799. */
  115800. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115801. /**
  115802. * Captures a screenshot of the current rendering
  115803. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115804. * @param engine defines the rendering engine
  115805. * @param camera defines the source camera
  115806. * @param size This parameter can be set to a single number or to an object with the
  115807. * following (optional) properties: precision, width, height. If a single number is passed,
  115808. * it will be used for both width and height. If an object is passed, the screenshot size
  115809. * will be derived from the parameters. The precision property is a multiplier allowing
  115810. * rendering at a higher or lower resolution
  115811. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115812. * Check your browser for supported MIME types
  115813. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115814. * to the src parameter of an <img> to display it
  115815. */
  115816. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115817. /**
  115818. * Generates an image screenshot from the specified camera.
  115819. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115820. * @param engine The engine to use for rendering
  115821. * @param camera The camera to use for rendering
  115822. * @param size This parameter can be set to a single number or to an object with the
  115823. * following (optional) properties: precision, width, height. If a single number is passed,
  115824. * it will be used for both width and height. If an object is passed, the screenshot size
  115825. * will be derived from the parameters. The precision property is a multiplier allowing
  115826. * rendering at a higher or lower resolution
  115827. * @param successCallback The callback receives a single parameter which contains the
  115828. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115829. * src parameter of an <img> to display it
  115830. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115831. * Check your browser for supported MIME types
  115832. * @param samples Texture samples (default: 1)
  115833. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115834. * @param fileName A name for for the downloaded file.
  115835. */
  115836. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115837. /**
  115838. * Generates an image screenshot from the specified camera.
  115839. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115840. * @param engine The engine to use for rendering
  115841. * @param camera The camera to use for rendering
  115842. * @param size This parameter can be set to a single number or to an object with the
  115843. * following (optional) properties: precision, width, height. If a single number is passed,
  115844. * it will be used for both width and height. If an object is passed, the screenshot size
  115845. * will be derived from the parameters. The precision property is a multiplier allowing
  115846. * rendering at a higher or lower resolution
  115847. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115848. * Check your browser for supported MIME types
  115849. * @param samples Texture samples (default: 1)
  115850. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115851. * @param fileName A name for for the downloaded file.
  115852. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115853. * to the src parameter of an <img> to display it
  115854. */
  115855. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115856. /**
  115857. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115858. * Be aware Math.random() could cause collisions, but:
  115859. * "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"
  115860. * @returns a pseudo random id
  115861. */
  115862. static RandomId(): string;
  115863. /**
  115864. * Test if the given uri is a base64 string
  115865. * @param uri The uri to test
  115866. * @return True if the uri is a base64 string or false otherwise
  115867. */
  115868. static IsBase64(uri: string): boolean;
  115869. /**
  115870. * Decode the given base64 uri.
  115871. * @param uri The uri to decode
  115872. * @return The decoded base64 data.
  115873. */
  115874. static DecodeBase64(uri: string): ArrayBuffer;
  115875. /**
  115876. * Gets the absolute url.
  115877. * @param url the input url
  115878. * @return the absolute url
  115879. */
  115880. static GetAbsoluteUrl(url: string): string;
  115881. /**
  115882. * No log
  115883. */
  115884. static readonly NoneLogLevel: number;
  115885. /**
  115886. * Only message logs
  115887. */
  115888. static readonly MessageLogLevel: number;
  115889. /**
  115890. * Only warning logs
  115891. */
  115892. static readonly WarningLogLevel: number;
  115893. /**
  115894. * Only error logs
  115895. */
  115896. static readonly ErrorLogLevel: number;
  115897. /**
  115898. * All logs
  115899. */
  115900. static readonly AllLogLevel: number;
  115901. /**
  115902. * Gets a value indicating the number of loading errors
  115903. * @ignorenaming
  115904. */
  115905. static get errorsCount(): number;
  115906. /**
  115907. * Callback called when a new log is added
  115908. */
  115909. static OnNewCacheEntry: (entry: string) => void;
  115910. /**
  115911. * Log a message to the console
  115912. * @param message defines the message to log
  115913. */
  115914. static Log(message: string): void;
  115915. /**
  115916. * Write a warning message to the console
  115917. * @param message defines the message to log
  115918. */
  115919. static Warn(message: string): void;
  115920. /**
  115921. * Write an error message to the console
  115922. * @param message defines the message to log
  115923. */
  115924. static Error(message: string): void;
  115925. /**
  115926. * Gets current log cache (list of logs)
  115927. */
  115928. static get LogCache(): string;
  115929. /**
  115930. * Clears the log cache
  115931. */
  115932. static ClearLogCache(): void;
  115933. /**
  115934. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115935. */
  115936. static set LogLevels(level: number);
  115937. /**
  115938. * Checks if the window object exists
  115939. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115940. */
  115941. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115942. /**
  115943. * No performance log
  115944. */
  115945. static readonly PerformanceNoneLogLevel: number;
  115946. /**
  115947. * Use user marks to log performance
  115948. */
  115949. static readonly PerformanceUserMarkLogLevel: number;
  115950. /**
  115951. * Log performance to the console
  115952. */
  115953. static readonly PerformanceConsoleLogLevel: number;
  115954. private static _performance;
  115955. /**
  115956. * Sets the current performance log level
  115957. */
  115958. static set PerformanceLogLevel(level: number);
  115959. private static _StartPerformanceCounterDisabled;
  115960. private static _EndPerformanceCounterDisabled;
  115961. private static _StartUserMark;
  115962. private static _EndUserMark;
  115963. private static _StartPerformanceConsole;
  115964. private static _EndPerformanceConsole;
  115965. /**
  115966. * Starts a performance counter
  115967. */
  115968. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115969. /**
  115970. * Ends a specific performance coutner
  115971. */
  115972. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115973. /**
  115974. * Gets either window.performance.now() if supported or Date.now() else
  115975. */
  115976. static get Now(): number;
  115977. /**
  115978. * This method will return the name of the class used to create the instance of the given object.
  115979. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115980. * @param object the object to get the class name from
  115981. * @param isType defines if the object is actually a type
  115982. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115983. */
  115984. static GetClassName(object: any, isType?: boolean): string;
  115985. /**
  115986. * Gets the first element of an array satisfying a given predicate
  115987. * @param array defines the array to browse
  115988. * @param predicate defines the predicate to use
  115989. * @returns null if not found or the element
  115990. */
  115991. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115992. /**
  115993. * This method will return the name of the full name of the class, including its owning module (if any).
  115994. * 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).
  115995. * @param object the object to get the class name from
  115996. * @param isType defines if the object is actually a type
  115997. * @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.
  115998. * @ignorenaming
  115999. */
  116000. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  116001. /**
  116002. * Returns a promise that resolves after the given amount of time.
  116003. * @param delay Number of milliseconds to delay
  116004. * @returns Promise that resolves after the given amount of time
  116005. */
  116006. static DelayAsync(delay: number): Promise<void>;
  116007. /**
  116008. * Utility function to detect if the current user agent is Safari
  116009. * @returns whether or not the current user agent is safari
  116010. */
  116011. static IsSafari(): boolean;
  116012. }
  116013. /**
  116014. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116015. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116016. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116017. * @param name The name of the class, case should be preserved
  116018. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116019. */
  116020. export function className(name: string, module?: string): (target: Object) => void;
  116021. /**
  116022. * An implementation of a loop for asynchronous functions.
  116023. */
  116024. export class AsyncLoop {
  116025. /**
  116026. * Defines the number of iterations for the loop
  116027. */
  116028. iterations: number;
  116029. /**
  116030. * Defines the current index of the loop.
  116031. */
  116032. index: number;
  116033. private _done;
  116034. private _fn;
  116035. private _successCallback;
  116036. /**
  116037. * Constructor.
  116038. * @param iterations the number of iterations.
  116039. * @param func the function to run each iteration
  116040. * @param successCallback the callback that will be called upon succesful execution
  116041. * @param offset starting offset.
  116042. */
  116043. constructor(
  116044. /**
  116045. * Defines the number of iterations for the loop
  116046. */
  116047. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116048. /**
  116049. * Execute the next iteration. Must be called after the last iteration was finished.
  116050. */
  116051. executeNext(): void;
  116052. /**
  116053. * Break the loop and run the success callback.
  116054. */
  116055. breakLoop(): void;
  116056. /**
  116057. * Create and run an async loop.
  116058. * @param iterations the number of iterations.
  116059. * @param fn the function to run each iteration
  116060. * @param successCallback the callback that will be called upon succesful execution
  116061. * @param offset starting offset.
  116062. * @returns the created async loop object
  116063. */
  116064. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116065. /**
  116066. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116067. * @param iterations total number of iterations
  116068. * @param syncedIterations number of synchronous iterations in each async iteration.
  116069. * @param fn the function to call each iteration.
  116070. * @param callback a success call back that will be called when iterating stops.
  116071. * @param breakFunction a break condition (optional)
  116072. * @param timeout timeout settings for the setTimeout function. default - 0.
  116073. * @returns the created async loop object
  116074. */
  116075. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116076. }
  116077. }
  116078. declare module BABYLON {
  116079. /**
  116080. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116081. * The underlying implementation relies on an associative array to ensure the best performances.
  116082. * The value can be anything including 'null' but except 'undefined'
  116083. */
  116084. export class StringDictionary<T> {
  116085. /**
  116086. * This will clear this dictionary and copy the content from the 'source' one.
  116087. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116088. * @param source the dictionary to take the content from and copy to this dictionary
  116089. */
  116090. copyFrom(source: StringDictionary<T>): void;
  116091. /**
  116092. * Get a value based from its key
  116093. * @param key the given key to get the matching value from
  116094. * @return the value if found, otherwise undefined is returned
  116095. */
  116096. get(key: string): T | undefined;
  116097. /**
  116098. * Get a value from its key or add it if it doesn't exist.
  116099. * This method will ensure you that a given key/data will be present in the dictionary.
  116100. * @param key the given key to get the matching value from
  116101. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116102. * The factory will only be invoked if there's no data for the given key.
  116103. * @return the value corresponding to the key.
  116104. */
  116105. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116106. /**
  116107. * Get a value from its key if present in the dictionary otherwise add it
  116108. * @param key the key to get the value from
  116109. * @param val if there's no such key/value pair in the dictionary add it with this value
  116110. * @return the value corresponding to the key
  116111. */
  116112. getOrAdd(key: string, val: T): T;
  116113. /**
  116114. * Check if there's a given key in the dictionary
  116115. * @param key the key to check for
  116116. * @return true if the key is present, false otherwise
  116117. */
  116118. contains(key: string): boolean;
  116119. /**
  116120. * Add a new key and its corresponding value
  116121. * @param key the key to add
  116122. * @param value the value corresponding to the key
  116123. * @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
  116124. */
  116125. add(key: string, value: T): boolean;
  116126. /**
  116127. * Update a specific value associated to a key
  116128. * @param key defines the key to use
  116129. * @param value defines the value to store
  116130. * @returns true if the value was updated (or false if the key was not found)
  116131. */
  116132. set(key: string, value: T): boolean;
  116133. /**
  116134. * Get the element of the given key and remove it from the dictionary
  116135. * @param key defines the key to search
  116136. * @returns the value associated with the key or null if not found
  116137. */
  116138. getAndRemove(key: string): Nullable<T>;
  116139. /**
  116140. * Remove a key/value from the dictionary.
  116141. * @param key the key to remove
  116142. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116143. */
  116144. remove(key: string): boolean;
  116145. /**
  116146. * Clear the whole content of the dictionary
  116147. */
  116148. clear(): void;
  116149. /**
  116150. * Gets the current count
  116151. */
  116152. get count(): number;
  116153. /**
  116154. * Execute a callback on each key/val of the dictionary.
  116155. * Note that you can remove any element in this dictionary in the callback implementation
  116156. * @param callback the callback to execute on a given key/value pair
  116157. */
  116158. forEach(callback: (key: string, val: T) => void): void;
  116159. /**
  116160. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116161. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116162. * Note that you can remove any element in this dictionary in the callback implementation
  116163. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116164. * @returns the first item
  116165. */
  116166. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116167. private _count;
  116168. private _data;
  116169. }
  116170. }
  116171. declare module BABYLON {
  116172. /** @hidden */
  116173. export interface ICollisionCoordinator {
  116174. createCollider(): Collider;
  116175. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116176. init(scene: Scene): void;
  116177. }
  116178. /** @hidden */
  116179. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116180. private _scene;
  116181. private _scaledPosition;
  116182. private _scaledVelocity;
  116183. private _finalPosition;
  116184. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116185. createCollider(): Collider;
  116186. init(scene: Scene): void;
  116187. private _collideWithWorld;
  116188. }
  116189. }
  116190. declare module BABYLON {
  116191. /**
  116192. * Class used to manage all inputs for the scene.
  116193. */
  116194. export class InputManager {
  116195. /** The distance in pixel that you have to move to prevent some events */
  116196. static DragMovementThreshold: number;
  116197. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116198. static LongPressDelay: number;
  116199. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116200. static DoubleClickDelay: number;
  116201. /** If you need to check double click without raising a single click at first click, enable this flag */
  116202. static ExclusiveDoubleClickMode: boolean;
  116203. private _wheelEventName;
  116204. private _onPointerMove;
  116205. private _onPointerDown;
  116206. private _onPointerUp;
  116207. private _initClickEvent;
  116208. private _initActionManager;
  116209. private _delayedSimpleClick;
  116210. private _delayedSimpleClickTimeout;
  116211. private _previousDelayedSimpleClickTimeout;
  116212. private _meshPickProceed;
  116213. private _previousButtonPressed;
  116214. private _currentPickResult;
  116215. private _previousPickResult;
  116216. private _totalPointersPressed;
  116217. private _doubleClickOccured;
  116218. private _pointerOverMesh;
  116219. private _pickedDownMesh;
  116220. private _pickedUpMesh;
  116221. private _pointerX;
  116222. private _pointerY;
  116223. private _unTranslatedPointerX;
  116224. private _unTranslatedPointerY;
  116225. private _startingPointerPosition;
  116226. private _previousStartingPointerPosition;
  116227. private _startingPointerTime;
  116228. private _previousStartingPointerTime;
  116229. private _pointerCaptures;
  116230. private _onKeyDown;
  116231. private _onKeyUp;
  116232. private _onCanvasFocusObserver;
  116233. private _onCanvasBlurObserver;
  116234. private _scene;
  116235. /**
  116236. * Creates a new InputManager
  116237. * @param scene defines the hosting scene
  116238. */
  116239. constructor(scene: Scene);
  116240. /**
  116241. * Gets the mesh that is currently under the pointer
  116242. */
  116243. get meshUnderPointer(): Nullable<AbstractMesh>;
  116244. /**
  116245. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116246. */
  116247. get unTranslatedPointer(): Vector2;
  116248. /**
  116249. * Gets or sets the current on-screen X position of the pointer
  116250. */
  116251. get pointerX(): number;
  116252. set pointerX(value: number);
  116253. /**
  116254. * Gets or sets the current on-screen Y position of the pointer
  116255. */
  116256. get pointerY(): number;
  116257. set pointerY(value: number);
  116258. private _updatePointerPosition;
  116259. private _processPointerMove;
  116260. private _setRayOnPointerInfo;
  116261. private _checkPrePointerObservable;
  116262. /**
  116263. * Use this method to simulate a pointer move on a mesh
  116264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116267. */
  116268. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116269. /**
  116270. * Use this method to simulate a pointer down on a mesh
  116271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116274. */
  116275. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116276. private _processPointerDown;
  116277. /** @hidden */
  116278. _isPointerSwiping(): boolean;
  116279. /**
  116280. * Use this method to simulate a pointer up on a mesh
  116281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116285. */
  116286. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116287. private _processPointerUp;
  116288. /**
  116289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116291. * @returns true if the pointer was captured
  116292. */
  116293. isPointerCaptured(pointerId?: number): boolean;
  116294. /**
  116295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116296. * @param attachUp defines if you want to attach events to pointerup
  116297. * @param attachDown defines if you want to attach events to pointerdown
  116298. * @param attachMove defines if you want to attach events to pointermove
  116299. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116300. */
  116301. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116302. /**
  116303. * Detaches all event handlers
  116304. */
  116305. detachControl(): void;
  116306. /**
  116307. * Force the value of meshUnderPointer
  116308. * @param mesh defines the mesh to use
  116309. */
  116310. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116311. /**
  116312. * Gets the mesh under the pointer
  116313. * @returns a Mesh or null if no mesh is under the pointer
  116314. */
  116315. getPointerOverMesh(): Nullable<AbstractMesh>;
  116316. }
  116317. }
  116318. declare module BABYLON {
  116319. /**
  116320. * This class defines the direct association between an animation and a target
  116321. */
  116322. export class TargetedAnimation {
  116323. /**
  116324. * Animation to perform
  116325. */
  116326. animation: Animation;
  116327. /**
  116328. * Target to animate
  116329. */
  116330. target: any;
  116331. /**
  116332. * Returns the string "TargetedAnimation"
  116333. * @returns "TargetedAnimation"
  116334. */
  116335. getClassName(): string;
  116336. /**
  116337. * Serialize the object
  116338. * @returns the JSON object representing the current entity
  116339. */
  116340. serialize(): any;
  116341. }
  116342. /**
  116343. * Use this class to create coordinated animations on multiple targets
  116344. */
  116345. export class AnimationGroup implements IDisposable {
  116346. /** The name of the animation group */
  116347. name: string;
  116348. private _scene;
  116349. private _targetedAnimations;
  116350. private _animatables;
  116351. private _from;
  116352. private _to;
  116353. private _isStarted;
  116354. private _isPaused;
  116355. private _speedRatio;
  116356. private _loopAnimation;
  116357. private _isAdditive;
  116358. /**
  116359. * Gets or sets the unique id of the node
  116360. */
  116361. uniqueId: number;
  116362. /**
  116363. * This observable will notify when one animation have ended
  116364. */
  116365. onAnimationEndObservable: Observable<TargetedAnimation>;
  116366. /**
  116367. * Observer raised when one animation loops
  116368. */
  116369. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116370. /**
  116371. * Observer raised when all animations have looped
  116372. */
  116373. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116374. /**
  116375. * This observable will notify when all animations have ended.
  116376. */
  116377. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116378. /**
  116379. * This observable will notify when all animations have paused.
  116380. */
  116381. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116382. /**
  116383. * This observable will notify when all animations are playing.
  116384. */
  116385. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116386. /**
  116387. * Gets the first frame
  116388. */
  116389. get from(): number;
  116390. /**
  116391. * Gets the last frame
  116392. */
  116393. get to(): number;
  116394. /**
  116395. * Define if the animations are started
  116396. */
  116397. get isStarted(): boolean;
  116398. /**
  116399. * Gets a value indicating that the current group is playing
  116400. */
  116401. get isPlaying(): boolean;
  116402. /**
  116403. * Gets or sets the speed ratio to use for all animations
  116404. */
  116405. get speedRatio(): number;
  116406. /**
  116407. * Gets or sets the speed ratio to use for all animations
  116408. */
  116409. set speedRatio(value: number);
  116410. /**
  116411. * Gets or sets if all animations should loop or not
  116412. */
  116413. get loopAnimation(): boolean;
  116414. set loopAnimation(value: boolean);
  116415. /**
  116416. * Gets or sets if all animations should be evaluated additively
  116417. */
  116418. get isAdditive(): boolean;
  116419. set isAdditive(value: boolean);
  116420. /**
  116421. * Gets the targeted animations for this animation group
  116422. */
  116423. get targetedAnimations(): Array<TargetedAnimation>;
  116424. /**
  116425. * returning the list of animatables controlled by this animation group.
  116426. */
  116427. get animatables(): Array<Animatable>;
  116428. /**
  116429. * Gets the list of target animations
  116430. */
  116431. get children(): TargetedAnimation[];
  116432. /**
  116433. * Instantiates a new Animation Group.
  116434. * This helps managing several animations at once.
  116435. * @see https://doc.babylonjs.com/how_to/group
  116436. * @param name Defines the name of the group
  116437. * @param scene Defines the scene the group belongs to
  116438. */
  116439. constructor(
  116440. /** The name of the animation group */
  116441. name: string, scene?: Nullable<Scene>);
  116442. /**
  116443. * Add an animation (with its target) in the group
  116444. * @param animation defines the animation we want to add
  116445. * @param target defines the target of the animation
  116446. * @returns the TargetedAnimation object
  116447. */
  116448. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116449. /**
  116450. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116451. * It can add constant keys at begin or end
  116452. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116453. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116454. * @returns the animation group
  116455. */
  116456. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116457. private _animationLoopCount;
  116458. private _animationLoopFlags;
  116459. private _processLoop;
  116460. /**
  116461. * Start all animations on given targets
  116462. * @param loop defines if animations must loop
  116463. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116464. * @param from defines the from key (optional)
  116465. * @param to defines the to key (optional)
  116466. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116467. * @returns the current animation group
  116468. */
  116469. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116470. /**
  116471. * Pause all animations
  116472. * @returns the animation group
  116473. */
  116474. pause(): AnimationGroup;
  116475. /**
  116476. * Play all animations to initial state
  116477. * This function will start() the animations if they were not started or will restart() them if they were paused
  116478. * @param loop defines if animations must loop
  116479. * @returns the animation group
  116480. */
  116481. play(loop?: boolean): AnimationGroup;
  116482. /**
  116483. * Reset all animations to initial state
  116484. * @returns the animation group
  116485. */
  116486. reset(): AnimationGroup;
  116487. /**
  116488. * Restart animations from key 0
  116489. * @returns the animation group
  116490. */
  116491. restart(): AnimationGroup;
  116492. /**
  116493. * Stop all animations
  116494. * @returns the animation group
  116495. */
  116496. stop(): AnimationGroup;
  116497. /**
  116498. * Set animation weight for all animatables
  116499. * @param weight defines the weight to use
  116500. * @return the animationGroup
  116501. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116502. */
  116503. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116504. /**
  116505. * Synchronize and normalize all animatables with a source animatable
  116506. * @param root defines the root animatable to synchronize with
  116507. * @return the animationGroup
  116508. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116509. */
  116510. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116511. /**
  116512. * Goes to a specific frame in this animation group
  116513. * @param frame the frame number to go to
  116514. * @return the animationGroup
  116515. */
  116516. goToFrame(frame: number): AnimationGroup;
  116517. /**
  116518. * Dispose all associated resources
  116519. */
  116520. dispose(): void;
  116521. private _checkAnimationGroupEnded;
  116522. /**
  116523. * Clone the current animation group and returns a copy
  116524. * @param newName defines the name of the new group
  116525. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116526. * @returns the new aniamtion group
  116527. */
  116528. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116529. /**
  116530. * Serializes the animationGroup to an object
  116531. * @returns Serialized object
  116532. */
  116533. serialize(): any;
  116534. /**
  116535. * Returns a new AnimationGroup object parsed from the source provided.
  116536. * @param parsedAnimationGroup defines the source
  116537. * @param scene defines the scene that will receive the animationGroup
  116538. * @returns a new AnimationGroup
  116539. */
  116540. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116541. /**
  116542. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116543. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116544. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116545. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116546. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116547. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116548. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116549. */
  116550. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116551. /**
  116552. * Returns the string "AnimationGroup"
  116553. * @returns "AnimationGroup"
  116554. */
  116555. getClassName(): string;
  116556. /**
  116557. * Creates a detailled string about the object
  116558. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116559. * @returns a string representing the object
  116560. */
  116561. toString(fullDetails?: boolean): string;
  116562. }
  116563. }
  116564. declare module BABYLON {
  116565. /**
  116566. * Define an interface for all classes that will hold resources
  116567. */
  116568. export interface IDisposable {
  116569. /**
  116570. * Releases all held resources
  116571. */
  116572. dispose(): void;
  116573. }
  116574. /** Interface defining initialization parameters for Scene class */
  116575. export interface SceneOptions {
  116576. /**
  116577. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116578. * It will improve performance when the number of geometries becomes important.
  116579. */
  116580. useGeometryUniqueIdsMap?: boolean;
  116581. /**
  116582. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116583. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116584. */
  116585. useMaterialMeshMap?: boolean;
  116586. /**
  116587. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116588. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116589. */
  116590. useClonedMeshMap?: boolean;
  116591. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116592. virtual?: boolean;
  116593. }
  116594. /**
  116595. * Represents a scene to be rendered by the engine.
  116596. * @see https://doc.babylonjs.com/features/scene
  116597. */
  116598. export class Scene extends AbstractScene implements IAnimatable {
  116599. /** The fog is deactivated */
  116600. static readonly FOGMODE_NONE: number;
  116601. /** The fog density is following an exponential function */
  116602. static readonly FOGMODE_EXP: number;
  116603. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116604. static readonly FOGMODE_EXP2: number;
  116605. /** The fog density is following a linear function. */
  116606. static readonly FOGMODE_LINEAR: number;
  116607. /**
  116608. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116609. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116610. */
  116611. static MinDeltaTime: number;
  116612. /**
  116613. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116614. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116615. */
  116616. static MaxDeltaTime: number;
  116617. /**
  116618. * Factory used to create the default material.
  116619. * @param name The name of the material to create
  116620. * @param scene The scene to create the material for
  116621. * @returns The default material
  116622. */
  116623. static DefaultMaterialFactory(scene: Scene): Material;
  116624. /**
  116625. * Factory used to create the a collision coordinator.
  116626. * @returns The collision coordinator
  116627. */
  116628. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116629. /** @hidden */
  116630. _inputManager: InputManager;
  116631. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116632. cameraToUseForPointers: Nullable<Camera>;
  116633. /** @hidden */
  116634. readonly _isScene: boolean;
  116635. /** @hidden */
  116636. _blockEntityCollection: boolean;
  116637. /**
  116638. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116639. */
  116640. autoClear: boolean;
  116641. /**
  116642. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116643. */
  116644. autoClearDepthAndStencil: boolean;
  116645. /**
  116646. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116647. */
  116648. clearColor: Color4;
  116649. /**
  116650. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116651. */
  116652. ambientColor: Color3;
  116653. /**
  116654. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116655. * It should only be one of the following (if not the default embedded one):
  116656. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116657. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116658. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116659. * The material properties need to be setup according to the type of texture in use.
  116660. */
  116661. environmentBRDFTexture: BaseTexture;
  116662. /** @hidden */
  116663. protected _environmentTexture: Nullable<BaseTexture>;
  116664. /**
  116665. * Texture used in all pbr material as the reflection texture.
  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 environmentTexture(): Nullable<BaseTexture>;
  116670. /**
  116671. * Texture used in all pbr material as the reflection texture.
  116672. * As in the majority of the scene they are the same (exception for multi room and so on),
  116673. * this is easier to set here than in all the materials.
  116674. */
  116675. set environmentTexture(value: Nullable<BaseTexture>);
  116676. /** @hidden */
  116677. protected _environmentIntensity: number;
  116678. /**
  116679. * Intensity of the environment in all pbr material.
  116680. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116681. * As in the majority of the scene they are the same (exception for multi room and so on),
  116682. * this is easier to reference from here than from all the materials.
  116683. */
  116684. get environmentIntensity(): number;
  116685. /**
  116686. * Intensity of the environment in all pbr material.
  116687. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116688. * As in the majority of the scene they are the same (exception for multi room and so on),
  116689. * this is easier to set here than in all the materials.
  116690. */
  116691. set environmentIntensity(value: number);
  116692. /** @hidden */
  116693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116694. /**
  116695. * Default image processing configuration used either in the rendering
  116696. * Forward main pass or through the imageProcessingPostProcess if present.
  116697. * As in the majority of the scene they are the same (exception for multi camera),
  116698. * this is easier to reference from here than from all the materials and post process.
  116699. *
  116700. * No setter as we it is a shared configuration, you can set the values instead.
  116701. */
  116702. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116703. private _forceWireframe;
  116704. /**
  116705. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116706. */
  116707. set forceWireframe(value: boolean);
  116708. get forceWireframe(): boolean;
  116709. private _skipFrustumClipping;
  116710. /**
  116711. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116712. */
  116713. set skipFrustumClipping(value: boolean);
  116714. get skipFrustumClipping(): boolean;
  116715. private _forcePointsCloud;
  116716. /**
  116717. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116718. */
  116719. set forcePointsCloud(value: boolean);
  116720. get forcePointsCloud(): boolean;
  116721. /**
  116722. * Gets or sets the active clipplane 1
  116723. */
  116724. clipPlane: Nullable<Plane>;
  116725. /**
  116726. * Gets or sets the active clipplane 2
  116727. */
  116728. clipPlane2: Nullable<Plane>;
  116729. /**
  116730. * Gets or sets the active clipplane 3
  116731. */
  116732. clipPlane3: Nullable<Plane>;
  116733. /**
  116734. * Gets or sets the active clipplane 4
  116735. */
  116736. clipPlane4: Nullable<Plane>;
  116737. /**
  116738. * Gets or sets the active clipplane 5
  116739. */
  116740. clipPlane5: Nullable<Plane>;
  116741. /**
  116742. * Gets or sets the active clipplane 6
  116743. */
  116744. clipPlane6: Nullable<Plane>;
  116745. /**
  116746. * Gets or sets a boolean indicating if animations are enabled
  116747. */
  116748. animationsEnabled: boolean;
  116749. private _animationPropertiesOverride;
  116750. /**
  116751. * Gets or sets the animation properties override
  116752. */
  116753. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116754. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116755. /**
  116756. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116757. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116758. */
  116759. useConstantAnimationDeltaTime: boolean;
  116760. /**
  116761. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116762. * Please note that it requires to run a ray cast through the scene on every frame
  116763. */
  116764. constantlyUpdateMeshUnderPointer: boolean;
  116765. /**
  116766. * Defines the HTML cursor to use when hovering over interactive elements
  116767. */
  116768. hoverCursor: string;
  116769. /**
  116770. * Defines the HTML default cursor to use (empty by default)
  116771. */
  116772. defaultCursor: string;
  116773. /**
  116774. * Defines whether cursors are handled by the scene.
  116775. */
  116776. doNotHandleCursors: boolean;
  116777. /**
  116778. * This is used to call preventDefault() on pointer down
  116779. * in order to block unwanted artifacts like system double clicks
  116780. */
  116781. preventDefaultOnPointerDown: boolean;
  116782. /**
  116783. * This is used to call preventDefault() on pointer up
  116784. * in order to block unwanted artifacts like system double clicks
  116785. */
  116786. preventDefaultOnPointerUp: boolean;
  116787. /**
  116788. * Gets or sets user defined metadata
  116789. */
  116790. metadata: any;
  116791. /**
  116792. * For internal use only. Please do not use.
  116793. */
  116794. reservedDataStore: any;
  116795. /**
  116796. * Gets the name of the plugin used to load this scene (null by default)
  116797. */
  116798. loadingPluginName: string;
  116799. /**
  116800. * Use this array to add regular expressions used to disable offline support for specific urls
  116801. */
  116802. disableOfflineSupportExceptionRules: RegExp[];
  116803. /**
  116804. * An event triggered when the scene is disposed.
  116805. */
  116806. onDisposeObservable: Observable<Scene>;
  116807. private _onDisposeObserver;
  116808. /** Sets a function to be executed when this scene is disposed. */
  116809. set onDispose(callback: () => void);
  116810. /**
  116811. * An event triggered before rendering the scene (right after animations and physics)
  116812. */
  116813. onBeforeRenderObservable: Observable<Scene>;
  116814. private _onBeforeRenderObserver;
  116815. /** Sets a function to be executed before rendering this scene */
  116816. set beforeRender(callback: Nullable<() => void>);
  116817. /**
  116818. * An event triggered after rendering the scene
  116819. */
  116820. onAfterRenderObservable: Observable<Scene>;
  116821. /**
  116822. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116823. */
  116824. onAfterRenderCameraObservable: Observable<Camera>;
  116825. private _onAfterRenderObserver;
  116826. /** Sets a function to be executed after rendering this scene */
  116827. set afterRender(callback: Nullable<() => void>);
  116828. /**
  116829. * An event triggered before animating the scene
  116830. */
  116831. onBeforeAnimationsObservable: Observable<Scene>;
  116832. /**
  116833. * An event triggered after animations processing
  116834. */
  116835. onAfterAnimationsObservable: Observable<Scene>;
  116836. /**
  116837. * An event triggered before draw calls are ready to be sent
  116838. */
  116839. onBeforeDrawPhaseObservable: Observable<Scene>;
  116840. /**
  116841. * An event triggered after draw calls have been sent
  116842. */
  116843. onAfterDrawPhaseObservable: Observable<Scene>;
  116844. /**
  116845. * An event triggered when the scene is ready
  116846. */
  116847. onReadyObservable: Observable<Scene>;
  116848. /**
  116849. * An event triggered before rendering a camera
  116850. */
  116851. onBeforeCameraRenderObservable: Observable<Camera>;
  116852. private _onBeforeCameraRenderObserver;
  116853. /** Sets a function to be executed before rendering a camera*/
  116854. set beforeCameraRender(callback: () => void);
  116855. /**
  116856. * An event triggered after rendering a camera
  116857. */
  116858. onAfterCameraRenderObservable: Observable<Camera>;
  116859. private _onAfterCameraRenderObserver;
  116860. /** Sets a function to be executed after rendering a camera*/
  116861. set afterCameraRender(callback: () => void);
  116862. /**
  116863. * An event triggered when active meshes evaluation is about to start
  116864. */
  116865. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116866. /**
  116867. * An event triggered when active meshes evaluation is done
  116868. */
  116869. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116870. /**
  116871. * An event triggered when particles rendering is about to start
  116872. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116873. */
  116874. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116875. /**
  116876. * An event triggered when particles rendering is done
  116877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116878. */
  116879. onAfterParticlesRenderingObservable: Observable<Scene>;
  116880. /**
  116881. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116882. */
  116883. onDataLoadedObservable: Observable<Scene>;
  116884. /**
  116885. * An event triggered when a camera is created
  116886. */
  116887. onNewCameraAddedObservable: Observable<Camera>;
  116888. /**
  116889. * An event triggered when a camera is removed
  116890. */
  116891. onCameraRemovedObservable: Observable<Camera>;
  116892. /**
  116893. * An event triggered when a light is created
  116894. */
  116895. onNewLightAddedObservable: Observable<Light>;
  116896. /**
  116897. * An event triggered when a light is removed
  116898. */
  116899. onLightRemovedObservable: Observable<Light>;
  116900. /**
  116901. * An event triggered when a geometry is created
  116902. */
  116903. onNewGeometryAddedObservable: Observable<Geometry>;
  116904. /**
  116905. * An event triggered when a geometry is removed
  116906. */
  116907. onGeometryRemovedObservable: Observable<Geometry>;
  116908. /**
  116909. * An event triggered when a transform node is created
  116910. */
  116911. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116912. /**
  116913. * An event triggered when a transform node is removed
  116914. */
  116915. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116916. /**
  116917. * An event triggered when a mesh is created
  116918. */
  116919. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116920. /**
  116921. * An event triggered when a mesh is removed
  116922. */
  116923. onMeshRemovedObservable: Observable<AbstractMesh>;
  116924. /**
  116925. * An event triggered when a skeleton is created
  116926. */
  116927. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116928. /**
  116929. * An event triggered when a skeleton is removed
  116930. */
  116931. onSkeletonRemovedObservable: Observable<Skeleton>;
  116932. /**
  116933. * An event triggered when a material is created
  116934. */
  116935. onNewMaterialAddedObservable: Observable<Material>;
  116936. /**
  116937. * An event triggered when a material is removed
  116938. */
  116939. onMaterialRemovedObservable: Observable<Material>;
  116940. /**
  116941. * An event triggered when a texture is created
  116942. */
  116943. onNewTextureAddedObservable: Observable<BaseTexture>;
  116944. /**
  116945. * An event triggered when a texture is removed
  116946. */
  116947. onTextureRemovedObservable: Observable<BaseTexture>;
  116948. /**
  116949. * An event triggered when render targets are about to be rendered
  116950. * Can happen multiple times per frame.
  116951. */
  116952. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116953. /**
  116954. * An event triggered when render targets were rendered.
  116955. * Can happen multiple times per frame.
  116956. */
  116957. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116958. /**
  116959. * An event triggered before calculating deterministic simulation step
  116960. */
  116961. onBeforeStepObservable: Observable<Scene>;
  116962. /**
  116963. * An event triggered after calculating deterministic simulation step
  116964. */
  116965. onAfterStepObservable: Observable<Scene>;
  116966. /**
  116967. * An event triggered when the activeCamera property is updated
  116968. */
  116969. onActiveCameraChanged: Observable<Scene>;
  116970. /**
  116971. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116972. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116973. * 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)
  116974. */
  116975. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116976. /**
  116977. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116979. * 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)
  116980. */
  116981. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116982. /**
  116983. * This Observable will when a mesh has been imported into the scene.
  116984. */
  116985. onMeshImportedObservable: Observable<AbstractMesh>;
  116986. /**
  116987. * This Observable will when an animation file has been imported into the scene.
  116988. */
  116989. onAnimationFileImportedObservable: Observable<Scene>;
  116990. /**
  116991. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116992. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116993. */
  116994. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116995. /** @hidden */
  116996. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116997. /**
  116998. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116999. */
  117000. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  117001. /**
  117002. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  117003. */
  117004. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117005. /**
  117006. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117007. */
  117008. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117009. /** Callback called when a pointer move is detected */
  117010. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117011. /** Callback called when a pointer down is detected */
  117012. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117013. /** Callback called when a pointer up is detected */
  117014. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117015. /** Callback called when a pointer pick is detected */
  117016. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117017. /**
  117018. * 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).
  117019. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117020. */
  117021. onPrePointerObservable: Observable<PointerInfoPre>;
  117022. /**
  117023. * Observable event triggered each time an input event is received from the rendering canvas
  117024. */
  117025. onPointerObservable: Observable<PointerInfo>;
  117026. /**
  117027. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117028. */
  117029. get unTranslatedPointer(): Vector2;
  117030. /**
  117031. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117032. */
  117033. static get DragMovementThreshold(): number;
  117034. static set DragMovementThreshold(value: number);
  117035. /**
  117036. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117037. */
  117038. static get LongPressDelay(): number;
  117039. static set LongPressDelay(value: number);
  117040. /**
  117041. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117042. */
  117043. static get DoubleClickDelay(): number;
  117044. static set DoubleClickDelay(value: number);
  117045. /** If you need to check double click without raising a single click at first click, enable this flag */
  117046. static get ExclusiveDoubleClickMode(): boolean;
  117047. static set ExclusiveDoubleClickMode(value: boolean);
  117048. /** @hidden */
  117049. _mirroredCameraPosition: Nullable<Vector3>;
  117050. /**
  117051. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117052. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117053. */
  117054. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117055. /**
  117056. * Observable event triggered each time an keyboard event is received from the hosting window
  117057. */
  117058. onKeyboardObservable: Observable<KeyboardInfo>;
  117059. private _useRightHandedSystem;
  117060. /**
  117061. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117062. */
  117063. set useRightHandedSystem(value: boolean);
  117064. get useRightHandedSystem(): boolean;
  117065. private _timeAccumulator;
  117066. private _currentStepId;
  117067. private _currentInternalStep;
  117068. /**
  117069. * Sets the step Id used by deterministic lock step
  117070. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117071. * @param newStepId defines the step Id
  117072. */
  117073. setStepId(newStepId: number): void;
  117074. /**
  117075. * Gets the step Id used by deterministic lock step
  117076. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117077. * @returns the step Id
  117078. */
  117079. getStepId(): number;
  117080. /**
  117081. * Gets the internal step used by deterministic lock step
  117082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117083. * @returns the internal step
  117084. */
  117085. getInternalStep(): number;
  117086. private _fogEnabled;
  117087. /**
  117088. * Gets or sets a boolean indicating if fog is enabled on this scene
  117089. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117090. * (Default is true)
  117091. */
  117092. set fogEnabled(value: boolean);
  117093. get fogEnabled(): boolean;
  117094. private _fogMode;
  117095. /**
  117096. * Gets or sets the fog mode to use
  117097. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117098. * | mode | value |
  117099. * | --- | --- |
  117100. * | FOGMODE_NONE | 0 |
  117101. * | FOGMODE_EXP | 1 |
  117102. * | FOGMODE_EXP2 | 2 |
  117103. * | FOGMODE_LINEAR | 3 |
  117104. */
  117105. set fogMode(value: number);
  117106. get fogMode(): number;
  117107. /**
  117108. * Gets or sets the fog color to use
  117109. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117110. * (Default is Color3(0.2, 0.2, 0.3))
  117111. */
  117112. fogColor: Color3;
  117113. /**
  117114. * Gets or sets the fog density to use
  117115. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117116. * (Default is 0.1)
  117117. */
  117118. fogDensity: number;
  117119. /**
  117120. * Gets or sets the fog start distance to use
  117121. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117122. * (Default is 0)
  117123. */
  117124. fogStart: number;
  117125. /**
  117126. * Gets or sets the fog end distance to use
  117127. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117128. * (Default is 1000)
  117129. */
  117130. fogEnd: number;
  117131. /**
  117132. * Flag indicating that the frame buffer binding is handled by another component
  117133. */
  117134. prePass: boolean;
  117135. private _shadowsEnabled;
  117136. /**
  117137. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117138. */
  117139. set shadowsEnabled(value: boolean);
  117140. get shadowsEnabled(): boolean;
  117141. private _lightsEnabled;
  117142. /**
  117143. * Gets or sets a boolean indicating if lights are enabled on this scene
  117144. */
  117145. set lightsEnabled(value: boolean);
  117146. get lightsEnabled(): boolean;
  117147. /** All of the active cameras added to this scene. */
  117148. activeCameras: Camera[];
  117149. /** @hidden */
  117150. _activeCamera: Nullable<Camera>;
  117151. /** Gets or sets the current active camera */
  117152. get activeCamera(): Nullable<Camera>;
  117153. set activeCamera(value: Nullable<Camera>);
  117154. private _defaultMaterial;
  117155. /** The default material used on meshes when no material is affected */
  117156. get defaultMaterial(): Material;
  117157. /** The default material used on meshes when no material is affected */
  117158. set defaultMaterial(value: Material);
  117159. private _texturesEnabled;
  117160. /**
  117161. * Gets or sets a boolean indicating if textures are enabled on this scene
  117162. */
  117163. set texturesEnabled(value: boolean);
  117164. get texturesEnabled(): boolean;
  117165. /**
  117166. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117167. */
  117168. physicsEnabled: boolean;
  117169. /**
  117170. * Gets or sets a boolean indicating if particles are enabled on this scene
  117171. */
  117172. particlesEnabled: boolean;
  117173. /**
  117174. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117175. */
  117176. spritesEnabled: boolean;
  117177. private _skeletonsEnabled;
  117178. /**
  117179. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117180. */
  117181. set skeletonsEnabled(value: boolean);
  117182. get skeletonsEnabled(): boolean;
  117183. /**
  117184. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117185. */
  117186. lensFlaresEnabled: boolean;
  117187. /**
  117188. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117189. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117190. */
  117191. collisionsEnabled: boolean;
  117192. private _collisionCoordinator;
  117193. /** @hidden */
  117194. get collisionCoordinator(): ICollisionCoordinator;
  117195. /**
  117196. * Defines the gravity applied to this scene (used only for collisions)
  117197. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117198. */
  117199. gravity: Vector3;
  117200. /**
  117201. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117202. */
  117203. postProcessesEnabled: boolean;
  117204. /**
  117205. * The list of postprocesses added to the scene
  117206. */
  117207. postProcesses: PostProcess[];
  117208. /**
  117209. * Gets the current postprocess manager
  117210. */
  117211. postProcessManager: PostProcessManager;
  117212. /**
  117213. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117214. */
  117215. renderTargetsEnabled: boolean;
  117216. /**
  117217. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117218. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117219. */
  117220. dumpNextRenderTargets: boolean;
  117221. /**
  117222. * The list of user defined render targets added to the scene
  117223. */
  117224. customRenderTargets: RenderTargetTexture[];
  117225. /**
  117226. * Defines if texture loading must be delayed
  117227. * If true, textures will only be loaded when they need to be rendered
  117228. */
  117229. useDelayedTextureLoading: boolean;
  117230. /**
  117231. * Gets the list of meshes imported to the scene through SceneLoader
  117232. */
  117233. importedMeshesFiles: String[];
  117234. /**
  117235. * Gets or sets a boolean indicating if probes are enabled on this scene
  117236. */
  117237. probesEnabled: boolean;
  117238. /**
  117239. * Gets or sets the current offline provider to use to store scene data
  117240. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117241. */
  117242. offlineProvider: IOfflineProvider;
  117243. /**
  117244. * Gets or sets the action manager associated with the scene
  117245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117246. */
  117247. actionManager: AbstractActionManager;
  117248. private _meshesForIntersections;
  117249. /**
  117250. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117251. */
  117252. proceduralTexturesEnabled: boolean;
  117253. private _engine;
  117254. private _totalVertices;
  117255. /** @hidden */
  117256. _activeIndices: PerfCounter;
  117257. /** @hidden */
  117258. _activeParticles: PerfCounter;
  117259. /** @hidden */
  117260. _activeBones: PerfCounter;
  117261. private _animationRatio;
  117262. /** @hidden */
  117263. _animationTimeLast: number;
  117264. /** @hidden */
  117265. _animationTime: number;
  117266. /**
  117267. * Gets or sets a general scale for animation speed
  117268. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117269. */
  117270. animationTimeScale: number;
  117271. /** @hidden */
  117272. _cachedMaterial: Nullable<Material>;
  117273. /** @hidden */
  117274. _cachedEffect: Nullable<Effect>;
  117275. /** @hidden */
  117276. _cachedVisibility: Nullable<number>;
  117277. private _renderId;
  117278. private _frameId;
  117279. private _executeWhenReadyTimeoutId;
  117280. private _intermediateRendering;
  117281. private _viewUpdateFlag;
  117282. private _projectionUpdateFlag;
  117283. /** @hidden */
  117284. _toBeDisposed: Nullable<IDisposable>[];
  117285. private _activeRequests;
  117286. /** @hidden */
  117287. _pendingData: any[];
  117288. private _isDisposed;
  117289. /**
  117290. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117291. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117292. */
  117293. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117294. private _activeMeshes;
  117295. private _processedMaterials;
  117296. private _renderTargets;
  117297. /** @hidden */
  117298. _activeParticleSystems: SmartArray<IParticleSystem>;
  117299. private _activeSkeletons;
  117300. private _softwareSkinnedMeshes;
  117301. private _renderingManager;
  117302. /** @hidden */
  117303. _activeAnimatables: Animatable[];
  117304. private _transformMatrix;
  117305. private _sceneUbo;
  117306. /** @hidden */
  117307. _viewMatrix: Matrix;
  117308. private _projectionMatrix;
  117309. /** @hidden */
  117310. _forcedViewPosition: Nullable<Vector3>;
  117311. /** @hidden */
  117312. _frustumPlanes: Plane[];
  117313. /**
  117314. * Gets the list of frustum planes (built from the active camera)
  117315. */
  117316. get frustumPlanes(): Plane[];
  117317. /**
  117318. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117319. * This is useful if there are more lights that the maximum simulteanous authorized
  117320. */
  117321. requireLightSorting: boolean;
  117322. /** @hidden */
  117323. readonly useMaterialMeshMap: boolean;
  117324. /** @hidden */
  117325. readonly useClonedMeshMap: boolean;
  117326. private _externalData;
  117327. private _uid;
  117328. /**
  117329. * @hidden
  117330. * Backing store of defined scene components.
  117331. */
  117332. _components: ISceneComponent[];
  117333. /**
  117334. * @hidden
  117335. * Backing store of defined scene components.
  117336. */
  117337. _serializableComponents: ISceneSerializableComponent[];
  117338. /**
  117339. * List of components to register on the next registration step.
  117340. */
  117341. private _transientComponents;
  117342. /**
  117343. * Registers the transient components if needed.
  117344. */
  117345. private _registerTransientComponents;
  117346. /**
  117347. * @hidden
  117348. * Add a component to the scene.
  117349. * Note that the ccomponent could be registered on th next frame if this is called after
  117350. * the register component stage.
  117351. * @param component Defines the component to add to the scene
  117352. */
  117353. _addComponent(component: ISceneComponent): void;
  117354. /**
  117355. * @hidden
  117356. * Gets a component from the scene.
  117357. * @param name defines the name of the component to retrieve
  117358. * @returns the component or null if not present
  117359. */
  117360. _getComponent(name: string): Nullable<ISceneComponent>;
  117361. /**
  117362. * @hidden
  117363. * Defines the actions happening before camera updates.
  117364. */
  117365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117366. /**
  117367. * @hidden
  117368. * Defines the actions happening before clear the canvas.
  117369. */
  117370. _beforeClearStage: Stage<SimpleStageAction>;
  117371. /**
  117372. * @hidden
  117373. * Defines the actions when collecting render targets for the frame.
  117374. */
  117375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117376. /**
  117377. * @hidden
  117378. * Defines the actions happening for one camera in the frame.
  117379. */
  117380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117381. /**
  117382. * @hidden
  117383. * Defines the actions happening during the per mesh ready checks.
  117384. */
  117385. _isReadyForMeshStage: Stage<MeshStageAction>;
  117386. /**
  117387. * @hidden
  117388. * Defines the actions happening before evaluate active mesh checks.
  117389. */
  117390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117391. /**
  117392. * @hidden
  117393. * Defines the actions happening during the evaluate sub mesh checks.
  117394. */
  117395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117396. /**
  117397. * @hidden
  117398. * Defines the actions happening during the active mesh stage.
  117399. */
  117400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117401. /**
  117402. * @hidden
  117403. * Defines the actions happening during the per camera render target step.
  117404. */
  117405. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117406. /**
  117407. * @hidden
  117408. * Defines the actions happening just before the active camera is drawing.
  117409. */
  117410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117411. /**
  117412. * @hidden
  117413. * Defines the actions happening just before a render target is drawing.
  117414. */
  117415. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117416. /**
  117417. * @hidden
  117418. * Defines the actions happening just before a rendering group is drawing.
  117419. */
  117420. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117421. /**
  117422. * @hidden
  117423. * Defines the actions happening just before a mesh is drawing.
  117424. */
  117425. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117426. /**
  117427. * @hidden
  117428. * Defines the actions happening just after a mesh has been drawn.
  117429. */
  117430. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117431. /**
  117432. * @hidden
  117433. * Defines the actions happening just after a rendering group has been drawn.
  117434. */
  117435. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117436. /**
  117437. * @hidden
  117438. * Defines the actions happening just after the active camera has been drawn.
  117439. */
  117440. _afterCameraDrawStage: Stage<CameraStageAction>;
  117441. /**
  117442. * @hidden
  117443. * Defines the actions happening just after a render target has been drawn.
  117444. */
  117445. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117446. /**
  117447. * @hidden
  117448. * Defines the actions happening just after rendering all cameras and computing intersections.
  117449. */
  117450. _afterRenderStage: Stage<SimpleStageAction>;
  117451. /**
  117452. * @hidden
  117453. * Defines the actions happening when a pointer move event happens.
  117454. */
  117455. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117456. /**
  117457. * @hidden
  117458. * Defines the actions happening when a pointer down event happens.
  117459. */
  117460. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117461. /**
  117462. * @hidden
  117463. * Defines the actions happening when a pointer up event happens.
  117464. */
  117465. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117466. /**
  117467. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117468. */
  117469. private geometriesByUniqueId;
  117470. /**
  117471. * Creates a new Scene
  117472. * @param engine defines the engine to use to render this scene
  117473. * @param options defines the scene options
  117474. */
  117475. constructor(engine: Engine, options?: SceneOptions);
  117476. /**
  117477. * Gets a string idenfifying the name of the class
  117478. * @returns "Scene" string
  117479. */
  117480. getClassName(): string;
  117481. private _defaultMeshCandidates;
  117482. /**
  117483. * @hidden
  117484. */
  117485. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117486. private _defaultSubMeshCandidates;
  117487. /**
  117488. * @hidden
  117489. */
  117490. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117491. /**
  117492. * Sets the default candidate providers for the scene.
  117493. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117494. * and getCollidingSubMeshCandidates to their default function
  117495. */
  117496. setDefaultCandidateProviders(): void;
  117497. /**
  117498. * Gets the mesh that is currently under the pointer
  117499. */
  117500. get meshUnderPointer(): Nullable<AbstractMesh>;
  117501. /**
  117502. * Gets or sets the current on-screen X position of the pointer
  117503. */
  117504. get pointerX(): number;
  117505. set pointerX(value: number);
  117506. /**
  117507. * Gets or sets the current on-screen Y position of the pointer
  117508. */
  117509. get pointerY(): number;
  117510. set pointerY(value: number);
  117511. /**
  117512. * Gets the cached material (ie. the latest rendered one)
  117513. * @returns the cached material
  117514. */
  117515. getCachedMaterial(): Nullable<Material>;
  117516. /**
  117517. * Gets the cached effect (ie. the latest rendered one)
  117518. * @returns the cached effect
  117519. */
  117520. getCachedEffect(): Nullable<Effect>;
  117521. /**
  117522. * Gets the cached visibility state (ie. the latest rendered one)
  117523. * @returns the cached visibility state
  117524. */
  117525. getCachedVisibility(): Nullable<number>;
  117526. /**
  117527. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117528. * @param material defines the current material
  117529. * @param effect defines the current effect
  117530. * @param visibility defines the current visibility state
  117531. * @returns true if one parameter is not cached
  117532. */
  117533. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117534. /**
  117535. * Gets the engine associated with the scene
  117536. * @returns an Engine
  117537. */
  117538. getEngine(): Engine;
  117539. /**
  117540. * Gets the total number of vertices rendered per frame
  117541. * @returns the total number of vertices rendered per frame
  117542. */
  117543. getTotalVertices(): number;
  117544. /**
  117545. * Gets the performance counter for total vertices
  117546. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117547. */
  117548. get totalVerticesPerfCounter(): PerfCounter;
  117549. /**
  117550. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117551. * @returns the total number of active indices rendered per frame
  117552. */
  117553. getActiveIndices(): number;
  117554. /**
  117555. * Gets the performance counter for active indices
  117556. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117557. */
  117558. get totalActiveIndicesPerfCounter(): PerfCounter;
  117559. /**
  117560. * Gets the total number of active particles rendered per frame
  117561. * @returns the total number of active particles rendered per frame
  117562. */
  117563. getActiveParticles(): number;
  117564. /**
  117565. * Gets the performance counter for active particles
  117566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117567. */
  117568. get activeParticlesPerfCounter(): PerfCounter;
  117569. /**
  117570. * Gets the total number of active bones rendered per frame
  117571. * @returns the total number of active bones rendered per frame
  117572. */
  117573. getActiveBones(): number;
  117574. /**
  117575. * Gets the performance counter for active bones
  117576. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117577. */
  117578. get activeBonesPerfCounter(): PerfCounter;
  117579. /**
  117580. * Gets the array of active meshes
  117581. * @returns an array of AbstractMesh
  117582. */
  117583. getActiveMeshes(): SmartArray<AbstractMesh>;
  117584. /**
  117585. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117586. * @returns a number
  117587. */
  117588. getAnimationRatio(): number;
  117589. /**
  117590. * Gets an unique Id for the current render phase
  117591. * @returns a number
  117592. */
  117593. getRenderId(): number;
  117594. /**
  117595. * Gets an unique Id for the current frame
  117596. * @returns a number
  117597. */
  117598. getFrameId(): number;
  117599. /** Call this function if you want to manually increment the render Id*/
  117600. incrementRenderId(): void;
  117601. private _createUbo;
  117602. /**
  117603. * Use this method to simulate a pointer move on a mesh
  117604. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117605. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117606. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117607. * @returns the current scene
  117608. */
  117609. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117610. /**
  117611. * Use this method to simulate a pointer down on a mesh
  117612. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117613. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117614. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117615. * @returns the current scene
  117616. */
  117617. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117618. /**
  117619. * Use this method to simulate a pointer up on a mesh
  117620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117623. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117624. * @returns the current scene
  117625. */
  117626. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117627. /**
  117628. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117629. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117630. * @returns true if the pointer was captured
  117631. */
  117632. isPointerCaptured(pointerId?: number): boolean;
  117633. /**
  117634. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117635. * @param attachUp defines if you want to attach events to pointerup
  117636. * @param attachDown defines if you want to attach events to pointerdown
  117637. * @param attachMove defines if you want to attach events to pointermove
  117638. */
  117639. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117640. /** Detaches all event handlers*/
  117641. detachControl(): void;
  117642. /**
  117643. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117644. * Delay loaded resources are not taking in account
  117645. * @return true if all required resources are ready
  117646. */
  117647. isReady(): boolean;
  117648. /** Resets all cached information relative to material (including effect and visibility) */
  117649. resetCachedMaterial(): void;
  117650. /**
  117651. * Registers a function to be called before every frame render
  117652. * @param func defines the function to register
  117653. */
  117654. registerBeforeRender(func: () => void): void;
  117655. /**
  117656. * Unregisters a function called before every frame render
  117657. * @param func defines the function to unregister
  117658. */
  117659. unregisterBeforeRender(func: () => void): void;
  117660. /**
  117661. * Registers a function to be called after every frame render
  117662. * @param func defines the function to register
  117663. */
  117664. registerAfterRender(func: () => void): void;
  117665. /**
  117666. * Unregisters a function called after every frame render
  117667. * @param func defines the function to unregister
  117668. */
  117669. unregisterAfterRender(func: () => void): void;
  117670. private _executeOnceBeforeRender;
  117671. /**
  117672. * The provided function will run before render once and will be disposed afterwards.
  117673. * A timeout delay can be provided so that the function will be executed in N ms.
  117674. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117675. * @param func The function to be executed.
  117676. * @param timeout optional delay in ms
  117677. */
  117678. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117679. /** @hidden */
  117680. _addPendingData(data: any): void;
  117681. /** @hidden */
  117682. _removePendingData(data: any): void;
  117683. /**
  117684. * Returns the number of items waiting to be loaded
  117685. * @returns the number of items waiting to be loaded
  117686. */
  117687. getWaitingItemsCount(): number;
  117688. /**
  117689. * Returns a boolean indicating if the scene is still loading data
  117690. */
  117691. get isLoading(): boolean;
  117692. /**
  117693. * Registers a function to be executed when the scene is ready
  117694. * @param {Function} func - the function to be executed
  117695. */
  117696. executeWhenReady(func: () => void): void;
  117697. /**
  117698. * Returns a promise that resolves when the scene is ready
  117699. * @returns A promise that resolves when the scene is ready
  117700. */
  117701. whenReadyAsync(): Promise<void>;
  117702. /** @hidden */
  117703. _checkIsReady(): void;
  117704. /**
  117705. * Gets all animatable attached to the scene
  117706. */
  117707. get animatables(): Animatable[];
  117708. /**
  117709. * Resets the last animation time frame.
  117710. * Useful to override when animations start running when loading a scene for the first time.
  117711. */
  117712. resetLastAnimationTimeFrame(): void;
  117713. /**
  117714. * Gets the current view matrix
  117715. * @returns a Matrix
  117716. */
  117717. getViewMatrix(): Matrix;
  117718. /**
  117719. * Gets the current projection matrix
  117720. * @returns a Matrix
  117721. */
  117722. getProjectionMatrix(): Matrix;
  117723. /**
  117724. * Gets the current transform matrix
  117725. * @returns a Matrix made of View * Projection
  117726. */
  117727. getTransformMatrix(): Matrix;
  117728. /**
  117729. * Sets the current transform matrix
  117730. * @param viewL defines the View matrix to use
  117731. * @param projectionL defines the Projection matrix to use
  117732. * @param viewR defines the right View matrix to use (if provided)
  117733. * @param projectionR defines the right Projection matrix to use (if provided)
  117734. */
  117735. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117736. /**
  117737. * Gets the uniform buffer used to store scene data
  117738. * @returns a UniformBuffer
  117739. */
  117740. getSceneUniformBuffer(): UniformBuffer;
  117741. /**
  117742. * Gets an unique (relatively to the current scene) Id
  117743. * @returns an unique number for the scene
  117744. */
  117745. getUniqueId(): number;
  117746. /**
  117747. * Add a mesh to the list of scene's meshes
  117748. * @param newMesh defines the mesh to add
  117749. * @param recursive if all child meshes should also be added to the scene
  117750. */
  117751. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117752. /**
  117753. * Remove a mesh for the list of scene's meshes
  117754. * @param toRemove defines the mesh to remove
  117755. * @param recursive if all child meshes should also be removed from the scene
  117756. * @returns the index where the mesh was in the mesh list
  117757. */
  117758. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117759. /**
  117760. * Add a transform node to the list of scene's transform nodes
  117761. * @param newTransformNode defines the transform node to add
  117762. */
  117763. addTransformNode(newTransformNode: TransformNode): void;
  117764. /**
  117765. * Remove a transform node for the list of scene's transform nodes
  117766. * @param toRemove defines the transform node to remove
  117767. * @returns the index where the transform node was in the transform node list
  117768. */
  117769. removeTransformNode(toRemove: TransformNode): number;
  117770. /**
  117771. * Remove a skeleton for the list of scene's skeletons
  117772. * @param toRemove defines the skeleton to remove
  117773. * @returns the index where the skeleton was in the skeleton list
  117774. */
  117775. removeSkeleton(toRemove: Skeleton): number;
  117776. /**
  117777. * Remove a morph target for the list of scene's morph targets
  117778. * @param toRemove defines the morph target to remove
  117779. * @returns the index where the morph target was in the morph target list
  117780. */
  117781. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117782. /**
  117783. * Remove a light for the list of scene's lights
  117784. * @param toRemove defines the light to remove
  117785. * @returns the index where the light was in the light list
  117786. */
  117787. removeLight(toRemove: Light): number;
  117788. /**
  117789. * Remove a camera for the list of scene's cameras
  117790. * @param toRemove defines the camera to remove
  117791. * @returns the index where the camera was in the camera list
  117792. */
  117793. removeCamera(toRemove: Camera): number;
  117794. /**
  117795. * Remove a particle system for the list of scene's particle systems
  117796. * @param toRemove defines the particle system to remove
  117797. * @returns the index where the particle system was in the particle system list
  117798. */
  117799. removeParticleSystem(toRemove: IParticleSystem): number;
  117800. /**
  117801. * Remove a animation for the list of scene's animations
  117802. * @param toRemove defines the animation to remove
  117803. * @returns the index where the animation was in the animation list
  117804. */
  117805. removeAnimation(toRemove: Animation): number;
  117806. /**
  117807. * Will stop the animation of the given target
  117808. * @param target - the target
  117809. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117810. * @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)
  117811. */
  117812. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117813. /**
  117814. * Removes the given animation group from this scene.
  117815. * @param toRemove The animation group to remove
  117816. * @returns The index of the removed animation group
  117817. */
  117818. removeAnimationGroup(toRemove: AnimationGroup): number;
  117819. /**
  117820. * Removes the given multi-material from this scene.
  117821. * @param toRemove The multi-material to remove
  117822. * @returns The index of the removed multi-material
  117823. */
  117824. removeMultiMaterial(toRemove: MultiMaterial): number;
  117825. /**
  117826. * Removes the given material from this scene.
  117827. * @param toRemove The material to remove
  117828. * @returns The index of the removed material
  117829. */
  117830. removeMaterial(toRemove: Material): number;
  117831. /**
  117832. * Removes the given action manager from this scene.
  117833. * @param toRemove The action manager to remove
  117834. * @returns The index of the removed action manager
  117835. */
  117836. removeActionManager(toRemove: AbstractActionManager): number;
  117837. /**
  117838. * Removes the given texture from this scene.
  117839. * @param toRemove The texture to remove
  117840. * @returns The index of the removed texture
  117841. */
  117842. removeTexture(toRemove: BaseTexture): number;
  117843. /**
  117844. * Adds the given light to this scene
  117845. * @param newLight The light to add
  117846. */
  117847. addLight(newLight: Light): void;
  117848. /**
  117849. * Sorts the list list based on light priorities
  117850. */
  117851. sortLightsByPriority(): void;
  117852. /**
  117853. * Adds the given camera to this scene
  117854. * @param newCamera The camera to add
  117855. */
  117856. addCamera(newCamera: Camera): void;
  117857. /**
  117858. * Adds the given skeleton to this scene
  117859. * @param newSkeleton The skeleton to add
  117860. */
  117861. addSkeleton(newSkeleton: Skeleton): void;
  117862. /**
  117863. * Adds the given particle system to this scene
  117864. * @param newParticleSystem The particle system to add
  117865. */
  117866. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117867. /**
  117868. * Adds the given animation to this scene
  117869. * @param newAnimation The animation to add
  117870. */
  117871. addAnimation(newAnimation: Animation): void;
  117872. /**
  117873. * Adds the given animation group to this scene.
  117874. * @param newAnimationGroup The animation group to add
  117875. */
  117876. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117877. /**
  117878. * Adds the given multi-material to this scene
  117879. * @param newMultiMaterial The multi-material to add
  117880. */
  117881. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117882. /**
  117883. * Adds the given material to this scene
  117884. * @param newMaterial The material to add
  117885. */
  117886. addMaterial(newMaterial: Material): void;
  117887. /**
  117888. * Adds the given morph target to this scene
  117889. * @param newMorphTargetManager The morph target to add
  117890. */
  117891. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117892. /**
  117893. * Adds the given geometry to this scene
  117894. * @param newGeometry The geometry to add
  117895. */
  117896. addGeometry(newGeometry: Geometry): void;
  117897. /**
  117898. * Adds the given action manager to this scene
  117899. * @param newActionManager The action manager to add
  117900. */
  117901. addActionManager(newActionManager: AbstractActionManager): void;
  117902. /**
  117903. * Adds the given texture to this scene.
  117904. * @param newTexture The texture to add
  117905. */
  117906. addTexture(newTexture: BaseTexture): void;
  117907. /**
  117908. * Switch active camera
  117909. * @param newCamera defines the new active camera
  117910. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117911. */
  117912. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117913. /**
  117914. * sets the active camera of the scene using its ID
  117915. * @param id defines the camera's ID
  117916. * @return the new active camera or null if none found.
  117917. */
  117918. setActiveCameraByID(id: string): Nullable<Camera>;
  117919. /**
  117920. * sets the active camera of the scene using its name
  117921. * @param name defines the camera's name
  117922. * @returns the new active camera or null if none found.
  117923. */
  117924. setActiveCameraByName(name: string): Nullable<Camera>;
  117925. /**
  117926. * get an animation group using its name
  117927. * @param name defines the material's name
  117928. * @return the animation group or null if none found.
  117929. */
  117930. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117931. /**
  117932. * Get a material using its unique id
  117933. * @param uniqueId defines the material's unique id
  117934. * @return the material or null if none found.
  117935. */
  117936. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117937. /**
  117938. * get a material using its id
  117939. * @param id defines the material's ID
  117940. * @return the material or null if none found.
  117941. */
  117942. getMaterialByID(id: string): Nullable<Material>;
  117943. /**
  117944. * Gets a the last added material using a given id
  117945. * @param id defines the material's ID
  117946. * @return the last material with the given id or null if none found.
  117947. */
  117948. getLastMaterialByID(id: string): Nullable<Material>;
  117949. /**
  117950. * Gets a material using its name
  117951. * @param name defines the material's name
  117952. * @return the material or null if none found.
  117953. */
  117954. getMaterialByName(name: string): Nullable<Material>;
  117955. /**
  117956. * Get a texture using its unique id
  117957. * @param uniqueId defines the texture's unique id
  117958. * @return the texture or null if none found.
  117959. */
  117960. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117961. /**
  117962. * Gets a camera using its id
  117963. * @param id defines the id to look for
  117964. * @returns the camera or null if not found
  117965. */
  117966. getCameraByID(id: string): Nullable<Camera>;
  117967. /**
  117968. * Gets a camera using its unique id
  117969. * @param uniqueId defines the unique id to look for
  117970. * @returns the camera or null if not found
  117971. */
  117972. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117973. /**
  117974. * Gets a camera using its name
  117975. * @param name defines the camera's name
  117976. * @return the camera or null if none found.
  117977. */
  117978. getCameraByName(name: string): Nullable<Camera>;
  117979. /**
  117980. * Gets a bone using its id
  117981. * @param id defines the bone's id
  117982. * @return the bone or null if not found
  117983. */
  117984. getBoneByID(id: string): Nullable<Bone>;
  117985. /**
  117986. * Gets a bone using its id
  117987. * @param name defines the bone's name
  117988. * @return the bone or null if not found
  117989. */
  117990. getBoneByName(name: string): Nullable<Bone>;
  117991. /**
  117992. * Gets a light node using its name
  117993. * @param name defines the the light's name
  117994. * @return the light or null if none found.
  117995. */
  117996. getLightByName(name: string): Nullable<Light>;
  117997. /**
  117998. * Gets a light node using its id
  117999. * @param id defines the light's id
  118000. * @return the light or null if none found.
  118001. */
  118002. getLightByID(id: string): Nullable<Light>;
  118003. /**
  118004. * Gets a light node using its scene-generated unique ID
  118005. * @param uniqueId defines the light's unique id
  118006. * @return the light or null if none found.
  118007. */
  118008. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118009. /**
  118010. * Gets a particle system by id
  118011. * @param id defines the particle system id
  118012. * @return the corresponding system or null if none found
  118013. */
  118014. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118015. /**
  118016. * Gets a geometry using its ID
  118017. * @param id defines the geometry's id
  118018. * @return the geometry or null if none found.
  118019. */
  118020. getGeometryByID(id: string): Nullable<Geometry>;
  118021. private _getGeometryByUniqueID;
  118022. /**
  118023. * Add a new geometry to this scene
  118024. * @param geometry defines the geometry to be added to the scene.
  118025. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118026. * @return a boolean defining if the geometry was added or not
  118027. */
  118028. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118029. /**
  118030. * Removes an existing geometry
  118031. * @param geometry defines the geometry to be removed from the scene
  118032. * @return a boolean defining if the geometry was removed or not
  118033. */
  118034. removeGeometry(geometry: Geometry): boolean;
  118035. /**
  118036. * Gets the list of geometries attached to the scene
  118037. * @returns an array of Geometry
  118038. */
  118039. getGeometries(): Geometry[];
  118040. /**
  118041. * Gets the first added mesh found of a given ID
  118042. * @param id defines the id to search for
  118043. * @return the mesh found or null if not found at all
  118044. */
  118045. getMeshByID(id: string): Nullable<AbstractMesh>;
  118046. /**
  118047. * Gets a list of meshes using their id
  118048. * @param id defines the id to search for
  118049. * @returns a list of meshes
  118050. */
  118051. getMeshesByID(id: string): Array<AbstractMesh>;
  118052. /**
  118053. * Gets the first added transform node found of a given ID
  118054. * @param id defines the id to search for
  118055. * @return the found transform node or null if not found at all.
  118056. */
  118057. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118058. /**
  118059. * Gets a transform node with its auto-generated unique id
  118060. * @param uniqueId efines the unique id to search for
  118061. * @return the found transform node or null if not found at all.
  118062. */
  118063. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118064. /**
  118065. * Gets a list of transform nodes using their id
  118066. * @param id defines the id to search for
  118067. * @returns a list of transform nodes
  118068. */
  118069. getTransformNodesByID(id: string): Array<TransformNode>;
  118070. /**
  118071. * Gets a mesh with its auto-generated unique id
  118072. * @param uniqueId defines the unique id to search for
  118073. * @return the found mesh or null if not found at all.
  118074. */
  118075. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118076. /**
  118077. * Gets a the last added mesh using a given id
  118078. * @param id defines the id to search for
  118079. * @return the found mesh or null if not found at all.
  118080. */
  118081. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118082. /**
  118083. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118084. * @param id defines the id to search for
  118085. * @return the found node or null if not found at all
  118086. */
  118087. getLastEntryByID(id: string): Nullable<Node>;
  118088. /**
  118089. * Gets a node (Mesh, Camera, Light) using a given id
  118090. * @param id defines the id to search for
  118091. * @return the found node or null if not found at all
  118092. */
  118093. getNodeByID(id: string): Nullable<Node>;
  118094. /**
  118095. * Gets a node (Mesh, Camera, Light) using a given name
  118096. * @param name defines the name to search for
  118097. * @return the found node or null if not found at all.
  118098. */
  118099. getNodeByName(name: string): Nullable<Node>;
  118100. /**
  118101. * Gets a mesh using a given name
  118102. * @param name defines the name to search for
  118103. * @return the found mesh or null if not found at all.
  118104. */
  118105. getMeshByName(name: string): Nullable<AbstractMesh>;
  118106. /**
  118107. * Gets a transform node using a given name
  118108. * @param name defines the name to search for
  118109. * @return the found transform node or null if not found at all.
  118110. */
  118111. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118112. /**
  118113. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118114. * @param id defines the id to search for
  118115. * @return the found skeleton or null if not found at all.
  118116. */
  118117. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118118. /**
  118119. * Gets a skeleton using a given auto generated unique id
  118120. * @param uniqueId defines the unique id to search for
  118121. * @return the found skeleton or null if not found at all.
  118122. */
  118123. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118124. /**
  118125. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118126. * @param id defines the id to search for
  118127. * @return the found skeleton or null if not found at all.
  118128. */
  118129. getSkeletonById(id: string): Nullable<Skeleton>;
  118130. /**
  118131. * Gets a skeleton using a given name
  118132. * @param name defines the name to search for
  118133. * @return the found skeleton or null if not found at all.
  118134. */
  118135. getSkeletonByName(name: string): Nullable<Skeleton>;
  118136. /**
  118137. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118138. * @param id defines the id to search for
  118139. * @return the found morph target manager or null if not found at all.
  118140. */
  118141. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118142. /**
  118143. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118144. * @param id defines the id to search for
  118145. * @return the found morph target or null if not found at all.
  118146. */
  118147. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118148. /**
  118149. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118150. * @param name defines the name to search for
  118151. * @return the found morph target or null if not found at all.
  118152. */
  118153. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118154. /**
  118155. * Gets a boolean indicating if the given mesh is active
  118156. * @param mesh defines the mesh to look for
  118157. * @returns true if the mesh is in the active list
  118158. */
  118159. isActiveMesh(mesh: AbstractMesh): boolean;
  118160. /**
  118161. * Return a unique id as a string which can serve as an identifier for the scene
  118162. */
  118163. get uid(): string;
  118164. /**
  118165. * Add an externaly attached data from its key.
  118166. * This method call will fail and return false, if such key already exists.
  118167. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118168. * @param key the unique key that identifies the data
  118169. * @param data the data object to associate to the key for this Engine instance
  118170. * @return true if no such key were already present and the data was added successfully, false otherwise
  118171. */
  118172. addExternalData<T>(key: string, data: T): boolean;
  118173. /**
  118174. * Get an externaly attached data from its key
  118175. * @param key the unique key that identifies the data
  118176. * @return the associated data, if present (can be null), or undefined if not present
  118177. */
  118178. getExternalData<T>(key: string): Nullable<T>;
  118179. /**
  118180. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118181. * @param key the unique key that identifies the data
  118182. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118183. * @return the associated data, can be null if the factory returned null.
  118184. */
  118185. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118186. /**
  118187. * Remove an externaly attached data from the Engine instance
  118188. * @param key the unique key that identifies the data
  118189. * @return true if the data was successfully removed, false if it doesn't exist
  118190. */
  118191. removeExternalData(key: string): boolean;
  118192. private _evaluateSubMesh;
  118193. /**
  118194. * Clear the processed materials smart array preventing retention point in material dispose.
  118195. */
  118196. freeProcessedMaterials(): void;
  118197. private _preventFreeActiveMeshesAndRenderingGroups;
  118198. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118199. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118200. * when disposing several meshes in a row or a hierarchy of meshes.
  118201. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118202. */
  118203. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118204. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118205. /**
  118206. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118207. */
  118208. freeActiveMeshes(): void;
  118209. /**
  118210. * Clear the info related to rendering groups preventing retention points during dispose.
  118211. */
  118212. freeRenderingGroups(): void;
  118213. /** @hidden */
  118214. _isInIntermediateRendering(): boolean;
  118215. /**
  118216. * Lambda returning the list of potentially active meshes.
  118217. */
  118218. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118219. /**
  118220. * Lambda returning the list of potentially active sub meshes.
  118221. */
  118222. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118223. /**
  118224. * Lambda returning the list of potentially intersecting sub meshes.
  118225. */
  118226. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118227. /**
  118228. * Lambda returning the list of potentially colliding sub meshes.
  118229. */
  118230. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118231. private _activeMeshesFrozen;
  118232. private _skipEvaluateActiveMeshesCompletely;
  118233. /**
  118234. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118235. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118236. * @returns the current scene
  118237. */
  118238. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118239. /**
  118240. * Use this function to restart evaluating active meshes on every frame
  118241. * @returns the current scene
  118242. */
  118243. unfreezeActiveMeshes(): Scene;
  118244. private _evaluateActiveMeshes;
  118245. private _activeMesh;
  118246. /**
  118247. * Update the transform matrix to update from the current active camera
  118248. * @param force defines a boolean used to force the update even if cache is up to date
  118249. */
  118250. updateTransformMatrix(force?: boolean): void;
  118251. private _bindFrameBuffer;
  118252. /** @hidden */
  118253. _allowPostProcessClearColor: boolean;
  118254. /** @hidden */
  118255. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118256. private _processSubCameras;
  118257. private _checkIntersections;
  118258. /** @hidden */
  118259. _advancePhysicsEngineStep(step: number): void;
  118260. /**
  118261. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118262. */
  118263. getDeterministicFrameTime: () => number;
  118264. /** @hidden */
  118265. _animate(): void;
  118266. /** Execute all animations (for a frame) */
  118267. animate(): void;
  118268. /**
  118269. * Render the scene
  118270. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118271. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118272. */
  118273. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118274. /**
  118275. * Freeze all materials
  118276. * A frozen material will not be updatable but should be faster to render
  118277. */
  118278. freezeMaterials(): void;
  118279. /**
  118280. * Unfreeze all materials
  118281. * A frozen material will not be updatable but should be faster to render
  118282. */
  118283. unfreezeMaterials(): void;
  118284. /**
  118285. * Releases all held ressources
  118286. */
  118287. dispose(): void;
  118288. /**
  118289. * Gets if the scene is already disposed
  118290. */
  118291. get isDisposed(): boolean;
  118292. /**
  118293. * Call this function to reduce memory footprint of the scene.
  118294. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118295. */
  118296. clearCachedVertexData(): void;
  118297. /**
  118298. * This function will remove the local cached buffer data from texture.
  118299. * It will save memory but will prevent the texture from being rebuilt
  118300. */
  118301. cleanCachedTextureBuffer(): void;
  118302. /**
  118303. * Get the world extend vectors with an optional filter
  118304. *
  118305. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118306. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118307. */
  118308. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118309. min: Vector3;
  118310. max: Vector3;
  118311. };
  118312. /**
  118313. * Creates a ray that can be used to pick in the scene
  118314. * @param x defines the x coordinate of the origin (on-screen)
  118315. * @param y defines the y coordinate of the origin (on-screen)
  118316. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118317. * @param camera defines the camera to use for the picking
  118318. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118319. * @returns a Ray
  118320. */
  118321. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118322. /**
  118323. * Creates a ray that can be used to pick in the scene
  118324. * @param x defines the x coordinate of the origin (on-screen)
  118325. * @param y defines the y coordinate of the origin (on-screen)
  118326. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118327. * @param result defines the ray where to store the picking ray
  118328. * @param camera defines the camera to use for the picking
  118329. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118330. * @returns the current scene
  118331. */
  118332. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118333. /**
  118334. * Creates a ray that can be used to pick in the scene
  118335. * @param x defines the x coordinate of the origin (on-screen)
  118336. * @param y defines the y coordinate of the origin (on-screen)
  118337. * @param camera defines the camera to use for the picking
  118338. * @returns a Ray
  118339. */
  118340. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118341. /**
  118342. * Creates a ray that can be used to pick in the scene
  118343. * @param x defines the x coordinate of the origin (on-screen)
  118344. * @param y defines the y coordinate of the origin (on-screen)
  118345. * @param result defines the ray where to store the picking ray
  118346. * @param camera defines the camera to use for the picking
  118347. * @returns the current scene
  118348. */
  118349. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118350. /** Launch a ray to try to pick a mesh in the scene
  118351. * @param x position on screen
  118352. * @param y position on screen
  118353. * @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
  118354. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118355. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118356. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118357. * @returns a PickingInfo
  118358. */
  118359. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118360. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118361. * @param x position on screen
  118362. * @param y position on screen
  118363. * @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
  118364. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118365. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118366. * @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)
  118367. */
  118368. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118369. /** Use the given ray to pick a mesh in the scene
  118370. * @param ray The ray to use to pick meshes
  118371. * @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
  118372. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118374. * @returns a PickingInfo
  118375. */
  118376. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118377. /**
  118378. * Launch a ray to try to pick a mesh in the scene
  118379. * @param x X position on screen
  118380. * @param y Y position on screen
  118381. * @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
  118382. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118384. * @returns an array of PickingInfo
  118385. */
  118386. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118387. /**
  118388. * Launch a ray to try to pick a mesh in the scene
  118389. * @param ray Ray to use
  118390. * @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
  118391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118392. * @returns an array of PickingInfo
  118393. */
  118394. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118395. /**
  118396. * Force the value of meshUnderPointer
  118397. * @param mesh defines the mesh to use
  118398. */
  118399. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118400. /**
  118401. * Gets the mesh under the pointer
  118402. * @returns a Mesh or null if no mesh is under the pointer
  118403. */
  118404. getPointerOverMesh(): Nullable<AbstractMesh>;
  118405. /** @hidden */
  118406. _rebuildGeometries(): void;
  118407. /** @hidden */
  118408. _rebuildTextures(): void;
  118409. private _getByTags;
  118410. /**
  118411. * Get a list of meshes by tags
  118412. * @param tagsQuery defines the tags query to use
  118413. * @param forEach defines a predicate used to filter results
  118414. * @returns an array of Mesh
  118415. */
  118416. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118417. /**
  118418. * Get a list of cameras by tags
  118419. * @param tagsQuery defines the tags query to use
  118420. * @param forEach defines a predicate used to filter results
  118421. * @returns an array of Camera
  118422. */
  118423. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118424. /**
  118425. * Get a list of lights by tags
  118426. * @param tagsQuery defines the tags query to use
  118427. * @param forEach defines a predicate used to filter results
  118428. * @returns an array of Light
  118429. */
  118430. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118431. /**
  118432. * Get a list of materials by tags
  118433. * @param tagsQuery defines the tags query to use
  118434. * @param forEach defines a predicate used to filter results
  118435. * @returns an array of Material
  118436. */
  118437. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118438. /**
  118439. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118440. * This allowed control for front to back rendering or reversly depending of the special needs.
  118441. *
  118442. * @param renderingGroupId The rendering group id corresponding to its index
  118443. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118444. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118445. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118446. */
  118447. 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;
  118448. /**
  118449. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118450. *
  118451. * @param renderingGroupId The rendering group id corresponding to its index
  118452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118453. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118454. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118455. */
  118456. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118457. /**
  118458. * Gets the current auto clear configuration for one rendering group of the rendering
  118459. * manager.
  118460. * @param index the rendering group index to get the information for
  118461. * @returns The auto clear setup for the requested rendering group
  118462. */
  118463. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118464. private _blockMaterialDirtyMechanism;
  118465. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118466. get blockMaterialDirtyMechanism(): boolean;
  118467. set blockMaterialDirtyMechanism(value: boolean);
  118468. /**
  118469. * Will flag all materials as dirty to trigger new shader compilation
  118470. * @param flag defines the flag used to specify which material part must be marked as dirty
  118471. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118472. */
  118473. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118474. /** @hidden */
  118475. _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;
  118476. /** @hidden */
  118477. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118478. /** @hidden */
  118479. _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;
  118480. /** @hidden */
  118481. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118482. /** @hidden */
  118483. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118484. /** @hidden */
  118485. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118486. }
  118487. }
  118488. declare module BABYLON {
  118489. /**
  118490. * Set of assets to keep when moving a scene into an asset container.
  118491. */
  118492. export class KeepAssets extends AbstractScene {
  118493. }
  118494. /**
  118495. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118496. */
  118497. export class InstantiatedEntries {
  118498. /**
  118499. * List of new root nodes (eg. nodes with no parent)
  118500. */
  118501. rootNodes: TransformNode[];
  118502. /**
  118503. * List of new skeletons
  118504. */
  118505. skeletons: Skeleton[];
  118506. /**
  118507. * List of new animation groups
  118508. */
  118509. animationGroups: AnimationGroup[];
  118510. }
  118511. /**
  118512. * Container with a set of assets that can be added or removed from a scene.
  118513. */
  118514. export class AssetContainer extends AbstractScene {
  118515. private _wasAddedToScene;
  118516. /**
  118517. * The scene the AssetContainer belongs to.
  118518. */
  118519. scene: Scene;
  118520. /**
  118521. * Instantiates an AssetContainer.
  118522. * @param scene The scene the AssetContainer belongs to.
  118523. */
  118524. constructor(scene: Scene);
  118525. /**
  118526. * Instantiate or clone all meshes and add the new ones to the scene.
  118527. * Skeletons and animation groups will all be cloned
  118528. * @param nameFunction defines an optional function used to get new names for clones
  118529. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118530. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118531. */
  118532. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118533. /**
  118534. * Adds all the assets from the container to the scene.
  118535. */
  118536. addAllToScene(): void;
  118537. /**
  118538. * Removes all the assets in the container from the scene
  118539. */
  118540. removeAllFromScene(): void;
  118541. /**
  118542. * Disposes all the assets in the container
  118543. */
  118544. dispose(): void;
  118545. private _moveAssets;
  118546. /**
  118547. * Removes all the assets contained in the scene and adds them to the container.
  118548. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118549. */
  118550. moveAllFromScene(keepAssets?: KeepAssets): void;
  118551. /**
  118552. * 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.
  118553. * @returns the root mesh
  118554. */
  118555. createRootMesh(): Mesh;
  118556. /**
  118557. * Merge animations (direct and animation groups) from this asset container into a scene
  118558. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118559. * @param animatables set of animatables to retarget to a node from the scene
  118560. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118561. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118562. */
  118563. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118564. }
  118565. }
  118566. declare module BABYLON {
  118567. /**
  118568. * Defines how the parser contract is defined.
  118569. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118570. */
  118571. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118572. /**
  118573. * Defines how the individual parser contract is defined.
  118574. * These parser can parse an individual asset
  118575. */
  118576. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118577. /**
  118578. * Base class of the scene acting as a container for the different elements composing a scene.
  118579. * This class is dynamically extended by the different components of the scene increasing
  118580. * flexibility and reducing coupling
  118581. */
  118582. export abstract class AbstractScene {
  118583. /**
  118584. * Stores the list of available parsers in the application.
  118585. */
  118586. private static _BabylonFileParsers;
  118587. /**
  118588. * Stores the list of available individual parsers in the application.
  118589. */
  118590. private static _IndividualBabylonFileParsers;
  118591. /**
  118592. * Adds a parser in the list of available ones
  118593. * @param name Defines the name of the parser
  118594. * @param parser Defines the parser to add
  118595. */
  118596. static AddParser(name: string, parser: BabylonFileParser): void;
  118597. /**
  118598. * Gets a general parser from the list of avaialble ones
  118599. * @param name Defines the name of the parser
  118600. * @returns the requested parser or null
  118601. */
  118602. static GetParser(name: string): Nullable<BabylonFileParser>;
  118603. /**
  118604. * Adds n individual parser in the list of available ones
  118605. * @param name Defines the name of the parser
  118606. * @param parser Defines the parser to add
  118607. */
  118608. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118609. /**
  118610. * Gets an individual parser from the list of avaialble ones
  118611. * @param name Defines the name of the parser
  118612. * @returns the requested parser or null
  118613. */
  118614. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118615. /**
  118616. * Parser json data and populate both a scene and its associated container object
  118617. * @param jsonData Defines the data to parse
  118618. * @param scene Defines the scene to parse the data for
  118619. * @param container Defines the container attached to the parsing sequence
  118620. * @param rootUrl Defines the root url of the data
  118621. */
  118622. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118623. /**
  118624. * Gets the list of root nodes (ie. nodes with no parent)
  118625. */
  118626. rootNodes: Node[];
  118627. /** All of the cameras added to this scene
  118628. * @see https://doc.babylonjs.com/babylon101/cameras
  118629. */
  118630. cameras: Camera[];
  118631. /**
  118632. * All of the lights added to this scene
  118633. * @see https://doc.babylonjs.com/babylon101/lights
  118634. */
  118635. lights: Light[];
  118636. /**
  118637. * All of the (abstract) meshes added to this scene
  118638. */
  118639. meshes: AbstractMesh[];
  118640. /**
  118641. * The list of skeletons added to the scene
  118642. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118643. */
  118644. skeletons: Skeleton[];
  118645. /**
  118646. * All of the particle systems added to this scene
  118647. * @see https://doc.babylonjs.com/babylon101/particles
  118648. */
  118649. particleSystems: IParticleSystem[];
  118650. /**
  118651. * Gets a list of Animations associated with the scene
  118652. */
  118653. animations: Animation[];
  118654. /**
  118655. * All of the animation groups added to this scene
  118656. * @see https://doc.babylonjs.com/how_to/group
  118657. */
  118658. animationGroups: AnimationGroup[];
  118659. /**
  118660. * All of the multi-materials added to this scene
  118661. * @see https://doc.babylonjs.com/how_to/multi_materials
  118662. */
  118663. multiMaterials: MultiMaterial[];
  118664. /**
  118665. * All of the materials added to this scene
  118666. * In the context of a Scene, it is not supposed to be modified manually.
  118667. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118668. * Note also that the order of the Material within the array is not significant and might change.
  118669. * @see https://doc.babylonjs.com/babylon101/materials
  118670. */
  118671. materials: Material[];
  118672. /**
  118673. * The list of morph target managers added to the scene
  118674. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118675. */
  118676. morphTargetManagers: MorphTargetManager[];
  118677. /**
  118678. * The list of geometries used in the scene.
  118679. */
  118680. geometries: Geometry[];
  118681. /**
  118682. * All of the tranform nodes added to this scene
  118683. * In the context of a Scene, it is not supposed to be modified manually.
  118684. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118685. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118686. * @see https://doc.babylonjs.com/how_to/transformnode
  118687. */
  118688. transformNodes: TransformNode[];
  118689. /**
  118690. * ActionManagers available on the scene.
  118691. */
  118692. actionManagers: AbstractActionManager[];
  118693. /**
  118694. * Textures to keep.
  118695. */
  118696. textures: BaseTexture[];
  118697. /**
  118698. * Environment texture for the scene
  118699. */
  118700. environmentTexture: Nullable<BaseTexture>;
  118701. /**
  118702. * @returns all meshes, lights, cameras, transformNodes and bones
  118703. */
  118704. getNodes(): Array<Node>;
  118705. }
  118706. }
  118707. declare module BABYLON {
  118708. /**
  118709. * Interface used to define options for Sound class
  118710. */
  118711. export interface ISoundOptions {
  118712. /**
  118713. * Does the sound autoplay once loaded.
  118714. */
  118715. autoplay?: boolean;
  118716. /**
  118717. * Does the sound loop after it finishes playing once.
  118718. */
  118719. loop?: boolean;
  118720. /**
  118721. * Sound's volume
  118722. */
  118723. volume?: number;
  118724. /**
  118725. * Is it a spatial sound?
  118726. */
  118727. spatialSound?: boolean;
  118728. /**
  118729. * Maximum distance to hear that sound
  118730. */
  118731. maxDistance?: number;
  118732. /**
  118733. * Uses user defined attenuation function
  118734. */
  118735. useCustomAttenuation?: boolean;
  118736. /**
  118737. * Define the roll off factor of spatial sounds.
  118738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118739. */
  118740. rolloffFactor?: number;
  118741. /**
  118742. * Define the reference distance the sound should be heard perfectly.
  118743. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118744. */
  118745. refDistance?: number;
  118746. /**
  118747. * Define the distance attenuation model the sound will follow.
  118748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118749. */
  118750. distanceModel?: string;
  118751. /**
  118752. * Defines the playback speed (1 by default)
  118753. */
  118754. playbackRate?: number;
  118755. /**
  118756. * Defines if the sound is from a streaming source
  118757. */
  118758. streaming?: boolean;
  118759. /**
  118760. * Defines an optional length (in seconds) inside the sound file
  118761. */
  118762. length?: number;
  118763. /**
  118764. * Defines an optional offset (in seconds) inside the sound file
  118765. */
  118766. offset?: number;
  118767. /**
  118768. * If true, URLs will not be required to state the audio file codec to use.
  118769. */
  118770. skipCodecCheck?: boolean;
  118771. }
  118772. /**
  118773. * Defines a sound that can be played in the application.
  118774. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118776. */
  118777. export class Sound {
  118778. /**
  118779. * The name of the sound in the scene.
  118780. */
  118781. name: string;
  118782. /**
  118783. * Does the sound autoplay once loaded.
  118784. */
  118785. autoplay: boolean;
  118786. /**
  118787. * Does the sound loop after it finishes playing once.
  118788. */
  118789. loop: boolean;
  118790. /**
  118791. * Does the sound use a custom attenuation curve to simulate the falloff
  118792. * happening when the source gets further away from the camera.
  118793. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118794. */
  118795. useCustomAttenuation: boolean;
  118796. /**
  118797. * The sound track id this sound belongs to.
  118798. */
  118799. soundTrackId: number;
  118800. /**
  118801. * Is this sound currently played.
  118802. */
  118803. isPlaying: boolean;
  118804. /**
  118805. * Is this sound currently paused.
  118806. */
  118807. isPaused: boolean;
  118808. /**
  118809. * Does this sound enables spatial sound.
  118810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118811. */
  118812. spatialSound: boolean;
  118813. /**
  118814. * Define the reference distance the sound should be heard perfectly.
  118815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118816. */
  118817. refDistance: number;
  118818. /**
  118819. * Define the roll off factor of spatial sounds.
  118820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118821. */
  118822. rolloffFactor: number;
  118823. /**
  118824. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118826. */
  118827. maxDistance: number;
  118828. /**
  118829. * Define the distance attenuation model the sound will follow.
  118830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118831. */
  118832. distanceModel: string;
  118833. /**
  118834. * @hidden
  118835. * Back Compat
  118836. **/
  118837. onended: () => any;
  118838. /**
  118839. * Gets or sets an object used to store user defined information for the sound.
  118840. */
  118841. metadata: any;
  118842. /**
  118843. * Observable event when the current playing sound finishes.
  118844. */
  118845. onEndedObservable: Observable<Sound>;
  118846. private _panningModel;
  118847. private _playbackRate;
  118848. private _streaming;
  118849. private _startTime;
  118850. private _startOffset;
  118851. private _position;
  118852. /** @hidden */
  118853. _positionInEmitterSpace: boolean;
  118854. private _localDirection;
  118855. private _volume;
  118856. private _isReadyToPlay;
  118857. private _isDirectional;
  118858. private _readyToPlayCallback;
  118859. private _audioBuffer;
  118860. private _soundSource;
  118861. private _streamingSource;
  118862. private _soundPanner;
  118863. private _soundGain;
  118864. private _inputAudioNode;
  118865. private _outputAudioNode;
  118866. private _coneInnerAngle;
  118867. private _coneOuterAngle;
  118868. private _coneOuterGain;
  118869. private _scene;
  118870. private _connectedTransformNode;
  118871. private _customAttenuationFunction;
  118872. private _registerFunc;
  118873. private _isOutputConnected;
  118874. private _htmlAudioElement;
  118875. private _urlType;
  118876. private _length?;
  118877. private _offset?;
  118878. /** @hidden */
  118879. static _SceneComponentInitialization: (scene: Scene) => void;
  118880. /**
  118881. * Create a sound and attach it to a scene
  118882. * @param name Name of your sound
  118883. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118884. * @param scene defines the scene the sound belongs to
  118885. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118886. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118887. */
  118888. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118889. /**
  118890. * Release the sound and its associated resources
  118891. */
  118892. dispose(): void;
  118893. /**
  118894. * Gets if the sounds is ready to be played or not.
  118895. * @returns true if ready, otherwise false
  118896. */
  118897. isReady(): boolean;
  118898. private _soundLoaded;
  118899. /**
  118900. * Sets the data of the sound from an audiobuffer
  118901. * @param audioBuffer The audioBuffer containing the data
  118902. */
  118903. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118904. /**
  118905. * Updates the current sounds options such as maxdistance, loop...
  118906. * @param options A JSON object containing values named as the object properties
  118907. */
  118908. updateOptions(options: ISoundOptions): void;
  118909. private _createSpatialParameters;
  118910. private _updateSpatialParameters;
  118911. /**
  118912. * Switch the panning model to HRTF:
  118913. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118915. */
  118916. switchPanningModelToHRTF(): void;
  118917. /**
  118918. * Switch the panning model to Equal Power:
  118919. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118920. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118921. */
  118922. switchPanningModelToEqualPower(): void;
  118923. private _switchPanningModel;
  118924. /**
  118925. * Connect this sound to a sound track audio node like gain...
  118926. * @param soundTrackAudioNode the sound track audio node to connect to
  118927. */
  118928. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118929. /**
  118930. * Transform this sound into a directional source
  118931. * @param coneInnerAngle Size of the inner cone in degree
  118932. * @param coneOuterAngle Size of the outer cone in degree
  118933. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118934. */
  118935. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118936. /**
  118937. * Gets or sets the inner angle for the directional cone.
  118938. */
  118939. get directionalConeInnerAngle(): number;
  118940. /**
  118941. * Gets or sets the inner angle for the directional cone.
  118942. */
  118943. set directionalConeInnerAngle(value: number);
  118944. /**
  118945. * Gets or sets the outer angle for the directional cone.
  118946. */
  118947. get directionalConeOuterAngle(): number;
  118948. /**
  118949. * Gets or sets the outer angle for the directional cone.
  118950. */
  118951. set directionalConeOuterAngle(value: number);
  118952. /**
  118953. * Sets the position of the emitter if spatial sound is enabled
  118954. * @param newPosition Defines the new posisiton
  118955. */
  118956. setPosition(newPosition: Vector3): void;
  118957. /**
  118958. * Sets the local direction of the emitter if spatial sound is enabled
  118959. * @param newLocalDirection Defines the new local direction
  118960. */
  118961. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118962. private _updateDirection;
  118963. /** @hidden */
  118964. updateDistanceFromListener(): void;
  118965. /**
  118966. * Sets a new custom attenuation function for the sound.
  118967. * @param callback Defines the function used for the attenuation
  118968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118969. */
  118970. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118971. /**
  118972. * Play the sound
  118973. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118974. * @param offset (optional) Start the sound at a specific time in seconds
  118975. * @param length (optional) Sound duration (in seconds)
  118976. */
  118977. play(time?: number, offset?: number, length?: number): void;
  118978. private _onended;
  118979. /**
  118980. * Stop the sound
  118981. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118982. */
  118983. stop(time?: number): void;
  118984. /**
  118985. * Put the sound in pause
  118986. */
  118987. pause(): void;
  118988. /**
  118989. * Sets a dedicated volume for this sounds
  118990. * @param newVolume Define the new volume of the sound
  118991. * @param time Define time for gradual change to new volume
  118992. */
  118993. setVolume(newVolume: number, time?: number): void;
  118994. /**
  118995. * Set the sound play back rate
  118996. * @param newPlaybackRate Define the playback rate the sound should be played at
  118997. */
  118998. setPlaybackRate(newPlaybackRate: number): void;
  118999. /**
  119000. * Gets the volume of the sound.
  119001. * @returns the volume of the sound
  119002. */
  119003. getVolume(): number;
  119004. /**
  119005. * Attach the sound to a dedicated mesh
  119006. * @param transformNode The transform node to connect the sound with
  119007. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119008. */
  119009. attachToMesh(transformNode: TransformNode): void;
  119010. /**
  119011. * Detach the sound from the previously attached mesh
  119012. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119013. */
  119014. detachFromMesh(): void;
  119015. private _onRegisterAfterWorldMatrixUpdate;
  119016. /**
  119017. * Clone the current sound in the scene.
  119018. * @returns the new sound clone
  119019. */
  119020. clone(): Nullable<Sound>;
  119021. /**
  119022. * Gets the current underlying audio buffer containing the data
  119023. * @returns the audio buffer
  119024. */
  119025. getAudioBuffer(): Nullable<AudioBuffer>;
  119026. /**
  119027. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119028. * @returns the source node
  119029. */
  119030. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119031. /**
  119032. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119033. * @returns the gain node
  119034. */
  119035. getSoundGain(): Nullable<GainNode>;
  119036. /**
  119037. * Serializes the Sound in a JSON representation
  119038. * @returns the JSON representation of the sound
  119039. */
  119040. serialize(): any;
  119041. /**
  119042. * Parse a JSON representation of a sound to innstantiate in a given scene
  119043. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119044. * @param scene Define the scene the new parsed sound should be created in
  119045. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119046. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119047. * @returns the newly parsed sound
  119048. */
  119049. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119050. }
  119051. }
  119052. declare module BABYLON {
  119053. /**
  119054. * This defines an action helpful to play a defined sound on a triggered action.
  119055. */
  119056. export class PlaySoundAction extends Action {
  119057. private _sound;
  119058. /**
  119059. * Instantiate the action
  119060. * @param triggerOptions defines the trigger options
  119061. * @param sound defines the sound to play
  119062. * @param condition defines the trigger related conditions
  119063. */
  119064. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119065. /** @hidden */
  119066. _prepare(): void;
  119067. /**
  119068. * Execute the action and play the sound.
  119069. */
  119070. execute(): void;
  119071. /**
  119072. * Serializes the actions and its related information.
  119073. * @param parent defines the object to serialize in
  119074. * @returns the serialized object
  119075. */
  119076. serialize(parent: any): any;
  119077. }
  119078. /**
  119079. * This defines an action helpful to stop a defined sound on a triggered action.
  119080. */
  119081. export class StopSoundAction extends Action {
  119082. private _sound;
  119083. /**
  119084. * Instantiate the action
  119085. * @param triggerOptions defines the trigger options
  119086. * @param sound defines the sound to stop
  119087. * @param condition defines the trigger related conditions
  119088. */
  119089. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119090. /** @hidden */
  119091. _prepare(): void;
  119092. /**
  119093. * Execute the action and stop the sound.
  119094. */
  119095. execute(): void;
  119096. /**
  119097. * Serializes the actions and its related information.
  119098. * @param parent defines the object to serialize in
  119099. * @returns the serialized object
  119100. */
  119101. serialize(parent: any): any;
  119102. }
  119103. }
  119104. declare module BABYLON {
  119105. /**
  119106. * This defines an action responsible to change the value of a property
  119107. * by interpolating between its current value and the newly set one once triggered.
  119108. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119109. */
  119110. export class InterpolateValueAction extends Action {
  119111. /**
  119112. * Defines the path of the property where the value should be interpolated
  119113. */
  119114. propertyPath: string;
  119115. /**
  119116. * Defines the target value at the end of the interpolation.
  119117. */
  119118. value: any;
  119119. /**
  119120. * Defines the time it will take for the property to interpolate to the value.
  119121. */
  119122. duration: number;
  119123. /**
  119124. * Defines if the other scene animations should be stopped when the action has been triggered
  119125. */
  119126. stopOtherAnimations?: boolean;
  119127. /**
  119128. * Defines a callback raised once the interpolation animation has been done.
  119129. */
  119130. onInterpolationDone?: () => void;
  119131. /**
  119132. * Observable triggered once the interpolation animation has been done.
  119133. */
  119134. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119135. private _target;
  119136. private _effectiveTarget;
  119137. private _property;
  119138. /**
  119139. * Instantiate the action
  119140. * @param triggerOptions defines the trigger options
  119141. * @param target defines the object containing the value to interpolate
  119142. * @param propertyPath defines the path to the property in the target object
  119143. * @param value defines the target value at the end of the interpolation
  119144. * @param duration deines the time it will take for the property to interpolate to the value.
  119145. * @param condition defines the trigger related conditions
  119146. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119147. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119148. */
  119149. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119150. /** @hidden */
  119151. _prepare(): void;
  119152. /**
  119153. * Execute the action starts the value interpolation.
  119154. */
  119155. execute(): void;
  119156. /**
  119157. * Serializes the actions and its related information.
  119158. * @param parent defines the object to serialize in
  119159. * @returns the serialized object
  119160. */
  119161. serialize(parent: any): any;
  119162. }
  119163. }
  119164. declare module BABYLON {
  119165. /**
  119166. * Options allowed during the creation of a sound track.
  119167. */
  119168. export interface ISoundTrackOptions {
  119169. /**
  119170. * The volume the sound track should take during creation
  119171. */
  119172. volume?: number;
  119173. /**
  119174. * Define if the sound track is the main sound track of the scene
  119175. */
  119176. mainTrack?: boolean;
  119177. }
  119178. /**
  119179. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119180. * It will be also used in a future release to apply effects on a specific track.
  119181. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119182. */
  119183. export class SoundTrack {
  119184. /**
  119185. * The unique identifier of the sound track in the scene.
  119186. */
  119187. id: number;
  119188. /**
  119189. * The list of sounds included in the sound track.
  119190. */
  119191. soundCollection: Array<Sound>;
  119192. private _outputAudioNode;
  119193. private _scene;
  119194. private _connectedAnalyser;
  119195. private _options;
  119196. private _isInitialized;
  119197. /**
  119198. * Creates a new sound track.
  119199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119200. * @param scene Define the scene the sound track belongs to
  119201. * @param options
  119202. */
  119203. constructor(scene: Scene, options?: ISoundTrackOptions);
  119204. private _initializeSoundTrackAudioGraph;
  119205. /**
  119206. * Release the sound track and its associated resources
  119207. */
  119208. dispose(): void;
  119209. /**
  119210. * Adds a sound to this sound track
  119211. * @param sound define the cound to add
  119212. * @ignoreNaming
  119213. */
  119214. AddSound(sound: Sound): void;
  119215. /**
  119216. * Removes a sound to this sound track
  119217. * @param sound define the cound to remove
  119218. * @ignoreNaming
  119219. */
  119220. RemoveSound(sound: Sound): void;
  119221. /**
  119222. * Set a global volume for the full sound track.
  119223. * @param newVolume Define the new volume of the sound track
  119224. */
  119225. setVolume(newVolume: number): void;
  119226. /**
  119227. * Switch the panning model to HRTF:
  119228. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119230. */
  119231. switchPanningModelToHRTF(): void;
  119232. /**
  119233. * Switch the panning model to Equal Power:
  119234. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119236. */
  119237. switchPanningModelToEqualPower(): void;
  119238. /**
  119239. * Connect the sound track to an audio analyser allowing some amazing
  119240. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119242. * @param analyser The analyser to connect to the engine
  119243. */
  119244. connectToAnalyser(analyser: Analyser): void;
  119245. }
  119246. }
  119247. declare module BABYLON {
  119248. interface AbstractScene {
  119249. /**
  119250. * The list of sounds used in the scene.
  119251. */
  119252. sounds: Nullable<Array<Sound>>;
  119253. }
  119254. interface Scene {
  119255. /**
  119256. * @hidden
  119257. * Backing field
  119258. */
  119259. _mainSoundTrack: SoundTrack;
  119260. /**
  119261. * The main sound track played by the scene.
  119262. * It cotains your primary collection of sounds.
  119263. */
  119264. mainSoundTrack: SoundTrack;
  119265. /**
  119266. * The list of sound tracks added to the scene
  119267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119268. */
  119269. soundTracks: Nullable<Array<SoundTrack>>;
  119270. /**
  119271. * Gets a sound using a given name
  119272. * @param name defines the name to search for
  119273. * @return the found sound or null if not found at all.
  119274. */
  119275. getSoundByName(name: string): Nullable<Sound>;
  119276. /**
  119277. * Gets or sets if audio support is enabled
  119278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119279. */
  119280. audioEnabled: boolean;
  119281. /**
  119282. * Gets or sets if audio will be output to headphones
  119283. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119284. */
  119285. headphone: boolean;
  119286. /**
  119287. * Gets or sets custom audio listener position provider
  119288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119289. */
  119290. audioListenerPositionProvider: Nullable<() => Vector3>;
  119291. /**
  119292. * Gets or sets a refresh rate when using 3D audio positioning
  119293. */
  119294. audioPositioningRefreshRate: number;
  119295. }
  119296. /**
  119297. * Defines the sound scene component responsible to manage any sounds
  119298. * in a given scene.
  119299. */
  119300. export class AudioSceneComponent implements ISceneSerializableComponent {
  119301. /**
  119302. * The component name helpfull to identify the component in the list of scene components.
  119303. */
  119304. readonly name: string;
  119305. /**
  119306. * The scene the component belongs to.
  119307. */
  119308. scene: Scene;
  119309. private _audioEnabled;
  119310. /**
  119311. * Gets whether audio is enabled or not.
  119312. * Please use related enable/disable method to switch state.
  119313. */
  119314. get audioEnabled(): boolean;
  119315. private _headphone;
  119316. /**
  119317. * Gets whether audio is outputing to headphone or not.
  119318. * Please use the according Switch methods to change output.
  119319. */
  119320. get headphone(): boolean;
  119321. /**
  119322. * Gets or sets a refresh rate when using 3D audio positioning
  119323. */
  119324. audioPositioningRefreshRate: number;
  119325. private _audioListenerPositionProvider;
  119326. /**
  119327. * Gets the current audio listener position provider
  119328. */
  119329. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119330. /**
  119331. * Sets a custom listener position for all sounds in the scene
  119332. * By default, this is the position of the first active camera
  119333. */
  119334. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119335. /**
  119336. * Creates a new instance of the component for the given scene
  119337. * @param scene Defines the scene to register the component in
  119338. */
  119339. constructor(scene: Scene);
  119340. /**
  119341. * Registers the component in a given scene
  119342. */
  119343. register(): void;
  119344. /**
  119345. * Rebuilds the elements related to this component in case of
  119346. * context lost for instance.
  119347. */
  119348. rebuild(): void;
  119349. /**
  119350. * Serializes the component data to the specified json object
  119351. * @param serializationObject The object to serialize to
  119352. */
  119353. serialize(serializationObject: any): void;
  119354. /**
  119355. * Adds all the elements from the container to the scene
  119356. * @param container the container holding the elements
  119357. */
  119358. addFromContainer(container: AbstractScene): void;
  119359. /**
  119360. * Removes all the elements in the container from the scene
  119361. * @param container contains the elements to remove
  119362. * @param dispose if the removed element should be disposed (default: false)
  119363. */
  119364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119365. /**
  119366. * Disposes the component and the associated ressources.
  119367. */
  119368. dispose(): void;
  119369. /**
  119370. * Disables audio in the associated scene.
  119371. */
  119372. disableAudio(): void;
  119373. /**
  119374. * Enables audio in the associated scene.
  119375. */
  119376. enableAudio(): void;
  119377. /**
  119378. * Switch audio to headphone output.
  119379. */
  119380. switchAudioModeForHeadphones(): void;
  119381. /**
  119382. * Switch audio to normal speakers.
  119383. */
  119384. switchAudioModeForNormalSpeakers(): void;
  119385. private _cachedCameraDirection;
  119386. private _cachedCameraPosition;
  119387. private _lastCheck;
  119388. private _afterRender;
  119389. }
  119390. }
  119391. declare module BABYLON {
  119392. /**
  119393. * Wraps one or more Sound objects and selects one with random weight for playback.
  119394. */
  119395. export class WeightedSound {
  119396. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119397. loop: boolean;
  119398. private _coneInnerAngle;
  119399. private _coneOuterAngle;
  119400. private _volume;
  119401. /** A Sound is currently playing. */
  119402. isPlaying: boolean;
  119403. /** A Sound is currently paused. */
  119404. isPaused: boolean;
  119405. private _sounds;
  119406. private _weights;
  119407. private _currentIndex?;
  119408. /**
  119409. * Creates a new WeightedSound from the list of sounds given.
  119410. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119411. * @param sounds Array of Sounds that will be selected from.
  119412. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119413. */
  119414. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119415. /**
  119416. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119417. */
  119418. get directionalConeInnerAngle(): number;
  119419. /**
  119420. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119421. */
  119422. set directionalConeInnerAngle(value: number);
  119423. /**
  119424. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119425. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119426. */
  119427. get directionalConeOuterAngle(): number;
  119428. /**
  119429. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119430. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119431. */
  119432. set directionalConeOuterAngle(value: number);
  119433. /**
  119434. * Playback volume.
  119435. */
  119436. get volume(): number;
  119437. /**
  119438. * Playback volume.
  119439. */
  119440. set volume(value: number);
  119441. private _onended;
  119442. /**
  119443. * Suspend playback
  119444. */
  119445. pause(): void;
  119446. /**
  119447. * Stop playback
  119448. */
  119449. stop(): void;
  119450. /**
  119451. * Start playback.
  119452. * @param startOffset Position the clip head at a specific time in seconds.
  119453. */
  119454. play(startOffset?: number): void;
  119455. }
  119456. }
  119457. declare module BABYLON {
  119458. /**
  119459. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119461. */
  119462. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119463. /**
  119464. * Gets the name of the behavior.
  119465. */
  119466. get name(): string;
  119467. /**
  119468. * The easing function used by animations
  119469. */
  119470. static EasingFunction: BackEase;
  119471. /**
  119472. * The easing mode used by animations
  119473. */
  119474. static EasingMode: number;
  119475. /**
  119476. * The duration of the animation, in milliseconds
  119477. */
  119478. transitionDuration: number;
  119479. /**
  119480. * Length of the distance animated by the transition when lower radius is reached
  119481. */
  119482. lowerRadiusTransitionRange: number;
  119483. /**
  119484. * Length of the distance animated by the transition when upper radius is reached
  119485. */
  119486. upperRadiusTransitionRange: number;
  119487. private _autoTransitionRange;
  119488. /**
  119489. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119490. */
  119491. get autoTransitionRange(): boolean;
  119492. /**
  119493. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119494. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119495. */
  119496. set autoTransitionRange(value: boolean);
  119497. private _attachedCamera;
  119498. private _onAfterCheckInputsObserver;
  119499. private _onMeshTargetChangedObserver;
  119500. /**
  119501. * Initializes the behavior.
  119502. */
  119503. init(): void;
  119504. /**
  119505. * Attaches the behavior to its arc rotate camera.
  119506. * @param camera Defines the camera to attach the behavior to
  119507. */
  119508. attach(camera: ArcRotateCamera): void;
  119509. /**
  119510. * Detaches the behavior from its current arc rotate camera.
  119511. */
  119512. detach(): void;
  119513. private _radiusIsAnimating;
  119514. private _radiusBounceTransition;
  119515. private _animatables;
  119516. private _cachedWheelPrecision;
  119517. /**
  119518. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119519. * @param radiusLimit The limit to check against.
  119520. * @return Bool to indicate if at limit.
  119521. */
  119522. private _isRadiusAtLimit;
  119523. /**
  119524. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119525. * @param radiusDelta The delta by which to animate to. Can be negative.
  119526. */
  119527. private _applyBoundRadiusAnimation;
  119528. /**
  119529. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119530. */
  119531. protected _clearAnimationLocks(): void;
  119532. /**
  119533. * Stops and removes all animations that have been applied to the camera
  119534. */
  119535. stopAllAnimations(): void;
  119536. }
  119537. }
  119538. declare module BABYLON {
  119539. /**
  119540. * 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.
  119541. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119542. */
  119543. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119544. /**
  119545. * Gets the name of the behavior.
  119546. */
  119547. get name(): string;
  119548. private _mode;
  119549. private _radiusScale;
  119550. private _positionScale;
  119551. private _defaultElevation;
  119552. private _elevationReturnTime;
  119553. private _elevationReturnWaitTime;
  119554. private _zoomStopsAnimation;
  119555. private _framingTime;
  119556. /**
  119557. * The easing function used by animations
  119558. */
  119559. static EasingFunction: ExponentialEase;
  119560. /**
  119561. * The easing mode used by animations
  119562. */
  119563. static EasingMode: number;
  119564. /**
  119565. * Sets the current mode used by the behavior
  119566. */
  119567. set mode(mode: number);
  119568. /**
  119569. * Gets current mode used by the behavior.
  119570. */
  119571. get mode(): number;
  119572. /**
  119573. * Sets the scale applied to the radius (1 by default)
  119574. */
  119575. set radiusScale(radius: number);
  119576. /**
  119577. * Gets the scale applied to the radius
  119578. */
  119579. get radiusScale(): number;
  119580. /**
  119581. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119582. */
  119583. set positionScale(scale: number);
  119584. /**
  119585. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119586. */
  119587. get positionScale(): number;
  119588. /**
  119589. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119590. * behaviour is triggered, in radians.
  119591. */
  119592. set defaultElevation(elevation: number);
  119593. /**
  119594. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119595. * behaviour is triggered, in radians.
  119596. */
  119597. get defaultElevation(): number;
  119598. /**
  119599. * Sets the time (in milliseconds) taken to return to the default beta position.
  119600. * Negative value indicates camera should not return to default.
  119601. */
  119602. set elevationReturnTime(speed: number);
  119603. /**
  119604. * Gets the time (in milliseconds) taken to return to the default beta position.
  119605. * Negative value indicates camera should not return to default.
  119606. */
  119607. get elevationReturnTime(): number;
  119608. /**
  119609. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119610. */
  119611. set elevationReturnWaitTime(time: number);
  119612. /**
  119613. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119614. */
  119615. get elevationReturnWaitTime(): number;
  119616. /**
  119617. * Sets the flag that indicates if user zooming should stop animation.
  119618. */
  119619. set zoomStopsAnimation(flag: boolean);
  119620. /**
  119621. * Gets the flag that indicates if user zooming should stop animation.
  119622. */
  119623. get zoomStopsAnimation(): boolean;
  119624. /**
  119625. * Sets the transition time when framing the mesh, in milliseconds
  119626. */
  119627. set framingTime(time: number);
  119628. /**
  119629. * Gets the transition time when framing the mesh, in milliseconds
  119630. */
  119631. get framingTime(): number;
  119632. /**
  119633. * Define if the behavior should automatically change the configured
  119634. * camera limits and sensibilities.
  119635. */
  119636. autoCorrectCameraLimitsAndSensibility: boolean;
  119637. private _onPrePointerObservableObserver;
  119638. private _onAfterCheckInputsObserver;
  119639. private _onMeshTargetChangedObserver;
  119640. private _attachedCamera;
  119641. private _isPointerDown;
  119642. private _lastInteractionTime;
  119643. /**
  119644. * Initializes the behavior.
  119645. */
  119646. init(): void;
  119647. /**
  119648. * Attaches the behavior to its arc rotate camera.
  119649. * @param camera Defines the camera to attach the behavior to
  119650. */
  119651. attach(camera: ArcRotateCamera): void;
  119652. /**
  119653. * Detaches the behavior from its current arc rotate camera.
  119654. */
  119655. detach(): void;
  119656. private _animatables;
  119657. private _betaIsAnimating;
  119658. private _betaTransition;
  119659. private _radiusTransition;
  119660. private _vectorTransition;
  119661. /**
  119662. * Targets the given mesh and updates zoom level accordingly.
  119663. * @param mesh The mesh to target.
  119664. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119665. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119666. */
  119667. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119668. /**
  119669. * Targets the given mesh with its children and updates zoom level accordingly.
  119670. * @param mesh The mesh to target.
  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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119675. /**
  119676. * Targets the given meshes with their children and updates zoom level accordingly.
  119677. * @param meshes The mesh to target.
  119678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119680. */
  119681. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119682. /**
  119683. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119684. * @param minimumWorld Determines the smaller position of the bounding box extend
  119685. * @param maximumWorld Determines the bigger position of the bounding box extend
  119686. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119687. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119688. */
  119689. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119690. /**
  119691. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119692. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119693. * frustum width.
  119694. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119695. * to fully enclose the mesh in the viewing frustum.
  119696. */
  119697. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119698. /**
  119699. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119700. * is automatically returned to its default position (expected to be above ground plane).
  119701. */
  119702. private _maintainCameraAboveGround;
  119703. /**
  119704. * Returns the frustum slope based on the canvas ratio and camera FOV
  119705. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119706. */
  119707. private _getFrustumSlope;
  119708. /**
  119709. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119710. */
  119711. private _clearAnimationLocks;
  119712. /**
  119713. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119714. */
  119715. private _applyUserInteraction;
  119716. /**
  119717. * Stops and removes all animations that have been applied to the camera
  119718. */
  119719. stopAllAnimations(): void;
  119720. /**
  119721. * Gets a value indicating if the user is moving the camera
  119722. */
  119723. get isUserIsMoving(): boolean;
  119724. /**
  119725. * The camera can move all the way towards the mesh.
  119726. */
  119727. static IgnoreBoundsSizeMode: number;
  119728. /**
  119729. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119730. */
  119731. static FitFrustumSidesMode: number;
  119732. }
  119733. }
  119734. declare module BABYLON {
  119735. /**
  119736. * Base class for Camera Pointer Inputs.
  119737. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119738. * for example usage.
  119739. */
  119740. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119741. /**
  119742. * Defines the camera the input is attached to.
  119743. */
  119744. abstract camera: Camera;
  119745. /**
  119746. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119747. */
  119748. protected _altKey: boolean;
  119749. protected _ctrlKey: boolean;
  119750. protected _metaKey: boolean;
  119751. protected _shiftKey: boolean;
  119752. /**
  119753. * Which mouse buttons were pressed at time of last mouse event.
  119754. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119755. */
  119756. protected _buttonsPressed: number;
  119757. /**
  119758. * Defines the buttons associated with the input to handle camera move.
  119759. */
  119760. buttons: number[];
  119761. /**
  119762. * Attach the input controls to a specific dom element to get the input from.
  119763. * @param element Defines the element the controls should be listened from
  119764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119765. */
  119766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119767. /**
  119768. * Detach the current controls from the specified dom element.
  119769. * @param element Defines the element to stop listening the inputs from
  119770. */
  119771. detachControl(element: Nullable<HTMLElement>): void;
  119772. /**
  119773. * Gets the class name of the current input.
  119774. * @returns the class name
  119775. */
  119776. getClassName(): string;
  119777. /**
  119778. * Get the friendly name associated with the input class.
  119779. * @returns the input friendly name
  119780. */
  119781. getSimpleName(): string;
  119782. /**
  119783. * Called on pointer POINTERDOUBLETAP event.
  119784. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119785. */
  119786. protected onDoubleTap(type: string): void;
  119787. /**
  119788. * Called on pointer POINTERMOVE event if only a single touch is active.
  119789. * Override this method to provide functionality.
  119790. */
  119791. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119792. /**
  119793. * Called on pointer POINTERMOVE event if multiple touches are active.
  119794. * Override this method to provide functionality.
  119795. */
  119796. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119797. /**
  119798. * Called on JS contextmenu event.
  119799. * Override this method to provide functionality.
  119800. */
  119801. protected onContextMenu(evt: PointerEvent): void;
  119802. /**
  119803. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119804. * press.
  119805. * Override this method to provide functionality.
  119806. */
  119807. protected onButtonDown(evt: PointerEvent): void;
  119808. /**
  119809. * Called each time a new POINTERUP event occurs. Ie, for each button
  119810. * release.
  119811. * Override this method to provide functionality.
  119812. */
  119813. protected onButtonUp(evt: PointerEvent): void;
  119814. /**
  119815. * Called when window becomes inactive.
  119816. * Override this method to provide functionality.
  119817. */
  119818. protected onLostFocus(): void;
  119819. private _pointerInput;
  119820. private _observer;
  119821. private _onLostFocus;
  119822. private pointA;
  119823. private pointB;
  119824. }
  119825. }
  119826. declare module BABYLON {
  119827. /**
  119828. * Manage the pointers inputs to control an arc rotate camera.
  119829. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119830. */
  119831. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119832. /**
  119833. * Defines the camera the input is attached to.
  119834. */
  119835. camera: ArcRotateCamera;
  119836. /**
  119837. * Gets the class name of the current input.
  119838. * @returns the class name
  119839. */
  119840. getClassName(): string;
  119841. /**
  119842. * Defines the buttons associated with the input to handle camera move.
  119843. */
  119844. buttons: number[];
  119845. /**
  119846. * Defines the pointer angular sensibility along the X axis or how fast is
  119847. * the camera rotating.
  119848. */
  119849. angularSensibilityX: number;
  119850. /**
  119851. * Defines the pointer angular sensibility along the Y axis or how fast is
  119852. * the camera rotating.
  119853. */
  119854. angularSensibilityY: number;
  119855. /**
  119856. * Defines the pointer pinch precision or how fast is the camera zooming.
  119857. */
  119858. pinchPrecision: number;
  119859. /**
  119860. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119861. * from 0.
  119862. * It defines the percentage of current camera.radius to use as delta when
  119863. * pinch zoom is used.
  119864. */
  119865. pinchDeltaPercentage: number;
  119866. /**
  119867. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119868. * that any object in the plane at the camera's target point will scale
  119869. * perfectly with finger motion.
  119870. * Overrides pinchDeltaPercentage and pinchPrecision.
  119871. */
  119872. useNaturalPinchZoom: boolean;
  119873. /**
  119874. * Defines the pointer panning sensibility or how fast is the camera moving.
  119875. */
  119876. panningSensibility: number;
  119877. /**
  119878. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119879. */
  119880. multiTouchPanning: boolean;
  119881. /**
  119882. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119883. * zoom (pinch) through multitouch.
  119884. */
  119885. multiTouchPanAndZoom: boolean;
  119886. /**
  119887. * Revers pinch action direction.
  119888. */
  119889. pinchInwards: boolean;
  119890. private _isPanClick;
  119891. private _twoFingerActivityCount;
  119892. private _isPinching;
  119893. /**
  119894. * Called on pointer POINTERMOVE event if only a single touch is active.
  119895. */
  119896. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119897. /**
  119898. * Called on pointer POINTERDOUBLETAP event.
  119899. */
  119900. protected onDoubleTap(type: string): void;
  119901. /**
  119902. * Called on pointer POINTERMOVE event if multiple touches are active.
  119903. */
  119904. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119905. /**
  119906. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119907. * press.
  119908. */
  119909. protected onButtonDown(evt: PointerEvent): void;
  119910. /**
  119911. * Called each time a new POINTERUP event occurs. Ie, for each button
  119912. * release.
  119913. */
  119914. protected onButtonUp(evt: PointerEvent): void;
  119915. /**
  119916. * Called when window becomes inactive.
  119917. */
  119918. protected onLostFocus(): void;
  119919. }
  119920. }
  119921. declare module BABYLON {
  119922. /**
  119923. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119924. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  119925. */
  119926. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119927. /**
  119928. * Defines the camera the input is attached to.
  119929. */
  119930. camera: ArcRotateCamera;
  119931. /**
  119932. * Defines the list of key codes associated with the up action (increase alpha)
  119933. */
  119934. keysUp: number[];
  119935. /**
  119936. * Defines the list of key codes associated with the down action (decrease alpha)
  119937. */
  119938. keysDown: number[];
  119939. /**
  119940. * Defines the list of key codes associated with the left action (increase beta)
  119941. */
  119942. keysLeft: number[];
  119943. /**
  119944. * Defines the list of key codes associated with the right action (decrease beta)
  119945. */
  119946. keysRight: number[];
  119947. /**
  119948. * Defines the list of key codes associated with the reset action.
  119949. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119950. */
  119951. keysReset: number[];
  119952. /**
  119953. * Defines the panning sensibility of the inputs.
  119954. * (How fast is the camera panning)
  119955. */
  119956. panningSensibility: number;
  119957. /**
  119958. * Defines the zooming sensibility of the inputs.
  119959. * (How fast is the camera zooming)
  119960. */
  119961. zoomingSensibility: number;
  119962. /**
  119963. * Defines whether maintaining the alt key down switch the movement mode from
  119964. * orientation to zoom.
  119965. */
  119966. useAltToZoom: boolean;
  119967. /**
  119968. * Rotation speed of the camera
  119969. */
  119970. angularSpeed: number;
  119971. private _keys;
  119972. private _ctrlPressed;
  119973. private _altPressed;
  119974. private _onCanvasBlurObserver;
  119975. private _onKeyboardObserver;
  119976. private _engine;
  119977. private _scene;
  119978. /**
  119979. * Attach the input controls to a specific dom element to get the input from.
  119980. * @param element Defines the element the controls should be listened from
  119981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119982. */
  119983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119984. /**
  119985. * Detach the current controls from the specified dom element.
  119986. * @param element Defines the element to stop listening the inputs from
  119987. */
  119988. detachControl(element: Nullable<HTMLElement>): void;
  119989. /**
  119990. * Update the current camera state depending on the inputs that have been used this frame.
  119991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119992. */
  119993. checkInputs(): void;
  119994. /**
  119995. * Gets the class name of the current intput.
  119996. * @returns the class name
  119997. */
  119998. getClassName(): string;
  119999. /**
  120000. * Get the friendly name associated with the input class.
  120001. * @returns the input friendly name
  120002. */
  120003. getSimpleName(): string;
  120004. }
  120005. }
  120006. declare module BABYLON {
  120007. /**
  120008. * Manage the mouse wheel inputs to control an arc rotate camera.
  120009. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120010. */
  120011. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120012. /**
  120013. * Defines the camera the input is attached to.
  120014. */
  120015. camera: ArcRotateCamera;
  120016. /**
  120017. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120018. */
  120019. wheelPrecision: number;
  120020. /**
  120021. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120022. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120023. */
  120024. wheelDeltaPercentage: number;
  120025. private _wheel;
  120026. private _observer;
  120027. private computeDeltaFromMouseWheelLegacyEvent;
  120028. /**
  120029. * Attach the input controls to a specific dom element to get the input from.
  120030. * @param element Defines the element the controls should be listened from
  120031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120032. */
  120033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120034. /**
  120035. * Detach the current controls from the specified dom element.
  120036. * @param element Defines the element to stop listening the inputs from
  120037. */
  120038. detachControl(element: Nullable<HTMLElement>): void;
  120039. /**
  120040. * Gets the class name of the current intput.
  120041. * @returns the class name
  120042. */
  120043. getClassName(): string;
  120044. /**
  120045. * Get the friendly name associated with the input class.
  120046. * @returns the input friendly name
  120047. */
  120048. getSimpleName(): string;
  120049. }
  120050. }
  120051. declare module BABYLON {
  120052. /**
  120053. * Default Inputs manager for the ArcRotateCamera.
  120054. * It groups all the default supported inputs for ease of use.
  120055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120056. */
  120057. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120058. /**
  120059. * Instantiates a new ArcRotateCameraInputsManager.
  120060. * @param camera Defines the camera the inputs belong to
  120061. */
  120062. constructor(camera: ArcRotateCamera);
  120063. /**
  120064. * Add mouse wheel input support to the input manager.
  120065. * @returns the current input manager
  120066. */
  120067. addMouseWheel(): ArcRotateCameraInputsManager;
  120068. /**
  120069. * Add pointers input support to the input manager.
  120070. * @returns the current input manager
  120071. */
  120072. addPointers(): ArcRotateCameraInputsManager;
  120073. /**
  120074. * Add keyboard input support to the input manager.
  120075. * @returns the current input manager
  120076. */
  120077. addKeyboard(): ArcRotateCameraInputsManager;
  120078. }
  120079. }
  120080. declare module BABYLON {
  120081. /**
  120082. * This represents an orbital type of camera.
  120083. *
  120084. * 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.
  120085. * 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.
  120086. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120087. */
  120088. export class ArcRotateCamera extends TargetCamera {
  120089. /**
  120090. * Defines the rotation angle of the camera along the longitudinal axis.
  120091. */
  120092. alpha: number;
  120093. /**
  120094. * Defines the rotation angle of the camera along the latitudinal axis.
  120095. */
  120096. beta: number;
  120097. /**
  120098. * Defines the radius of the camera from it s target point.
  120099. */
  120100. radius: number;
  120101. protected _target: Vector3;
  120102. protected _targetHost: Nullable<AbstractMesh>;
  120103. /**
  120104. * Defines the target point of the camera.
  120105. * The camera looks towards it form the radius distance.
  120106. */
  120107. get target(): Vector3;
  120108. set target(value: Vector3);
  120109. /**
  120110. * Define the current local position of the camera in the scene
  120111. */
  120112. get position(): Vector3;
  120113. set position(newPosition: Vector3);
  120114. protected _upVector: Vector3;
  120115. protected _upToYMatrix: Matrix;
  120116. protected _YToUpMatrix: Matrix;
  120117. /**
  120118. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120119. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120120. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120121. */
  120122. set upVector(vec: Vector3);
  120123. get upVector(): Vector3;
  120124. /**
  120125. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120126. */
  120127. setMatUp(): void;
  120128. /**
  120129. * Current inertia value on the longitudinal axis.
  120130. * The bigger this number the longer it will take for the camera to stop.
  120131. */
  120132. inertialAlphaOffset: number;
  120133. /**
  120134. * Current inertia value on the latitudinal axis.
  120135. * The bigger this number the longer it will take for the camera to stop.
  120136. */
  120137. inertialBetaOffset: number;
  120138. /**
  120139. * Current inertia value on the radius axis.
  120140. * The bigger this number the longer it will take for the camera to stop.
  120141. */
  120142. inertialRadiusOffset: number;
  120143. /**
  120144. * Minimum allowed angle on the longitudinal axis.
  120145. * This can help limiting how the Camera is able to move in the scene.
  120146. */
  120147. lowerAlphaLimit: Nullable<number>;
  120148. /**
  120149. * Maximum allowed angle on the longitudinal axis.
  120150. * This can help limiting how the Camera is able to move in the scene.
  120151. */
  120152. upperAlphaLimit: Nullable<number>;
  120153. /**
  120154. * Minimum allowed angle on the latitudinal axis.
  120155. * This can help limiting how the Camera is able to move in the scene.
  120156. */
  120157. lowerBetaLimit: number;
  120158. /**
  120159. * Maximum allowed angle on the latitudinal axis.
  120160. * This can help limiting how the Camera is able to move in the scene.
  120161. */
  120162. upperBetaLimit: number;
  120163. /**
  120164. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120165. * This can help limiting how the Camera is able to move in the scene.
  120166. */
  120167. lowerRadiusLimit: Nullable<number>;
  120168. /**
  120169. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120170. * This can help limiting how the Camera is able to move in the scene.
  120171. */
  120172. upperRadiusLimit: Nullable<number>;
  120173. /**
  120174. * Defines the current inertia value used during panning of the camera along the X axis.
  120175. */
  120176. inertialPanningX: number;
  120177. /**
  120178. * Defines the current inertia value used during panning of the camera along the Y axis.
  120179. */
  120180. inertialPanningY: number;
  120181. /**
  120182. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120183. * Basically if your fingers moves away from more than this distance you will be considered
  120184. * in pinch mode.
  120185. */
  120186. pinchToPanMaxDistance: number;
  120187. /**
  120188. * Defines the maximum distance the camera can pan.
  120189. * This could help keeping the cammera always in your scene.
  120190. */
  120191. panningDistanceLimit: Nullable<number>;
  120192. /**
  120193. * Defines the target of the camera before paning.
  120194. */
  120195. panningOriginTarget: Vector3;
  120196. /**
  120197. * Defines the value of the inertia used during panning.
  120198. * 0 would mean stop inertia and one would mean no decelleration at all.
  120199. */
  120200. panningInertia: number;
  120201. /**
  120202. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120203. */
  120204. get angularSensibilityX(): number;
  120205. set angularSensibilityX(value: number);
  120206. /**
  120207. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120208. */
  120209. get angularSensibilityY(): number;
  120210. set angularSensibilityY(value: number);
  120211. /**
  120212. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120213. */
  120214. get pinchPrecision(): number;
  120215. set pinchPrecision(value: number);
  120216. /**
  120217. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120218. * It will be used instead of pinchDeltaPrecision if different from 0.
  120219. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120220. */
  120221. get pinchDeltaPercentage(): number;
  120222. set pinchDeltaPercentage(value: number);
  120223. /**
  120224. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120225. * and pinch delta percentage.
  120226. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120227. * that any object in the plane at the camera's target point will scale
  120228. * perfectly with finger motion.
  120229. */
  120230. get useNaturalPinchZoom(): boolean;
  120231. set useNaturalPinchZoom(value: boolean);
  120232. /**
  120233. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120234. */
  120235. get panningSensibility(): number;
  120236. set panningSensibility(value: number);
  120237. /**
  120238. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120239. */
  120240. get keysUp(): number[];
  120241. set keysUp(value: number[]);
  120242. /**
  120243. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120244. */
  120245. get keysDown(): number[];
  120246. set keysDown(value: number[]);
  120247. /**
  120248. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120249. */
  120250. get keysLeft(): number[];
  120251. set keysLeft(value: number[]);
  120252. /**
  120253. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120254. */
  120255. get keysRight(): number[];
  120256. set keysRight(value: number[]);
  120257. /**
  120258. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120259. */
  120260. get wheelPrecision(): number;
  120261. set wheelPrecision(value: number);
  120262. /**
  120263. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120264. * It will be used instead of pinchDeltaPrecision if different from 0.
  120265. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120266. */
  120267. get wheelDeltaPercentage(): number;
  120268. set wheelDeltaPercentage(value: number);
  120269. /**
  120270. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120271. */
  120272. zoomOnFactor: number;
  120273. /**
  120274. * Defines a screen offset for the camera position.
  120275. */
  120276. targetScreenOffset: Vector2;
  120277. /**
  120278. * Allows the camera to be completely reversed.
  120279. * If false the camera can not arrive upside down.
  120280. */
  120281. allowUpsideDown: boolean;
  120282. /**
  120283. * Define if double tap/click is used to restore the previously saved state of the camera.
  120284. */
  120285. useInputToRestoreState: boolean;
  120286. /** @hidden */
  120287. _viewMatrix: Matrix;
  120288. /** @hidden */
  120289. _useCtrlForPanning: boolean;
  120290. /** @hidden */
  120291. _panningMouseButton: number;
  120292. /**
  120293. * Defines the input associated to the camera.
  120294. */
  120295. inputs: ArcRotateCameraInputsManager;
  120296. /** @hidden */
  120297. _reset: () => void;
  120298. /**
  120299. * Defines the allowed panning axis.
  120300. */
  120301. panningAxis: Vector3;
  120302. protected _localDirection: Vector3;
  120303. protected _transformedDirection: Vector3;
  120304. private _bouncingBehavior;
  120305. /**
  120306. * Gets the bouncing behavior of the camera if it has been enabled.
  120307. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120308. */
  120309. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120310. /**
  120311. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120312. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120313. */
  120314. get useBouncingBehavior(): boolean;
  120315. set useBouncingBehavior(value: boolean);
  120316. private _framingBehavior;
  120317. /**
  120318. * Gets the framing behavior of the camera if it has been enabled.
  120319. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120320. */
  120321. get framingBehavior(): Nullable<FramingBehavior>;
  120322. /**
  120323. * Defines if the framing behavior of the camera is enabled on the camera.
  120324. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120325. */
  120326. get useFramingBehavior(): boolean;
  120327. set useFramingBehavior(value: boolean);
  120328. private _autoRotationBehavior;
  120329. /**
  120330. * Gets the auto rotation behavior of the camera if it has been enabled.
  120331. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120332. */
  120333. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120334. /**
  120335. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120336. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120337. */
  120338. get useAutoRotationBehavior(): boolean;
  120339. set useAutoRotationBehavior(value: boolean);
  120340. /**
  120341. * Observable triggered when the mesh target has been changed on the camera.
  120342. */
  120343. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120344. /**
  120345. * Event raised when the camera is colliding with a mesh.
  120346. */
  120347. onCollide: (collidedMesh: AbstractMesh) => void;
  120348. /**
  120349. * Defines whether the camera should check collision with the objects oh the scene.
  120350. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120351. */
  120352. checkCollisions: boolean;
  120353. /**
  120354. * Defines the collision radius of the camera.
  120355. * This simulates a sphere around the camera.
  120356. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120357. */
  120358. collisionRadius: Vector3;
  120359. protected _collider: Collider;
  120360. protected _previousPosition: Vector3;
  120361. protected _collisionVelocity: Vector3;
  120362. protected _newPosition: Vector3;
  120363. protected _previousAlpha: number;
  120364. protected _previousBeta: number;
  120365. protected _previousRadius: number;
  120366. protected _collisionTriggered: boolean;
  120367. protected _targetBoundingCenter: Nullable<Vector3>;
  120368. private _computationVector;
  120369. /**
  120370. * Instantiates a new ArcRotateCamera in a given scene
  120371. * @param name Defines the name of the camera
  120372. * @param alpha Defines the camera rotation along the logitudinal axis
  120373. * @param beta Defines the camera rotation along the latitudinal axis
  120374. * @param radius Defines the camera distance from its target
  120375. * @param target Defines the camera target
  120376. * @param scene Defines the scene the camera belongs to
  120377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120378. */
  120379. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120380. /** @hidden */
  120381. _initCache(): void;
  120382. /** @hidden */
  120383. _updateCache(ignoreParentClass?: boolean): void;
  120384. protected _getTargetPosition(): Vector3;
  120385. private _storedAlpha;
  120386. private _storedBeta;
  120387. private _storedRadius;
  120388. private _storedTarget;
  120389. private _storedTargetScreenOffset;
  120390. /**
  120391. * Stores the current state of the camera (alpha, beta, radius and target)
  120392. * @returns the camera itself
  120393. */
  120394. storeState(): Camera;
  120395. /**
  120396. * @hidden
  120397. * Restored camera state. You must call storeState() first
  120398. */
  120399. _restoreStateValues(): boolean;
  120400. /** @hidden */
  120401. _isSynchronizedViewMatrix(): boolean;
  120402. /**
  120403. * Attached controls to the current camera.
  120404. * @param element Defines the element the controls should be listened from
  120405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120406. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120407. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120408. */
  120409. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120410. /**
  120411. * Detach the current controls from the camera.
  120412. * The camera will stop reacting to inputs.
  120413. * @param element Defines the element to stop listening the inputs from
  120414. */
  120415. detachControl(element: HTMLElement): void;
  120416. /** @hidden */
  120417. _checkInputs(): void;
  120418. protected _checkLimits(): void;
  120419. /**
  120420. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120421. */
  120422. rebuildAnglesAndRadius(): void;
  120423. /**
  120424. * Use a position to define the current camera related information like alpha, beta and radius
  120425. * @param position Defines the position to set the camera at
  120426. */
  120427. setPosition(position: Vector3): void;
  120428. /**
  120429. * Defines the target the camera should look at.
  120430. * This will automatically adapt alpha beta and radius to fit within the new target.
  120431. * @param target Defines the new target as a Vector or a mesh
  120432. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120433. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120434. */
  120435. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120436. /** @hidden */
  120437. _getViewMatrix(): Matrix;
  120438. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120439. /**
  120440. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120441. * @param meshes Defines the mesh to zoom on
  120442. * @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)
  120443. */
  120444. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120445. /**
  120446. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120447. * The target will be changed but the radius
  120448. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120449. * @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)
  120450. */
  120451. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120452. min: Vector3;
  120453. max: Vector3;
  120454. distance: number;
  120455. }, doNotUpdateMaxZ?: boolean): void;
  120456. /**
  120457. * @override
  120458. * Override Camera.createRigCamera
  120459. */
  120460. createRigCamera(name: string, cameraIndex: number): Camera;
  120461. /**
  120462. * @hidden
  120463. * @override
  120464. * Override Camera._updateRigCameras
  120465. */
  120466. _updateRigCameras(): void;
  120467. /**
  120468. * Destroy the camera and release the current resources hold by it.
  120469. */
  120470. dispose(): void;
  120471. /**
  120472. * Gets the current object class name.
  120473. * @return the class name
  120474. */
  120475. getClassName(): string;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120481. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120482. */
  120483. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120484. /**
  120485. * Gets the name of the behavior.
  120486. */
  120487. get name(): string;
  120488. private _zoomStopsAnimation;
  120489. private _idleRotationSpeed;
  120490. private _idleRotationWaitTime;
  120491. private _idleRotationSpinupTime;
  120492. /**
  120493. * Sets the flag that indicates if user zooming should stop animation.
  120494. */
  120495. set zoomStopsAnimation(flag: boolean);
  120496. /**
  120497. * Gets the flag that indicates if user zooming should stop animation.
  120498. */
  120499. get zoomStopsAnimation(): boolean;
  120500. /**
  120501. * Sets the default speed at which the camera rotates around the model.
  120502. */
  120503. set idleRotationSpeed(speed: number);
  120504. /**
  120505. * Gets the default speed at which the camera rotates around the model.
  120506. */
  120507. get idleRotationSpeed(): number;
  120508. /**
  120509. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120510. */
  120511. set idleRotationWaitTime(time: number);
  120512. /**
  120513. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120514. */
  120515. get idleRotationWaitTime(): number;
  120516. /**
  120517. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120518. */
  120519. set idleRotationSpinupTime(time: number);
  120520. /**
  120521. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120522. */
  120523. get idleRotationSpinupTime(): number;
  120524. /**
  120525. * Gets a value indicating if the camera is currently rotating because of this behavior
  120526. */
  120527. get rotationInProgress(): boolean;
  120528. private _onPrePointerObservableObserver;
  120529. private _onAfterCheckInputsObserver;
  120530. private _attachedCamera;
  120531. private _isPointerDown;
  120532. private _lastFrameTime;
  120533. private _lastInteractionTime;
  120534. private _cameraRotationSpeed;
  120535. /**
  120536. * Initializes the behavior.
  120537. */
  120538. init(): void;
  120539. /**
  120540. * Attaches the behavior to its arc rotate camera.
  120541. * @param camera Defines the camera to attach the behavior to
  120542. */
  120543. attach(camera: ArcRotateCamera): void;
  120544. /**
  120545. * Detaches the behavior from its current arc rotate camera.
  120546. */
  120547. detach(): void;
  120548. /**
  120549. * Returns true if user is scrolling.
  120550. * @return true if user is scrolling.
  120551. */
  120552. private _userIsZooming;
  120553. private _lastFrameRadius;
  120554. private _shouldAnimationStopForInteraction;
  120555. /**
  120556. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120557. */
  120558. private _applyUserInteraction;
  120559. private _userIsMoving;
  120560. }
  120561. }
  120562. declare module BABYLON {
  120563. /**
  120564. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120565. */
  120566. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120567. private ui;
  120568. /**
  120569. * The name of the behavior
  120570. */
  120571. name: string;
  120572. /**
  120573. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120574. */
  120575. distanceAwayFromFace: number;
  120576. /**
  120577. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120578. */
  120579. distanceAwayFromBottomOfFace: number;
  120580. private _faceVectors;
  120581. private _target;
  120582. private _scene;
  120583. private _onRenderObserver;
  120584. private _tmpMatrix;
  120585. private _tmpVector;
  120586. /**
  120587. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120588. * @param ui The transform node that should be attched to the mesh
  120589. */
  120590. constructor(ui: TransformNode);
  120591. /**
  120592. * Initializes the behavior
  120593. */
  120594. init(): void;
  120595. private _closestFace;
  120596. private _zeroVector;
  120597. private _lookAtTmpMatrix;
  120598. private _lookAtToRef;
  120599. /**
  120600. * Attaches the AttachToBoxBehavior to the passed in mesh
  120601. * @param target The mesh that the specified node will be attached to
  120602. */
  120603. attach(target: Mesh): void;
  120604. /**
  120605. * Detaches the behavior from the mesh
  120606. */
  120607. detach(): void;
  120608. }
  120609. }
  120610. declare module BABYLON {
  120611. /**
  120612. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120613. */
  120614. export class FadeInOutBehavior implements Behavior<Mesh> {
  120615. /**
  120616. * Time in milliseconds to delay before fading in (Default: 0)
  120617. */
  120618. delay: number;
  120619. /**
  120620. * Time in milliseconds for the mesh to fade in (Default: 300)
  120621. */
  120622. fadeInTime: number;
  120623. private _millisecondsPerFrame;
  120624. private _hovered;
  120625. private _hoverValue;
  120626. private _ownerNode;
  120627. /**
  120628. * Instatiates the FadeInOutBehavior
  120629. */
  120630. constructor();
  120631. /**
  120632. * The name of the behavior
  120633. */
  120634. get name(): string;
  120635. /**
  120636. * Initializes the behavior
  120637. */
  120638. init(): void;
  120639. /**
  120640. * Attaches the fade behavior on the passed in mesh
  120641. * @param ownerNode The mesh that will be faded in/out once attached
  120642. */
  120643. attach(ownerNode: Mesh): void;
  120644. /**
  120645. * Detaches the behavior from the mesh
  120646. */
  120647. detach(): void;
  120648. /**
  120649. * Triggers the mesh to begin fading in or out
  120650. * @param value if the object should fade in or out (true to fade in)
  120651. */
  120652. fadeIn(value: boolean): void;
  120653. private _update;
  120654. private _setAllVisibility;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * Class containing a set of static utilities functions for managing Pivots
  120660. * @hidden
  120661. */
  120662. export class PivotTools {
  120663. private static _PivotCached;
  120664. private static _OldPivotPoint;
  120665. private static _PivotTranslation;
  120666. private static _PivotTmpVector;
  120667. /** @hidden */
  120668. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120669. /** @hidden */
  120670. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * Class containing static functions to help procedurally build meshes
  120676. */
  120677. export class PlaneBuilder {
  120678. /**
  120679. * Creates a plane mesh
  120680. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120681. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120682. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120684. * * 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
  120685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120686. * @param name defines the name of the mesh
  120687. * @param options defines the options used to create the mesh
  120688. * @param scene defines the hosting scene
  120689. * @returns the plane mesh
  120690. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120691. */
  120692. static CreatePlane(name: string, options: {
  120693. size?: number;
  120694. width?: number;
  120695. height?: number;
  120696. sideOrientation?: number;
  120697. frontUVs?: Vector4;
  120698. backUVs?: Vector4;
  120699. updatable?: boolean;
  120700. sourcePlane?: Plane;
  120701. }, scene?: Nullable<Scene>): Mesh;
  120702. }
  120703. }
  120704. declare module BABYLON {
  120705. /**
  120706. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120707. */
  120708. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120709. private static _AnyMouseID;
  120710. /**
  120711. * Abstract mesh the behavior is set on
  120712. */
  120713. attachedNode: AbstractMesh;
  120714. private _dragPlane;
  120715. private _scene;
  120716. private _pointerObserver;
  120717. private _beforeRenderObserver;
  120718. private static _planeScene;
  120719. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120720. /**
  120721. * 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)
  120722. */
  120723. maxDragAngle: number;
  120724. /**
  120725. * @hidden
  120726. */
  120727. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120728. /**
  120729. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120730. */
  120731. currentDraggingPointerID: number;
  120732. /**
  120733. * The last position where the pointer hit the drag plane in world space
  120734. */
  120735. lastDragPosition: Vector3;
  120736. /**
  120737. * If the behavior is currently in a dragging state
  120738. */
  120739. dragging: boolean;
  120740. /**
  120741. * 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)
  120742. */
  120743. dragDeltaRatio: number;
  120744. /**
  120745. * If the drag plane orientation should be updated during the dragging (Default: true)
  120746. */
  120747. updateDragPlane: boolean;
  120748. private _debugMode;
  120749. private _moving;
  120750. /**
  120751. * Fires each time the attached mesh is dragged with the pointer
  120752. * * delta between last drag position and current drag position in world space
  120753. * * dragDistance along the drag axis
  120754. * * dragPlaneNormal normal of the current drag plane used during the drag
  120755. * * dragPlanePoint in world space where the drag intersects the drag plane
  120756. */
  120757. onDragObservable: Observable<{
  120758. delta: Vector3;
  120759. dragPlanePoint: Vector3;
  120760. dragPlaneNormal: Vector3;
  120761. dragDistance: number;
  120762. pointerId: number;
  120763. }>;
  120764. /**
  120765. * Fires each time a drag begins (eg. mouse down on mesh)
  120766. */
  120767. onDragStartObservable: Observable<{
  120768. dragPlanePoint: Vector3;
  120769. pointerId: number;
  120770. }>;
  120771. /**
  120772. * Fires each time a drag ends (eg. mouse release after drag)
  120773. */
  120774. onDragEndObservable: Observable<{
  120775. dragPlanePoint: Vector3;
  120776. pointerId: number;
  120777. }>;
  120778. /**
  120779. * If the attached mesh should be moved when dragged
  120780. */
  120781. moveAttached: boolean;
  120782. /**
  120783. * If the drag behavior will react to drag events (Default: true)
  120784. */
  120785. enabled: boolean;
  120786. /**
  120787. * If pointer events should start and release the drag (Default: true)
  120788. */
  120789. startAndReleaseDragOnPointerEvents: boolean;
  120790. /**
  120791. * If camera controls should be detached during the drag
  120792. */
  120793. detachCameraControls: boolean;
  120794. /**
  120795. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120796. */
  120797. useObjectOrientationForDragging: boolean;
  120798. private _options;
  120799. /**
  120800. * Gets the options used by the behavior
  120801. */
  120802. get options(): {
  120803. dragAxis?: Vector3;
  120804. dragPlaneNormal?: Vector3;
  120805. };
  120806. /**
  120807. * Sets the options used by the behavior
  120808. */
  120809. set options(options: {
  120810. dragAxis?: Vector3;
  120811. dragPlaneNormal?: Vector3;
  120812. });
  120813. /**
  120814. * Creates a pointer drag behavior that can be attached to a mesh
  120815. * @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)
  120816. */
  120817. constructor(options?: {
  120818. dragAxis?: Vector3;
  120819. dragPlaneNormal?: Vector3;
  120820. });
  120821. /**
  120822. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120823. */
  120824. validateDrag: (targetPosition: Vector3) => boolean;
  120825. /**
  120826. * The name of the behavior
  120827. */
  120828. get name(): string;
  120829. /**
  120830. * Initializes the behavior
  120831. */
  120832. init(): void;
  120833. private _tmpVector;
  120834. private _alternatePickedPoint;
  120835. private _worldDragAxis;
  120836. private _targetPosition;
  120837. private _attachedElement;
  120838. /**
  120839. * Attaches the drag behavior the passed in mesh
  120840. * @param ownerNode The mesh that will be dragged around once attached
  120841. * @param predicate Predicate to use for pick filtering
  120842. */
  120843. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120844. /**
  120845. * Force relase the drag action by code.
  120846. */
  120847. releaseDrag(): void;
  120848. private _startDragRay;
  120849. private _lastPointerRay;
  120850. /**
  120851. * Simulates the start of a pointer drag event on the behavior
  120852. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120853. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120854. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120855. */
  120856. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120857. private _startDrag;
  120858. private _dragDelta;
  120859. private _moveDrag;
  120860. private _pickWithRayOnDragPlane;
  120861. private _pointA;
  120862. private _pointB;
  120863. private _pointC;
  120864. private _lineA;
  120865. private _lineB;
  120866. private _localAxis;
  120867. private _lookAt;
  120868. private _updateDragPlanePosition;
  120869. /**
  120870. * Detaches the behavior from the mesh
  120871. */
  120872. detach(): void;
  120873. }
  120874. }
  120875. declare module BABYLON {
  120876. /**
  120877. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120878. */
  120879. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120880. private _dragBehaviorA;
  120881. private _dragBehaviorB;
  120882. private _startDistance;
  120883. private _initialScale;
  120884. private _targetScale;
  120885. private _ownerNode;
  120886. private _sceneRenderObserver;
  120887. /**
  120888. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120889. */
  120890. constructor();
  120891. /**
  120892. * The name of the behavior
  120893. */
  120894. get name(): string;
  120895. /**
  120896. * Initializes the behavior
  120897. */
  120898. init(): void;
  120899. private _getCurrentDistance;
  120900. /**
  120901. * Attaches the scale behavior the passed in mesh
  120902. * @param ownerNode The mesh that will be scaled around once attached
  120903. */
  120904. attach(ownerNode: Mesh): void;
  120905. /**
  120906. * Detaches the behavior from the mesh
  120907. */
  120908. detach(): void;
  120909. }
  120910. }
  120911. declare module BABYLON {
  120912. /**
  120913. * 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
  120914. */
  120915. export class SixDofDragBehavior implements Behavior<Mesh> {
  120916. private static _virtualScene;
  120917. private _ownerNode;
  120918. private _sceneRenderObserver;
  120919. private _scene;
  120920. private _targetPosition;
  120921. private _virtualOriginMesh;
  120922. private _virtualDragMesh;
  120923. private _pointerObserver;
  120924. private _moving;
  120925. private _startingOrientation;
  120926. private _attachedElement;
  120927. /**
  120928. * 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)
  120929. */
  120930. private zDragFactor;
  120931. /**
  120932. * If the object should rotate to face the drag origin
  120933. */
  120934. rotateDraggedObject: boolean;
  120935. /**
  120936. * If the behavior is currently in a dragging state
  120937. */
  120938. dragging: boolean;
  120939. /**
  120940. * 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)
  120941. */
  120942. dragDeltaRatio: number;
  120943. /**
  120944. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120945. */
  120946. currentDraggingPointerID: number;
  120947. /**
  120948. * If camera controls should be detached during the drag
  120949. */
  120950. detachCameraControls: boolean;
  120951. /**
  120952. * Fires each time a drag starts
  120953. */
  120954. onDragStartObservable: Observable<{}>;
  120955. /**
  120956. * Fires each time a drag ends (eg. mouse release after drag)
  120957. */
  120958. onDragEndObservable: Observable<{}>;
  120959. /**
  120960. * 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
  120961. */
  120962. constructor();
  120963. /**
  120964. * The name of the behavior
  120965. */
  120966. get name(): string;
  120967. /**
  120968. * Initializes the behavior
  120969. */
  120970. init(): void;
  120971. /**
  120972. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120973. */
  120974. private get _pointerCamera();
  120975. /**
  120976. * Attaches the scale behavior the passed in mesh
  120977. * @param ownerNode The mesh that will be scaled around once attached
  120978. */
  120979. attach(ownerNode: Mesh): void;
  120980. /**
  120981. * Detaches the behavior from the mesh
  120982. */
  120983. detach(): void;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /**
  120988. * Class used to apply inverse kinematics to bones
  120989. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120990. */
  120991. export class BoneIKController {
  120992. private static _tmpVecs;
  120993. private static _tmpQuat;
  120994. private static _tmpMats;
  120995. /**
  120996. * Gets or sets the target mesh
  120997. */
  120998. targetMesh: AbstractMesh;
  120999. /** Gets or sets the mesh used as pole */
  121000. poleTargetMesh: AbstractMesh;
  121001. /**
  121002. * Gets or sets the bone used as pole
  121003. */
  121004. poleTargetBone: Nullable<Bone>;
  121005. /**
  121006. * Gets or sets the target position
  121007. */
  121008. targetPosition: Vector3;
  121009. /**
  121010. * Gets or sets the pole target position
  121011. */
  121012. poleTargetPosition: Vector3;
  121013. /**
  121014. * Gets or sets the pole target local offset
  121015. */
  121016. poleTargetLocalOffset: Vector3;
  121017. /**
  121018. * Gets or sets the pole angle
  121019. */
  121020. poleAngle: number;
  121021. /**
  121022. * Gets or sets the mesh associated with the controller
  121023. */
  121024. mesh: AbstractMesh;
  121025. /**
  121026. * 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)
  121027. */
  121028. slerpAmount: number;
  121029. private _bone1Quat;
  121030. private _bone1Mat;
  121031. private _bone2Ang;
  121032. private _bone1;
  121033. private _bone2;
  121034. private _bone1Length;
  121035. private _bone2Length;
  121036. private _maxAngle;
  121037. private _maxReach;
  121038. private _rightHandedSystem;
  121039. private _bendAxis;
  121040. private _slerping;
  121041. private _adjustRoll;
  121042. /**
  121043. * Gets or sets maximum allowed angle
  121044. */
  121045. get maxAngle(): number;
  121046. set maxAngle(value: number);
  121047. /**
  121048. * Creates a new BoneIKController
  121049. * @param mesh defines the mesh to control
  121050. * @param bone defines the bone to control
  121051. * @param options defines options to set up the controller
  121052. */
  121053. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121054. targetMesh?: AbstractMesh;
  121055. poleTargetMesh?: AbstractMesh;
  121056. poleTargetBone?: Bone;
  121057. poleTargetLocalOffset?: Vector3;
  121058. poleAngle?: number;
  121059. bendAxis?: Vector3;
  121060. maxAngle?: number;
  121061. slerpAmount?: number;
  121062. });
  121063. private _setMaxAngle;
  121064. /**
  121065. * Force the controller to update the bones
  121066. */
  121067. update(): void;
  121068. }
  121069. }
  121070. declare module BABYLON {
  121071. /**
  121072. * Class used to make a bone look toward a point in space
  121073. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121074. */
  121075. export class BoneLookController {
  121076. private static _tmpVecs;
  121077. private static _tmpQuat;
  121078. private static _tmpMats;
  121079. /**
  121080. * The target Vector3 that the bone will look at
  121081. */
  121082. target: Vector3;
  121083. /**
  121084. * The mesh that the bone is attached to
  121085. */
  121086. mesh: AbstractMesh;
  121087. /**
  121088. * The bone that will be looking to the target
  121089. */
  121090. bone: Bone;
  121091. /**
  121092. * The up axis of the coordinate system that is used when the bone is rotated
  121093. */
  121094. upAxis: Vector3;
  121095. /**
  121096. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121097. */
  121098. upAxisSpace: Space;
  121099. /**
  121100. * Used to make an adjustment to the yaw of the bone
  121101. */
  121102. adjustYaw: number;
  121103. /**
  121104. * Used to make an adjustment to the pitch of the bone
  121105. */
  121106. adjustPitch: number;
  121107. /**
  121108. * Used to make an adjustment to the roll of the bone
  121109. */
  121110. adjustRoll: number;
  121111. /**
  121112. * 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)
  121113. */
  121114. slerpAmount: number;
  121115. private _minYaw;
  121116. private _maxYaw;
  121117. private _minPitch;
  121118. private _maxPitch;
  121119. private _minYawSin;
  121120. private _minYawCos;
  121121. private _maxYawSin;
  121122. private _maxYawCos;
  121123. private _midYawConstraint;
  121124. private _minPitchTan;
  121125. private _maxPitchTan;
  121126. private _boneQuat;
  121127. private _slerping;
  121128. private _transformYawPitch;
  121129. private _transformYawPitchInv;
  121130. private _firstFrameSkipped;
  121131. private _yawRange;
  121132. private _fowardAxis;
  121133. /**
  121134. * Gets or sets the minimum yaw angle that the bone can look to
  121135. */
  121136. get minYaw(): number;
  121137. set minYaw(value: number);
  121138. /**
  121139. * Gets or sets the maximum yaw angle that the bone can look to
  121140. */
  121141. get maxYaw(): number;
  121142. set maxYaw(value: number);
  121143. /**
  121144. * Gets or sets the minimum pitch angle that the bone can look to
  121145. */
  121146. get minPitch(): number;
  121147. set minPitch(value: number);
  121148. /**
  121149. * Gets or sets the maximum pitch angle that the bone can look to
  121150. */
  121151. get maxPitch(): number;
  121152. set maxPitch(value: number);
  121153. /**
  121154. * Create a BoneLookController
  121155. * @param mesh the mesh that the bone belongs to
  121156. * @param bone the bone that will be looking to the target
  121157. * @param target the target Vector3 to look at
  121158. * @param options optional settings:
  121159. * * maxYaw: the maximum angle the bone will yaw to
  121160. * * minYaw: the minimum angle the bone will yaw to
  121161. * * maxPitch: the maximum angle the bone will pitch to
  121162. * * minPitch: the minimum angle the bone will yaw to
  121163. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121164. * * upAxis: the up axis of the coordinate system
  121165. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121166. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121167. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121168. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121169. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121170. * * adjustRoll: used to make an adjustment to the roll of the bone
  121171. **/
  121172. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121173. maxYaw?: number;
  121174. minYaw?: number;
  121175. maxPitch?: number;
  121176. minPitch?: number;
  121177. slerpAmount?: number;
  121178. upAxis?: Vector3;
  121179. upAxisSpace?: Space;
  121180. yawAxis?: Vector3;
  121181. pitchAxis?: Vector3;
  121182. adjustYaw?: number;
  121183. adjustPitch?: number;
  121184. adjustRoll?: number;
  121185. });
  121186. /**
  121187. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121188. */
  121189. update(): void;
  121190. private _getAngleDiff;
  121191. private _getAngleBetween;
  121192. private _isAngleBetween;
  121193. }
  121194. }
  121195. declare module BABYLON {
  121196. /**
  121197. * Manage the gamepad inputs to control an arc rotate camera.
  121198. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121199. */
  121200. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121201. /**
  121202. * Defines the camera the input is attached to.
  121203. */
  121204. camera: ArcRotateCamera;
  121205. /**
  121206. * Defines the gamepad the input is gathering event from.
  121207. */
  121208. gamepad: Nullable<Gamepad>;
  121209. /**
  121210. * Defines the gamepad rotation sensiblity.
  121211. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121212. */
  121213. gamepadRotationSensibility: number;
  121214. /**
  121215. * Defines the gamepad move sensiblity.
  121216. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121217. */
  121218. gamepadMoveSensibility: number;
  121219. private _yAxisScale;
  121220. /**
  121221. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121222. */
  121223. get invertYAxis(): boolean;
  121224. set invertYAxis(value: boolean);
  121225. private _onGamepadConnectedObserver;
  121226. private _onGamepadDisconnectedObserver;
  121227. /**
  121228. * Attach the input controls to a specific dom element to get the input from.
  121229. * @param element Defines the element the controls should be listened from
  121230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121231. */
  121232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121233. /**
  121234. * Detach the current controls from the specified dom element.
  121235. * @param element Defines the element to stop listening the inputs from
  121236. */
  121237. detachControl(element: Nullable<HTMLElement>): void;
  121238. /**
  121239. * Update the current camera state depending on the inputs that have been used this frame.
  121240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121241. */
  121242. checkInputs(): void;
  121243. /**
  121244. * Gets the class name of the current intput.
  121245. * @returns the class name
  121246. */
  121247. getClassName(): string;
  121248. /**
  121249. * Get the friendly name associated with the input class.
  121250. * @returns the input friendly name
  121251. */
  121252. getSimpleName(): string;
  121253. }
  121254. }
  121255. declare module BABYLON {
  121256. interface ArcRotateCameraInputsManager {
  121257. /**
  121258. * Add orientation input support to the input manager.
  121259. * @returns the current input manager
  121260. */
  121261. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121262. }
  121263. /**
  121264. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121266. */
  121267. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121268. /**
  121269. * Defines the camera the input is attached to.
  121270. */
  121271. camera: ArcRotateCamera;
  121272. /**
  121273. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121274. */
  121275. alphaCorrection: number;
  121276. /**
  121277. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121278. */
  121279. gammaCorrection: number;
  121280. private _alpha;
  121281. private _gamma;
  121282. private _dirty;
  121283. private _deviceOrientationHandler;
  121284. /**
  121285. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121286. */
  121287. constructor();
  121288. /**
  121289. * Attach the input controls to a specific dom element to get the input from.
  121290. * @param element Defines the element the controls should be listened from
  121291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121292. */
  121293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121294. /** @hidden */
  121295. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121296. /**
  121297. * Update the current camera state depending on the inputs that have been used this frame.
  121298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121299. */
  121300. checkInputs(): void;
  121301. /**
  121302. * Detach the current controls from the specified dom element.
  121303. * @param element Defines the element to stop listening the inputs from
  121304. */
  121305. detachControl(element: Nullable<HTMLElement>): void;
  121306. /**
  121307. * Gets the class name of the current intput.
  121308. * @returns the class name
  121309. */
  121310. getClassName(): string;
  121311. /**
  121312. * Get the friendly name associated with the input class.
  121313. * @returns the input friendly name
  121314. */
  121315. getSimpleName(): string;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. /**
  121320. * Listen to mouse events to control the camera.
  121321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121322. */
  121323. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121324. /**
  121325. * Defines the camera the input is attached to.
  121326. */
  121327. camera: FlyCamera;
  121328. /**
  121329. * Defines if touch is enabled. (Default is true.)
  121330. */
  121331. touchEnabled: boolean;
  121332. /**
  121333. * Defines the buttons associated with the input to handle camera rotation.
  121334. */
  121335. buttons: number[];
  121336. /**
  121337. * Assign buttons for Yaw control.
  121338. */
  121339. buttonsYaw: number[];
  121340. /**
  121341. * Assign buttons for Pitch control.
  121342. */
  121343. buttonsPitch: number[];
  121344. /**
  121345. * Assign buttons for Roll control.
  121346. */
  121347. buttonsRoll: number[];
  121348. /**
  121349. * Detect if any button is being pressed while mouse is moved.
  121350. * -1 = Mouse locked.
  121351. * 0 = Left button.
  121352. * 1 = Middle Button.
  121353. * 2 = Right Button.
  121354. */
  121355. activeButton: number;
  121356. /**
  121357. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121358. * Higher values reduce its sensitivity.
  121359. */
  121360. angularSensibility: number;
  121361. private _mousemoveCallback;
  121362. private _observer;
  121363. private _rollObserver;
  121364. private previousPosition;
  121365. private noPreventDefault;
  121366. private element;
  121367. /**
  121368. * Listen to mouse events to control the camera.
  121369. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121370. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121371. */
  121372. constructor(touchEnabled?: boolean);
  121373. /**
  121374. * Attach the mouse control to the HTML DOM element.
  121375. * @param element Defines the element that listens to the input events.
  121376. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121377. */
  121378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121379. /**
  121380. * Detach the current controls from the specified dom element.
  121381. * @param element Defines the element to stop listening the inputs from
  121382. */
  121383. detachControl(element: Nullable<HTMLElement>): void;
  121384. /**
  121385. * Gets the class name of the current input.
  121386. * @returns the class name.
  121387. */
  121388. getClassName(): string;
  121389. /**
  121390. * Get the friendly name associated with the input class.
  121391. * @returns the input's friendly name.
  121392. */
  121393. getSimpleName(): string;
  121394. private _pointerInput;
  121395. private _onMouseMove;
  121396. /**
  121397. * Rotate camera by mouse offset.
  121398. */
  121399. private rotateCamera;
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /**
  121404. * Default Inputs manager for the FlyCamera.
  121405. * It groups all the default supported inputs for ease of use.
  121406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121407. */
  121408. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121409. /**
  121410. * Instantiates a new FlyCameraInputsManager.
  121411. * @param camera Defines the camera the inputs belong to.
  121412. */
  121413. constructor(camera: FlyCamera);
  121414. /**
  121415. * Add keyboard input support to the input manager.
  121416. * @returns the new FlyCameraKeyboardMoveInput().
  121417. */
  121418. addKeyboard(): FlyCameraInputsManager;
  121419. /**
  121420. * Add mouse input support to the input manager.
  121421. * @param touchEnabled Enable touch screen support.
  121422. * @returns the new FlyCameraMouseInput().
  121423. */
  121424. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121425. }
  121426. }
  121427. declare module BABYLON {
  121428. /**
  121429. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121430. * such as in a 3D Space Shooter or a Flight Simulator.
  121431. */
  121432. export class FlyCamera extends TargetCamera {
  121433. /**
  121434. * Define the collision ellipsoid of the camera.
  121435. * This is helpful for simulating a camera body, like a player's body.
  121436. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121437. */
  121438. ellipsoid: Vector3;
  121439. /**
  121440. * Define an offset for the position of the ellipsoid around the camera.
  121441. * This can be helpful if the camera is attached away from the player's body center,
  121442. * such as at its head.
  121443. */
  121444. ellipsoidOffset: Vector3;
  121445. /**
  121446. * Enable or disable collisions of the camera with the rest of the scene objects.
  121447. */
  121448. checkCollisions: boolean;
  121449. /**
  121450. * Enable or disable gravity on the camera.
  121451. */
  121452. applyGravity: boolean;
  121453. /**
  121454. * Define the current direction the camera is moving to.
  121455. */
  121456. cameraDirection: Vector3;
  121457. /**
  121458. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121459. * This overrides and empties cameraRotation.
  121460. */
  121461. rotationQuaternion: Quaternion;
  121462. /**
  121463. * Track Roll to maintain the wanted Rolling when looking around.
  121464. */
  121465. _trackRoll: number;
  121466. /**
  121467. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121468. */
  121469. rollCorrect: number;
  121470. /**
  121471. * Mimic a banked turn, Rolling the camera when Yawing.
  121472. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121473. */
  121474. bankedTurn: boolean;
  121475. /**
  121476. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121477. */
  121478. bankedTurnLimit: number;
  121479. /**
  121480. * Value of 0 disables the banked Roll.
  121481. * Value of 1 is equal to the Yaw angle in radians.
  121482. */
  121483. bankedTurnMultiplier: number;
  121484. /**
  121485. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121486. */
  121487. inputs: FlyCameraInputsManager;
  121488. /**
  121489. * Gets the input sensibility for mouse input.
  121490. * Higher values reduce sensitivity.
  121491. */
  121492. get angularSensibility(): number;
  121493. /**
  121494. * Sets the input sensibility for a mouse input.
  121495. * Higher values reduce sensitivity.
  121496. */
  121497. set angularSensibility(value: number);
  121498. /**
  121499. * Get the keys for camera movement forward.
  121500. */
  121501. get keysForward(): number[];
  121502. /**
  121503. * Set the keys for camera movement forward.
  121504. */
  121505. set keysForward(value: number[]);
  121506. /**
  121507. * Get the keys for camera movement backward.
  121508. */
  121509. get keysBackward(): number[];
  121510. set keysBackward(value: number[]);
  121511. /**
  121512. * Get the keys for camera movement up.
  121513. */
  121514. get keysUp(): number[];
  121515. /**
  121516. * Set the keys for camera movement up.
  121517. */
  121518. set keysUp(value: number[]);
  121519. /**
  121520. * Get the keys for camera movement down.
  121521. */
  121522. get keysDown(): number[];
  121523. /**
  121524. * Set the keys for camera movement down.
  121525. */
  121526. set keysDown(value: number[]);
  121527. /**
  121528. * Get the keys for camera movement left.
  121529. */
  121530. get keysLeft(): number[];
  121531. /**
  121532. * Set the keys for camera movement left.
  121533. */
  121534. set keysLeft(value: number[]);
  121535. /**
  121536. * Set the keys for camera movement right.
  121537. */
  121538. get keysRight(): number[];
  121539. /**
  121540. * Set the keys for camera movement right.
  121541. */
  121542. set keysRight(value: number[]);
  121543. /**
  121544. * Event raised when the camera collides with a mesh in the scene.
  121545. */
  121546. onCollide: (collidedMesh: AbstractMesh) => void;
  121547. private _collider;
  121548. private _needMoveForGravity;
  121549. private _oldPosition;
  121550. private _diffPosition;
  121551. private _newPosition;
  121552. /** @hidden */
  121553. _localDirection: Vector3;
  121554. /** @hidden */
  121555. _transformedDirection: Vector3;
  121556. /**
  121557. * Instantiates a FlyCamera.
  121558. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121559. * such as in a 3D Space Shooter or a Flight Simulator.
  121560. * @param name Define the name of the camera in the scene.
  121561. * @param position Define the starting position of the camera in the scene.
  121562. * @param scene Define the scene the camera belongs to.
  121563. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121564. */
  121565. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121566. /**
  121567. * Attach a control to the HTML DOM element.
  121568. * @param element Defines the element that listens to the input events.
  121569. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121570. */
  121571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121572. /**
  121573. * Detach a control from the HTML DOM element.
  121574. * The camera will stop reacting to that input.
  121575. * @param element Defines the element that listens to the input events.
  121576. */
  121577. detachControl(element: HTMLElement): void;
  121578. private _collisionMask;
  121579. /**
  121580. * Get the mask that the camera ignores in collision events.
  121581. */
  121582. get collisionMask(): number;
  121583. /**
  121584. * Set the mask that the camera ignores in collision events.
  121585. */
  121586. set collisionMask(mask: number);
  121587. /** @hidden */
  121588. _collideWithWorld(displacement: Vector3): void;
  121589. /** @hidden */
  121590. private _onCollisionPositionChange;
  121591. /** @hidden */
  121592. _checkInputs(): void;
  121593. /** @hidden */
  121594. _decideIfNeedsToMove(): boolean;
  121595. /** @hidden */
  121596. _updatePosition(): void;
  121597. /**
  121598. * Restore the Roll to its target value at the rate specified.
  121599. * @param rate - Higher means slower restoring.
  121600. * @hidden
  121601. */
  121602. restoreRoll(rate: number): void;
  121603. /**
  121604. * Destroy the camera and release the current resources held by it.
  121605. */
  121606. dispose(): void;
  121607. /**
  121608. * Get the current object class name.
  121609. * @returns the class name.
  121610. */
  121611. getClassName(): string;
  121612. }
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * Listen to keyboard events to control the camera.
  121617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121618. */
  121619. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121620. /**
  121621. * Defines the camera the input is attached to.
  121622. */
  121623. camera: FlyCamera;
  121624. /**
  121625. * The list of keyboard keys used to control the forward move of the camera.
  121626. */
  121627. keysForward: number[];
  121628. /**
  121629. * The list of keyboard keys used to control the backward move of the camera.
  121630. */
  121631. keysBackward: number[];
  121632. /**
  121633. * The list of keyboard keys used to control the forward move of the camera.
  121634. */
  121635. keysUp: number[];
  121636. /**
  121637. * The list of keyboard keys used to control the backward move of the camera.
  121638. */
  121639. keysDown: number[];
  121640. /**
  121641. * The list of keyboard keys used to control the right strafe move of the camera.
  121642. */
  121643. keysRight: number[];
  121644. /**
  121645. * The list of keyboard keys used to control the left strafe move of the camera.
  121646. */
  121647. keysLeft: number[];
  121648. private _keys;
  121649. private _onCanvasBlurObserver;
  121650. private _onKeyboardObserver;
  121651. private _engine;
  121652. private _scene;
  121653. /**
  121654. * Attach the input controls to a specific dom element to get the input from.
  121655. * @param element Defines the element the controls should be listened from
  121656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121657. */
  121658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121659. /**
  121660. * Detach the current controls from the specified dom element.
  121661. * @param element Defines the element to stop listening the inputs from
  121662. */
  121663. detachControl(element: Nullable<HTMLElement>): void;
  121664. /**
  121665. * Gets the class name of the current intput.
  121666. * @returns the class name
  121667. */
  121668. getClassName(): string;
  121669. /** @hidden */
  121670. _onLostFocus(e: FocusEvent): void;
  121671. /**
  121672. * Get the friendly name associated with the input class.
  121673. * @returns the input friendly name
  121674. */
  121675. getSimpleName(): string;
  121676. /**
  121677. * Update the current camera state depending on the inputs that have been used this frame.
  121678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121679. */
  121680. checkInputs(): void;
  121681. }
  121682. }
  121683. declare module BABYLON {
  121684. /**
  121685. * Manage the mouse wheel inputs to control a follow camera.
  121686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121687. */
  121688. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121689. /**
  121690. * Defines the camera the input is attached to.
  121691. */
  121692. camera: FollowCamera;
  121693. /**
  121694. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121695. */
  121696. axisControlRadius: boolean;
  121697. /**
  121698. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121699. */
  121700. axisControlHeight: boolean;
  121701. /**
  121702. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121703. */
  121704. axisControlRotation: boolean;
  121705. /**
  121706. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121707. * relation to mouseWheel events.
  121708. */
  121709. wheelPrecision: number;
  121710. /**
  121711. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121712. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121713. */
  121714. wheelDeltaPercentage: number;
  121715. private _wheel;
  121716. private _observer;
  121717. /**
  121718. * Attach the input controls to a specific dom element to get the input from.
  121719. * @param element Defines the element the controls should be listened from
  121720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121721. */
  121722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121723. /**
  121724. * Detach the current controls from the specified dom element.
  121725. * @param element Defines the element to stop listening the inputs from
  121726. */
  121727. detachControl(element: Nullable<HTMLElement>): void;
  121728. /**
  121729. * Gets the class name of the current intput.
  121730. * @returns the class name
  121731. */
  121732. getClassName(): string;
  121733. /**
  121734. * Get the friendly name associated with the input class.
  121735. * @returns the input friendly name
  121736. */
  121737. getSimpleName(): string;
  121738. }
  121739. }
  121740. declare module BABYLON {
  121741. /**
  121742. * Manage the pointers inputs to control an follow camera.
  121743. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121744. */
  121745. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121746. /**
  121747. * Defines the camera the input is attached to.
  121748. */
  121749. camera: FollowCamera;
  121750. /**
  121751. * Gets the class name of the current input.
  121752. * @returns the class name
  121753. */
  121754. getClassName(): string;
  121755. /**
  121756. * Defines the pointer angular sensibility along the X axis or how fast is
  121757. * the camera rotating.
  121758. * A negative number will reverse the axis direction.
  121759. */
  121760. angularSensibilityX: number;
  121761. /**
  121762. * Defines the pointer angular sensibility along the Y axis or how fast is
  121763. * the camera rotating.
  121764. * A negative number will reverse the axis direction.
  121765. */
  121766. angularSensibilityY: number;
  121767. /**
  121768. * Defines the pointer pinch precision or how fast is the camera zooming.
  121769. * A negative number will reverse the axis direction.
  121770. */
  121771. pinchPrecision: number;
  121772. /**
  121773. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121774. * from 0.
  121775. * It defines the percentage of current camera.radius to use as delta when
  121776. * pinch zoom is used.
  121777. */
  121778. pinchDeltaPercentage: number;
  121779. /**
  121780. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121781. */
  121782. axisXControlRadius: boolean;
  121783. /**
  121784. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121785. */
  121786. axisXControlHeight: boolean;
  121787. /**
  121788. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121789. */
  121790. axisXControlRotation: boolean;
  121791. /**
  121792. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121793. */
  121794. axisYControlRadius: boolean;
  121795. /**
  121796. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121797. */
  121798. axisYControlHeight: boolean;
  121799. /**
  121800. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121801. */
  121802. axisYControlRotation: boolean;
  121803. /**
  121804. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121805. */
  121806. axisPinchControlRadius: boolean;
  121807. /**
  121808. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121809. */
  121810. axisPinchControlHeight: boolean;
  121811. /**
  121812. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121813. */
  121814. axisPinchControlRotation: boolean;
  121815. /**
  121816. * Log error messages if basic misconfiguration has occurred.
  121817. */
  121818. warningEnable: boolean;
  121819. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121820. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121821. private _warningCounter;
  121822. private _warning;
  121823. }
  121824. }
  121825. declare module BABYLON {
  121826. /**
  121827. * Default Inputs manager for the FollowCamera.
  121828. * It groups all the default supported inputs for ease of use.
  121829. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121830. */
  121831. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121832. /**
  121833. * Instantiates a new FollowCameraInputsManager.
  121834. * @param camera Defines the camera the inputs belong to
  121835. */
  121836. constructor(camera: FollowCamera);
  121837. /**
  121838. * Add keyboard input support to the input manager.
  121839. * @returns the current input manager
  121840. */
  121841. addKeyboard(): FollowCameraInputsManager;
  121842. /**
  121843. * Add mouse wheel input support to the input manager.
  121844. * @returns the current input manager
  121845. */
  121846. addMouseWheel(): FollowCameraInputsManager;
  121847. /**
  121848. * Add pointers input support to the input manager.
  121849. * @returns the current input manager
  121850. */
  121851. addPointers(): FollowCameraInputsManager;
  121852. /**
  121853. * Add orientation input support to the input manager.
  121854. * @returns the current input manager
  121855. */
  121856. addVRDeviceOrientation(): FollowCameraInputsManager;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121862. * an arc rotate version arcFollowCamera are available.
  121863. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121864. */
  121865. export class FollowCamera extends TargetCamera {
  121866. /**
  121867. * Distance the follow camera should follow an object at
  121868. */
  121869. radius: number;
  121870. /**
  121871. * Minimum allowed distance of the camera to the axis of rotation
  121872. * (The camera can not get closer).
  121873. * This can help limiting how the Camera is able to move in the scene.
  121874. */
  121875. lowerRadiusLimit: Nullable<number>;
  121876. /**
  121877. * Maximum allowed distance of the camera to the axis of rotation
  121878. * (The camera can not get further).
  121879. * This can help limiting how the Camera is able to move in the scene.
  121880. */
  121881. upperRadiusLimit: Nullable<number>;
  121882. /**
  121883. * Define a rotation offset between the camera and the object it follows
  121884. */
  121885. rotationOffset: number;
  121886. /**
  121887. * Minimum allowed angle to camera position relative to target object.
  121888. * This can help limiting how the Camera is able to move in the scene.
  121889. */
  121890. lowerRotationOffsetLimit: Nullable<number>;
  121891. /**
  121892. * Maximum allowed angle to camera position relative to target object.
  121893. * This can help limiting how the Camera is able to move in the scene.
  121894. */
  121895. upperRotationOffsetLimit: Nullable<number>;
  121896. /**
  121897. * Define a height offset between the camera and the object it follows.
  121898. * It can help following an object from the top (like a car chaing a plane)
  121899. */
  121900. heightOffset: number;
  121901. /**
  121902. * Minimum allowed height of camera position relative to target object.
  121903. * This can help limiting how the Camera is able to move in the scene.
  121904. */
  121905. lowerHeightOffsetLimit: Nullable<number>;
  121906. /**
  121907. * Maximum allowed height of camera position relative to target object.
  121908. * This can help limiting how the Camera is able to move in the scene.
  121909. */
  121910. upperHeightOffsetLimit: Nullable<number>;
  121911. /**
  121912. * Define how fast the camera can accelerate to follow it s target.
  121913. */
  121914. cameraAcceleration: number;
  121915. /**
  121916. * Define the speed limit of the camera following an object.
  121917. */
  121918. maxCameraSpeed: number;
  121919. /**
  121920. * Define the target of the camera.
  121921. */
  121922. lockedTarget: Nullable<AbstractMesh>;
  121923. /**
  121924. * Defines the input associated with the camera.
  121925. */
  121926. inputs: FollowCameraInputsManager;
  121927. /**
  121928. * Instantiates the follow camera.
  121929. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121930. * @param name Define the name of the camera in the scene
  121931. * @param position Define the position of the camera
  121932. * @param scene Define the scene the camera belong to
  121933. * @param lockedTarget Define the target of the camera
  121934. */
  121935. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121936. private _follow;
  121937. /**
  121938. * Attached controls to the current camera.
  121939. * @param element Defines the element the controls should be listened from
  121940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121941. */
  121942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121943. /**
  121944. * Detach the current controls from the camera.
  121945. * The camera will stop reacting to inputs.
  121946. * @param element Defines the element to stop listening the inputs from
  121947. */
  121948. detachControl(element: HTMLElement): void;
  121949. /** @hidden */
  121950. _checkInputs(): void;
  121951. private _checkLimits;
  121952. /**
  121953. * Gets the camera class name.
  121954. * @returns the class name
  121955. */
  121956. getClassName(): string;
  121957. }
  121958. /**
  121959. * Arc Rotate version of the follow camera.
  121960. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121961. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121962. */
  121963. export class ArcFollowCamera extends TargetCamera {
  121964. /** The longitudinal angle of the camera */
  121965. alpha: number;
  121966. /** The latitudinal angle of the camera */
  121967. beta: number;
  121968. /** The radius of the camera from its target */
  121969. radius: number;
  121970. /** Define the camera target (the mesh it should follow) */
  121971. target: Nullable<AbstractMesh>;
  121972. private _cartesianCoordinates;
  121973. /**
  121974. * Instantiates a new ArcFollowCamera
  121975. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  121976. * @param name Define the name of the camera
  121977. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121978. * @param beta Define the rotation angle of the camera around the elevation axis
  121979. * @param radius Define the radius of the camera from its target point
  121980. * @param target Define the target of the camera
  121981. * @param scene Define the scene the camera belongs to
  121982. */
  121983. constructor(name: string,
  121984. /** The longitudinal angle of the camera */
  121985. alpha: number,
  121986. /** The latitudinal angle of the camera */
  121987. beta: number,
  121988. /** The radius of the camera from its target */
  121989. radius: number,
  121990. /** Define the camera target (the mesh it should follow) */
  121991. target: Nullable<AbstractMesh>, scene: Scene);
  121992. private _follow;
  121993. /** @hidden */
  121994. _checkInputs(): void;
  121995. /**
  121996. * Returns the class name of the object.
  121997. * It is mostly used internally for serialization purposes.
  121998. */
  121999. getClassName(): string;
  122000. }
  122001. }
  122002. declare module BABYLON {
  122003. /**
  122004. * Manage the keyboard inputs to control the movement of a follow camera.
  122005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122006. */
  122007. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122008. /**
  122009. * Defines the camera the input is attached to.
  122010. */
  122011. camera: FollowCamera;
  122012. /**
  122013. * Defines the list of key codes associated with the up action (increase heightOffset)
  122014. */
  122015. keysHeightOffsetIncr: number[];
  122016. /**
  122017. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122018. */
  122019. keysHeightOffsetDecr: number[];
  122020. /**
  122021. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122022. */
  122023. keysHeightOffsetModifierAlt: boolean;
  122024. /**
  122025. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122026. */
  122027. keysHeightOffsetModifierCtrl: boolean;
  122028. /**
  122029. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122030. */
  122031. keysHeightOffsetModifierShift: boolean;
  122032. /**
  122033. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122034. */
  122035. keysRotationOffsetIncr: number[];
  122036. /**
  122037. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122038. */
  122039. keysRotationOffsetDecr: number[];
  122040. /**
  122041. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122042. */
  122043. keysRotationOffsetModifierAlt: boolean;
  122044. /**
  122045. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122046. */
  122047. keysRotationOffsetModifierCtrl: boolean;
  122048. /**
  122049. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122050. */
  122051. keysRotationOffsetModifierShift: boolean;
  122052. /**
  122053. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122054. */
  122055. keysRadiusIncr: number[];
  122056. /**
  122057. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122058. */
  122059. keysRadiusDecr: number[];
  122060. /**
  122061. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122062. */
  122063. keysRadiusModifierAlt: boolean;
  122064. /**
  122065. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122066. */
  122067. keysRadiusModifierCtrl: boolean;
  122068. /**
  122069. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122070. */
  122071. keysRadiusModifierShift: boolean;
  122072. /**
  122073. * Defines the rate of change of heightOffset.
  122074. */
  122075. heightSensibility: number;
  122076. /**
  122077. * Defines the rate of change of rotationOffset.
  122078. */
  122079. rotationSensibility: number;
  122080. /**
  122081. * Defines the rate of change of radius.
  122082. */
  122083. radiusSensibility: number;
  122084. private _keys;
  122085. private _ctrlPressed;
  122086. private _altPressed;
  122087. private _shiftPressed;
  122088. private _onCanvasBlurObserver;
  122089. private _onKeyboardObserver;
  122090. private _engine;
  122091. private _scene;
  122092. /**
  122093. * Attach the input controls to a specific dom element to get the input from.
  122094. * @param element Defines the element the controls should be listened from
  122095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122096. */
  122097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122098. /**
  122099. * Detach the current controls from the specified dom element.
  122100. * @param element Defines the element to stop listening the inputs from
  122101. */
  122102. detachControl(element: Nullable<HTMLElement>): void;
  122103. /**
  122104. * Update the current camera state depending on the inputs that have been used this frame.
  122105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122106. */
  122107. checkInputs(): void;
  122108. /**
  122109. * Gets the class name of the current input.
  122110. * @returns the class name
  122111. */
  122112. getClassName(): string;
  122113. /**
  122114. * Get the friendly name associated with the input class.
  122115. * @returns the input friendly name
  122116. */
  122117. getSimpleName(): string;
  122118. /**
  122119. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122120. * allow modification of the heightOffset value.
  122121. */
  122122. private _modifierHeightOffset;
  122123. /**
  122124. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122125. * allow modification of the rotationOffset value.
  122126. */
  122127. private _modifierRotationOffset;
  122128. /**
  122129. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122130. * allow modification of the radius value.
  122131. */
  122132. private _modifierRadius;
  122133. }
  122134. }
  122135. declare module BABYLON {
  122136. interface FreeCameraInputsManager {
  122137. /**
  122138. * @hidden
  122139. */
  122140. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122141. /**
  122142. * Add orientation input support to the input manager.
  122143. * @returns the current input manager
  122144. */
  122145. addDeviceOrientation(): FreeCameraInputsManager;
  122146. }
  122147. /**
  122148. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122149. * Screen rotation is taken into account.
  122150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122151. */
  122152. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122153. private _camera;
  122154. private _screenOrientationAngle;
  122155. private _constantTranform;
  122156. private _screenQuaternion;
  122157. private _alpha;
  122158. private _beta;
  122159. private _gamma;
  122160. /**
  122161. * Can be used to detect if a device orientation sensor is available on a device
  122162. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122163. * @returns a promise that will resolve on orientation change
  122164. */
  122165. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122166. /**
  122167. * @hidden
  122168. */
  122169. _onDeviceOrientationChangedObservable: Observable<void>;
  122170. /**
  122171. * Instantiates a new input
  122172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122173. */
  122174. constructor();
  122175. /**
  122176. * Define the camera controlled by the input.
  122177. */
  122178. get camera(): FreeCamera;
  122179. set camera(camera: FreeCamera);
  122180. /**
  122181. * Attach the input controls to a specific dom element to get the input from.
  122182. * @param element Defines the element the controls should be listened from
  122183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122184. */
  122185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122186. private _orientationChanged;
  122187. private _deviceOrientation;
  122188. /**
  122189. * Detach the current controls from the specified dom element.
  122190. * @param element Defines the element to stop listening the inputs from
  122191. */
  122192. detachControl(element: Nullable<HTMLElement>): void;
  122193. /**
  122194. * Update the current camera state depending on the inputs that have been used this frame.
  122195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122196. */
  122197. checkInputs(): void;
  122198. /**
  122199. * Gets the class name of the current intput.
  122200. * @returns the class name
  122201. */
  122202. getClassName(): string;
  122203. /**
  122204. * Get the friendly name associated with the input class.
  122205. * @returns the input friendly name
  122206. */
  122207. getSimpleName(): string;
  122208. }
  122209. }
  122210. declare module BABYLON {
  122211. /**
  122212. * Manage the gamepad inputs to control a free camera.
  122213. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122214. */
  122215. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122216. /**
  122217. * Define the camera the input is attached to.
  122218. */
  122219. camera: FreeCamera;
  122220. /**
  122221. * Define the Gamepad controlling the input
  122222. */
  122223. gamepad: Nullable<Gamepad>;
  122224. /**
  122225. * Defines the gamepad rotation sensiblity.
  122226. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122227. */
  122228. gamepadAngularSensibility: number;
  122229. /**
  122230. * Defines the gamepad move sensiblity.
  122231. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122232. */
  122233. gamepadMoveSensibility: number;
  122234. private _yAxisScale;
  122235. /**
  122236. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122237. */
  122238. get invertYAxis(): boolean;
  122239. set invertYAxis(value: boolean);
  122240. private _onGamepadConnectedObserver;
  122241. private _onGamepadDisconnectedObserver;
  122242. private _cameraTransform;
  122243. private _deltaTransform;
  122244. private _vector3;
  122245. private _vector2;
  122246. /**
  122247. * Attach the input controls to a specific dom element to get the input from.
  122248. * @param element Defines the element the controls should be listened from
  122249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122250. */
  122251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122252. /**
  122253. * Detach the current controls from the specified dom element.
  122254. * @param element Defines the element to stop listening the inputs from
  122255. */
  122256. detachControl(element: Nullable<HTMLElement>): void;
  122257. /**
  122258. * Update the current camera state depending on the inputs that have been used this frame.
  122259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122260. */
  122261. checkInputs(): void;
  122262. /**
  122263. * Gets the class name of the current intput.
  122264. * @returns the class name
  122265. */
  122266. getClassName(): string;
  122267. /**
  122268. * Get the friendly name associated with the input class.
  122269. * @returns the input friendly name
  122270. */
  122271. getSimpleName(): string;
  122272. }
  122273. }
  122274. declare module BABYLON {
  122275. /**
  122276. * Defines the potential axis of a Joystick
  122277. */
  122278. export enum JoystickAxis {
  122279. /** X axis */
  122280. X = 0,
  122281. /** Y axis */
  122282. Y = 1,
  122283. /** Z axis */
  122284. Z = 2
  122285. }
  122286. /**
  122287. * Represents the different customization options available
  122288. * for VirtualJoystick
  122289. */
  122290. interface VirtualJoystickCustomizations {
  122291. /**
  122292. * Size of the joystick's puck
  122293. */
  122294. puckSize: number;
  122295. /**
  122296. * Size of the joystick's container
  122297. */
  122298. containerSize: number;
  122299. /**
  122300. * Color of the joystick && puck
  122301. */
  122302. color: string;
  122303. /**
  122304. * Image URL for the joystick's puck
  122305. */
  122306. puckImage?: string;
  122307. /**
  122308. * Image URL for the joystick's container
  122309. */
  122310. containerImage?: string;
  122311. /**
  122312. * Defines the unmoving position of the joystick container
  122313. */
  122314. position?: {
  122315. x: number;
  122316. y: number;
  122317. };
  122318. /**
  122319. * Defines whether or not the joystick container is always visible
  122320. */
  122321. alwaysVisible: boolean;
  122322. /**
  122323. * Defines whether or not to limit the movement of the puck to the joystick's container
  122324. */
  122325. limitToContainer: boolean;
  122326. }
  122327. /**
  122328. * Class used to define virtual joystick (used in touch mode)
  122329. */
  122330. export class VirtualJoystick {
  122331. /**
  122332. * Gets or sets a boolean indicating that left and right values must be inverted
  122333. */
  122334. reverseLeftRight: boolean;
  122335. /**
  122336. * Gets or sets a boolean indicating that up and down values must be inverted
  122337. */
  122338. reverseUpDown: boolean;
  122339. /**
  122340. * Gets the offset value for the position (ie. the change of the position value)
  122341. */
  122342. deltaPosition: Vector3;
  122343. /**
  122344. * Gets a boolean indicating if the virtual joystick was pressed
  122345. */
  122346. pressed: boolean;
  122347. /**
  122348. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122349. */
  122350. static Canvas: Nullable<HTMLCanvasElement>;
  122351. /**
  122352. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122353. */
  122354. limitToContainer: boolean;
  122355. private static _globalJoystickIndex;
  122356. private static _alwaysVisibleSticks;
  122357. private static vjCanvasContext;
  122358. private static vjCanvasWidth;
  122359. private static vjCanvasHeight;
  122360. private static halfWidth;
  122361. private static _GetDefaultOptions;
  122362. private _action;
  122363. private _axisTargetedByLeftAndRight;
  122364. private _axisTargetedByUpAndDown;
  122365. private _joystickSensibility;
  122366. private _inversedSensibility;
  122367. private _joystickPointerID;
  122368. private _joystickColor;
  122369. private _joystickPointerPos;
  122370. private _joystickPreviousPointerPos;
  122371. private _joystickPointerStartPos;
  122372. private _deltaJoystickVector;
  122373. private _leftJoystick;
  122374. private _touches;
  122375. private _joystickPosition;
  122376. private _alwaysVisible;
  122377. private _puckImage;
  122378. private _containerImage;
  122379. private _joystickPuckSize;
  122380. private _joystickContainerSize;
  122381. private _clearPuckSize;
  122382. private _clearContainerSize;
  122383. private _clearPuckSizeOffset;
  122384. private _clearContainerSizeOffset;
  122385. private _onPointerDownHandlerRef;
  122386. private _onPointerMoveHandlerRef;
  122387. private _onPointerUpHandlerRef;
  122388. private _onResize;
  122389. /**
  122390. * Creates a new virtual joystick
  122391. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122392. * @param customizations Defines the options we want to customize the VirtualJoystick
  122393. */
  122394. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122395. /**
  122396. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122397. * @param newJoystickSensibility defines the new sensibility
  122398. */
  122399. setJoystickSensibility(newJoystickSensibility: number): void;
  122400. private _onPointerDown;
  122401. private _onPointerMove;
  122402. private _onPointerUp;
  122403. /**
  122404. * Change the color of the virtual joystick
  122405. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122406. */
  122407. setJoystickColor(newColor: string): void;
  122408. /**
  122409. * Size of the joystick's container
  122410. */
  122411. set containerSize(newSize: number);
  122412. get containerSize(): number;
  122413. /**
  122414. * Size of the joystick's puck
  122415. */
  122416. set puckSize(newSize: number);
  122417. get puckSize(): number;
  122418. /**
  122419. * Clears the set position of the joystick
  122420. */
  122421. clearPosition(): void;
  122422. /**
  122423. * Defines whether or not the joystick container is always visible
  122424. */
  122425. set alwaysVisible(value: boolean);
  122426. get alwaysVisible(): boolean;
  122427. /**
  122428. * Sets the constant position of the Joystick container
  122429. * @param x X axis coordinate
  122430. * @param y Y axis coordinate
  122431. */
  122432. setPosition(x: number, y: number): void;
  122433. /**
  122434. * Defines a callback to call when the joystick is touched
  122435. * @param action defines the callback
  122436. */
  122437. setActionOnTouch(action: () => any): void;
  122438. /**
  122439. * Defines which axis you'd like to control for left & right
  122440. * @param axis defines the axis to use
  122441. */
  122442. setAxisForLeftRight(axis: JoystickAxis): void;
  122443. /**
  122444. * Defines which axis you'd like to control for up & down
  122445. * @param axis defines the axis to use
  122446. */
  122447. setAxisForUpDown(axis: JoystickAxis): void;
  122448. /**
  122449. * Clears the canvas from the previous puck / container draw
  122450. */
  122451. private _clearPreviousDraw;
  122452. /**
  122453. * Loads `urlPath` to be used for the container's image
  122454. * @param urlPath defines the urlPath of an image to use
  122455. */
  122456. setContainerImage(urlPath: string): void;
  122457. /**
  122458. * Loads `urlPath` to be used for the puck's image
  122459. * @param urlPath defines the urlPath of an image to use
  122460. */
  122461. setPuckImage(urlPath: string): void;
  122462. /**
  122463. * Draws the Virtual Joystick's container
  122464. */
  122465. private _drawContainer;
  122466. /**
  122467. * Draws the Virtual Joystick's puck
  122468. */
  122469. private _drawPuck;
  122470. private _drawVirtualJoystick;
  122471. /**
  122472. * Release internal HTML canvas
  122473. */
  122474. releaseCanvas(): void;
  122475. }
  122476. }
  122477. declare module BABYLON {
  122478. interface FreeCameraInputsManager {
  122479. /**
  122480. * Add virtual joystick input support to the input manager.
  122481. * @returns the current input manager
  122482. */
  122483. addVirtualJoystick(): FreeCameraInputsManager;
  122484. }
  122485. /**
  122486. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122488. */
  122489. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122490. /**
  122491. * Defines the camera the input is attached to.
  122492. */
  122493. camera: FreeCamera;
  122494. private _leftjoystick;
  122495. private _rightjoystick;
  122496. /**
  122497. * Gets the left stick of the virtual joystick.
  122498. * @returns The virtual Joystick
  122499. */
  122500. getLeftJoystick(): VirtualJoystick;
  122501. /**
  122502. * Gets the right stick of the virtual joystick.
  122503. * @returns The virtual Joystick
  122504. */
  122505. getRightJoystick(): VirtualJoystick;
  122506. /**
  122507. * Update the current camera state depending on the inputs that have been used this frame.
  122508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122509. */
  122510. checkInputs(): void;
  122511. /**
  122512. * Attach the input controls to a specific dom element to get the input from.
  122513. * @param element Defines the element the controls should be listened from
  122514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122515. */
  122516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122517. /**
  122518. * Detach the current controls from the specified dom element.
  122519. * @param element Defines the element to stop listening the inputs from
  122520. */
  122521. detachControl(element: Nullable<HTMLElement>): void;
  122522. /**
  122523. * Gets the class name of the current intput.
  122524. * @returns the class name
  122525. */
  122526. getClassName(): string;
  122527. /**
  122528. * Get the friendly name associated with the input class.
  122529. * @returns the input friendly name
  122530. */
  122531. getSimpleName(): string;
  122532. }
  122533. }
  122534. declare module BABYLON {
  122535. /**
  122536. * This represents a FPS type of camera controlled by touch.
  122537. * This is like a universal camera minus the Gamepad controls.
  122538. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122539. */
  122540. export class TouchCamera extends FreeCamera {
  122541. /**
  122542. * Defines the touch sensibility for rotation.
  122543. * The higher the faster.
  122544. */
  122545. get touchAngularSensibility(): number;
  122546. set touchAngularSensibility(value: number);
  122547. /**
  122548. * Defines the touch sensibility for move.
  122549. * The higher the faster.
  122550. */
  122551. get touchMoveSensibility(): number;
  122552. set touchMoveSensibility(value: number);
  122553. /**
  122554. * Instantiates a new touch camera.
  122555. * This represents a FPS type of camera controlled by touch.
  122556. * This is like a universal camera minus the Gamepad controls.
  122557. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122558. * @param name Define the name of the camera in the scene
  122559. * @param position Define the start position of the camera in the scene
  122560. * @param scene Define the scene the camera belongs to
  122561. */
  122562. constructor(name: string, position: Vector3, scene: Scene);
  122563. /**
  122564. * Gets the current object class name.
  122565. * @return the class name
  122566. */
  122567. getClassName(): string;
  122568. /** @hidden */
  122569. _setupInputs(): void;
  122570. }
  122571. }
  122572. declare module BABYLON {
  122573. /**
  122574. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122575. * being tilted forward or back and left or right.
  122576. */
  122577. export class DeviceOrientationCamera extends FreeCamera {
  122578. private _initialQuaternion;
  122579. private _quaternionCache;
  122580. private _tmpDragQuaternion;
  122581. private _disablePointerInputWhenUsingDeviceOrientation;
  122582. /**
  122583. * Creates a new device orientation camera
  122584. * @param name The name of the camera
  122585. * @param position The start position camera
  122586. * @param scene The scene the camera belongs to
  122587. */
  122588. constructor(name: string, position: Vector3, scene: Scene);
  122589. /**
  122590. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122591. */
  122592. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122593. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122594. private _dragFactor;
  122595. /**
  122596. * Enabled turning on the y axis when the orientation sensor is active
  122597. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122598. */
  122599. enableHorizontalDragging(dragFactor?: number): void;
  122600. /**
  122601. * Gets the current instance class name ("DeviceOrientationCamera").
  122602. * This helps avoiding instanceof at run time.
  122603. * @returns the class name
  122604. */
  122605. getClassName(): string;
  122606. /**
  122607. * @hidden
  122608. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122609. */
  122610. _checkInputs(): void;
  122611. /**
  122612. * Reset the camera to its default orientation on the specified axis only.
  122613. * @param axis The axis to reset
  122614. */
  122615. resetToCurrentRotation(axis?: Axis): void;
  122616. }
  122617. }
  122618. declare module BABYLON {
  122619. /**
  122620. * Defines supported buttons for XBox360 compatible gamepads
  122621. */
  122622. export enum Xbox360Button {
  122623. /** A */
  122624. A = 0,
  122625. /** B */
  122626. B = 1,
  122627. /** X */
  122628. X = 2,
  122629. /** Y */
  122630. Y = 3,
  122631. /** Left button */
  122632. LB = 4,
  122633. /** Right button */
  122634. RB = 5,
  122635. /** Back */
  122636. Back = 8,
  122637. /** Start */
  122638. Start = 9,
  122639. /** Left stick */
  122640. LeftStick = 10,
  122641. /** Right stick */
  122642. RightStick = 11
  122643. }
  122644. /** Defines values for XBox360 DPad */
  122645. export enum Xbox360Dpad {
  122646. /** Up */
  122647. Up = 12,
  122648. /** Down */
  122649. Down = 13,
  122650. /** Left */
  122651. Left = 14,
  122652. /** Right */
  122653. Right = 15
  122654. }
  122655. /**
  122656. * Defines a XBox360 gamepad
  122657. */
  122658. export class Xbox360Pad extends Gamepad {
  122659. private _leftTrigger;
  122660. private _rightTrigger;
  122661. private _onlefttriggerchanged;
  122662. private _onrighttriggerchanged;
  122663. private _onbuttondown;
  122664. private _onbuttonup;
  122665. private _ondpaddown;
  122666. private _ondpadup;
  122667. /** Observable raised when a button is pressed */
  122668. onButtonDownObservable: Observable<Xbox360Button>;
  122669. /** Observable raised when a button is released */
  122670. onButtonUpObservable: Observable<Xbox360Button>;
  122671. /** Observable raised when a pad is pressed */
  122672. onPadDownObservable: Observable<Xbox360Dpad>;
  122673. /** Observable raised when a pad is released */
  122674. onPadUpObservable: Observable<Xbox360Dpad>;
  122675. private _buttonA;
  122676. private _buttonB;
  122677. private _buttonX;
  122678. private _buttonY;
  122679. private _buttonBack;
  122680. private _buttonStart;
  122681. private _buttonLB;
  122682. private _buttonRB;
  122683. private _buttonLeftStick;
  122684. private _buttonRightStick;
  122685. private _dPadUp;
  122686. private _dPadDown;
  122687. private _dPadLeft;
  122688. private _dPadRight;
  122689. private _isXboxOnePad;
  122690. /**
  122691. * Creates a new XBox360 gamepad object
  122692. * @param id defines the id of this gamepad
  122693. * @param index defines its index
  122694. * @param gamepad defines the internal HTML gamepad object
  122695. * @param xboxOne defines if it is a XBox One gamepad
  122696. */
  122697. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122698. /**
  122699. * Defines the callback to call when left trigger is pressed
  122700. * @param callback defines the callback to use
  122701. */
  122702. onlefttriggerchanged(callback: (value: number) => void): void;
  122703. /**
  122704. * Defines the callback to call when right trigger is pressed
  122705. * @param callback defines the callback to use
  122706. */
  122707. onrighttriggerchanged(callback: (value: number) => void): void;
  122708. /**
  122709. * Gets the left trigger value
  122710. */
  122711. get leftTrigger(): number;
  122712. /**
  122713. * Sets the left trigger value
  122714. */
  122715. set leftTrigger(newValue: number);
  122716. /**
  122717. * Gets the right trigger value
  122718. */
  122719. get rightTrigger(): number;
  122720. /**
  122721. * Sets the right trigger value
  122722. */
  122723. set rightTrigger(newValue: number);
  122724. /**
  122725. * Defines the callback to call when a button is pressed
  122726. * @param callback defines the callback to use
  122727. */
  122728. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122729. /**
  122730. * Defines the callback to call when a button is released
  122731. * @param callback defines the callback to use
  122732. */
  122733. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122734. /**
  122735. * Defines the callback to call when a pad is pressed
  122736. * @param callback defines the callback to use
  122737. */
  122738. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122739. /**
  122740. * Defines the callback to call when a pad is released
  122741. * @param callback defines the callback to use
  122742. */
  122743. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122744. private _setButtonValue;
  122745. private _setDPadValue;
  122746. /**
  122747. * Gets the value of the `A` button
  122748. */
  122749. get buttonA(): number;
  122750. /**
  122751. * Sets the value of the `A` button
  122752. */
  122753. set buttonA(value: number);
  122754. /**
  122755. * Gets the value of the `B` button
  122756. */
  122757. get buttonB(): number;
  122758. /**
  122759. * Sets the value of the `B` button
  122760. */
  122761. set buttonB(value: number);
  122762. /**
  122763. * Gets the value of the `X` button
  122764. */
  122765. get buttonX(): number;
  122766. /**
  122767. * Sets the value of the `X` button
  122768. */
  122769. set buttonX(value: number);
  122770. /**
  122771. * Gets the value of the `Y` button
  122772. */
  122773. get buttonY(): number;
  122774. /**
  122775. * Sets the value of the `Y` button
  122776. */
  122777. set buttonY(value: number);
  122778. /**
  122779. * Gets the value of the `Start` button
  122780. */
  122781. get buttonStart(): number;
  122782. /**
  122783. * Sets the value of the `Start` button
  122784. */
  122785. set buttonStart(value: number);
  122786. /**
  122787. * Gets the value of the `Back` button
  122788. */
  122789. get buttonBack(): number;
  122790. /**
  122791. * Sets the value of the `Back` button
  122792. */
  122793. set buttonBack(value: number);
  122794. /**
  122795. * Gets the value of the `Left` button
  122796. */
  122797. get buttonLB(): number;
  122798. /**
  122799. * Sets the value of the `Left` button
  122800. */
  122801. set buttonLB(value: number);
  122802. /**
  122803. * Gets the value of the `Right` button
  122804. */
  122805. get buttonRB(): number;
  122806. /**
  122807. * Sets the value of the `Right` button
  122808. */
  122809. set buttonRB(value: number);
  122810. /**
  122811. * Gets the value of the Left joystick
  122812. */
  122813. get buttonLeftStick(): number;
  122814. /**
  122815. * Sets the value of the Left joystick
  122816. */
  122817. set buttonLeftStick(value: number);
  122818. /**
  122819. * Gets the value of the Right joystick
  122820. */
  122821. get buttonRightStick(): number;
  122822. /**
  122823. * Sets the value of the Right joystick
  122824. */
  122825. set buttonRightStick(value: number);
  122826. /**
  122827. * Gets the value of D-pad up
  122828. */
  122829. get dPadUp(): number;
  122830. /**
  122831. * Sets the value of D-pad up
  122832. */
  122833. set dPadUp(value: number);
  122834. /**
  122835. * Gets the value of D-pad down
  122836. */
  122837. get dPadDown(): number;
  122838. /**
  122839. * Sets the value of D-pad down
  122840. */
  122841. set dPadDown(value: number);
  122842. /**
  122843. * Gets the value of D-pad left
  122844. */
  122845. get dPadLeft(): number;
  122846. /**
  122847. * Sets the value of D-pad left
  122848. */
  122849. set dPadLeft(value: number);
  122850. /**
  122851. * Gets the value of D-pad right
  122852. */
  122853. get dPadRight(): number;
  122854. /**
  122855. * Sets the value of D-pad right
  122856. */
  122857. set dPadRight(value: number);
  122858. /**
  122859. * Force the gamepad to synchronize with device values
  122860. */
  122861. update(): void;
  122862. /**
  122863. * Disposes the gamepad
  122864. */
  122865. dispose(): void;
  122866. }
  122867. }
  122868. declare module BABYLON {
  122869. /**
  122870. * Defines supported buttons for DualShock compatible gamepads
  122871. */
  122872. export enum DualShockButton {
  122873. /** Cross */
  122874. Cross = 0,
  122875. /** Circle */
  122876. Circle = 1,
  122877. /** Square */
  122878. Square = 2,
  122879. /** Triangle */
  122880. Triangle = 3,
  122881. /** L1 */
  122882. L1 = 4,
  122883. /** R1 */
  122884. R1 = 5,
  122885. /** Share */
  122886. Share = 8,
  122887. /** Options */
  122888. Options = 9,
  122889. /** Left stick */
  122890. LeftStick = 10,
  122891. /** Right stick */
  122892. RightStick = 11
  122893. }
  122894. /** Defines values for DualShock DPad */
  122895. export enum DualShockDpad {
  122896. /** Up */
  122897. Up = 12,
  122898. /** Down */
  122899. Down = 13,
  122900. /** Left */
  122901. Left = 14,
  122902. /** Right */
  122903. Right = 15
  122904. }
  122905. /**
  122906. * Defines a DualShock gamepad
  122907. */
  122908. export class DualShockPad extends Gamepad {
  122909. private _leftTrigger;
  122910. private _rightTrigger;
  122911. private _onlefttriggerchanged;
  122912. private _onrighttriggerchanged;
  122913. private _onbuttondown;
  122914. private _onbuttonup;
  122915. private _ondpaddown;
  122916. private _ondpadup;
  122917. /** Observable raised when a button is pressed */
  122918. onButtonDownObservable: Observable<DualShockButton>;
  122919. /** Observable raised when a button is released */
  122920. onButtonUpObservable: Observable<DualShockButton>;
  122921. /** Observable raised when a pad is pressed */
  122922. onPadDownObservable: Observable<DualShockDpad>;
  122923. /** Observable raised when a pad is released */
  122924. onPadUpObservable: Observable<DualShockDpad>;
  122925. private _buttonCross;
  122926. private _buttonCircle;
  122927. private _buttonSquare;
  122928. private _buttonTriangle;
  122929. private _buttonShare;
  122930. private _buttonOptions;
  122931. private _buttonL1;
  122932. private _buttonR1;
  122933. private _buttonLeftStick;
  122934. private _buttonRightStick;
  122935. private _dPadUp;
  122936. private _dPadDown;
  122937. private _dPadLeft;
  122938. private _dPadRight;
  122939. /**
  122940. * Creates a new DualShock gamepad object
  122941. * @param id defines the id of this gamepad
  122942. * @param index defines its index
  122943. * @param gamepad defines the internal HTML gamepad object
  122944. */
  122945. constructor(id: string, index: number, gamepad: any);
  122946. /**
  122947. * Defines the callback to call when left trigger is pressed
  122948. * @param callback defines the callback to use
  122949. */
  122950. onlefttriggerchanged(callback: (value: number) => void): void;
  122951. /**
  122952. * Defines the callback to call when right trigger is pressed
  122953. * @param callback defines the callback to use
  122954. */
  122955. onrighttriggerchanged(callback: (value: number) => void): void;
  122956. /**
  122957. * Gets the left trigger value
  122958. */
  122959. get leftTrigger(): number;
  122960. /**
  122961. * Sets the left trigger value
  122962. */
  122963. set leftTrigger(newValue: number);
  122964. /**
  122965. * Gets the right trigger value
  122966. */
  122967. get rightTrigger(): number;
  122968. /**
  122969. * Sets the right trigger value
  122970. */
  122971. set rightTrigger(newValue: number);
  122972. /**
  122973. * Defines the callback to call when a button is pressed
  122974. * @param callback defines the callback to use
  122975. */
  122976. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122977. /**
  122978. * Defines the callback to call when a button is released
  122979. * @param callback defines the callback to use
  122980. */
  122981. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122982. /**
  122983. * Defines the callback to call when a pad is pressed
  122984. * @param callback defines the callback to use
  122985. */
  122986. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122987. /**
  122988. * Defines the callback to call when a pad is released
  122989. * @param callback defines the callback to use
  122990. */
  122991. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122992. private _setButtonValue;
  122993. private _setDPadValue;
  122994. /**
  122995. * Gets the value of the `Cross` button
  122996. */
  122997. get buttonCross(): number;
  122998. /**
  122999. * Sets the value of the `Cross` button
  123000. */
  123001. set buttonCross(value: number);
  123002. /**
  123003. * Gets the value of the `Circle` button
  123004. */
  123005. get buttonCircle(): number;
  123006. /**
  123007. * Sets the value of the `Circle` button
  123008. */
  123009. set buttonCircle(value: number);
  123010. /**
  123011. * Gets the value of the `Square` button
  123012. */
  123013. get buttonSquare(): number;
  123014. /**
  123015. * Sets the value of the `Square` button
  123016. */
  123017. set buttonSquare(value: number);
  123018. /**
  123019. * Gets the value of the `Triangle` button
  123020. */
  123021. get buttonTriangle(): number;
  123022. /**
  123023. * Sets the value of the `Triangle` button
  123024. */
  123025. set buttonTriangle(value: number);
  123026. /**
  123027. * Gets the value of the `Options` button
  123028. */
  123029. get buttonOptions(): number;
  123030. /**
  123031. * Sets the value of the `Options` button
  123032. */
  123033. set buttonOptions(value: number);
  123034. /**
  123035. * Gets the value of the `Share` button
  123036. */
  123037. get buttonShare(): number;
  123038. /**
  123039. * Sets the value of the `Share` button
  123040. */
  123041. set buttonShare(value: number);
  123042. /**
  123043. * Gets the value of the `L1` button
  123044. */
  123045. get buttonL1(): number;
  123046. /**
  123047. * Sets the value of the `L1` button
  123048. */
  123049. set buttonL1(value: number);
  123050. /**
  123051. * Gets the value of the `R1` button
  123052. */
  123053. get buttonR1(): number;
  123054. /**
  123055. * Sets the value of the `R1` button
  123056. */
  123057. set buttonR1(value: number);
  123058. /**
  123059. * Gets the value of the Left joystick
  123060. */
  123061. get buttonLeftStick(): number;
  123062. /**
  123063. * Sets the value of the Left joystick
  123064. */
  123065. set buttonLeftStick(value: number);
  123066. /**
  123067. * Gets the value of the Right joystick
  123068. */
  123069. get buttonRightStick(): number;
  123070. /**
  123071. * Sets the value of the Right joystick
  123072. */
  123073. set buttonRightStick(value: number);
  123074. /**
  123075. * Gets the value of D-pad up
  123076. */
  123077. get dPadUp(): number;
  123078. /**
  123079. * Sets the value of D-pad up
  123080. */
  123081. set dPadUp(value: number);
  123082. /**
  123083. * Gets the value of D-pad down
  123084. */
  123085. get dPadDown(): number;
  123086. /**
  123087. * Sets the value of D-pad down
  123088. */
  123089. set dPadDown(value: number);
  123090. /**
  123091. * Gets the value of D-pad left
  123092. */
  123093. get dPadLeft(): number;
  123094. /**
  123095. * Sets the value of D-pad left
  123096. */
  123097. set dPadLeft(value: number);
  123098. /**
  123099. * Gets the value of D-pad right
  123100. */
  123101. get dPadRight(): number;
  123102. /**
  123103. * Sets the value of D-pad right
  123104. */
  123105. set dPadRight(value: number);
  123106. /**
  123107. * Force the gamepad to synchronize with device values
  123108. */
  123109. update(): void;
  123110. /**
  123111. * Disposes the gamepad
  123112. */
  123113. dispose(): void;
  123114. }
  123115. }
  123116. declare module BABYLON {
  123117. /**
  123118. * Manager for handling gamepads
  123119. */
  123120. export class GamepadManager {
  123121. private _scene?;
  123122. private _babylonGamepads;
  123123. private _oneGamepadConnected;
  123124. /** @hidden */
  123125. _isMonitoring: boolean;
  123126. private _gamepadEventSupported;
  123127. private _gamepadSupport?;
  123128. /**
  123129. * observable to be triggered when the gamepad controller has been connected
  123130. */
  123131. onGamepadConnectedObservable: Observable<Gamepad>;
  123132. /**
  123133. * observable to be triggered when the gamepad controller has been disconnected
  123134. */
  123135. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123136. private _onGamepadConnectedEvent;
  123137. private _onGamepadDisconnectedEvent;
  123138. /**
  123139. * Initializes the gamepad manager
  123140. * @param _scene BabylonJS scene
  123141. */
  123142. constructor(_scene?: Scene | undefined);
  123143. /**
  123144. * The gamepads in the game pad manager
  123145. */
  123146. get gamepads(): Gamepad[];
  123147. /**
  123148. * Get the gamepad controllers based on type
  123149. * @param type The type of gamepad controller
  123150. * @returns Nullable gamepad
  123151. */
  123152. getGamepadByType(type?: number): Nullable<Gamepad>;
  123153. /**
  123154. * Disposes the gamepad manager
  123155. */
  123156. dispose(): void;
  123157. private _addNewGamepad;
  123158. private _startMonitoringGamepads;
  123159. private _stopMonitoringGamepads;
  123160. /** @hidden */
  123161. _checkGamepadsStatus(): void;
  123162. private _updateGamepadObjects;
  123163. }
  123164. }
  123165. declare module BABYLON {
  123166. interface Scene {
  123167. /** @hidden */
  123168. _gamepadManager: Nullable<GamepadManager>;
  123169. /**
  123170. * Gets the gamepad manager associated with the scene
  123171. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123172. */
  123173. gamepadManager: GamepadManager;
  123174. }
  123175. /**
  123176. * Interface representing a free camera inputs manager
  123177. */
  123178. interface FreeCameraInputsManager {
  123179. /**
  123180. * Adds gamepad input support to the FreeCameraInputsManager.
  123181. * @returns the FreeCameraInputsManager
  123182. */
  123183. addGamepad(): FreeCameraInputsManager;
  123184. }
  123185. /**
  123186. * Interface representing an arc rotate camera inputs manager
  123187. */
  123188. interface ArcRotateCameraInputsManager {
  123189. /**
  123190. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123191. * @returns the camera inputs manager
  123192. */
  123193. addGamepad(): ArcRotateCameraInputsManager;
  123194. }
  123195. /**
  123196. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123197. */
  123198. export class GamepadSystemSceneComponent implements ISceneComponent {
  123199. /**
  123200. * The component name helpfull to identify the component in the list of scene components.
  123201. */
  123202. readonly name: string;
  123203. /**
  123204. * The scene the component belongs to.
  123205. */
  123206. scene: Scene;
  123207. /**
  123208. * Creates a new instance of the component for the given scene
  123209. * @param scene Defines the scene to register the component in
  123210. */
  123211. constructor(scene: Scene);
  123212. /**
  123213. * Registers the component in a given scene
  123214. */
  123215. register(): void;
  123216. /**
  123217. * Rebuilds the elements related to this component in case of
  123218. * context lost for instance.
  123219. */
  123220. rebuild(): void;
  123221. /**
  123222. * Disposes the component and the associated ressources
  123223. */
  123224. dispose(): void;
  123225. private _beforeCameraUpdate;
  123226. }
  123227. }
  123228. declare module BABYLON {
  123229. /**
  123230. * 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,
  123231. * which still works and will still be found in many Playgrounds.
  123232. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123233. */
  123234. export class UniversalCamera extends TouchCamera {
  123235. /**
  123236. * Defines the gamepad rotation sensiblity.
  123237. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123238. */
  123239. get gamepadAngularSensibility(): number;
  123240. set gamepadAngularSensibility(value: number);
  123241. /**
  123242. * Defines the gamepad move sensiblity.
  123243. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123244. */
  123245. get gamepadMoveSensibility(): number;
  123246. set gamepadMoveSensibility(value: number);
  123247. /**
  123248. * 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,
  123249. * which still works and will still be found in many Playgrounds.
  123250. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123251. * @param name Define the name of the camera in the scene
  123252. * @param position Define the start position of the camera in the scene
  123253. * @param scene Define the scene the camera belongs to
  123254. */
  123255. constructor(name: string, position: Vector3, scene: Scene);
  123256. /**
  123257. * Gets the current object class name.
  123258. * @return the class name
  123259. */
  123260. getClassName(): string;
  123261. }
  123262. }
  123263. declare module BABYLON {
  123264. /**
  123265. * This represents a FPS type of camera. This is only here for back compat purpose.
  123266. * Please use the UniversalCamera instead as both are identical.
  123267. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123268. */
  123269. export class GamepadCamera extends UniversalCamera {
  123270. /**
  123271. * Instantiates a new Gamepad Camera
  123272. * This represents a FPS type of camera. This is only here for back compat purpose.
  123273. * Please use the UniversalCamera instead as both are identical.
  123274. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123275. * @param name Define the name of the camera in the scene
  123276. * @param position Define the start position of the camera in the scene
  123277. * @param scene Define the scene the camera belongs to
  123278. */
  123279. constructor(name: string, position: Vector3, scene: Scene);
  123280. /**
  123281. * Gets the current object class name.
  123282. * @return the class name
  123283. */
  123284. getClassName(): string;
  123285. }
  123286. }
  123287. declare module BABYLON {
  123288. /** @hidden */
  123289. export var passPixelShader: {
  123290. name: string;
  123291. shader: string;
  123292. };
  123293. }
  123294. declare module BABYLON {
  123295. /** @hidden */
  123296. export var passCubePixelShader: {
  123297. name: string;
  123298. shader: string;
  123299. };
  123300. }
  123301. declare module BABYLON {
  123302. /**
  123303. * PassPostProcess which produces an output the same as it's input
  123304. */
  123305. export class PassPostProcess extends PostProcess {
  123306. /**
  123307. * Creates the PassPostProcess
  123308. * @param name The name of the effect.
  123309. * @param options The required width/height ratio to downsize to before computing the render pass.
  123310. * @param camera The camera to apply the render pass to.
  123311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123312. * @param engine The engine which the post process will be applied. (default: current engine)
  123313. * @param reusable If the post process can be reused on the same frame. (default: false)
  123314. * @param textureType The type of texture to be used when performing the post processing.
  123315. * @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)
  123316. */
  123317. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123318. }
  123319. /**
  123320. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123321. */
  123322. export class PassCubePostProcess extends PostProcess {
  123323. private _face;
  123324. /**
  123325. * Gets or sets the cube face to display.
  123326. * * 0 is +X
  123327. * * 1 is -X
  123328. * * 2 is +Y
  123329. * * 3 is -Y
  123330. * * 4 is +Z
  123331. * * 5 is -Z
  123332. */
  123333. get face(): number;
  123334. set face(value: number);
  123335. /**
  123336. * Creates the PassCubePostProcess
  123337. * @param name The name of the effect.
  123338. * @param options The required width/height ratio to downsize to before computing the render pass.
  123339. * @param camera The camera to apply the render pass to.
  123340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123341. * @param engine The engine which the post process will be applied. (default: current engine)
  123342. * @param reusable If the post process can be reused on the same frame. (default: false)
  123343. * @param textureType The type of texture to be used when performing the post processing.
  123344. * @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)
  123345. */
  123346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123347. }
  123348. }
  123349. declare module BABYLON {
  123350. /** @hidden */
  123351. export var anaglyphPixelShader: {
  123352. name: string;
  123353. shader: string;
  123354. };
  123355. }
  123356. declare module BABYLON {
  123357. /**
  123358. * Postprocess used to generate anaglyphic rendering
  123359. */
  123360. export class AnaglyphPostProcess extends PostProcess {
  123361. private _passedProcess;
  123362. /**
  123363. * Creates a new AnaglyphPostProcess
  123364. * @param name defines postprocess name
  123365. * @param options defines creation options or target ratio scale
  123366. * @param rigCameras defines cameras using this postprocess
  123367. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123368. * @param engine defines hosting engine
  123369. * @param reusable defines if the postprocess will be reused multiple times per frame
  123370. */
  123371. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123372. }
  123373. }
  123374. declare module BABYLON {
  123375. /**
  123376. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123377. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123378. */
  123379. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123380. /**
  123381. * Creates a new AnaglyphArcRotateCamera
  123382. * @param name defines camera name
  123383. * @param alpha defines alpha angle (in radians)
  123384. * @param beta defines beta angle (in radians)
  123385. * @param radius defines radius
  123386. * @param target defines camera target
  123387. * @param interaxialDistance defines distance between each color axis
  123388. * @param scene defines the hosting scene
  123389. */
  123390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123391. /**
  123392. * Gets camera class name
  123393. * @returns AnaglyphArcRotateCamera
  123394. */
  123395. getClassName(): string;
  123396. }
  123397. }
  123398. declare module BABYLON {
  123399. /**
  123400. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123401. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123402. */
  123403. export class AnaglyphFreeCamera extends FreeCamera {
  123404. /**
  123405. * Creates a new AnaglyphFreeCamera
  123406. * @param name defines camera name
  123407. * @param position defines initial position
  123408. * @param interaxialDistance defines distance between each color axis
  123409. * @param scene defines the hosting scene
  123410. */
  123411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123412. /**
  123413. * Gets camera class name
  123414. * @returns AnaglyphFreeCamera
  123415. */
  123416. getClassName(): string;
  123417. }
  123418. }
  123419. declare module BABYLON {
  123420. /**
  123421. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123422. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123423. */
  123424. export class AnaglyphGamepadCamera extends GamepadCamera {
  123425. /**
  123426. * Creates a new AnaglyphGamepadCamera
  123427. * @param name defines camera name
  123428. * @param position defines initial position
  123429. * @param interaxialDistance defines distance between each color axis
  123430. * @param scene defines the hosting scene
  123431. */
  123432. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123433. /**
  123434. * Gets camera class name
  123435. * @returns AnaglyphGamepadCamera
  123436. */
  123437. getClassName(): string;
  123438. }
  123439. }
  123440. declare module BABYLON {
  123441. /**
  123442. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123443. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123444. */
  123445. export class AnaglyphUniversalCamera extends UniversalCamera {
  123446. /**
  123447. * Creates a new AnaglyphUniversalCamera
  123448. * @param name defines camera name
  123449. * @param position defines initial position
  123450. * @param interaxialDistance defines distance between each color axis
  123451. * @param scene defines the hosting scene
  123452. */
  123453. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123454. /**
  123455. * Gets camera class name
  123456. * @returns AnaglyphUniversalCamera
  123457. */
  123458. getClassName(): string;
  123459. }
  123460. }
  123461. declare module BABYLON {
  123462. /**
  123463. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123464. * @see https://doc.babylonjs.com/features/cameras
  123465. */
  123466. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123467. /**
  123468. * Creates a new StereoscopicArcRotateCamera
  123469. * @param name defines camera name
  123470. * @param alpha defines alpha angle (in radians)
  123471. * @param beta defines beta angle (in radians)
  123472. * @param radius defines radius
  123473. * @param target defines camera target
  123474. * @param interaxialDistance defines distance between each color axis
  123475. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123476. * @param scene defines the hosting scene
  123477. */
  123478. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123479. /**
  123480. * Gets camera class name
  123481. * @returns StereoscopicArcRotateCamera
  123482. */
  123483. getClassName(): string;
  123484. }
  123485. }
  123486. declare module BABYLON {
  123487. /**
  123488. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123489. * @see https://doc.babylonjs.com/features/cameras
  123490. */
  123491. export class StereoscopicFreeCamera extends FreeCamera {
  123492. /**
  123493. * Creates a new StereoscopicFreeCamera
  123494. * @param name defines camera name
  123495. * @param position defines initial position
  123496. * @param interaxialDistance defines distance between each color axis
  123497. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123498. * @param scene defines the hosting scene
  123499. */
  123500. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123501. /**
  123502. * Gets camera class name
  123503. * @returns StereoscopicFreeCamera
  123504. */
  123505. getClassName(): string;
  123506. }
  123507. }
  123508. declare module BABYLON {
  123509. /**
  123510. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123511. * @see https://doc.babylonjs.com/features/cameras
  123512. */
  123513. export class StereoscopicGamepadCamera extends GamepadCamera {
  123514. /**
  123515. * Creates a new StereoscopicGamepadCamera
  123516. * @param name defines camera name
  123517. * @param position defines initial position
  123518. * @param interaxialDistance defines distance between each color axis
  123519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123520. * @param scene defines the hosting scene
  123521. */
  123522. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123523. /**
  123524. * Gets camera class name
  123525. * @returns StereoscopicGamepadCamera
  123526. */
  123527. getClassName(): string;
  123528. }
  123529. }
  123530. declare module BABYLON {
  123531. /**
  123532. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123533. * @see https://doc.babylonjs.com/features/cameras
  123534. */
  123535. export class StereoscopicUniversalCamera extends UniversalCamera {
  123536. /**
  123537. * Creates a new StereoscopicUniversalCamera
  123538. * @param name defines camera name
  123539. * @param position defines initial position
  123540. * @param interaxialDistance defines distance between each color axis
  123541. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123542. * @param scene defines the hosting scene
  123543. */
  123544. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123545. /**
  123546. * Gets camera class name
  123547. * @returns StereoscopicUniversalCamera
  123548. */
  123549. getClassName(): string;
  123550. }
  123551. }
  123552. declare module BABYLON {
  123553. /**
  123554. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123555. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123556. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123557. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123558. */
  123559. export class VirtualJoysticksCamera extends FreeCamera {
  123560. /**
  123561. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123562. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123563. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123564. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123565. * @param name Define the name of the camera in the scene
  123566. * @param position Define the start position of the camera in the scene
  123567. * @param scene Define the scene the camera belongs to
  123568. */
  123569. constructor(name: string, position: Vector3, scene: Scene);
  123570. /**
  123571. * Gets the current object class name.
  123572. * @return the class name
  123573. */
  123574. getClassName(): string;
  123575. }
  123576. }
  123577. declare module BABYLON {
  123578. /**
  123579. * This represents all the required metrics to create a VR camera.
  123580. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123581. */
  123582. export class VRCameraMetrics {
  123583. /**
  123584. * Define the horizontal resolution off the screen.
  123585. */
  123586. hResolution: number;
  123587. /**
  123588. * Define the vertical resolution off the screen.
  123589. */
  123590. vResolution: number;
  123591. /**
  123592. * Define the horizontal screen size.
  123593. */
  123594. hScreenSize: number;
  123595. /**
  123596. * Define the vertical screen size.
  123597. */
  123598. vScreenSize: number;
  123599. /**
  123600. * Define the vertical screen center position.
  123601. */
  123602. vScreenCenter: number;
  123603. /**
  123604. * Define the distance of the eyes to the screen.
  123605. */
  123606. eyeToScreenDistance: number;
  123607. /**
  123608. * Define the distance between both lenses
  123609. */
  123610. lensSeparationDistance: number;
  123611. /**
  123612. * Define the distance between both viewer's eyes.
  123613. */
  123614. interpupillaryDistance: number;
  123615. /**
  123616. * Define the distortion factor of the VR postprocess.
  123617. * Please, touch with care.
  123618. */
  123619. distortionK: number[];
  123620. /**
  123621. * Define the chromatic aberration correction factors for the VR post process.
  123622. */
  123623. chromaAbCorrection: number[];
  123624. /**
  123625. * Define the scale factor of the post process.
  123626. * The smaller the better but the slower.
  123627. */
  123628. postProcessScaleFactor: number;
  123629. /**
  123630. * Define an offset for the lens center.
  123631. */
  123632. lensCenterOffset: number;
  123633. /**
  123634. * Define if the current vr camera should compensate the distortion of the lense or not.
  123635. */
  123636. compensateDistortion: boolean;
  123637. /**
  123638. * Defines if multiview should be enabled when rendering (Default: false)
  123639. */
  123640. multiviewEnabled: boolean;
  123641. /**
  123642. * Gets the rendering aspect ratio based on the provided resolutions.
  123643. */
  123644. get aspectRatio(): number;
  123645. /**
  123646. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123647. */
  123648. get aspectRatioFov(): number;
  123649. /**
  123650. * @hidden
  123651. */
  123652. get leftHMatrix(): Matrix;
  123653. /**
  123654. * @hidden
  123655. */
  123656. get rightHMatrix(): Matrix;
  123657. /**
  123658. * @hidden
  123659. */
  123660. get leftPreViewMatrix(): Matrix;
  123661. /**
  123662. * @hidden
  123663. */
  123664. get rightPreViewMatrix(): Matrix;
  123665. /**
  123666. * Get the default VRMetrics based on the most generic setup.
  123667. * @returns the default vr metrics
  123668. */
  123669. static GetDefault(): VRCameraMetrics;
  123670. }
  123671. }
  123672. declare module BABYLON {
  123673. /** @hidden */
  123674. export var vrDistortionCorrectionPixelShader: {
  123675. name: string;
  123676. shader: string;
  123677. };
  123678. }
  123679. declare module BABYLON {
  123680. /**
  123681. * VRDistortionCorrectionPostProcess used for mobile VR
  123682. */
  123683. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123684. private _isRightEye;
  123685. private _distortionFactors;
  123686. private _postProcessScaleFactor;
  123687. private _lensCenterOffset;
  123688. private _scaleIn;
  123689. private _scaleFactor;
  123690. private _lensCenter;
  123691. /**
  123692. * Initializes the VRDistortionCorrectionPostProcess
  123693. * @param name The name of the effect.
  123694. * @param camera The camera to apply the render pass to.
  123695. * @param isRightEye If this is for the right eye distortion
  123696. * @param vrMetrics All the required metrics for the VR camera
  123697. */
  123698. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123699. }
  123700. }
  123701. declare module BABYLON {
  123702. /**
  123703. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123704. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123705. */
  123706. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123707. /**
  123708. * Creates a new VRDeviceOrientationArcRotateCamera
  123709. * @param name defines camera name
  123710. * @param alpha defines the camera rotation along the logitudinal axis
  123711. * @param beta defines the camera rotation along the latitudinal axis
  123712. * @param radius defines the camera distance from its target
  123713. * @param target defines the camera target
  123714. * @param scene defines the scene the camera belongs to
  123715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123717. */
  123718. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123719. /**
  123720. * Gets camera class name
  123721. * @returns VRDeviceOrientationArcRotateCamera
  123722. */
  123723. getClassName(): string;
  123724. }
  123725. }
  123726. declare module BABYLON {
  123727. /**
  123728. * Camera used to simulate VR rendering (based on FreeCamera)
  123729. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123730. */
  123731. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123732. /**
  123733. * Creates a new VRDeviceOrientationFreeCamera
  123734. * @param name defines camera name
  123735. * @param position defines the start position of the camera
  123736. * @param scene defines the scene the camera belongs to
  123737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123739. */
  123740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123741. /**
  123742. * Gets camera class name
  123743. * @returns VRDeviceOrientationFreeCamera
  123744. */
  123745. getClassName(): string;
  123746. }
  123747. }
  123748. declare module BABYLON {
  123749. /**
  123750. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123751. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123752. */
  123753. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123754. /**
  123755. * Creates a new VRDeviceOrientationGamepadCamera
  123756. * @param name defines camera name
  123757. * @param position defines the start position of the camera
  123758. * @param scene defines the scene the camera belongs to
  123759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123761. */
  123762. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123763. /**
  123764. * Gets camera class name
  123765. * @returns VRDeviceOrientationGamepadCamera
  123766. */
  123767. getClassName(): string;
  123768. }
  123769. }
  123770. declare module BABYLON {
  123771. /**
  123772. * A class extending Texture allowing drawing on a texture
  123773. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123774. */
  123775. export class DynamicTexture extends Texture {
  123776. private _generateMipMaps;
  123777. private _canvas;
  123778. private _context;
  123779. /**
  123780. * Creates a DynamicTexture
  123781. * @param name defines the name of the texture
  123782. * @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
  123783. * @param scene defines the scene where you want the texture
  123784. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123785. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123786. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123787. */
  123788. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123789. /**
  123790. * Get the current class name of the texture useful for serialization or dynamic coding.
  123791. * @returns "DynamicTexture"
  123792. */
  123793. getClassName(): string;
  123794. /**
  123795. * Gets the current state of canRescale
  123796. */
  123797. get canRescale(): boolean;
  123798. private _recreate;
  123799. /**
  123800. * Scales the texture
  123801. * @param ratio the scale factor to apply to both width and height
  123802. */
  123803. scale(ratio: number): void;
  123804. /**
  123805. * Resizes the texture
  123806. * @param width the new width
  123807. * @param height the new height
  123808. */
  123809. scaleTo(width: number, height: number): void;
  123810. /**
  123811. * Gets the context of the canvas used by the texture
  123812. * @returns the canvas context of the dynamic texture
  123813. */
  123814. getContext(): CanvasRenderingContext2D;
  123815. /**
  123816. * Clears the texture
  123817. */
  123818. clear(): void;
  123819. /**
  123820. * Updates the texture
  123821. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123822. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123823. */
  123824. update(invertY?: boolean, premulAlpha?: boolean): void;
  123825. /**
  123826. * Draws text onto the texture
  123827. * @param text defines the text to be drawn
  123828. * @param x defines the placement of the text from the left
  123829. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123830. * @param font defines the font to be used with font-style, font-size, font-name
  123831. * @param color defines the color used for the text
  123832. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123833. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123834. * @param update defines whether texture is immediately update (default is true)
  123835. */
  123836. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123837. /**
  123838. * Clones the texture
  123839. * @returns the clone of the texture.
  123840. */
  123841. clone(): DynamicTexture;
  123842. /**
  123843. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123844. * @returns a serialized dynamic texture object
  123845. */
  123846. serialize(): any;
  123847. private _IsCanvasElement;
  123848. /** @hidden */
  123849. _rebuild(): void;
  123850. }
  123851. }
  123852. declare module BABYLON {
  123853. /** @hidden */
  123854. export var imageProcessingPixelShader: {
  123855. name: string;
  123856. shader: string;
  123857. };
  123858. }
  123859. declare module BABYLON {
  123860. /**
  123861. * ImageProcessingPostProcess
  123862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123863. */
  123864. export class ImageProcessingPostProcess extends PostProcess {
  123865. /**
  123866. * Default configuration related to image processing available in the PBR Material.
  123867. */
  123868. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123869. /**
  123870. * Gets the image processing configuration used either in this material.
  123871. */
  123872. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123873. /**
  123874. * Sets the Default image processing configuration used either in the this material.
  123875. *
  123876. * If sets to null, the scene one is in use.
  123877. */
  123878. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123879. /**
  123880. * Keep track of the image processing observer to allow dispose and replace.
  123881. */
  123882. private _imageProcessingObserver;
  123883. /**
  123884. * Attaches a new image processing configuration to the PBR Material.
  123885. * @param configuration
  123886. */
  123887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123888. /**
  123889. * If the post process is supported.
  123890. */
  123891. get isSupported(): boolean;
  123892. /**
  123893. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123894. */
  123895. get colorCurves(): Nullable<ColorCurves>;
  123896. /**
  123897. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123898. */
  123899. set colorCurves(value: Nullable<ColorCurves>);
  123900. /**
  123901. * Gets wether the color curves effect is enabled.
  123902. */
  123903. get colorCurvesEnabled(): boolean;
  123904. /**
  123905. * Sets wether the color curves effect is enabled.
  123906. */
  123907. set colorCurvesEnabled(value: boolean);
  123908. /**
  123909. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123910. */
  123911. get colorGradingTexture(): Nullable<BaseTexture>;
  123912. /**
  123913. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123914. */
  123915. set colorGradingTexture(value: Nullable<BaseTexture>);
  123916. /**
  123917. * Gets wether the color grading effect is enabled.
  123918. */
  123919. get colorGradingEnabled(): boolean;
  123920. /**
  123921. * Gets wether the color grading effect is enabled.
  123922. */
  123923. set colorGradingEnabled(value: boolean);
  123924. /**
  123925. * Gets exposure used in the effect.
  123926. */
  123927. get exposure(): number;
  123928. /**
  123929. * Sets exposure used in the effect.
  123930. */
  123931. set exposure(value: number);
  123932. /**
  123933. * Gets wether tonemapping is enabled or not.
  123934. */
  123935. get toneMappingEnabled(): boolean;
  123936. /**
  123937. * Sets wether tonemapping is enabled or not
  123938. */
  123939. set toneMappingEnabled(value: boolean);
  123940. /**
  123941. * Gets the type of tone mapping effect.
  123942. */
  123943. get toneMappingType(): number;
  123944. /**
  123945. * Sets the type of tone mapping effect.
  123946. */
  123947. set toneMappingType(value: number);
  123948. /**
  123949. * Gets contrast used in the effect.
  123950. */
  123951. get contrast(): number;
  123952. /**
  123953. * Sets contrast used in the effect.
  123954. */
  123955. set contrast(value: number);
  123956. /**
  123957. * Gets Vignette stretch size.
  123958. */
  123959. get vignetteStretch(): number;
  123960. /**
  123961. * Sets Vignette stretch size.
  123962. */
  123963. set vignetteStretch(value: number);
  123964. /**
  123965. * Gets Vignette centre X Offset.
  123966. */
  123967. get vignetteCentreX(): number;
  123968. /**
  123969. * Sets Vignette centre X Offset.
  123970. */
  123971. set vignetteCentreX(value: number);
  123972. /**
  123973. * Gets Vignette centre Y Offset.
  123974. */
  123975. get vignetteCentreY(): number;
  123976. /**
  123977. * Sets Vignette centre Y Offset.
  123978. */
  123979. set vignetteCentreY(value: number);
  123980. /**
  123981. * Gets Vignette weight or intensity of the vignette effect.
  123982. */
  123983. get vignetteWeight(): number;
  123984. /**
  123985. * Sets Vignette weight or intensity of the vignette effect.
  123986. */
  123987. set vignetteWeight(value: number);
  123988. /**
  123989. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123990. * if vignetteEnabled is set to true.
  123991. */
  123992. get vignetteColor(): Color4;
  123993. /**
  123994. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123995. * if vignetteEnabled is set to true.
  123996. */
  123997. set vignetteColor(value: Color4);
  123998. /**
  123999. * Gets Camera field of view used by the Vignette effect.
  124000. */
  124001. get vignetteCameraFov(): number;
  124002. /**
  124003. * Sets Camera field of view used by the Vignette effect.
  124004. */
  124005. set vignetteCameraFov(value: number);
  124006. /**
  124007. * Gets the vignette blend mode allowing different kind of effect.
  124008. */
  124009. get vignetteBlendMode(): number;
  124010. /**
  124011. * Sets the vignette blend mode allowing different kind of effect.
  124012. */
  124013. set vignetteBlendMode(value: number);
  124014. /**
  124015. * Gets wether the vignette effect is enabled.
  124016. */
  124017. get vignetteEnabled(): boolean;
  124018. /**
  124019. * Sets wether the vignette effect is enabled.
  124020. */
  124021. set vignetteEnabled(value: boolean);
  124022. private _fromLinearSpace;
  124023. /**
  124024. * Gets wether the input of the processing is in Gamma or Linear Space.
  124025. */
  124026. get fromLinearSpace(): boolean;
  124027. /**
  124028. * Sets wether the input of the processing is in Gamma or Linear Space.
  124029. */
  124030. set fromLinearSpace(value: boolean);
  124031. /**
  124032. * Defines cache preventing GC.
  124033. */
  124034. private _defines;
  124035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124036. /**
  124037. * "ImageProcessingPostProcess"
  124038. * @returns "ImageProcessingPostProcess"
  124039. */
  124040. getClassName(): string;
  124041. protected _updateParameters(): void;
  124042. dispose(camera?: Camera): void;
  124043. }
  124044. }
  124045. declare module BABYLON {
  124046. /**
  124047. * Class containing static functions to help procedurally build meshes
  124048. */
  124049. export class GroundBuilder {
  124050. /**
  124051. * Creates a ground mesh
  124052. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124053. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124055. * @param name defines the name of the mesh
  124056. * @param options defines the options used to create the mesh
  124057. * @param scene defines the hosting scene
  124058. * @returns the ground mesh
  124059. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124060. */
  124061. static CreateGround(name: string, options: {
  124062. width?: number;
  124063. height?: number;
  124064. subdivisions?: number;
  124065. subdivisionsX?: number;
  124066. subdivisionsY?: number;
  124067. updatable?: boolean;
  124068. }, scene: any): Mesh;
  124069. /**
  124070. * Creates a tiled ground mesh
  124071. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124072. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124073. * * 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
  124074. * * 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
  124075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124076. * @param name defines the name of the mesh
  124077. * @param options defines the options used to create the mesh
  124078. * @param scene defines the hosting scene
  124079. * @returns the tiled ground mesh
  124080. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124081. */
  124082. static CreateTiledGround(name: string, options: {
  124083. xmin: number;
  124084. zmin: number;
  124085. xmax: number;
  124086. zmax: number;
  124087. subdivisions?: {
  124088. w: number;
  124089. h: number;
  124090. };
  124091. precision?: {
  124092. w: number;
  124093. h: number;
  124094. };
  124095. updatable?: boolean;
  124096. }, scene?: Nullable<Scene>): Mesh;
  124097. /**
  124098. * Creates a ground mesh from a height map
  124099. * * The parameter `url` sets the URL of the height map image resource.
  124100. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124101. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124102. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124103. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124104. * * 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.
  124105. * * 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).
  124106. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124108. * @param name defines the name of the mesh
  124109. * @param url defines the url to the height map
  124110. * @param options defines the options used to create the mesh
  124111. * @param scene defines the hosting scene
  124112. * @returns the ground mesh
  124113. * @see https://doc.babylonjs.com/babylon101/height_map
  124114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124115. */
  124116. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124117. width?: number;
  124118. height?: number;
  124119. subdivisions?: number;
  124120. minHeight?: number;
  124121. maxHeight?: number;
  124122. colorFilter?: Color3;
  124123. alphaFilter?: number;
  124124. updatable?: boolean;
  124125. onReady?: (mesh: GroundMesh) => void;
  124126. }, scene?: Nullable<Scene>): GroundMesh;
  124127. }
  124128. }
  124129. declare module BABYLON {
  124130. /**
  124131. * Class containing static functions to help procedurally build meshes
  124132. */
  124133. export class TorusBuilder {
  124134. /**
  124135. * Creates a torus mesh
  124136. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124137. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124138. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124140. * * 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
  124141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124142. * @param name defines the name of the mesh
  124143. * @param options defines the options used to create the mesh
  124144. * @param scene defines the hosting scene
  124145. * @returns the torus mesh
  124146. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124147. */
  124148. static CreateTorus(name: string, options: {
  124149. diameter?: number;
  124150. thickness?: number;
  124151. tessellation?: number;
  124152. updatable?: boolean;
  124153. sideOrientation?: number;
  124154. frontUVs?: Vector4;
  124155. backUVs?: Vector4;
  124156. }, scene: any): Mesh;
  124157. }
  124158. }
  124159. declare module BABYLON {
  124160. /**
  124161. * Class containing static functions to help procedurally build meshes
  124162. */
  124163. export class CylinderBuilder {
  124164. /**
  124165. * Creates a cylinder or a cone mesh
  124166. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124167. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124168. * * 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.
  124169. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124170. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124171. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124172. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124173. * * 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).
  124174. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124175. * * 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).
  124176. * * 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
  124177. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124178. * * 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
  124179. * * 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.
  124180. * * If `enclose` is false, a ring surface is one element.
  124181. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124182. * * 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
  124183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124184. * * 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
  124185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124186. * @param name defines the name of the mesh
  124187. * @param options defines the options used to create the mesh
  124188. * @param scene defines the hosting scene
  124189. * @returns the cylinder mesh
  124190. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124191. */
  124192. static CreateCylinder(name: string, options: {
  124193. height?: number;
  124194. diameterTop?: number;
  124195. diameterBottom?: number;
  124196. diameter?: number;
  124197. tessellation?: number;
  124198. subdivisions?: number;
  124199. arc?: number;
  124200. faceColors?: Color4[];
  124201. faceUV?: Vector4[];
  124202. updatable?: boolean;
  124203. hasRings?: boolean;
  124204. enclose?: boolean;
  124205. cap?: number;
  124206. sideOrientation?: number;
  124207. frontUVs?: Vector4;
  124208. backUVs?: Vector4;
  124209. }, scene: any): Mesh;
  124210. }
  124211. }
  124212. declare module BABYLON {
  124213. /**
  124214. * States of the webXR experience
  124215. */
  124216. export enum WebXRState {
  124217. /**
  124218. * Transitioning to being in XR mode
  124219. */
  124220. ENTERING_XR = 0,
  124221. /**
  124222. * Transitioning to non XR mode
  124223. */
  124224. EXITING_XR = 1,
  124225. /**
  124226. * In XR mode and presenting
  124227. */
  124228. IN_XR = 2,
  124229. /**
  124230. * Not entered XR mode
  124231. */
  124232. NOT_IN_XR = 3
  124233. }
  124234. /**
  124235. * Abstraction of the XR render target
  124236. */
  124237. export interface WebXRRenderTarget extends IDisposable {
  124238. /**
  124239. * xrpresent context of the canvas which can be used to display/mirror xr content
  124240. */
  124241. canvasContext: WebGLRenderingContext;
  124242. /**
  124243. * xr layer for the canvas
  124244. */
  124245. xrLayer: Nullable<XRWebGLLayer>;
  124246. /**
  124247. * Initializes the xr layer for the session
  124248. * @param xrSession xr session
  124249. * @returns a promise that will resolve once the XR Layer has been created
  124250. */
  124251. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124252. }
  124253. }
  124254. declare module BABYLON {
  124255. /**
  124256. * COnfiguration object for WebXR output canvas
  124257. */
  124258. export class WebXRManagedOutputCanvasOptions {
  124259. /**
  124260. * An optional canvas in case you wish to create it yourself and provide it here.
  124261. * If not provided, a new canvas will be created
  124262. */
  124263. canvasElement?: HTMLCanvasElement;
  124264. /**
  124265. * Options for this XR Layer output
  124266. */
  124267. canvasOptions?: XRWebGLLayerOptions;
  124268. /**
  124269. * CSS styling for a newly created canvas (if not provided)
  124270. */
  124271. newCanvasCssStyle?: string;
  124272. /**
  124273. * Get the default values of the configuration object
  124274. * @returns default values of this configuration object
  124275. */
  124276. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124277. }
  124278. /**
  124279. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124280. */
  124281. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124282. private _options;
  124283. private _canvas;
  124284. private _engine;
  124285. private _originalCanvasSize;
  124286. /**
  124287. * Rendering context of the canvas which can be used to display/mirror xr content
  124288. */
  124289. canvasContext: WebGLRenderingContext;
  124290. /**
  124291. * xr layer for the canvas
  124292. */
  124293. xrLayer: Nullable<XRWebGLLayer>;
  124294. /**
  124295. * Obseervers registered here will be triggered when the xr layer was initialized
  124296. */
  124297. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124298. /**
  124299. * Initializes the canvas to be added/removed upon entering/exiting xr
  124300. * @param _xrSessionManager The XR Session manager
  124301. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124302. */
  124303. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124304. /**
  124305. * Disposes of the object
  124306. */
  124307. dispose(): void;
  124308. /**
  124309. * Initializes the xr layer for the session
  124310. * @param xrSession xr session
  124311. * @returns a promise that will resolve once the XR Layer has been created
  124312. */
  124313. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124314. private _addCanvas;
  124315. private _removeCanvas;
  124316. private _setCanvasSize;
  124317. private _setManagedOutputCanvas;
  124318. }
  124319. }
  124320. declare module BABYLON {
  124321. /**
  124322. * Manages an XRSession to work with Babylon's engine
  124323. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124324. */
  124325. export class WebXRSessionManager implements IDisposable {
  124326. /** The scene which the session should be created for */
  124327. scene: Scene;
  124328. private _referenceSpace;
  124329. private _rttProvider;
  124330. private _sessionEnded;
  124331. private _xrNavigator;
  124332. private baseLayer;
  124333. /**
  124334. * The base reference space from which the session started. good if you want to reset your
  124335. * reference space
  124336. */
  124337. baseReferenceSpace: XRReferenceSpace;
  124338. /**
  124339. * Current XR frame
  124340. */
  124341. currentFrame: Nullable<XRFrame>;
  124342. /** WebXR timestamp updated every frame */
  124343. currentTimestamp: number;
  124344. /**
  124345. * Used just in case of a failure to initialize an immersive session.
  124346. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124347. */
  124348. defaultHeightCompensation: number;
  124349. /**
  124350. * Fires every time a new xrFrame arrives which can be used to update the camera
  124351. */
  124352. onXRFrameObservable: Observable<XRFrame>;
  124353. /**
  124354. * Fires when the reference space changed
  124355. */
  124356. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124357. /**
  124358. * Fires when the xr session is ended either by the device or manually done
  124359. */
  124360. onXRSessionEnded: Observable<any>;
  124361. /**
  124362. * Fires when the xr session is ended either by the device or manually done
  124363. */
  124364. onXRSessionInit: Observable<XRSession>;
  124365. /**
  124366. * Underlying xr session
  124367. */
  124368. session: XRSession;
  124369. /**
  124370. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124371. * or get the offset the player is currently at.
  124372. */
  124373. viewerReferenceSpace: XRReferenceSpace;
  124374. /**
  124375. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124376. * @param scene The scene which the session should be created for
  124377. */
  124378. constructor(
  124379. /** The scene which the session should be created for */
  124380. scene: Scene);
  124381. /**
  124382. * The current reference space used in this session. This reference space can constantly change!
  124383. * It is mainly used to offset the camera's position.
  124384. */
  124385. get referenceSpace(): XRReferenceSpace;
  124386. /**
  124387. * Set a new reference space and triggers the observable
  124388. */
  124389. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124390. /**
  124391. * Disposes of the session manager
  124392. */
  124393. dispose(): void;
  124394. /**
  124395. * Stops the xrSession and restores the render loop
  124396. * @returns Promise which resolves after it exits XR
  124397. */
  124398. exitXRAsync(): Promise<void>;
  124399. /**
  124400. * Gets the correct render target texture to be rendered this frame for this eye
  124401. * @param eye the eye for which to get the render target
  124402. * @returns the render target for the specified eye
  124403. */
  124404. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124405. /**
  124406. * Creates a WebXRRenderTarget object for the XR session
  124407. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124408. * @param options optional options to provide when creating a new render target
  124409. * @returns a WebXR render target to which the session can render
  124410. */
  124411. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124412. /**
  124413. * Initializes the manager
  124414. * After initialization enterXR can be called to start an XR session
  124415. * @returns Promise which resolves after it is initialized
  124416. */
  124417. initializeAsync(): Promise<void>;
  124418. /**
  124419. * Initializes an xr session
  124420. * @param xrSessionMode mode to initialize
  124421. * @param xrSessionInit defines optional and required values to pass to the session builder
  124422. * @returns a promise which will resolve once the session has been initialized
  124423. */
  124424. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124425. /**
  124426. * Checks if a session would be supported for the creation options specified
  124427. * @param sessionMode session mode to check if supported eg. immersive-vr
  124428. * @returns A Promise that resolves to true if supported and false if not
  124429. */
  124430. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124431. /**
  124432. * Resets the reference space to the one started the session
  124433. */
  124434. resetReferenceSpace(): void;
  124435. /**
  124436. * Starts rendering to the xr layer
  124437. */
  124438. runXRRenderLoop(): void;
  124439. /**
  124440. * Sets the reference space on the xr session
  124441. * @param referenceSpaceType space to set
  124442. * @returns a promise that will resolve once the reference space has been set
  124443. */
  124444. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124445. /**
  124446. * Updates the render state of the session
  124447. * @param state state to set
  124448. * @returns a promise that resolves once the render state has been updated
  124449. */
  124450. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124451. /**
  124452. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124453. * @param sessionMode defines the session to test
  124454. * @returns a promise with boolean as final value
  124455. */
  124456. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124457. private _createRenderTargetTexture;
  124458. }
  124459. }
  124460. declare module BABYLON {
  124461. /**
  124462. * WebXR Camera which holds the views for the xrSession
  124463. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124464. */
  124465. export class WebXRCamera extends FreeCamera {
  124466. private _xrSessionManager;
  124467. private _firstFrame;
  124468. private _referenceQuaternion;
  124469. private _referencedPosition;
  124470. private _xrInvPositionCache;
  124471. private _xrInvQuaternionCache;
  124472. /**
  124473. * Should position compensation execute on first frame.
  124474. * This is used when copying the position from a native (non XR) camera
  124475. */
  124476. compensateOnFirstFrame: boolean;
  124477. /**
  124478. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124479. * @param name the name of the camera
  124480. * @param scene the scene to add the camera to
  124481. * @param _xrSessionManager a constructed xr session manager
  124482. */
  124483. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124484. /**
  124485. * Return the user's height, unrelated to the current ground.
  124486. * This will be the y position of this camera, when ground level is 0.
  124487. */
  124488. get realWorldHeight(): number;
  124489. /** @hidden */
  124490. _updateForDualEyeDebugging(): void;
  124491. /**
  124492. * Sets this camera's transformation based on a non-vr camera
  124493. * @param otherCamera the non-vr camera to copy the transformation from
  124494. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124495. */
  124496. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124497. /**
  124498. * Gets the current instance class name ("WebXRCamera").
  124499. * @returns the class name
  124500. */
  124501. getClassName(): string;
  124502. private _rotate180;
  124503. private _updateFromXRSession;
  124504. private _updateNumberOfRigCameras;
  124505. private _updateReferenceSpace;
  124506. private _updateReferenceSpaceOffset;
  124507. }
  124508. }
  124509. declare module BABYLON {
  124510. /**
  124511. * Defining the interface required for a (webxr) feature
  124512. */
  124513. export interface IWebXRFeature extends IDisposable {
  124514. /**
  124515. * Is this feature attached
  124516. */
  124517. attached: boolean;
  124518. /**
  124519. * Should auto-attach be disabled?
  124520. */
  124521. disableAutoAttach: boolean;
  124522. /**
  124523. * Attach the feature to the session
  124524. * Will usually be called by the features manager
  124525. *
  124526. * @param force should attachment be forced (even when already attached)
  124527. * @returns true if successful.
  124528. */
  124529. attach(force?: boolean): boolean;
  124530. /**
  124531. * Detach the feature from the session
  124532. * Will usually be called by the features manager
  124533. *
  124534. * @returns true if successful.
  124535. */
  124536. detach(): boolean;
  124537. }
  124538. /**
  124539. * A list of the currently available features without referencing them
  124540. */
  124541. export class WebXRFeatureName {
  124542. /**
  124543. * The name of the anchor system feature
  124544. */
  124545. static ANCHOR_SYSTEM: string;
  124546. /**
  124547. * The name of the background remover feature
  124548. */
  124549. static BACKGROUND_REMOVER: string;
  124550. /**
  124551. * The name of the hit test feature
  124552. */
  124553. static HIT_TEST: string;
  124554. /**
  124555. * physics impostors for xr controllers feature
  124556. */
  124557. static PHYSICS_CONTROLLERS: string;
  124558. /**
  124559. * The name of the plane detection feature
  124560. */
  124561. static PLANE_DETECTION: string;
  124562. /**
  124563. * The name of the pointer selection feature
  124564. */
  124565. static POINTER_SELECTION: string;
  124566. /**
  124567. * The name of the teleportation feature
  124568. */
  124569. static TELEPORTATION: string;
  124570. }
  124571. /**
  124572. * Defining the constructor of a feature. Used to register the modules.
  124573. */
  124574. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124575. /**
  124576. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124577. * It is mainly used in AR sessions.
  124578. *
  124579. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124580. */
  124581. export class WebXRFeaturesManager implements IDisposable {
  124582. private _xrSessionManager;
  124583. private static readonly _AvailableFeatures;
  124584. private _features;
  124585. /**
  124586. * constructs a new features manages.
  124587. *
  124588. * @param _xrSessionManager an instance of WebXRSessionManager
  124589. */
  124590. constructor(_xrSessionManager: WebXRSessionManager);
  124591. /**
  124592. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124593. * Mainly used internally.
  124594. *
  124595. * @param featureName the name of the feature to register
  124596. * @param constructorFunction the function used to construct the module
  124597. * @param version the (babylon) version of the module
  124598. * @param stable is that a stable version of this module
  124599. */
  124600. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124601. /**
  124602. * Returns a constructor of a specific feature.
  124603. *
  124604. * @param featureName the name of the feature to construct
  124605. * @param version the version of the feature to load
  124606. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124607. * @param options optional options provided to the module.
  124608. * @returns a function that, when called, will return a new instance of this feature
  124609. */
  124610. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124611. /**
  124612. * Can be used to return the list of features currently registered
  124613. *
  124614. * @returns an Array of available features
  124615. */
  124616. static GetAvailableFeatures(): string[];
  124617. /**
  124618. * Gets the versions available for a specific feature
  124619. * @param featureName the name of the feature
  124620. * @returns an array with the available versions
  124621. */
  124622. static GetAvailableVersions(featureName: string): string[];
  124623. /**
  124624. * Return the latest unstable version of this feature
  124625. * @param featureName the name of the feature to search
  124626. * @returns the version number. if not found will return -1
  124627. */
  124628. static GetLatestVersionOfFeature(featureName: string): number;
  124629. /**
  124630. * Return the latest stable version of this feature
  124631. * @param featureName the name of the feature to search
  124632. * @returns the version number. if not found will return -1
  124633. */
  124634. static GetStableVersionOfFeature(featureName: string): number;
  124635. /**
  124636. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124637. * Can be used during a session to start a feature
  124638. * @param featureName the name of feature to attach
  124639. */
  124640. attachFeature(featureName: string): void;
  124641. /**
  124642. * Can be used inside a session or when the session ends to detach a specific feature
  124643. * @param featureName the name of the feature to detach
  124644. */
  124645. detachFeature(featureName: string): void;
  124646. /**
  124647. * Used to disable an already-enabled feature
  124648. * The feature will be disposed and will be recreated once enabled.
  124649. * @param featureName the feature to disable
  124650. * @returns true if disable was successful
  124651. */
  124652. disableFeature(featureName: string | {
  124653. Name: string;
  124654. }): boolean;
  124655. /**
  124656. * dispose this features manager
  124657. */
  124658. dispose(): void;
  124659. /**
  124660. * 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.
  124661. * 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.
  124662. *
  124663. * @param featureName the name of the feature to load or the class of the feature
  124664. * @param version optional version to load. if not provided the latest version will be enabled
  124665. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124666. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124667. * @returns a new constructed feature or throws an error if feature not found.
  124668. */
  124669. enableFeature(featureName: string | {
  124670. Name: string;
  124671. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124672. /**
  124673. * get the implementation of an enabled feature.
  124674. * @param featureName the name of the feature to load
  124675. * @returns the feature class, if found
  124676. */
  124677. getEnabledFeature(featureName: string): IWebXRFeature;
  124678. /**
  124679. * Get the list of enabled features
  124680. * @returns an array of enabled features
  124681. */
  124682. getEnabledFeatures(): string[];
  124683. }
  124684. }
  124685. declare module BABYLON {
  124686. /**
  124687. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124688. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124689. */
  124690. export class WebXRExperienceHelper implements IDisposable {
  124691. private scene;
  124692. private _nonVRCamera;
  124693. private _originalSceneAutoClear;
  124694. private _supported;
  124695. /**
  124696. * Camera used to render xr content
  124697. */
  124698. camera: WebXRCamera;
  124699. /** A features manager for this xr session */
  124700. featuresManager: WebXRFeaturesManager;
  124701. /**
  124702. * Observers registered here will be triggered after the camera's initial transformation is set
  124703. * This can be used to set a different ground level or an extra rotation.
  124704. *
  124705. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124706. * to the position set after this observable is done executing.
  124707. */
  124708. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124709. /**
  124710. * Fires when the state of the experience helper has changed
  124711. */
  124712. onStateChangedObservable: Observable<WebXRState>;
  124713. /** Session manager used to keep track of xr session */
  124714. sessionManager: WebXRSessionManager;
  124715. /**
  124716. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124717. */
  124718. state: WebXRState;
  124719. /**
  124720. * Creates a WebXRExperienceHelper
  124721. * @param scene The scene the helper should be created in
  124722. */
  124723. private constructor();
  124724. /**
  124725. * Creates the experience helper
  124726. * @param scene the scene to attach the experience helper to
  124727. * @returns a promise for the experience helper
  124728. */
  124729. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124730. /**
  124731. * Disposes of the experience helper
  124732. */
  124733. dispose(): void;
  124734. /**
  124735. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124736. * @param sessionMode options for the XR session
  124737. * @param referenceSpaceType frame of reference of the XR session
  124738. * @param renderTarget the output canvas that will be used to enter XR mode
  124739. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124740. * @returns promise that resolves after xr mode has entered
  124741. */
  124742. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124743. /**
  124744. * Exits XR mode and returns the scene to its original state
  124745. * @returns promise that resolves after xr mode has exited
  124746. */
  124747. exitXRAsync(): Promise<void>;
  124748. private _nonXRToXRCamera;
  124749. private _setState;
  124750. }
  124751. }
  124752. declare module BABYLON {
  124753. /**
  124754. * X-Y values for axes in WebXR
  124755. */
  124756. export interface IWebXRMotionControllerAxesValue {
  124757. /**
  124758. * The value of the x axis
  124759. */
  124760. x: number;
  124761. /**
  124762. * The value of the y-axis
  124763. */
  124764. y: number;
  124765. }
  124766. /**
  124767. * changed / previous values for the values of this component
  124768. */
  124769. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124770. /**
  124771. * current (this frame) value
  124772. */
  124773. current: T;
  124774. /**
  124775. * previous (last change) value
  124776. */
  124777. previous: T;
  124778. }
  124779. /**
  124780. * Represents changes in the component between current frame and last values recorded
  124781. */
  124782. export interface IWebXRMotionControllerComponentChanges {
  124783. /**
  124784. * will be populated with previous and current values if axes changed
  124785. */
  124786. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124787. /**
  124788. * will be populated with previous and current values if pressed changed
  124789. */
  124790. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124791. /**
  124792. * will be populated with previous and current values if touched changed
  124793. */
  124794. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124795. /**
  124796. * will be populated with previous and current values if value changed
  124797. */
  124798. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124799. }
  124800. /**
  124801. * This class represents a single component (for example button or thumbstick) of a motion controller
  124802. */
  124803. export class WebXRControllerComponent implements IDisposable {
  124804. /**
  124805. * the id of this component
  124806. */
  124807. id: string;
  124808. /**
  124809. * the type of the component
  124810. */
  124811. type: MotionControllerComponentType;
  124812. private _buttonIndex;
  124813. private _axesIndices;
  124814. private _axes;
  124815. private _changes;
  124816. private _currentValue;
  124817. private _hasChanges;
  124818. private _pressed;
  124819. private _touched;
  124820. /**
  124821. * button component type
  124822. */
  124823. static BUTTON_TYPE: MotionControllerComponentType;
  124824. /**
  124825. * squeeze component type
  124826. */
  124827. static SQUEEZE_TYPE: MotionControllerComponentType;
  124828. /**
  124829. * Thumbstick component type
  124830. */
  124831. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124832. /**
  124833. * Touchpad component type
  124834. */
  124835. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124836. /**
  124837. * trigger component type
  124838. */
  124839. static TRIGGER_TYPE: MotionControllerComponentType;
  124840. /**
  124841. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124842. * the axes data changes
  124843. */
  124844. onAxisValueChangedObservable: Observable<{
  124845. x: number;
  124846. y: number;
  124847. }>;
  124848. /**
  124849. * Observers registered here will be triggered when the state of a button changes
  124850. * State change is either pressed / touched / value
  124851. */
  124852. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124853. /**
  124854. * Creates a new component for a motion controller.
  124855. * It is created by the motion controller itself
  124856. *
  124857. * @param id the id of this component
  124858. * @param type the type of the component
  124859. * @param _buttonIndex index in the buttons array of the gamepad
  124860. * @param _axesIndices indices of the values in the axes array of the gamepad
  124861. */
  124862. constructor(
  124863. /**
  124864. * the id of this component
  124865. */
  124866. id: string,
  124867. /**
  124868. * the type of the component
  124869. */
  124870. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124871. /**
  124872. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124873. */
  124874. get axes(): IWebXRMotionControllerAxesValue;
  124875. /**
  124876. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124877. */
  124878. get changes(): IWebXRMotionControllerComponentChanges;
  124879. /**
  124880. * Return whether or not the component changed the last frame
  124881. */
  124882. get hasChanges(): boolean;
  124883. /**
  124884. * is the button currently pressed
  124885. */
  124886. get pressed(): boolean;
  124887. /**
  124888. * is the button currently touched
  124889. */
  124890. get touched(): boolean;
  124891. /**
  124892. * Get the current value of this component
  124893. */
  124894. get value(): number;
  124895. /**
  124896. * Dispose this component
  124897. */
  124898. dispose(): void;
  124899. /**
  124900. * Are there axes correlating to this component
  124901. * @return true is axes data is available
  124902. */
  124903. isAxes(): boolean;
  124904. /**
  124905. * Is this component a button (hence - pressable)
  124906. * @returns true if can be pressed
  124907. */
  124908. isButton(): boolean;
  124909. /**
  124910. * update this component using the gamepad object it is in. Called on every frame
  124911. * @param nativeController the native gamepad controller object
  124912. */
  124913. update(nativeController: IMinimalMotionControllerObject): void;
  124914. }
  124915. }
  124916. declare module BABYLON {
  124917. /**
  124918. * Interface used to represent data loading progression
  124919. */
  124920. export interface ISceneLoaderProgressEvent {
  124921. /**
  124922. * Defines if data length to load can be evaluated
  124923. */
  124924. readonly lengthComputable: boolean;
  124925. /**
  124926. * Defines the loaded data length
  124927. */
  124928. readonly loaded: number;
  124929. /**
  124930. * Defines the data length to load
  124931. */
  124932. readonly total: number;
  124933. }
  124934. /**
  124935. * Interface used by SceneLoader plugins to define supported file extensions
  124936. */
  124937. export interface ISceneLoaderPluginExtensions {
  124938. /**
  124939. * Defines the list of supported extensions
  124940. */
  124941. [extension: string]: {
  124942. isBinary: boolean;
  124943. };
  124944. }
  124945. /**
  124946. * Interface used by SceneLoader plugin factory
  124947. */
  124948. export interface ISceneLoaderPluginFactory {
  124949. /**
  124950. * Defines the name of the factory
  124951. */
  124952. name: string;
  124953. /**
  124954. * Function called to create a new plugin
  124955. * @return the new plugin
  124956. */
  124957. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124958. /**
  124959. * The callback that returns true if the data can be directly loaded.
  124960. * @param data string containing the file data
  124961. * @returns if the data can be loaded directly
  124962. */
  124963. canDirectLoad?(data: string): boolean;
  124964. }
  124965. /**
  124966. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124967. */
  124968. export interface ISceneLoaderPluginBase {
  124969. /**
  124970. * The friendly name of this plugin.
  124971. */
  124972. name: string;
  124973. /**
  124974. * The file extensions supported by this plugin.
  124975. */
  124976. extensions: string | ISceneLoaderPluginExtensions;
  124977. /**
  124978. * The callback called when loading from a url.
  124979. * @param scene scene loading this url
  124980. * @param url url to load
  124981. * @param onSuccess callback called when the file successfully loads
  124982. * @param onProgress callback called while file is loading (if the server supports this mode)
  124983. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124984. * @param onError callback called when the file fails to load
  124985. * @returns a file request object
  124986. */
  124987. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124988. /**
  124989. * The callback called when loading from a file object.
  124990. * @param scene scene loading this file
  124991. * @param file defines the file to load
  124992. * @param onSuccess defines the callback to call when data is loaded
  124993. * @param onProgress defines the callback to call during loading process
  124994. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124995. * @param onError defines the callback to call when an error occurs
  124996. * @returns a file request object
  124997. */
  124998. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124999. /**
  125000. * The callback that returns true if the data can be directly loaded.
  125001. * @param data string containing the file data
  125002. * @returns if the data can be loaded directly
  125003. */
  125004. canDirectLoad?(data: string): boolean;
  125005. /**
  125006. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125007. * @param scene scene loading this data
  125008. * @param data string containing the data
  125009. * @returns data to pass to the plugin
  125010. */
  125011. directLoad?(scene: Scene, data: string): any;
  125012. /**
  125013. * The callback that allows custom handling of the root url based on the response url.
  125014. * @param rootUrl the original root url
  125015. * @param responseURL the response url if available
  125016. * @returns the new root url
  125017. */
  125018. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125019. }
  125020. /**
  125021. * Interface used to define a SceneLoader plugin
  125022. */
  125023. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125024. /**
  125025. * Import meshes into a scene.
  125026. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125027. * @param scene The scene to import into
  125028. * @param data The data to import
  125029. * @param rootUrl The root url for scene and resources
  125030. * @param meshes The meshes array to import into
  125031. * @param particleSystems The particle systems array to import into
  125032. * @param skeletons The skeletons array to import into
  125033. * @param onError The callback when import fails
  125034. * @returns True if successful or false otherwise
  125035. */
  125036. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125037. /**
  125038. * Load into a scene.
  125039. * @param scene The scene to load into
  125040. * @param data The data to import
  125041. * @param rootUrl The root url for scene and resources
  125042. * @param onError The callback when import fails
  125043. * @returns True if successful or false otherwise
  125044. */
  125045. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125046. /**
  125047. * Load into an asset container.
  125048. * @param scene The scene to load into
  125049. * @param data The data to import
  125050. * @param rootUrl The root url for scene and resources
  125051. * @param onError The callback when import fails
  125052. * @returns The loaded asset container
  125053. */
  125054. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125055. }
  125056. /**
  125057. * Interface used to define an async SceneLoader plugin
  125058. */
  125059. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125060. /**
  125061. * Import meshes into a scene.
  125062. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125063. * @param scene The scene to import into
  125064. * @param data The data to import
  125065. * @param rootUrl The root url for scene and resources
  125066. * @param onProgress The callback when the load progresses
  125067. * @param fileName Defines the name of the file to load
  125068. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125069. */
  125070. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125071. meshes: AbstractMesh[];
  125072. particleSystems: IParticleSystem[];
  125073. skeletons: Skeleton[];
  125074. animationGroups: AnimationGroup[];
  125075. }>;
  125076. /**
  125077. * Load into a scene.
  125078. * @param scene The scene to load into
  125079. * @param data The data to import
  125080. * @param rootUrl The root url for scene and resources
  125081. * @param onProgress The callback when the load progresses
  125082. * @param fileName Defines the name of the file to load
  125083. * @returns Nothing
  125084. */
  125085. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125086. /**
  125087. * Load into an asset container.
  125088. * @param scene The scene to load into
  125089. * @param data The data to import
  125090. * @param rootUrl The root url for scene and resources
  125091. * @param onProgress The callback when the load progresses
  125092. * @param fileName Defines the name of the file to load
  125093. * @returns The loaded asset container
  125094. */
  125095. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125096. }
  125097. /**
  125098. * Mode that determines how to handle old animation groups before loading new ones.
  125099. */
  125100. export enum SceneLoaderAnimationGroupLoadingMode {
  125101. /**
  125102. * Reset all old animations to initial state then dispose them.
  125103. */
  125104. Clean = 0,
  125105. /**
  125106. * Stop all old animations.
  125107. */
  125108. Stop = 1,
  125109. /**
  125110. * Restart old animations from first frame.
  125111. */
  125112. Sync = 2,
  125113. /**
  125114. * Old animations remains untouched.
  125115. */
  125116. NoSync = 3
  125117. }
  125118. /**
  125119. * Class used to load scene from various file formats using registered plugins
  125120. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125121. */
  125122. export class SceneLoader {
  125123. /**
  125124. * No logging while loading
  125125. */
  125126. static readonly NO_LOGGING: number;
  125127. /**
  125128. * Minimal logging while loading
  125129. */
  125130. static readonly MINIMAL_LOGGING: number;
  125131. /**
  125132. * Summary logging while loading
  125133. */
  125134. static readonly SUMMARY_LOGGING: number;
  125135. /**
  125136. * Detailled logging while loading
  125137. */
  125138. static readonly DETAILED_LOGGING: number;
  125139. /**
  125140. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125141. */
  125142. static get ForceFullSceneLoadingForIncremental(): boolean;
  125143. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125144. /**
  125145. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125146. */
  125147. static get ShowLoadingScreen(): boolean;
  125148. static set ShowLoadingScreen(value: boolean);
  125149. /**
  125150. * Defines the current logging level (while loading the scene)
  125151. * @ignorenaming
  125152. */
  125153. static get loggingLevel(): number;
  125154. static set loggingLevel(value: number);
  125155. /**
  125156. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125157. */
  125158. static get CleanBoneMatrixWeights(): boolean;
  125159. static set CleanBoneMatrixWeights(value: boolean);
  125160. /**
  125161. * Event raised when a plugin is used to load a scene
  125162. */
  125163. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125164. private static _registeredPlugins;
  125165. private static _getDefaultPlugin;
  125166. private static _getPluginForExtension;
  125167. private static _getPluginForDirectLoad;
  125168. private static _getPluginForFilename;
  125169. private static _getDirectLoad;
  125170. private static _loadData;
  125171. private static _getFileInfo;
  125172. /**
  125173. * Gets a plugin that can load the given extension
  125174. * @param extension defines the extension to load
  125175. * @returns a plugin or null if none works
  125176. */
  125177. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125178. /**
  125179. * Gets a boolean indicating that the given extension can be loaded
  125180. * @param extension defines the extension to load
  125181. * @returns true if the extension is supported
  125182. */
  125183. static IsPluginForExtensionAvailable(extension: string): boolean;
  125184. /**
  125185. * Adds a new plugin to the list of registered plugins
  125186. * @param plugin defines the plugin to add
  125187. */
  125188. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125189. /**
  125190. * Import meshes into a scene
  125191. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125192. * @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)
  125193. * @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)
  125194. * @param scene the instance of BABYLON.Scene to append to
  125195. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125196. * @param onProgress a callback with a progress event for each file being loaded
  125197. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125198. * @param pluginExtension the extension used to determine the plugin
  125199. * @returns The loaded plugin
  125200. */
  125201. 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>;
  125202. /**
  125203. * Import meshes into a scene
  125204. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125205. * @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)
  125206. * @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)
  125207. * @param scene the instance of BABYLON.Scene to append to
  125208. * @param onProgress a callback with a progress event for each file being loaded
  125209. * @param pluginExtension the extension used to determine the plugin
  125210. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125211. */
  125212. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125213. meshes: AbstractMesh[];
  125214. particleSystems: IParticleSystem[];
  125215. skeletons: Skeleton[];
  125216. animationGroups: AnimationGroup[];
  125217. }>;
  125218. /**
  125219. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  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 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>;
  125230. /**
  125231. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  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 loaded scene
  125238. */
  125239. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125240. /**
  125241. * Append a scene
  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
  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 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>;
  125252. /**
  125253. * Append a scene
  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 or a File object (default: empty string)
  125256. * @param scene is the instance of BABYLON.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 given scene
  125260. */
  125261. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125262. /**
  125263. * Load a scene into an asset container
  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 onSuccess a callback with the scene when import succeeds
  125268. * @param onProgress a callback with a progress event for each file being loaded
  125269. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125270. * @param pluginExtension the extension used to determine the plugin
  125271. * @returns The loaded plugin
  125272. */
  125273. 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>;
  125274. /**
  125275. * Load a scene into an asset container
  125276. * @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)
  125277. * @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)
  125278. * @param scene is the instance of Scene to append to
  125279. * @param onProgress a callback with a progress event for each file being loaded
  125280. * @param pluginExtension the extension used to determine the plugin
  125281. * @returns The loaded asset container
  125282. */
  125283. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125284. /**
  125285. * Import animations from a file into a scene
  125286. * @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)
  125287. * @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)
  125288. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125289. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125290. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125291. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125292. * @param onSuccess a callback with the scene when import succeeds
  125293. * @param onProgress a callback with a progress event for each file being loaded
  125294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125295. * @param pluginExtension the extension used to determine the plugin
  125296. */
  125297. 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;
  125298. /**
  125299. * Import animations from a file into a scene
  125300. * @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)
  125301. * @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)
  125302. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125303. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125304. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125305. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125306. * @param onSuccess a callback with the scene when import succeeds
  125307. * @param onProgress a callback with a progress event for each file being loaded
  125308. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125309. * @param pluginExtension the extension used to determine the plugin
  125310. * @returns the updated scene with imported animations
  125311. */
  125312. 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>;
  125313. }
  125314. }
  125315. declare module BABYLON {
  125316. /**
  125317. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125318. */
  125319. export type MotionControllerHandedness = "none" | "left" | "right";
  125320. /**
  125321. * The type of components available in motion controllers.
  125322. * This is not the name of the component.
  125323. */
  125324. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125325. /**
  125326. * The state of a controller component
  125327. */
  125328. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125329. /**
  125330. * The schema of motion controller layout.
  125331. * No object will be initialized using this interface
  125332. * This is used just to define the profile.
  125333. */
  125334. export interface IMotionControllerLayout {
  125335. /**
  125336. * Path to load the assets. Usually relative to the base path
  125337. */
  125338. assetPath: string;
  125339. /**
  125340. * Available components (unsorted)
  125341. */
  125342. components: {
  125343. /**
  125344. * A map of component Ids
  125345. */
  125346. [componentId: string]: {
  125347. /**
  125348. * The type of input the component outputs
  125349. */
  125350. type: MotionControllerComponentType;
  125351. /**
  125352. * The indices of this component in the gamepad object
  125353. */
  125354. gamepadIndices: {
  125355. /**
  125356. * Index of button
  125357. */
  125358. button?: number;
  125359. /**
  125360. * If available, index of x-axis
  125361. */
  125362. xAxis?: number;
  125363. /**
  125364. * If available, index of y-axis
  125365. */
  125366. yAxis?: number;
  125367. };
  125368. /**
  125369. * The mesh's root node name
  125370. */
  125371. rootNodeName: string;
  125372. /**
  125373. * Animation definitions for this model
  125374. */
  125375. visualResponses: {
  125376. [stateKey: string]: {
  125377. /**
  125378. * What property will be animated
  125379. */
  125380. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125381. /**
  125382. * What states influence this visual response
  125383. */
  125384. states: MotionControllerComponentStateType[];
  125385. /**
  125386. * Type of animation - movement or visibility
  125387. */
  125388. valueNodeProperty: "transform" | "visibility";
  125389. /**
  125390. * Base node name to move. Its position will be calculated according to the min and max nodes
  125391. */
  125392. valueNodeName?: string;
  125393. /**
  125394. * Minimum movement node
  125395. */
  125396. minNodeName?: string;
  125397. /**
  125398. * Max movement node
  125399. */
  125400. maxNodeName?: string;
  125401. };
  125402. };
  125403. /**
  125404. * If touch enabled, what is the name of node to display user feedback
  125405. */
  125406. touchPointNodeName?: string;
  125407. };
  125408. };
  125409. /**
  125410. * Is it xr standard mapping or not
  125411. */
  125412. gamepadMapping: "" | "xr-standard";
  125413. /**
  125414. * Base root node of this entire model
  125415. */
  125416. rootNodeName: string;
  125417. /**
  125418. * Defines the main button component id
  125419. */
  125420. selectComponentId: string;
  125421. }
  125422. /**
  125423. * A definition for the layout map in the input profile
  125424. */
  125425. export interface IMotionControllerLayoutMap {
  125426. /**
  125427. * Layouts with handedness type as a key
  125428. */
  125429. [handedness: string]: IMotionControllerLayout;
  125430. }
  125431. /**
  125432. * The XR Input profile schema
  125433. * Profiles can be found here:
  125434. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125435. */
  125436. export interface IMotionControllerProfile {
  125437. /**
  125438. * fallback profiles for this profileId
  125439. */
  125440. fallbackProfileIds: string[];
  125441. /**
  125442. * The layout map, with handedness as key
  125443. */
  125444. layouts: IMotionControllerLayoutMap;
  125445. /**
  125446. * The id of this profile
  125447. * correlates to the profile(s) in the xrInput.profiles array
  125448. */
  125449. profileId: string;
  125450. }
  125451. /**
  125452. * A helper-interface for the 3 meshes needed for controller button animation
  125453. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125454. */
  125455. export interface IMotionControllerButtonMeshMap {
  125456. /**
  125457. * the mesh that defines the pressed value mesh position.
  125458. * This is used to find the max-position of this button
  125459. */
  125460. pressedMesh: AbstractMesh;
  125461. /**
  125462. * the mesh that defines the unpressed value mesh position.
  125463. * This is used to find the min (or initial) position of this button
  125464. */
  125465. unpressedMesh: AbstractMesh;
  125466. /**
  125467. * The mesh that will be changed when value changes
  125468. */
  125469. valueMesh: AbstractMesh;
  125470. }
  125471. /**
  125472. * A helper-interface for the 3 meshes needed for controller axis animation.
  125473. * This will be expanded when touchpad animations are fully supported
  125474. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125475. */
  125476. export interface IMotionControllerMeshMap {
  125477. /**
  125478. * the mesh that defines the maximum value mesh position.
  125479. */
  125480. maxMesh?: AbstractMesh;
  125481. /**
  125482. * the mesh that defines the minimum value mesh position.
  125483. */
  125484. minMesh?: AbstractMesh;
  125485. /**
  125486. * The mesh that will be changed when axis value changes
  125487. */
  125488. valueMesh: AbstractMesh;
  125489. }
  125490. /**
  125491. * The elements needed for change-detection of the gamepad objects in motion controllers
  125492. */
  125493. export interface IMinimalMotionControllerObject {
  125494. /**
  125495. * Available axes of this controller
  125496. */
  125497. axes: number[];
  125498. /**
  125499. * An array of available buttons
  125500. */
  125501. buttons: Array<{
  125502. /**
  125503. * Value of the button/trigger
  125504. */
  125505. value: number;
  125506. /**
  125507. * If the button/trigger is currently touched
  125508. */
  125509. touched: boolean;
  125510. /**
  125511. * If the button/trigger is currently pressed
  125512. */
  125513. pressed: boolean;
  125514. }>;
  125515. /**
  125516. * EXPERIMENTAL haptic support.
  125517. */
  125518. hapticActuators?: Array<{
  125519. pulse: (value: number, duration: number) => Promise<boolean>;
  125520. }>;
  125521. }
  125522. /**
  125523. * An Abstract Motion controller
  125524. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125525. * Each component has an observable to check for changes in value and state
  125526. */
  125527. export abstract class WebXRAbstractMotionController implements IDisposable {
  125528. protected scene: Scene;
  125529. protected layout: IMotionControllerLayout;
  125530. /**
  125531. * The gamepad object correlating to this controller
  125532. */
  125533. gamepadObject: IMinimalMotionControllerObject;
  125534. /**
  125535. * handedness (left/right/none) of this controller
  125536. */
  125537. handedness: MotionControllerHandedness;
  125538. private _initComponent;
  125539. private _modelReady;
  125540. /**
  125541. * A map of components (WebXRControllerComponent) in this motion controller
  125542. * Components have a ComponentType and can also have both button and axis definitions
  125543. */
  125544. readonly components: {
  125545. [id: string]: WebXRControllerComponent;
  125546. };
  125547. /**
  125548. * Disable the model's animation. Can be set at any time.
  125549. */
  125550. disableAnimation: boolean;
  125551. /**
  125552. * Observers registered here will be triggered when the model of this controller is done loading
  125553. */
  125554. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125555. /**
  125556. * The profile id of this motion controller
  125557. */
  125558. abstract profileId: string;
  125559. /**
  125560. * The root mesh of the model. It is null if the model was not yet initialized
  125561. */
  125562. rootMesh: Nullable<AbstractMesh>;
  125563. /**
  125564. * constructs a new abstract motion controller
  125565. * @param scene the scene to which the model of the controller will be added
  125566. * @param layout The profile layout to load
  125567. * @param gamepadObject The gamepad object correlating to this controller
  125568. * @param handedness handedness (left/right/none) of this controller
  125569. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125570. */
  125571. constructor(scene: Scene, layout: IMotionControllerLayout,
  125572. /**
  125573. * The gamepad object correlating to this controller
  125574. */
  125575. gamepadObject: IMinimalMotionControllerObject,
  125576. /**
  125577. * handedness (left/right/none) of this controller
  125578. */
  125579. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125580. /**
  125581. * Dispose this controller, the model mesh and all its components
  125582. */
  125583. dispose(): void;
  125584. /**
  125585. * Returns all components of specific type
  125586. * @param type the type to search for
  125587. * @return an array of components with this type
  125588. */
  125589. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125590. /**
  125591. * get a component based an its component id as defined in layout.components
  125592. * @param id the id of the component
  125593. * @returns the component correlates to the id or undefined if not found
  125594. */
  125595. getComponent(id: string): WebXRControllerComponent;
  125596. /**
  125597. * Get the list of components available in this motion controller
  125598. * @returns an array of strings correlating to available components
  125599. */
  125600. getComponentIds(): string[];
  125601. /**
  125602. * Get the first component of specific type
  125603. * @param type type of component to find
  125604. * @return a controller component or null if not found
  125605. */
  125606. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125607. /**
  125608. * Get the main (Select) component of this controller as defined in the layout
  125609. * @returns the main component of this controller
  125610. */
  125611. getMainComponent(): WebXRControllerComponent;
  125612. /**
  125613. * Loads the model correlating to this controller
  125614. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125615. * @returns A promise fulfilled with the result of the model loading
  125616. */
  125617. loadModel(): Promise<boolean>;
  125618. /**
  125619. * Update this model using the current XRFrame
  125620. * @param xrFrame the current xr frame to use and update the model
  125621. */
  125622. updateFromXRFrame(xrFrame: XRFrame): void;
  125623. /**
  125624. * Backwards compatibility due to a deeply-integrated typo
  125625. */
  125626. get handness(): XREye;
  125627. /**
  125628. * Pulse (vibrate) this controller
  125629. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125630. * Consecutive calls to this function will cancel the last pulse call
  125631. *
  125632. * @param value the strength of the pulse in 0.0...1.0 range
  125633. * @param duration Duration of the pulse in milliseconds
  125634. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125635. * @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
  125636. */
  125637. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125638. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125639. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125640. /**
  125641. * Moves the axis on the controller mesh based on its current state
  125642. * @param axis the index of the axis
  125643. * @param axisValue the value of the axis which determines the meshes new position
  125644. * @hidden
  125645. */
  125646. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125647. /**
  125648. * Update the model itself with the current frame data
  125649. * @param xrFrame the frame to use for updating the model mesh
  125650. */
  125651. protected updateModel(xrFrame: XRFrame): void;
  125652. /**
  125653. * Get the filename and path for this controller's model
  125654. * @returns a map of filename and path
  125655. */
  125656. protected abstract _getFilenameAndPath(): {
  125657. filename: string;
  125658. path: string;
  125659. };
  125660. /**
  125661. * This function is called before the mesh is loaded. It checks for loading constraints.
  125662. * For example, this function can check if the GLB loader is available
  125663. * If this function returns false, the generic controller will be loaded instead
  125664. * @returns Is the client ready to load the mesh
  125665. */
  125666. protected abstract _getModelLoadingConstraints(): boolean;
  125667. /**
  125668. * This function will be called after the model was successfully loaded and can be used
  125669. * for mesh transformations before it is available for the user
  125670. * @param meshes the loaded meshes
  125671. */
  125672. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125673. /**
  125674. * Set the root mesh for this controller. Important for the WebXR controller class
  125675. * @param meshes the loaded meshes
  125676. */
  125677. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125678. /**
  125679. * A function executed each frame that updates the mesh (if needed)
  125680. * @param xrFrame the current xrFrame
  125681. */
  125682. protected abstract _updateModel(xrFrame: XRFrame): void;
  125683. private _getGenericFilenameAndPath;
  125684. private _getGenericParentMesh;
  125685. }
  125686. }
  125687. declare module BABYLON {
  125688. /**
  125689. * A generic trigger-only motion controller for WebXR
  125690. */
  125691. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125692. /**
  125693. * Static version of the profile id of this controller
  125694. */
  125695. static ProfileId: string;
  125696. profileId: string;
  125697. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125698. protected _getFilenameAndPath(): {
  125699. filename: string;
  125700. path: string;
  125701. };
  125702. protected _getModelLoadingConstraints(): boolean;
  125703. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125704. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125705. protected _updateModel(): void;
  125706. }
  125707. }
  125708. declare module BABYLON {
  125709. /**
  125710. * Class containing static functions to help procedurally build meshes
  125711. */
  125712. export class SphereBuilder {
  125713. /**
  125714. * Creates a sphere mesh
  125715. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125716. * * 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`)
  125717. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125718. * * 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
  125719. * * 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)
  125720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125721. * * 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
  125722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125723. * @param name defines the name of the mesh
  125724. * @param options defines the options used to create the mesh
  125725. * @param scene defines the hosting scene
  125726. * @returns the sphere mesh
  125727. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125728. */
  125729. static CreateSphere(name: string, options: {
  125730. segments?: number;
  125731. diameter?: number;
  125732. diameterX?: number;
  125733. diameterY?: number;
  125734. diameterZ?: number;
  125735. arc?: number;
  125736. slice?: number;
  125737. sideOrientation?: number;
  125738. frontUVs?: Vector4;
  125739. backUVs?: Vector4;
  125740. updatable?: boolean;
  125741. }, scene?: Nullable<Scene>): Mesh;
  125742. }
  125743. }
  125744. declare module BABYLON {
  125745. /**
  125746. * A profiled motion controller has its profile loaded from an online repository.
  125747. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125748. */
  125749. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125750. private _repositoryUrl;
  125751. private _buttonMeshMapping;
  125752. private _touchDots;
  125753. /**
  125754. * The profile ID of this controller. Will be populated when the controller initializes.
  125755. */
  125756. profileId: string;
  125757. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125758. dispose(): void;
  125759. protected _getFilenameAndPath(): {
  125760. filename: string;
  125761. path: string;
  125762. };
  125763. protected _getModelLoadingConstraints(): boolean;
  125764. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125765. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125766. protected _updateModel(_xrFrame: XRFrame): void;
  125767. }
  125768. }
  125769. declare module BABYLON {
  125770. /**
  125771. * A construction function type to create a new controller based on an xrInput object
  125772. */
  125773. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125774. /**
  125775. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125776. *
  125777. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125778. * it should be replaced with auto-loaded controllers.
  125779. *
  125780. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125781. */
  125782. export class WebXRMotionControllerManager {
  125783. private static _AvailableControllers;
  125784. private static _Fallbacks;
  125785. private static _ProfileLoadingPromises;
  125786. private static _ProfilesList;
  125787. /**
  125788. * The base URL of the online controller repository. Can be changed at any time.
  125789. */
  125790. static BaseRepositoryUrl: string;
  125791. /**
  125792. * Which repository gets priority - local or online
  125793. */
  125794. static PrioritizeOnlineRepository: boolean;
  125795. /**
  125796. * Use the online repository, or use only locally-defined controllers
  125797. */
  125798. static UseOnlineRepository: boolean;
  125799. /**
  125800. * Clear the cache used for profile loading and reload when requested again
  125801. */
  125802. static ClearProfilesCache(): void;
  125803. /**
  125804. * Register the default fallbacks.
  125805. * This function is called automatically when this file is imported.
  125806. */
  125807. static DefaultFallbacks(): void;
  125808. /**
  125809. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125810. * @param profileId the profile to which a fallback needs to be found
  125811. * @return an array with corresponding fallback profiles
  125812. */
  125813. static FindFallbackWithProfileId(profileId: string): string[];
  125814. /**
  125815. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125816. * The order of search:
  125817. *
  125818. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125819. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125820. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125821. * 4) return the generic trigger controller if none were found
  125822. *
  125823. * @param xrInput the xrInput to which a new controller is initialized
  125824. * @param scene the scene to which the model will be added
  125825. * @param forceProfile force a certain profile for this controller
  125826. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125827. */
  125828. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125829. /**
  125830. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125831. *
  125832. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125833. *
  125834. * @param type the profile type to register
  125835. * @param constructFunction the function to be called when loading this profile
  125836. */
  125837. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125838. /**
  125839. * Register a fallback to a specific profile.
  125840. * @param profileId the profileId that will receive the fallbacks
  125841. * @param fallbacks A list of fallback profiles
  125842. */
  125843. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125844. /**
  125845. * Will update the list of profiles available in the repository
  125846. * @return a promise that resolves to a map of profiles available online
  125847. */
  125848. static UpdateProfilesList(): Promise<{
  125849. [profile: string]: string;
  125850. }>;
  125851. private static _LoadProfileFromRepository;
  125852. private static _LoadProfilesFromAvailableControllers;
  125853. }
  125854. }
  125855. declare module BABYLON {
  125856. /**
  125857. * Configuration options for the WebXR controller creation
  125858. */
  125859. export interface IWebXRControllerOptions {
  125860. /**
  125861. * Should the controller mesh be animated when a user interacts with it
  125862. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125863. */
  125864. disableMotionControllerAnimation?: boolean;
  125865. /**
  125866. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125867. */
  125868. doNotLoadControllerMesh?: boolean;
  125869. /**
  125870. * Force a specific controller type for this controller.
  125871. * This can be used when creating your own profile or when testing different controllers
  125872. */
  125873. forceControllerProfile?: string;
  125874. /**
  125875. * Defines a rendering group ID for meshes that will be loaded.
  125876. * This is for the default controllers only.
  125877. */
  125878. renderingGroupId?: number;
  125879. }
  125880. /**
  125881. * Represents an XR controller
  125882. */
  125883. export class WebXRInputSource {
  125884. private _scene;
  125885. /** The underlying input source for the controller */
  125886. inputSource: XRInputSource;
  125887. private _options;
  125888. private _tmpVector;
  125889. private _uniqueId;
  125890. /**
  125891. * 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
  125892. */
  125893. grip?: AbstractMesh;
  125894. /**
  125895. * If available, this is the gamepad object related to this controller.
  125896. * Using this object it is possible to get click events and trackpad changes of the
  125897. * webxr controller that is currently being used.
  125898. */
  125899. motionController?: WebXRAbstractMotionController;
  125900. /**
  125901. * Event that fires when the controller is removed/disposed.
  125902. * The object provided as event data is this controller, after associated assets were disposed.
  125903. * uniqueId is still available.
  125904. */
  125905. onDisposeObservable: Observable<WebXRInputSource>;
  125906. /**
  125907. * Will be triggered when the mesh associated with the motion controller is done loading.
  125908. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125909. * A shortened version of controller -> motion controller -> on mesh loaded.
  125910. */
  125911. onMeshLoadedObservable: Observable<AbstractMesh>;
  125912. /**
  125913. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125914. */
  125915. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125916. /**
  125917. * Pointer which can be used to select objects or attach a visible laser to
  125918. */
  125919. pointer: AbstractMesh;
  125920. /**
  125921. * Creates the input source object
  125922. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  125923. * @param _scene the scene which the controller should be associated to
  125924. * @param inputSource the underlying input source for the controller
  125925. * @param _options options for this controller creation
  125926. */
  125927. constructor(_scene: Scene,
  125928. /** The underlying input source for the controller */
  125929. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125930. /**
  125931. * Get this controllers unique id
  125932. */
  125933. get uniqueId(): string;
  125934. /**
  125935. * Disposes of the object
  125936. */
  125937. dispose(): void;
  125938. /**
  125939. * Gets a world space ray coming from the pointer or grip
  125940. * @param result the resulting ray
  125941. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125942. */
  125943. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125944. /**
  125945. * Updates the controller pose based on the given XRFrame
  125946. * @param xrFrame xr frame to update the pose with
  125947. * @param referenceSpace reference space to use
  125948. */
  125949. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125950. }
  125951. }
  125952. declare module BABYLON {
  125953. /**
  125954. * The schema for initialization options of the XR Input class
  125955. */
  125956. export interface IWebXRInputOptions {
  125957. /**
  125958. * If set to true no model will be automatically loaded
  125959. */
  125960. doNotLoadControllerMeshes?: boolean;
  125961. /**
  125962. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125963. * If not found, the xr input profile data will be used.
  125964. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125965. */
  125966. forceInputProfile?: string;
  125967. /**
  125968. * Do not send a request to the controller repository to load the profile.
  125969. *
  125970. * Instead, use the controllers available in babylon itself.
  125971. */
  125972. disableOnlineControllerRepository?: boolean;
  125973. /**
  125974. * A custom URL for the controllers repository
  125975. */
  125976. customControllersRepositoryURL?: string;
  125977. /**
  125978. * Should the controller model's components not move according to the user input
  125979. */
  125980. disableControllerAnimation?: boolean;
  125981. /**
  125982. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125983. */
  125984. controllerOptions?: IWebXRControllerOptions;
  125985. }
  125986. /**
  125987. * XR input used to track XR inputs such as controllers/rays
  125988. */
  125989. export class WebXRInput implements IDisposable {
  125990. /**
  125991. * the xr session manager for this session
  125992. */
  125993. xrSessionManager: WebXRSessionManager;
  125994. /**
  125995. * the WebXR camera for this session. Mainly used for teleportation
  125996. */
  125997. xrCamera: WebXRCamera;
  125998. private readonly options;
  125999. /**
  126000. * XR controllers being tracked
  126001. */
  126002. controllers: Array<WebXRInputSource>;
  126003. private _frameObserver;
  126004. private _sessionEndedObserver;
  126005. private _sessionInitObserver;
  126006. /**
  126007. * Event when a controller has been connected/added
  126008. */
  126009. onControllerAddedObservable: Observable<WebXRInputSource>;
  126010. /**
  126011. * Event when a controller has been removed/disconnected
  126012. */
  126013. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126014. /**
  126015. * Initializes the WebXRInput
  126016. * @param xrSessionManager the xr session manager for this session
  126017. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126018. * @param options = initialization options for this xr input
  126019. */
  126020. constructor(
  126021. /**
  126022. * the xr session manager for this session
  126023. */
  126024. xrSessionManager: WebXRSessionManager,
  126025. /**
  126026. * the WebXR camera for this session. Mainly used for teleportation
  126027. */
  126028. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126029. private _onInputSourcesChange;
  126030. private _addAndRemoveControllers;
  126031. /**
  126032. * Disposes of the object
  126033. */
  126034. dispose(): void;
  126035. }
  126036. }
  126037. declare module BABYLON {
  126038. /**
  126039. * This is the base class for all WebXR features.
  126040. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126041. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126042. */
  126043. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126044. protected _xrSessionManager: WebXRSessionManager;
  126045. private _attached;
  126046. private _removeOnDetach;
  126047. /**
  126048. * Should auto-attach be disabled?
  126049. */
  126050. disableAutoAttach: boolean;
  126051. /**
  126052. * Construct a new (abstract) WebXR feature
  126053. * @param _xrSessionManager the xr session manager for this feature
  126054. */
  126055. constructor(_xrSessionManager: WebXRSessionManager);
  126056. /**
  126057. * Is this feature attached
  126058. */
  126059. get attached(): boolean;
  126060. /**
  126061. * attach this feature
  126062. *
  126063. * @param force should attachment be forced (even when already attached)
  126064. * @returns true if successful, false is failed or already attached
  126065. */
  126066. attach(force?: boolean): boolean;
  126067. /**
  126068. * detach this feature.
  126069. *
  126070. * @returns true if successful, false if failed or already detached
  126071. */
  126072. detach(): boolean;
  126073. /**
  126074. * Dispose this feature and all of the resources attached
  126075. */
  126076. dispose(): void;
  126077. /**
  126078. * This is used to register callbacks that will automatically be removed when detach is called.
  126079. * @param observable the observable to which the observer will be attached
  126080. * @param callback the callback to register
  126081. */
  126082. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126083. /**
  126084. * Code in this function will be executed on each xrFrame received from the browser.
  126085. * This function will not execute after the feature is detached.
  126086. * @param _xrFrame the current frame
  126087. */
  126088. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126089. }
  126090. }
  126091. declare module BABYLON {
  126092. /**
  126093. * Renders a layer on top of an existing scene
  126094. */
  126095. export class UtilityLayerRenderer implements IDisposable {
  126096. /** the original scene that will be rendered on top of */
  126097. originalScene: Scene;
  126098. private _pointerCaptures;
  126099. private _lastPointerEvents;
  126100. private static _DefaultUtilityLayer;
  126101. private static _DefaultKeepDepthUtilityLayer;
  126102. private _sharedGizmoLight;
  126103. private _renderCamera;
  126104. /**
  126105. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126106. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126107. * @returns the camera that is used when rendering the utility layer
  126108. */
  126109. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126110. /**
  126111. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126112. * @param cam the camera that should be used when rendering the utility layer
  126113. */
  126114. setRenderCamera(cam: Nullable<Camera>): void;
  126115. /**
  126116. * @hidden
  126117. * Light which used by gizmos to get light shading
  126118. */
  126119. _getSharedGizmoLight(): HemisphericLight;
  126120. /**
  126121. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126122. */
  126123. pickUtilitySceneFirst: boolean;
  126124. /**
  126125. * 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)
  126126. */
  126127. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126128. /**
  126129. * 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)
  126130. */
  126131. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126132. /**
  126133. * The scene that is rendered on top of the original scene
  126134. */
  126135. utilityLayerScene: Scene;
  126136. /**
  126137. * If the utility layer should automatically be rendered on top of existing scene
  126138. */
  126139. shouldRender: boolean;
  126140. /**
  126141. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126142. */
  126143. onlyCheckPointerDownEvents: boolean;
  126144. /**
  126145. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126146. */
  126147. processAllEvents: boolean;
  126148. /**
  126149. * Observable raised when the pointer move from the utility layer scene to the main scene
  126150. */
  126151. onPointerOutObservable: Observable<number>;
  126152. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126153. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126154. private _afterRenderObserver;
  126155. private _sceneDisposeObserver;
  126156. private _originalPointerObserver;
  126157. /**
  126158. * Instantiates a UtilityLayerRenderer
  126159. * @param originalScene the original scene that will be rendered on top of
  126160. * @param handleEvents boolean indicating if the utility layer should handle events
  126161. */
  126162. constructor(
  126163. /** the original scene that will be rendered on top of */
  126164. originalScene: Scene, handleEvents?: boolean);
  126165. private _notifyObservers;
  126166. /**
  126167. * Renders the utility layers scene on top of the original scene
  126168. */
  126169. render(): void;
  126170. /**
  126171. * Disposes of the renderer
  126172. */
  126173. dispose(): void;
  126174. private _updateCamera;
  126175. }
  126176. }
  126177. declare module BABYLON {
  126178. /**
  126179. * Options interface for the pointer selection module
  126180. */
  126181. export interface IWebXRControllerPointerSelectionOptions {
  126182. /**
  126183. * if provided, this scene will be used to render meshes.
  126184. */
  126185. customUtilityLayerScene?: Scene;
  126186. /**
  126187. * 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)
  126188. * If not disabled, the last picked point will be used to execute a pointer up event
  126189. * If disabled, pointer up event will be triggered right after the pointer down event.
  126190. * Used in screen and gaze target ray mode only
  126191. */
  126192. disablePointerUpOnTouchOut: boolean;
  126193. /**
  126194. * For gaze mode (time to select instead of press)
  126195. */
  126196. forceGazeMode: boolean;
  126197. /**
  126198. * 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
  126199. * to start a new countdown to the pointer down event.
  126200. * Defaults to 1.
  126201. */
  126202. gazeModePointerMovedFactor?: number;
  126203. /**
  126204. * Different button type to use instead of the main component
  126205. */
  126206. overrideButtonId?: string;
  126207. /**
  126208. * use this rendering group id for the meshes (optional)
  126209. */
  126210. renderingGroupId?: number;
  126211. /**
  126212. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126213. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126214. * 3000 means 3 seconds between pointing at something and selecting it
  126215. */
  126216. timeToSelect?: number;
  126217. /**
  126218. * Should meshes created here be added to a utility layer or the main scene
  126219. */
  126220. useUtilityLayer?: boolean;
  126221. /**
  126222. * the xr input to use with this pointer selection
  126223. */
  126224. xrInput: WebXRInput;
  126225. }
  126226. /**
  126227. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126228. */
  126229. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126230. private readonly _options;
  126231. private static _idCounter;
  126232. private _attachController;
  126233. private _controllers;
  126234. private _scene;
  126235. private _tmpVectorForPickCompare;
  126236. /**
  126237. * The module's name
  126238. */
  126239. static readonly Name: string;
  126240. /**
  126241. * The (Babylon) version of this module.
  126242. * This is an integer representing the implementation version.
  126243. * This number does not correspond to the WebXR specs version
  126244. */
  126245. static readonly Version: number;
  126246. /**
  126247. * Disable lighting on the laser pointer (so it will always be visible)
  126248. */
  126249. disablePointerLighting: boolean;
  126250. /**
  126251. * Disable lighting on the selection mesh (so it will always be visible)
  126252. */
  126253. disableSelectionMeshLighting: boolean;
  126254. /**
  126255. * Should the laser pointer be displayed
  126256. */
  126257. displayLaserPointer: boolean;
  126258. /**
  126259. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126260. */
  126261. displaySelectionMesh: boolean;
  126262. /**
  126263. * This color will be set to the laser pointer when selection is triggered
  126264. */
  126265. laserPointerPickedColor: Color3;
  126266. /**
  126267. * Default color of the laser pointer
  126268. */
  126269. laserPointerDefaultColor: Color3;
  126270. /**
  126271. * default color of the selection ring
  126272. */
  126273. selectionMeshDefaultColor: Color3;
  126274. /**
  126275. * This color will be applied to the selection ring when selection is triggered
  126276. */
  126277. selectionMeshPickedColor: Color3;
  126278. /**
  126279. * Optional filter to be used for ray selection. This predicate shares behavior with
  126280. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126281. */
  126282. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126283. /**
  126284. * constructs a new background remover module
  126285. * @param _xrSessionManager the session manager for this module
  126286. * @param _options read-only options to be used in this module
  126287. */
  126288. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126289. /**
  126290. * attach this feature
  126291. * Will usually be called by the features manager
  126292. *
  126293. * @returns true if successful.
  126294. */
  126295. attach(): boolean;
  126296. /**
  126297. * detach this feature.
  126298. * Will usually be called by the features manager
  126299. *
  126300. * @returns true if successful.
  126301. */
  126302. detach(): boolean;
  126303. /**
  126304. * Will get the mesh under a specific pointer.
  126305. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126306. * @param controllerId the controllerId to check
  126307. * @returns The mesh under pointer or null if no mesh is under the pointer
  126308. */
  126309. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126310. /**
  126311. * Get the xr controller that correlates to the pointer id in the pointer event
  126312. *
  126313. * @param id the pointer id to search for
  126314. * @returns the controller that correlates to this id or null if not found
  126315. */
  126316. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126317. protected _onXRFrame(_xrFrame: XRFrame): void;
  126318. private _attachGazeMode;
  126319. private _attachScreenRayMode;
  126320. private _attachTrackedPointerRayMode;
  126321. private _convertNormalToDirectionOfRay;
  126322. private _detachController;
  126323. private _generateNewMeshPair;
  126324. private _pickingMoved;
  126325. private _updatePointerDistance;
  126326. /** @hidden */
  126327. get lasterPointerDefaultColor(): Color3;
  126328. }
  126329. }
  126330. declare module BABYLON {
  126331. /**
  126332. * Button which can be used to enter a different mode of XR
  126333. */
  126334. export class WebXREnterExitUIButton {
  126335. /** button element */
  126336. element: HTMLElement;
  126337. /** XR initialization options for the button */
  126338. sessionMode: XRSessionMode;
  126339. /** Reference space type */
  126340. referenceSpaceType: XRReferenceSpaceType;
  126341. /**
  126342. * Creates a WebXREnterExitUIButton
  126343. * @param element button element
  126344. * @param sessionMode XR initialization session mode
  126345. * @param referenceSpaceType the type of reference space to be used
  126346. */
  126347. constructor(
  126348. /** button element */
  126349. element: HTMLElement,
  126350. /** XR initialization options for the button */
  126351. sessionMode: XRSessionMode,
  126352. /** Reference space type */
  126353. referenceSpaceType: XRReferenceSpaceType);
  126354. /**
  126355. * Extendable function which can be used to update the button's visuals when the state changes
  126356. * @param activeButton the current active button in the UI
  126357. */
  126358. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126359. }
  126360. /**
  126361. * Options to create the webXR UI
  126362. */
  126363. export class WebXREnterExitUIOptions {
  126364. /**
  126365. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126366. */
  126367. customButtons?: Array<WebXREnterExitUIButton>;
  126368. /**
  126369. * A reference space type to use when creating the default button.
  126370. * Default is local-floor
  126371. */
  126372. referenceSpaceType?: XRReferenceSpaceType;
  126373. /**
  126374. * Context to enter xr with
  126375. */
  126376. renderTarget?: Nullable<WebXRRenderTarget>;
  126377. /**
  126378. * A session mode to use when creating the default button.
  126379. * Default is immersive-vr
  126380. */
  126381. sessionMode?: XRSessionMode;
  126382. /**
  126383. * A list of optional features to init the session with
  126384. */
  126385. optionalFeatures?: string[];
  126386. /**
  126387. * A list of optional features to init the session with
  126388. */
  126389. requiredFeatures?: string[];
  126390. }
  126391. /**
  126392. * UI to allow the user to enter/exit XR mode
  126393. */
  126394. export class WebXREnterExitUI implements IDisposable {
  126395. private scene;
  126396. /** version of the options passed to this UI */
  126397. options: WebXREnterExitUIOptions;
  126398. private _activeButton;
  126399. private _buttons;
  126400. private _overlay;
  126401. /**
  126402. * Fired every time the active button is changed.
  126403. *
  126404. * When xr is entered via a button that launches xr that button will be the callback parameter
  126405. *
  126406. * When exiting xr the callback parameter will be null)
  126407. */
  126408. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126409. /**
  126410. *
  126411. * @param scene babylon scene object to use
  126412. * @param options (read-only) version of the options passed to this UI
  126413. */
  126414. private constructor();
  126415. /**
  126416. * Creates UI to allow the user to enter/exit XR mode
  126417. * @param scene the scene to add the ui to
  126418. * @param helper the xr experience helper to enter/exit xr with
  126419. * @param options options to configure the UI
  126420. * @returns the created ui
  126421. */
  126422. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126423. /**
  126424. * Disposes of the XR UI component
  126425. */
  126426. dispose(): void;
  126427. private _updateButtons;
  126428. }
  126429. }
  126430. declare module BABYLON {
  126431. /**
  126432. * Class containing static functions to help procedurally build meshes
  126433. */
  126434. export class LinesBuilder {
  126435. /**
  126436. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126437. * * 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
  126438. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126439. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126440. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126441. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126442. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126443. * * 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
  126444. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126447. * @param name defines the name of the new line system
  126448. * @param options defines the options used to create the line system
  126449. * @param scene defines the hosting scene
  126450. * @returns a new line system mesh
  126451. */
  126452. static CreateLineSystem(name: string, options: {
  126453. lines: Vector3[][];
  126454. updatable?: boolean;
  126455. instance?: Nullable<LinesMesh>;
  126456. colors?: Nullable<Color4[][]>;
  126457. useVertexAlpha?: boolean;
  126458. }, scene: Nullable<Scene>): LinesMesh;
  126459. /**
  126460. * Creates a line mesh
  126461. * 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
  126462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126463. * * The parameter `points` is an array successive Vector3
  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 `colors` is an array of successive Color4, one per line point
  126466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126467. * * When updating an instance, remember that only point positions can change, not the number of points
  126468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126470. * @param name defines the name of the new line system
  126471. * @param options defines the options used to create the line system
  126472. * @param scene defines the hosting scene
  126473. * @returns a new line mesh
  126474. */
  126475. static CreateLines(name: string, options: {
  126476. points: Vector3[];
  126477. updatable?: boolean;
  126478. instance?: Nullable<LinesMesh>;
  126479. colors?: Color4[];
  126480. useVertexAlpha?: boolean;
  126481. }, scene?: Nullable<Scene>): LinesMesh;
  126482. /**
  126483. * Creates a dashed line mesh
  126484. * * 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
  126485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126486. * * The parameter `points` is an array successive Vector3
  126487. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126488. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126489. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126490. * * 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
  126491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126492. * * When updating an instance, remember that only point positions can change, not the number of points
  126493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126494. * @param name defines the name of the mesh
  126495. * @param options defines the options used to create the mesh
  126496. * @param scene defines the hosting scene
  126497. * @returns the dashed line mesh
  126498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126499. */
  126500. static CreateDashedLines(name: string, options: {
  126501. points: Vector3[];
  126502. dashSize?: number;
  126503. gapSize?: number;
  126504. dashNb?: number;
  126505. updatable?: boolean;
  126506. instance?: LinesMesh;
  126507. useVertexAlpha?: boolean;
  126508. }, scene?: Nullable<Scene>): LinesMesh;
  126509. }
  126510. }
  126511. declare module BABYLON {
  126512. /**
  126513. * Construction options for a timer
  126514. */
  126515. export interface ITimerOptions<T> {
  126516. /**
  126517. * Time-to-end
  126518. */
  126519. timeout: number;
  126520. /**
  126521. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126522. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126523. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126524. */
  126525. contextObservable: Observable<T>;
  126526. /**
  126527. * Optional parameters when adding an observer to the observable
  126528. */
  126529. observableParameters?: {
  126530. mask?: number;
  126531. insertFirst?: boolean;
  126532. scope?: any;
  126533. };
  126534. /**
  126535. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126536. */
  126537. breakCondition?: (data?: ITimerData<T>) => boolean;
  126538. /**
  126539. * Will be triggered when the time condition has met
  126540. */
  126541. onEnded?: (data: ITimerData<any>) => void;
  126542. /**
  126543. * Will be triggered when the break condition has met (prematurely ended)
  126544. */
  126545. onAborted?: (data: ITimerData<any>) => void;
  126546. /**
  126547. * Optional function to execute on each tick (or count)
  126548. */
  126549. onTick?: (data: ITimerData<any>) => void;
  126550. }
  126551. /**
  126552. * An interface defining the data sent by the timer
  126553. */
  126554. export interface ITimerData<T> {
  126555. /**
  126556. * When did it start
  126557. */
  126558. startTime: number;
  126559. /**
  126560. * Time now
  126561. */
  126562. currentTime: number;
  126563. /**
  126564. * Time passed since started
  126565. */
  126566. deltaTime: number;
  126567. /**
  126568. * How much is completed, in [0.0...1.0].
  126569. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126570. */
  126571. completeRate: number;
  126572. /**
  126573. * What the registered observable sent in the last count
  126574. */
  126575. payload: T;
  126576. }
  126577. /**
  126578. * The current state of the timer
  126579. */
  126580. export enum TimerState {
  126581. /**
  126582. * Timer initialized, not yet started
  126583. */
  126584. INIT = 0,
  126585. /**
  126586. * Timer started and counting
  126587. */
  126588. STARTED = 1,
  126589. /**
  126590. * Timer ended (whether aborted or time reached)
  126591. */
  126592. ENDED = 2
  126593. }
  126594. /**
  126595. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126596. *
  126597. * @param options options with which to initialize this timer
  126598. */
  126599. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126600. /**
  126601. * An advanced implementation of a timer class
  126602. */
  126603. export class AdvancedTimer<T = any> implements IDisposable {
  126604. /**
  126605. * Will notify each time the timer calculates the remaining time
  126606. */
  126607. onEachCountObservable: Observable<ITimerData<T>>;
  126608. /**
  126609. * Will trigger when the timer was aborted due to the break condition
  126610. */
  126611. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126612. /**
  126613. * Will trigger when the timer ended successfully
  126614. */
  126615. onTimerEndedObservable: Observable<ITimerData<T>>;
  126616. /**
  126617. * Will trigger when the timer state has changed
  126618. */
  126619. onStateChangedObservable: Observable<TimerState>;
  126620. private _observer;
  126621. private _contextObservable;
  126622. private _observableParameters;
  126623. private _startTime;
  126624. private _timer;
  126625. private _state;
  126626. private _breakCondition;
  126627. private _timeToEnd;
  126628. private _breakOnNextTick;
  126629. /**
  126630. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126631. * @param options construction options for this advanced timer
  126632. */
  126633. constructor(options: ITimerOptions<T>);
  126634. /**
  126635. * set a breaking condition for this timer. Default is to never break during count
  126636. * @param predicate the new break condition. Returns true to break, false otherwise
  126637. */
  126638. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126639. /**
  126640. * Reset ALL associated observables in this advanced timer
  126641. */
  126642. clearObservables(): void;
  126643. /**
  126644. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126645. *
  126646. * @param timeToEnd how much time to measure until timer ended
  126647. */
  126648. start(timeToEnd?: number): void;
  126649. /**
  126650. * Will force a stop on the next tick.
  126651. */
  126652. stop(): void;
  126653. /**
  126654. * Dispose this timer, clearing all resources
  126655. */
  126656. dispose(): void;
  126657. private _setState;
  126658. private _tick;
  126659. private _stop;
  126660. }
  126661. }
  126662. declare module BABYLON {
  126663. /**
  126664. * The options container for the teleportation module
  126665. */
  126666. export interface IWebXRTeleportationOptions {
  126667. /**
  126668. * if provided, this scene will be used to render meshes.
  126669. */
  126670. customUtilityLayerScene?: Scene;
  126671. /**
  126672. * Values to configure the default target mesh
  126673. */
  126674. defaultTargetMeshOptions?: {
  126675. /**
  126676. * Fill color of the teleportation area
  126677. */
  126678. teleportationFillColor?: string;
  126679. /**
  126680. * Border color for the teleportation area
  126681. */
  126682. teleportationBorderColor?: string;
  126683. /**
  126684. * Disable the mesh's animation sequence
  126685. */
  126686. disableAnimation?: boolean;
  126687. /**
  126688. * Disable lighting on the material or the ring and arrow
  126689. */
  126690. disableLighting?: boolean;
  126691. /**
  126692. * Override the default material of the torus and arrow
  126693. */
  126694. torusArrowMaterial?: Material;
  126695. };
  126696. /**
  126697. * A list of meshes to use as floor meshes.
  126698. * Meshes can be added and removed after initializing the feature using the
  126699. * addFloorMesh and removeFloorMesh functions
  126700. * If empty, rotation will still work
  126701. */
  126702. floorMeshes?: AbstractMesh[];
  126703. /**
  126704. * use this rendering group id for the meshes (optional)
  126705. */
  126706. renderingGroupId?: number;
  126707. /**
  126708. * Should teleportation move only to snap points
  126709. */
  126710. snapPointsOnly?: boolean;
  126711. /**
  126712. * An array of points to which the teleportation will snap to.
  126713. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126714. */
  126715. snapPositions?: Vector3[];
  126716. /**
  126717. * How close should the teleportation ray be in order to snap to position.
  126718. * Default to 0.8 units (meters)
  126719. */
  126720. snapToPositionRadius?: number;
  126721. /**
  126722. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126723. * If you want to support rotation, make sure your mesh has a direction indicator.
  126724. *
  126725. * When left untouched, the default mesh will be initialized.
  126726. */
  126727. teleportationTargetMesh?: AbstractMesh;
  126728. /**
  126729. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126730. */
  126731. timeToTeleport?: number;
  126732. /**
  126733. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126734. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126735. */
  126736. useMainComponentOnly?: boolean;
  126737. /**
  126738. * Should meshes created here be added to a utility layer or the main scene
  126739. */
  126740. useUtilityLayer?: boolean;
  126741. /**
  126742. * Babylon XR Input class for controller
  126743. */
  126744. xrInput: WebXRInput;
  126745. }
  126746. /**
  126747. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126748. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126749. * the input of the attached controllers.
  126750. */
  126751. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126752. private _options;
  126753. private _controllers;
  126754. private _currentTeleportationControllerId;
  126755. private _floorMeshes;
  126756. private _quadraticBezierCurve;
  126757. private _selectionFeature;
  126758. private _snapToPositions;
  126759. private _snappedToPoint;
  126760. private _teleportationRingMaterial?;
  126761. private _tmpRay;
  126762. private _tmpVector;
  126763. /**
  126764. * The module's name
  126765. */
  126766. static readonly Name: string;
  126767. /**
  126768. * The (Babylon) version of this module.
  126769. * This is an integer representing the implementation version.
  126770. * This number does not correspond to the webxr specs version
  126771. */
  126772. static readonly Version: number;
  126773. /**
  126774. * Is movement backwards enabled
  126775. */
  126776. backwardsMovementEnabled: boolean;
  126777. /**
  126778. * Distance to travel when moving backwards
  126779. */
  126780. backwardsTeleportationDistance: number;
  126781. /**
  126782. * The distance from the user to the inspection point in the direction of the controller
  126783. * A higher number will allow the user to move further
  126784. * defaults to 5 (meters, in xr units)
  126785. */
  126786. parabolicCheckRadius: number;
  126787. /**
  126788. * Should the module support parabolic ray on top of direct ray
  126789. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126790. * Very helpful when moving between floors / different heights
  126791. */
  126792. parabolicRayEnabled: boolean;
  126793. /**
  126794. * How much rotation should be applied when rotating right and left
  126795. */
  126796. rotationAngle: number;
  126797. /**
  126798. * Is rotation enabled when moving forward?
  126799. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126800. */
  126801. rotationEnabled: boolean;
  126802. /**
  126803. * constructs a new anchor system
  126804. * @param _xrSessionManager an instance of WebXRSessionManager
  126805. * @param _options configuration object for this feature
  126806. */
  126807. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126808. /**
  126809. * Get the snapPointsOnly flag
  126810. */
  126811. get snapPointsOnly(): boolean;
  126812. /**
  126813. * Sets the snapPointsOnly flag
  126814. * @param snapToPoints should teleportation be exclusively to snap points
  126815. */
  126816. set snapPointsOnly(snapToPoints: boolean);
  126817. /**
  126818. * Add a new mesh to the floor meshes array
  126819. * @param mesh the mesh to use as floor mesh
  126820. */
  126821. addFloorMesh(mesh: AbstractMesh): void;
  126822. /**
  126823. * Add a new snap-to point to fix teleportation to this position
  126824. * @param newSnapPoint The new Snap-To point
  126825. */
  126826. addSnapPoint(newSnapPoint: Vector3): void;
  126827. attach(): boolean;
  126828. detach(): boolean;
  126829. dispose(): void;
  126830. /**
  126831. * Remove a mesh from the floor meshes array
  126832. * @param mesh the mesh to remove
  126833. */
  126834. removeFloorMesh(mesh: AbstractMesh): void;
  126835. /**
  126836. * Remove a mesh from the floor meshes array using its name
  126837. * @param name the mesh name to remove
  126838. */
  126839. removeFloorMeshByName(name: string): void;
  126840. /**
  126841. * 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
  126842. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126843. * @returns was the point found and removed or not
  126844. */
  126845. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126846. /**
  126847. * This function sets a selection feature that will be disabled when
  126848. * the forward ray is shown and will be reattached when hidden.
  126849. * This is used to remove the selection rays when moving.
  126850. * @param selectionFeature the feature to disable when forward movement is enabled
  126851. */
  126852. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126853. protected _onXRFrame(_xrFrame: XRFrame): void;
  126854. private _attachController;
  126855. private _createDefaultTargetMesh;
  126856. private _detachController;
  126857. private _findClosestSnapPointWithRadius;
  126858. private _setTargetMeshPosition;
  126859. private _setTargetMeshVisibility;
  126860. private _showParabolicPath;
  126861. private _teleportForward;
  126862. }
  126863. }
  126864. declare module BABYLON {
  126865. /**
  126866. * Options for the default xr helper
  126867. */
  126868. export class WebXRDefaultExperienceOptions {
  126869. /**
  126870. * Enable or disable default UI to enter XR
  126871. */
  126872. disableDefaultUI?: boolean;
  126873. /**
  126874. * Should teleportation not initialize. defaults to false.
  126875. */
  126876. disableTeleportation?: boolean;
  126877. /**
  126878. * Floor meshes that will be used for teleport
  126879. */
  126880. floorMeshes?: Array<AbstractMesh>;
  126881. /**
  126882. * If set to true, the first frame will not be used to reset position
  126883. * The first frame is mainly used when copying transformation from the old camera
  126884. * Mainly used in AR
  126885. */
  126886. ignoreNativeCameraTransformation?: boolean;
  126887. /**
  126888. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126889. */
  126890. inputOptions?: IWebXRInputOptions;
  126891. /**
  126892. * optional configuration for the output canvas
  126893. */
  126894. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126895. /**
  126896. * optional UI options. This can be used among other to change session mode and reference space type
  126897. */
  126898. uiOptions?: WebXREnterExitUIOptions;
  126899. /**
  126900. * When loading teleportation and pointer select, use stable versions instead of latest.
  126901. */
  126902. useStablePlugins?: boolean;
  126903. /**
  126904. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126905. */
  126906. renderingGroupId?: number;
  126907. /**
  126908. * A list of optional features to init the session with
  126909. * If set to true, all features we support will be added
  126910. */
  126911. optionalFeatures?: boolean | string[];
  126912. }
  126913. /**
  126914. * Default experience which provides a similar setup to the previous webVRExperience
  126915. */
  126916. export class WebXRDefaultExperience {
  126917. /**
  126918. * Base experience
  126919. */
  126920. baseExperience: WebXRExperienceHelper;
  126921. /**
  126922. * Enables ui for entering/exiting xr
  126923. */
  126924. enterExitUI: WebXREnterExitUI;
  126925. /**
  126926. * Input experience extension
  126927. */
  126928. input: WebXRInput;
  126929. /**
  126930. * Enables laser pointer and selection
  126931. */
  126932. pointerSelection: WebXRControllerPointerSelection;
  126933. /**
  126934. * Default target xr should render to
  126935. */
  126936. renderTarget: WebXRRenderTarget;
  126937. /**
  126938. * Enables teleportation
  126939. */
  126940. teleportation: WebXRMotionControllerTeleportation;
  126941. private constructor();
  126942. /**
  126943. * Creates the default xr experience
  126944. * @param scene scene
  126945. * @param options options for basic configuration
  126946. * @returns resulting WebXRDefaultExperience
  126947. */
  126948. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126949. /**
  126950. * DIsposes of the experience helper
  126951. */
  126952. dispose(): void;
  126953. }
  126954. }
  126955. declare module BABYLON {
  126956. /**
  126957. * Options to modify the vr teleportation behavior.
  126958. */
  126959. export interface VRTeleportationOptions {
  126960. /**
  126961. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126962. */
  126963. floorMeshName?: string;
  126964. /**
  126965. * A list of meshes to be used as the teleportation floor. (default: empty)
  126966. */
  126967. floorMeshes?: Mesh[];
  126968. /**
  126969. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126970. */
  126971. teleportationMode?: number;
  126972. /**
  126973. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126974. */
  126975. teleportationTime?: number;
  126976. /**
  126977. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126978. */
  126979. teleportationSpeed?: number;
  126980. /**
  126981. * The easing function used in the animation or null for Linear. (default CircleEase)
  126982. */
  126983. easingFunction?: EasingFunction;
  126984. }
  126985. /**
  126986. * Options to modify the vr experience helper's behavior.
  126987. */
  126988. export interface VRExperienceHelperOptions extends WebVROptions {
  126989. /**
  126990. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126991. */
  126992. createDeviceOrientationCamera?: boolean;
  126993. /**
  126994. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126995. */
  126996. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126997. /**
  126998. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126999. */
  127000. laserToggle?: boolean;
  127001. /**
  127002. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  127003. */
  127004. floorMeshes?: Mesh[];
  127005. /**
  127006. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127007. */
  127008. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127009. /**
  127010. * Defines if WebXR should be used instead of WebVR (if available)
  127011. */
  127012. useXR?: boolean;
  127013. }
  127014. /**
  127015. * Event containing information after VR has been entered
  127016. */
  127017. export class OnAfterEnteringVRObservableEvent {
  127018. /**
  127019. * If entering vr was successful
  127020. */
  127021. success: boolean;
  127022. }
  127023. /**
  127024. * Helps to quickly add VR support to an existing scene.
  127025. * See https://doc.babylonjs.com/how_to/webvr_helper
  127026. */
  127027. export class VRExperienceHelper {
  127028. /** Options to modify the vr experience helper's behavior. */
  127029. webVROptions: VRExperienceHelperOptions;
  127030. private _scene;
  127031. private _position;
  127032. private _btnVR;
  127033. private _btnVRDisplayed;
  127034. private _webVRsupported;
  127035. private _webVRready;
  127036. private _webVRrequesting;
  127037. private _webVRpresenting;
  127038. private _hasEnteredVR;
  127039. private _fullscreenVRpresenting;
  127040. private _inputElement;
  127041. private _webVRCamera;
  127042. private _vrDeviceOrientationCamera;
  127043. private _deviceOrientationCamera;
  127044. private _existingCamera;
  127045. private _onKeyDown;
  127046. private _onVrDisplayPresentChange;
  127047. private _onVRDisplayChanged;
  127048. private _onVRRequestPresentStart;
  127049. private _onVRRequestPresentComplete;
  127050. /**
  127051. * 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)
  127052. */
  127053. enableGazeEvenWhenNoPointerLock: boolean;
  127054. /**
  127055. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127056. */
  127057. exitVROnDoubleTap: boolean;
  127058. /**
  127059. * Observable raised right before entering VR.
  127060. */
  127061. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127062. /**
  127063. * Observable raised when entering VR has completed.
  127064. */
  127065. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127066. /**
  127067. * Observable raised when exiting VR.
  127068. */
  127069. onExitingVRObservable: Observable<VRExperienceHelper>;
  127070. /**
  127071. * Observable raised when controller mesh is loaded.
  127072. */
  127073. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127074. /** Return this.onEnteringVRObservable
  127075. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127076. */
  127077. get onEnteringVR(): Observable<VRExperienceHelper>;
  127078. /** Return this.onExitingVRObservable
  127079. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127080. */
  127081. get onExitingVR(): Observable<VRExperienceHelper>;
  127082. /** Return this.onControllerMeshLoadedObservable
  127083. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127084. */
  127085. get onControllerMeshLoaded(): Observable<WebVRController>;
  127086. private _rayLength;
  127087. private _useCustomVRButton;
  127088. private _teleportationRequested;
  127089. private _teleportActive;
  127090. private _floorMeshName;
  127091. private _floorMeshesCollection;
  127092. private _teleportationMode;
  127093. private _teleportationTime;
  127094. private _teleportationSpeed;
  127095. private _teleportationEasing;
  127096. private _rotationAllowed;
  127097. private _teleportBackwardsVector;
  127098. private _teleportationTarget;
  127099. private _isDefaultTeleportationTarget;
  127100. private _postProcessMove;
  127101. private _teleportationFillColor;
  127102. private _teleportationBorderColor;
  127103. private _rotationAngle;
  127104. private _haloCenter;
  127105. private _cameraGazer;
  127106. private _padSensibilityUp;
  127107. private _padSensibilityDown;
  127108. private _leftController;
  127109. private _rightController;
  127110. private _gazeColor;
  127111. private _laserColor;
  127112. private _pickedLaserColor;
  127113. private _pickedGazeColor;
  127114. /**
  127115. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127116. */
  127117. onNewMeshSelected: Observable<AbstractMesh>;
  127118. /**
  127119. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127120. * This observable will provide the mesh and the controller used to select the mesh
  127121. */
  127122. onMeshSelectedWithController: Observable<{
  127123. mesh: AbstractMesh;
  127124. controller: WebVRController;
  127125. }>;
  127126. /**
  127127. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127128. */
  127129. onNewMeshPicked: Observable<PickingInfo>;
  127130. private _circleEase;
  127131. /**
  127132. * Observable raised before camera teleportation
  127133. */
  127134. onBeforeCameraTeleport: Observable<Vector3>;
  127135. /**
  127136. * Observable raised after camera teleportation
  127137. */
  127138. onAfterCameraTeleport: Observable<Vector3>;
  127139. /**
  127140. * Observable raised when current selected mesh gets unselected
  127141. */
  127142. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127143. private _raySelectionPredicate;
  127144. /**
  127145. * To be optionaly changed by user to define custom ray selection
  127146. */
  127147. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127148. /**
  127149. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127150. */
  127151. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127152. /**
  127153. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127154. */
  127155. teleportationEnabled: boolean;
  127156. private _defaultHeight;
  127157. private _teleportationInitialized;
  127158. private _interactionsEnabled;
  127159. private _interactionsRequested;
  127160. private _displayGaze;
  127161. private _displayLaserPointer;
  127162. /**
  127163. * The mesh used to display where the user is going to teleport.
  127164. */
  127165. get teleportationTarget(): Mesh;
  127166. /**
  127167. * Sets the mesh to be used to display where the user is going to teleport.
  127168. */
  127169. set teleportationTarget(value: Mesh);
  127170. /**
  127171. * 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
  127172. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127173. * See https://doc.babylonjs.com/resources/baking_transformations
  127174. */
  127175. get gazeTrackerMesh(): Mesh;
  127176. set gazeTrackerMesh(value: Mesh);
  127177. /**
  127178. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127179. */
  127180. updateGazeTrackerScale: boolean;
  127181. /**
  127182. * If the gaze trackers color should be updated when selecting meshes
  127183. */
  127184. updateGazeTrackerColor: boolean;
  127185. /**
  127186. * If the controller laser color should be updated when selecting meshes
  127187. */
  127188. updateControllerLaserColor: boolean;
  127189. /**
  127190. * The gaze tracking mesh corresponding to the left controller
  127191. */
  127192. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127193. /**
  127194. * The gaze tracking mesh corresponding to the right controller
  127195. */
  127196. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127197. /**
  127198. * If the ray of the gaze should be displayed.
  127199. */
  127200. get displayGaze(): boolean;
  127201. /**
  127202. * Sets if the ray of the gaze should be displayed.
  127203. */
  127204. set displayGaze(value: boolean);
  127205. /**
  127206. * If the ray of the LaserPointer should be displayed.
  127207. */
  127208. get displayLaserPointer(): boolean;
  127209. /**
  127210. * Sets if the ray of the LaserPointer should be displayed.
  127211. */
  127212. set displayLaserPointer(value: boolean);
  127213. /**
  127214. * The deviceOrientationCamera used as the camera when not in VR.
  127215. */
  127216. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127217. /**
  127218. * Based on the current WebVR support, returns the current VR camera used.
  127219. */
  127220. get currentVRCamera(): Nullable<Camera>;
  127221. /**
  127222. * The webVRCamera which is used when in VR.
  127223. */
  127224. get webVRCamera(): WebVRFreeCamera;
  127225. /**
  127226. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127227. */
  127228. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127229. /**
  127230. * The html button that is used to trigger entering into VR.
  127231. */
  127232. get vrButton(): Nullable<HTMLButtonElement>;
  127233. private get _teleportationRequestInitiated();
  127234. /**
  127235. * Defines whether or not Pointer lock should be requested when switching to
  127236. * full screen.
  127237. */
  127238. requestPointerLockOnFullScreen: boolean;
  127239. /**
  127240. * If asking to force XR, this will be populated with the default xr experience
  127241. */
  127242. xr: WebXRDefaultExperience;
  127243. /**
  127244. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127245. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127246. */
  127247. xrTestDone: boolean;
  127248. /**
  127249. * Instantiates a VRExperienceHelper.
  127250. * Helps to quickly add VR support to an existing scene.
  127251. * @param scene The scene the VRExperienceHelper belongs to.
  127252. * @param webVROptions Options to modify the vr experience helper's behavior.
  127253. */
  127254. constructor(scene: Scene,
  127255. /** Options to modify the vr experience helper's behavior. */
  127256. webVROptions?: VRExperienceHelperOptions);
  127257. private completeVRInit;
  127258. private _onDefaultMeshLoaded;
  127259. private _onResize;
  127260. private _onFullscreenChange;
  127261. /**
  127262. * Gets a value indicating if we are currently in VR mode.
  127263. */
  127264. get isInVRMode(): boolean;
  127265. private onVrDisplayPresentChange;
  127266. private onVRDisplayChanged;
  127267. private moveButtonToBottomRight;
  127268. private displayVRButton;
  127269. private updateButtonVisibility;
  127270. private _cachedAngularSensibility;
  127271. /**
  127272. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127273. * Otherwise, will use the fullscreen API.
  127274. */
  127275. enterVR(): void;
  127276. /**
  127277. * Attempt to exit VR, or fullscreen.
  127278. */
  127279. exitVR(): void;
  127280. /**
  127281. * The position of the vr experience helper.
  127282. */
  127283. get position(): Vector3;
  127284. /**
  127285. * Sets the position of the vr experience helper.
  127286. */
  127287. set position(value: Vector3);
  127288. /**
  127289. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127290. */
  127291. enableInteractions(): void;
  127292. private get _noControllerIsActive();
  127293. private beforeRender;
  127294. private _isTeleportationFloor;
  127295. /**
  127296. * Adds a floor mesh to be used for teleportation.
  127297. * @param floorMesh the mesh to be used for teleportation.
  127298. */
  127299. addFloorMesh(floorMesh: Mesh): void;
  127300. /**
  127301. * Removes a floor mesh from being used for teleportation.
  127302. * @param floorMesh the mesh to be removed.
  127303. */
  127304. removeFloorMesh(floorMesh: Mesh): void;
  127305. /**
  127306. * Enables interactions and teleportation using the VR controllers and gaze.
  127307. * @param vrTeleportationOptions options to modify teleportation behavior.
  127308. */
  127309. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127310. private _onNewGamepadConnected;
  127311. private _tryEnableInteractionOnController;
  127312. private _onNewGamepadDisconnected;
  127313. private _enableInteractionOnController;
  127314. private _checkTeleportWithRay;
  127315. private _checkRotate;
  127316. private _checkTeleportBackwards;
  127317. private _enableTeleportationOnController;
  127318. private _createTeleportationCircles;
  127319. private _displayTeleportationTarget;
  127320. private _hideTeleportationTarget;
  127321. private _rotateCamera;
  127322. private _moveTeleportationSelectorTo;
  127323. private _workingVector;
  127324. private _workingQuaternion;
  127325. private _workingMatrix;
  127326. /**
  127327. * Time Constant Teleportation Mode
  127328. */
  127329. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127330. /**
  127331. * Speed Constant Teleportation Mode
  127332. */
  127333. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127334. /**
  127335. * Teleports the users feet to the desired location
  127336. * @param location The location where the user's feet should be placed
  127337. */
  127338. teleportCamera(location: Vector3): void;
  127339. private _convertNormalToDirectionOfRay;
  127340. private _castRayAndSelectObject;
  127341. private _notifySelectedMeshUnselected;
  127342. /**
  127343. * Permanently set new colors for the laser pointer
  127344. * @param color the new laser color
  127345. * @param pickedColor the new laser color when picked mesh detected
  127346. */
  127347. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127348. /**
  127349. * Set lighting enabled / disabled on the laser pointer of both controllers
  127350. * @param enabled should the lighting be enabled on the laser pointer
  127351. */
  127352. setLaserLightingState(enabled?: boolean): void;
  127353. /**
  127354. * Permanently set new colors for the gaze pointer
  127355. * @param color the new gaze color
  127356. * @param pickedColor the new gaze color when picked mesh detected
  127357. */
  127358. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127359. /**
  127360. * Sets the color of the laser ray from the vr controllers.
  127361. * @param color new color for the ray.
  127362. */
  127363. changeLaserColor(color: Color3): void;
  127364. /**
  127365. * Sets the color of the ray from the vr headsets gaze.
  127366. * @param color new color for the ray.
  127367. */
  127368. changeGazeColor(color: Color3): void;
  127369. /**
  127370. * Exits VR and disposes of the vr experience helper
  127371. */
  127372. dispose(): void;
  127373. /**
  127374. * Gets the name of the VRExperienceHelper class
  127375. * @returns "VRExperienceHelper"
  127376. */
  127377. getClassName(): string;
  127378. }
  127379. }
  127380. declare module BABYLON {
  127381. /**
  127382. * Contains an array of blocks representing the octree
  127383. */
  127384. export interface IOctreeContainer<T> {
  127385. /**
  127386. * Blocks within the octree
  127387. */
  127388. blocks: Array<OctreeBlock<T>>;
  127389. }
  127390. /**
  127391. * Class used to store a cell in an octree
  127392. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127393. */
  127394. export class OctreeBlock<T> {
  127395. /**
  127396. * Gets the content of the current block
  127397. */
  127398. entries: T[];
  127399. /**
  127400. * Gets the list of block children
  127401. */
  127402. blocks: Array<OctreeBlock<T>>;
  127403. private _depth;
  127404. private _maxDepth;
  127405. private _capacity;
  127406. private _minPoint;
  127407. private _maxPoint;
  127408. private _boundingVectors;
  127409. private _creationFunc;
  127410. /**
  127411. * Creates a new block
  127412. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127413. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127414. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127415. * @param depth defines the current depth of this block in the octree
  127416. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127417. * @param creationFunc defines a callback to call when an element is added to the block
  127418. */
  127419. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127420. /**
  127421. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127422. */
  127423. get capacity(): number;
  127424. /**
  127425. * Gets the minimum vector (in world space) of the block's bounding box
  127426. */
  127427. get minPoint(): Vector3;
  127428. /**
  127429. * Gets the maximum vector (in world space) of the block's bounding box
  127430. */
  127431. get maxPoint(): Vector3;
  127432. /**
  127433. * Add a new element to this block
  127434. * @param entry defines the element to add
  127435. */
  127436. addEntry(entry: T): void;
  127437. /**
  127438. * Remove an element from this block
  127439. * @param entry defines the element to remove
  127440. */
  127441. removeEntry(entry: T): void;
  127442. /**
  127443. * Add an array of elements to this block
  127444. * @param entries defines the array of elements to add
  127445. */
  127446. addEntries(entries: T[]): void;
  127447. /**
  127448. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127449. * @param frustumPlanes defines the frustum planes to test
  127450. * @param selection defines the array to store current content if selection is positive
  127451. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127452. */
  127453. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127454. /**
  127455. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127456. * @param sphereCenter defines the bounding sphere center
  127457. * @param sphereRadius defines the bounding sphere radius
  127458. * @param selection defines the array to store current content if selection is positive
  127459. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127460. */
  127461. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127462. /**
  127463. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127464. * @param ray defines the ray to test with
  127465. * @param selection defines the array to store current content if selection is positive
  127466. */
  127467. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127468. /**
  127469. * Subdivide the content into child blocks (this block will then be empty)
  127470. */
  127471. createInnerBlocks(): void;
  127472. /**
  127473. * @hidden
  127474. */
  127475. 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;
  127476. }
  127477. }
  127478. declare module BABYLON {
  127479. /**
  127480. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127481. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127482. */
  127483. export class Octree<T> {
  127484. /** 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.) */
  127485. maxDepth: number;
  127486. /**
  127487. * Blocks within the octree containing objects
  127488. */
  127489. blocks: Array<OctreeBlock<T>>;
  127490. /**
  127491. * Content stored in the octree
  127492. */
  127493. dynamicContent: T[];
  127494. private _maxBlockCapacity;
  127495. private _selectionContent;
  127496. private _creationFunc;
  127497. /**
  127498. * Creates a octree
  127499. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127500. * @param creationFunc function to be used to instatiate the octree
  127501. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127502. * @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.)
  127503. */
  127504. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127505. /** 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.) */
  127506. maxDepth?: number);
  127507. /**
  127508. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127509. * @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);
  127510. * @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);
  127511. * @param entries meshes to be added to the octree blocks
  127512. */
  127513. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127514. /**
  127515. * Adds a mesh to the octree
  127516. * @param entry Mesh to add to the octree
  127517. */
  127518. addMesh(entry: T): void;
  127519. /**
  127520. * Remove an element from the octree
  127521. * @param entry defines the element to remove
  127522. */
  127523. removeMesh(entry: T): void;
  127524. /**
  127525. * Selects an array of meshes within the frustum
  127526. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127527. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127528. * @returns array of meshes within the frustum
  127529. */
  127530. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127531. /**
  127532. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127533. * @param sphereCenter defines the bounding sphere center
  127534. * @param sphereRadius defines the bounding sphere radius
  127535. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127536. * @returns an array of objects that intersect the sphere
  127537. */
  127538. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127539. /**
  127540. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127541. * @param ray defines the ray to test with
  127542. * @returns array of intersected objects
  127543. */
  127544. intersectsRay(ray: Ray): SmartArray<T>;
  127545. /**
  127546. * Adds a mesh into the octree block if it intersects the block
  127547. */
  127548. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127549. /**
  127550. * Adds a submesh into the octree block if it intersects the block
  127551. */
  127552. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127553. }
  127554. }
  127555. declare module BABYLON {
  127556. interface Scene {
  127557. /**
  127558. * @hidden
  127559. * Backing Filed
  127560. */
  127561. _selectionOctree: Octree<AbstractMesh>;
  127562. /**
  127563. * Gets the octree used to boost mesh selection (picking)
  127564. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127565. */
  127566. selectionOctree: Octree<AbstractMesh>;
  127567. /**
  127568. * Creates or updates the octree used to boost selection (picking)
  127569. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127570. * @param maxCapacity defines the maximum capacity per leaf
  127571. * @param maxDepth defines the maximum depth of the octree
  127572. * @returns an octree of AbstractMesh
  127573. */
  127574. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127575. }
  127576. interface AbstractMesh {
  127577. /**
  127578. * @hidden
  127579. * Backing Field
  127580. */
  127581. _submeshesOctree: Octree<SubMesh>;
  127582. /**
  127583. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127584. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127585. * @param maxCapacity defines the maximum size of each block (64 by default)
  127586. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127587. * @returns the new octree
  127588. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127590. */
  127591. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127592. }
  127593. /**
  127594. * Defines the octree scene component responsible to manage any octrees
  127595. * in a given scene.
  127596. */
  127597. export class OctreeSceneComponent {
  127598. /**
  127599. * The component name help to identify the component in the list of scene components.
  127600. */
  127601. readonly name: string;
  127602. /**
  127603. * The scene the component belongs to.
  127604. */
  127605. scene: Scene;
  127606. /**
  127607. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127608. */
  127609. readonly checksIsEnabled: boolean;
  127610. /**
  127611. * Creates a new instance of the component for the given scene
  127612. * @param scene Defines the scene to register the component in
  127613. */
  127614. constructor(scene: Scene);
  127615. /**
  127616. * Registers the component in a given scene
  127617. */
  127618. register(): void;
  127619. /**
  127620. * Return the list of active meshes
  127621. * @returns the list of active meshes
  127622. */
  127623. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127624. /**
  127625. * Return the list of active sub meshes
  127626. * @param mesh The mesh to get the candidates sub meshes from
  127627. * @returns the list of active sub meshes
  127628. */
  127629. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127630. private _tempRay;
  127631. /**
  127632. * Return the list of sub meshes intersecting with a given local ray
  127633. * @param mesh defines the mesh to find the submesh for
  127634. * @param localRay defines the ray in local space
  127635. * @returns the list of intersecting sub meshes
  127636. */
  127637. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127638. /**
  127639. * Return the list of sub meshes colliding with a collider
  127640. * @param mesh defines the mesh to find the submesh for
  127641. * @param collider defines the collider to evaluate the collision against
  127642. * @returns the list of colliding sub meshes
  127643. */
  127644. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127645. /**
  127646. * Rebuilds the elements related to this component in case of
  127647. * context lost for instance.
  127648. */
  127649. rebuild(): void;
  127650. /**
  127651. * Disposes the component and the associated ressources.
  127652. */
  127653. dispose(): void;
  127654. }
  127655. }
  127656. declare module BABYLON {
  127657. /**
  127658. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127659. */
  127660. export class Gizmo implements IDisposable {
  127661. /** The utility layer the gizmo will be added to */
  127662. gizmoLayer: UtilityLayerRenderer;
  127663. /**
  127664. * The root mesh of the gizmo
  127665. */
  127666. _rootMesh: Mesh;
  127667. private _attachedMesh;
  127668. /**
  127669. * Ratio for the scale of the gizmo (Default: 1)
  127670. */
  127671. scaleRatio: number;
  127672. /**
  127673. * If a custom mesh has been set (Default: false)
  127674. */
  127675. protected _customMeshSet: boolean;
  127676. /**
  127677. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127678. * * When set, interactions will be enabled
  127679. */
  127680. get attachedMesh(): Nullable<AbstractMesh>;
  127681. set attachedMesh(value: Nullable<AbstractMesh>);
  127682. /**
  127683. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127684. * @param mesh The mesh to replace the default mesh of the gizmo
  127685. */
  127686. setCustomMesh(mesh: Mesh): void;
  127687. /**
  127688. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127689. */
  127690. updateGizmoRotationToMatchAttachedMesh: boolean;
  127691. /**
  127692. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127693. */
  127694. updateGizmoPositionToMatchAttachedMesh: boolean;
  127695. /**
  127696. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127697. */
  127698. updateScale: boolean;
  127699. protected _interactionsEnabled: boolean;
  127700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127701. private _beforeRenderObserver;
  127702. private _tempVector;
  127703. /**
  127704. * Creates a gizmo
  127705. * @param gizmoLayer The utility layer the gizmo will be added to
  127706. */
  127707. constructor(
  127708. /** The utility layer the gizmo will be added to */
  127709. gizmoLayer?: UtilityLayerRenderer);
  127710. /**
  127711. * Updates the gizmo to match the attached mesh's position/rotation
  127712. */
  127713. protected _update(): void;
  127714. /**
  127715. * Disposes of the gizmo
  127716. */
  127717. dispose(): void;
  127718. }
  127719. }
  127720. declare module BABYLON {
  127721. /**
  127722. * Single plane drag gizmo
  127723. */
  127724. export class PlaneDragGizmo extends Gizmo {
  127725. /**
  127726. * Drag behavior responsible for the gizmos dragging interactions
  127727. */
  127728. dragBehavior: PointerDragBehavior;
  127729. private _pointerObserver;
  127730. /**
  127731. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127732. */
  127733. snapDistance: number;
  127734. /**
  127735. * Event that fires each time the gizmo snaps to a new location.
  127736. * * snapDistance is the the change in distance
  127737. */
  127738. onSnapObservable: Observable<{
  127739. snapDistance: number;
  127740. }>;
  127741. private _plane;
  127742. private _coloredMaterial;
  127743. private _hoverMaterial;
  127744. private _isEnabled;
  127745. private _parent;
  127746. /** @hidden */
  127747. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127748. /** @hidden */
  127749. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127750. /**
  127751. * Creates a PlaneDragGizmo
  127752. * @param gizmoLayer The utility layer the gizmo will be added to
  127753. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127754. * @param color The color of the gizmo
  127755. */
  127756. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127757. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127758. /**
  127759. * If the gizmo is enabled
  127760. */
  127761. set isEnabled(value: boolean);
  127762. get isEnabled(): boolean;
  127763. /**
  127764. * Disposes of the gizmo
  127765. */
  127766. dispose(): void;
  127767. }
  127768. }
  127769. declare module BABYLON {
  127770. /**
  127771. * Gizmo that enables dragging a mesh along 3 axis
  127772. */
  127773. export class PositionGizmo extends Gizmo {
  127774. /**
  127775. * Internal gizmo used for interactions on the x axis
  127776. */
  127777. xGizmo: AxisDragGizmo;
  127778. /**
  127779. * Internal gizmo used for interactions on the y axis
  127780. */
  127781. yGizmo: AxisDragGizmo;
  127782. /**
  127783. * Internal gizmo used for interactions on the z axis
  127784. */
  127785. zGizmo: AxisDragGizmo;
  127786. /**
  127787. * Internal gizmo used for interactions on the yz plane
  127788. */
  127789. xPlaneGizmo: PlaneDragGizmo;
  127790. /**
  127791. * Internal gizmo used for interactions on the xz plane
  127792. */
  127793. yPlaneGizmo: PlaneDragGizmo;
  127794. /**
  127795. * Internal gizmo used for interactions on the xy plane
  127796. */
  127797. zPlaneGizmo: PlaneDragGizmo;
  127798. /**
  127799. * private variables
  127800. */
  127801. private _meshAttached;
  127802. private _updateGizmoRotationToMatchAttachedMesh;
  127803. private _snapDistance;
  127804. private _scaleRatio;
  127805. /** Fires an event when any of it's sub gizmos are dragged */
  127806. onDragStartObservable: Observable<unknown>;
  127807. /** Fires an event when any of it's sub gizmos are released from dragging */
  127808. onDragEndObservable: Observable<unknown>;
  127809. /**
  127810. * If set to true, planar drag is enabled
  127811. */
  127812. private _planarGizmoEnabled;
  127813. get attachedMesh(): Nullable<AbstractMesh>;
  127814. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127815. /**
  127816. * Creates a PositionGizmo
  127817. * @param gizmoLayer The utility layer the gizmo will be added to
  127818. */
  127819. constructor(gizmoLayer?: UtilityLayerRenderer);
  127820. /**
  127821. * If the planar drag gizmo is enabled
  127822. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127823. */
  127824. set planarGizmoEnabled(value: boolean);
  127825. get planarGizmoEnabled(): boolean;
  127826. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127827. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127828. /**
  127829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127830. */
  127831. set snapDistance(value: number);
  127832. get snapDistance(): number;
  127833. /**
  127834. * Ratio for the scale of the gizmo (Default: 1)
  127835. */
  127836. set scaleRatio(value: number);
  127837. get scaleRatio(): number;
  127838. /**
  127839. * Disposes of the gizmo
  127840. */
  127841. dispose(): void;
  127842. /**
  127843. * CustomMeshes are not supported by this gizmo
  127844. * @param mesh The mesh to replace the default mesh of the gizmo
  127845. */
  127846. setCustomMesh(mesh: Mesh): void;
  127847. }
  127848. }
  127849. declare module BABYLON {
  127850. /**
  127851. * Single axis drag gizmo
  127852. */
  127853. export class AxisDragGizmo extends Gizmo {
  127854. /**
  127855. * Drag behavior responsible for the gizmos dragging interactions
  127856. */
  127857. dragBehavior: PointerDragBehavior;
  127858. private _pointerObserver;
  127859. /**
  127860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127861. */
  127862. snapDistance: number;
  127863. /**
  127864. * Event that fires each time the gizmo snaps to a new location.
  127865. * * snapDistance is the the change in distance
  127866. */
  127867. onSnapObservable: Observable<{
  127868. snapDistance: number;
  127869. }>;
  127870. private _isEnabled;
  127871. private _parent;
  127872. private _arrow;
  127873. private _coloredMaterial;
  127874. private _hoverMaterial;
  127875. /** @hidden */
  127876. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127877. /** @hidden */
  127878. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127879. /**
  127880. * Creates an AxisDragGizmo
  127881. * @param gizmoLayer The utility layer the gizmo will be added to
  127882. * @param dragAxis The axis which the gizmo will be able to drag on
  127883. * @param color The color of the gizmo
  127884. */
  127885. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127887. /**
  127888. * If the gizmo is enabled
  127889. */
  127890. set isEnabled(value: boolean);
  127891. get isEnabled(): boolean;
  127892. /**
  127893. * Disposes of the gizmo
  127894. */
  127895. dispose(): void;
  127896. }
  127897. }
  127898. declare module BABYLON.Debug {
  127899. /**
  127900. * The Axes viewer will show 3 axes in a specific point in space
  127901. */
  127902. export class AxesViewer {
  127903. private _xAxis;
  127904. private _yAxis;
  127905. private _zAxis;
  127906. private _scaleLinesFactor;
  127907. private _instanced;
  127908. /**
  127909. * Gets the hosting scene
  127910. */
  127911. scene: Scene;
  127912. /**
  127913. * Gets or sets a number used to scale line length
  127914. */
  127915. scaleLines: number;
  127916. /** Gets the node hierarchy used to render x-axis */
  127917. get xAxis(): TransformNode;
  127918. /** Gets the node hierarchy used to render y-axis */
  127919. get yAxis(): TransformNode;
  127920. /** Gets the node hierarchy used to render z-axis */
  127921. get zAxis(): TransformNode;
  127922. /**
  127923. * Creates a new AxesViewer
  127924. * @param scene defines the hosting scene
  127925. * @param scaleLines defines a number used to scale line length (1 by default)
  127926. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127927. * @param xAxis defines the node hierarchy used to render the x-axis
  127928. * @param yAxis defines the node hierarchy used to render the y-axis
  127929. * @param zAxis defines the node hierarchy used to render the z-axis
  127930. */
  127931. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127932. /**
  127933. * Force the viewer to update
  127934. * @param position defines the position of the viewer
  127935. * @param xaxis defines the x axis of the viewer
  127936. * @param yaxis defines the y axis of the viewer
  127937. * @param zaxis defines the z axis of the viewer
  127938. */
  127939. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127940. /**
  127941. * Creates an instance of this axes viewer.
  127942. * @returns a new axes viewer with instanced meshes
  127943. */
  127944. createInstance(): AxesViewer;
  127945. /** Releases resources */
  127946. dispose(): void;
  127947. private static _SetRenderingGroupId;
  127948. }
  127949. }
  127950. declare module BABYLON.Debug {
  127951. /**
  127952. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127953. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127954. */
  127955. export class BoneAxesViewer extends AxesViewer {
  127956. /**
  127957. * Gets or sets the target mesh where to display the axes viewer
  127958. */
  127959. mesh: Nullable<Mesh>;
  127960. /**
  127961. * Gets or sets the target bone where to display the axes viewer
  127962. */
  127963. bone: Nullable<Bone>;
  127964. /** Gets current position */
  127965. pos: Vector3;
  127966. /** Gets direction of X axis */
  127967. xaxis: Vector3;
  127968. /** Gets direction of Y axis */
  127969. yaxis: Vector3;
  127970. /** Gets direction of Z axis */
  127971. zaxis: Vector3;
  127972. /**
  127973. * Creates a new BoneAxesViewer
  127974. * @param scene defines the hosting scene
  127975. * @param bone defines the target bone
  127976. * @param mesh defines the target mesh
  127977. * @param scaleLines defines a scaling factor for line length (1 by default)
  127978. */
  127979. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127980. /**
  127981. * Force the viewer to update
  127982. */
  127983. update(): void;
  127984. /** Releases resources */
  127985. dispose(): void;
  127986. }
  127987. }
  127988. declare module BABYLON {
  127989. /**
  127990. * Interface used to define scene explorer extensibility option
  127991. */
  127992. export interface IExplorerExtensibilityOption {
  127993. /**
  127994. * Define the option label
  127995. */
  127996. label: string;
  127997. /**
  127998. * Defines the action to execute on click
  127999. */
  128000. action: (entity: any) => void;
  128001. }
  128002. /**
  128003. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  128004. */
  128005. export interface IExplorerExtensibilityGroup {
  128006. /**
  128007. * Defines a predicate to test if a given type mut be extended
  128008. */
  128009. predicate: (entity: any) => boolean;
  128010. /**
  128011. * Gets the list of options added to a type
  128012. */
  128013. entries: IExplorerExtensibilityOption[];
  128014. }
  128015. /**
  128016. * Interface used to define the options to use to create the Inspector
  128017. */
  128018. export interface IInspectorOptions {
  128019. /**
  128020. * Display in overlay mode (default: false)
  128021. */
  128022. overlay?: boolean;
  128023. /**
  128024. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128025. */
  128026. globalRoot?: HTMLElement;
  128027. /**
  128028. * Display the Scene explorer
  128029. */
  128030. showExplorer?: boolean;
  128031. /**
  128032. * Display the property inspector
  128033. */
  128034. showInspector?: boolean;
  128035. /**
  128036. * Display in embed mode (both panes on the right)
  128037. */
  128038. embedMode?: boolean;
  128039. /**
  128040. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128041. */
  128042. handleResize?: boolean;
  128043. /**
  128044. * Allow the panes to popup (default: true)
  128045. */
  128046. enablePopup?: boolean;
  128047. /**
  128048. * Allow the panes to be closed by users (default: true)
  128049. */
  128050. enableClose?: boolean;
  128051. /**
  128052. * Optional list of extensibility entries
  128053. */
  128054. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128055. /**
  128056. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128057. */
  128058. inspectorURL?: string;
  128059. /**
  128060. * Optional initial tab (default to DebugLayerTab.Properties)
  128061. */
  128062. initialTab?: DebugLayerTab;
  128063. }
  128064. interface Scene {
  128065. /**
  128066. * @hidden
  128067. * Backing field
  128068. */
  128069. _debugLayer: DebugLayer;
  128070. /**
  128071. * Gets the debug layer (aka Inspector) associated with the scene
  128072. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128073. */
  128074. debugLayer: DebugLayer;
  128075. }
  128076. /**
  128077. * Enum of inspector action tab
  128078. */
  128079. export enum DebugLayerTab {
  128080. /**
  128081. * Properties tag (default)
  128082. */
  128083. Properties = 0,
  128084. /**
  128085. * Debug tab
  128086. */
  128087. Debug = 1,
  128088. /**
  128089. * Statistics tab
  128090. */
  128091. Statistics = 2,
  128092. /**
  128093. * Tools tab
  128094. */
  128095. Tools = 3,
  128096. /**
  128097. * Settings tab
  128098. */
  128099. Settings = 4
  128100. }
  128101. /**
  128102. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128103. * what is happening in your scene
  128104. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128105. */
  128106. export class DebugLayer {
  128107. /**
  128108. * Define the url to get the inspector script from.
  128109. * By default it uses the babylonjs CDN.
  128110. * @ignoreNaming
  128111. */
  128112. static InspectorURL: string;
  128113. private _scene;
  128114. private BJSINSPECTOR;
  128115. private _onPropertyChangedObservable?;
  128116. /**
  128117. * Observable triggered when a property is changed through the inspector.
  128118. */
  128119. get onPropertyChangedObservable(): any;
  128120. /**
  128121. * Instantiates a new debug layer.
  128122. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128123. * what is happening in your scene
  128124. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128125. * @param scene Defines the scene to inspect
  128126. */
  128127. constructor(scene: Scene);
  128128. /** Creates the inspector window. */
  128129. private _createInspector;
  128130. /**
  128131. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128132. * @param entity defines the entity to select
  128133. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128134. */
  128135. select(entity: any, lineContainerTitles?: string | string[]): void;
  128136. /** Get the inspector from bundle or global */
  128137. private _getGlobalInspector;
  128138. /**
  128139. * Get if the inspector is visible or not.
  128140. * @returns true if visible otherwise, false
  128141. */
  128142. isVisible(): boolean;
  128143. /**
  128144. * Hide the inspector and close its window.
  128145. */
  128146. hide(): void;
  128147. /**
  128148. * Update the scene in the inspector
  128149. */
  128150. setAsActiveScene(): void;
  128151. /**
  128152. * Launch the debugLayer.
  128153. * @param config Define the configuration of the inspector
  128154. * @return a promise fulfilled when the debug layer is visible
  128155. */
  128156. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128157. }
  128158. }
  128159. declare module BABYLON {
  128160. /**
  128161. * Class containing static functions to help procedurally build meshes
  128162. */
  128163. export class BoxBuilder {
  128164. /**
  128165. * Creates a box mesh
  128166. * * The parameter `size` sets the size (float) of each box side (default 1)
  128167. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128168. * * 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)
  128169. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128171. * * 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
  128172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128173. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128174. * @param name defines the name of the mesh
  128175. * @param options defines the options used to create the mesh
  128176. * @param scene defines the hosting scene
  128177. * @returns the box mesh
  128178. */
  128179. static CreateBox(name: string, options: {
  128180. size?: number;
  128181. width?: number;
  128182. height?: number;
  128183. depth?: number;
  128184. faceUV?: Vector4[];
  128185. faceColors?: Color4[];
  128186. sideOrientation?: number;
  128187. frontUVs?: Vector4;
  128188. backUVs?: Vector4;
  128189. wrap?: boolean;
  128190. topBaseAt?: number;
  128191. bottomBaseAt?: number;
  128192. updatable?: boolean;
  128193. }, scene?: Nullable<Scene>): Mesh;
  128194. }
  128195. }
  128196. declare module BABYLON.Debug {
  128197. /**
  128198. * Used to show the physics impostor around the specific mesh
  128199. */
  128200. export class PhysicsViewer {
  128201. /** @hidden */
  128202. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128203. /** @hidden */
  128204. protected _meshes: Array<Nullable<AbstractMesh>>;
  128205. /** @hidden */
  128206. protected _scene: Nullable<Scene>;
  128207. /** @hidden */
  128208. protected _numMeshes: number;
  128209. /** @hidden */
  128210. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128211. private _renderFunction;
  128212. private _utilityLayer;
  128213. private _debugBoxMesh;
  128214. private _debugSphereMesh;
  128215. private _debugCylinderMesh;
  128216. private _debugMaterial;
  128217. private _debugMeshMeshes;
  128218. /**
  128219. * Creates a new PhysicsViewer
  128220. * @param scene defines the hosting scene
  128221. */
  128222. constructor(scene: Scene);
  128223. /** @hidden */
  128224. protected _updateDebugMeshes(): void;
  128225. /**
  128226. * Renders a specified physic impostor
  128227. * @param impostor defines the impostor to render
  128228. * @param targetMesh defines the mesh represented by the impostor
  128229. * @returns the new debug mesh used to render the impostor
  128230. */
  128231. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128232. /**
  128233. * Hides a specified physic impostor
  128234. * @param impostor defines the impostor to hide
  128235. */
  128236. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128237. private _getDebugMaterial;
  128238. private _getDebugBoxMesh;
  128239. private _getDebugSphereMesh;
  128240. private _getDebugCylinderMesh;
  128241. private _getDebugMeshMesh;
  128242. private _getDebugMesh;
  128243. /** Releases all resources */
  128244. dispose(): void;
  128245. }
  128246. }
  128247. declare module BABYLON {
  128248. /**
  128249. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128250. * in order to better appreciate the issue one might have.
  128251. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128252. */
  128253. export class RayHelper {
  128254. /**
  128255. * Defines the ray we are currently tryin to visualize.
  128256. */
  128257. ray: Nullable<Ray>;
  128258. private _renderPoints;
  128259. private _renderLine;
  128260. private _renderFunction;
  128261. private _scene;
  128262. private _updateToMeshFunction;
  128263. private _attachedToMesh;
  128264. private _meshSpaceDirection;
  128265. private _meshSpaceOrigin;
  128266. /**
  128267. * Helper function to create a colored helper in a scene in one line.
  128268. * @param ray Defines the ray we are currently tryin to visualize
  128269. * @param scene Defines the scene the ray is used in
  128270. * @param color Defines the color we want to see the ray in
  128271. * @returns The newly created ray helper.
  128272. */
  128273. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128274. /**
  128275. * Instantiate a new ray helper.
  128276. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128277. * in order to better appreciate the issue one might have.
  128278. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128279. * @param ray Defines the ray we are currently tryin to visualize
  128280. */
  128281. constructor(ray: Ray);
  128282. /**
  128283. * Shows the ray we are willing to debug.
  128284. * @param scene Defines the scene the ray needs to be rendered in
  128285. * @param color Defines the color the ray needs to be rendered in
  128286. */
  128287. show(scene: Scene, color?: Color3): void;
  128288. /**
  128289. * Hides the ray we are debugging.
  128290. */
  128291. hide(): void;
  128292. private _render;
  128293. /**
  128294. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128295. * @param mesh Defines the mesh we want the helper attached to
  128296. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128297. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128298. * @param length Defines the length of the ray
  128299. */
  128300. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128301. /**
  128302. * Detach the ray helper from the mesh it has previously been attached to.
  128303. */
  128304. detachFromMesh(): void;
  128305. private _updateToMesh;
  128306. /**
  128307. * Dispose the helper and release its associated resources.
  128308. */
  128309. dispose(): void;
  128310. }
  128311. }
  128312. declare module BABYLON.Debug {
  128313. /**
  128314. * Class used to render a debug view of a given skeleton
  128315. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128316. */
  128317. export class SkeletonViewer {
  128318. /** defines the skeleton to render */
  128319. skeleton: Skeleton;
  128320. /** defines the mesh attached to the skeleton */
  128321. mesh: AbstractMesh;
  128322. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128323. autoUpdateBonesMatrices: boolean;
  128324. /** defines the rendering group id to use with the viewer */
  128325. renderingGroupId: number;
  128326. /** Gets or sets the color used to render the skeleton */
  128327. color: Color3;
  128328. private _scene;
  128329. private _debugLines;
  128330. private _debugMesh;
  128331. private _isEnabled;
  128332. private _renderFunction;
  128333. private _utilityLayer;
  128334. /**
  128335. * Returns the mesh used to render the bones
  128336. */
  128337. get debugMesh(): Nullable<LinesMesh>;
  128338. /**
  128339. * Creates a new SkeletonViewer
  128340. * @param skeleton defines the skeleton to render
  128341. * @param mesh defines the mesh attached to the skeleton
  128342. * @param scene defines the hosting scene
  128343. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128344. * @param renderingGroupId defines the rendering group id to use with the viewer
  128345. */
  128346. constructor(
  128347. /** defines the skeleton to render */
  128348. skeleton: Skeleton,
  128349. /** defines the mesh attached to the skeleton */
  128350. mesh: AbstractMesh, scene: Scene,
  128351. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128352. autoUpdateBonesMatrices?: boolean,
  128353. /** defines the rendering group id to use with the viewer */
  128354. renderingGroupId?: number);
  128355. /** Gets or sets a boolean indicating if the viewer is enabled */
  128356. set isEnabled(value: boolean);
  128357. get isEnabled(): boolean;
  128358. private _getBonePosition;
  128359. private _getLinesForBonesWithLength;
  128360. private _getLinesForBonesNoLength;
  128361. /** Update the viewer to sync with current skeleton state */
  128362. update(): void;
  128363. /** Release associated resources */
  128364. dispose(): void;
  128365. }
  128366. }
  128367. declare module BABYLON {
  128368. /**
  128369. * Enum for Device Types
  128370. */
  128371. export enum DeviceType {
  128372. /** Generic */
  128373. Generic = 0,
  128374. /** Keyboard */
  128375. Keyboard = 1,
  128376. /** Mouse */
  128377. Mouse = 2,
  128378. /** Touch Pointers */
  128379. Touch = 3,
  128380. /** PS4 Dual Shock */
  128381. DualShock = 4,
  128382. /** Xbox */
  128383. Xbox = 5,
  128384. /** Switch Controller */
  128385. Switch = 6
  128386. }
  128387. /**
  128388. * Enum for All Pointers (Touch/Mouse)
  128389. */
  128390. export enum PointerInput {
  128391. /** Horizontal Axis */
  128392. Horizontal = 0,
  128393. /** Vertical Axis */
  128394. Vertical = 1,
  128395. /** Left Click or Touch */
  128396. LeftClick = 2,
  128397. /** Middle Click */
  128398. MiddleClick = 3,
  128399. /** Right Click */
  128400. RightClick = 4,
  128401. /** Browser Back */
  128402. BrowserBack = 5,
  128403. /** Browser Forward */
  128404. BrowserForward = 6
  128405. }
  128406. /**
  128407. * Enum for Dual Shock Gamepad
  128408. */
  128409. export enum DualShockInput {
  128410. /** Cross */
  128411. Cross = 0,
  128412. /** Circle */
  128413. Circle = 1,
  128414. /** Square */
  128415. Square = 2,
  128416. /** Triangle */
  128417. Triangle = 3,
  128418. /** L1 */
  128419. L1 = 4,
  128420. /** R1 */
  128421. R1 = 5,
  128422. /** L2 */
  128423. L2 = 6,
  128424. /** R2 */
  128425. R2 = 7,
  128426. /** Share */
  128427. Share = 8,
  128428. /** Options */
  128429. Options = 9,
  128430. /** L3 */
  128431. L3 = 10,
  128432. /** R3 */
  128433. R3 = 11,
  128434. /** DPadUp */
  128435. DPadUp = 12,
  128436. /** DPadDown */
  128437. DPadDown = 13,
  128438. /** DPadLeft */
  128439. DPadLeft = 14,
  128440. /** DRight */
  128441. DPadRight = 15,
  128442. /** Home */
  128443. Home = 16,
  128444. /** TouchPad */
  128445. TouchPad = 17,
  128446. /** LStickXAxis */
  128447. LStickXAxis = 18,
  128448. /** LStickYAxis */
  128449. LStickYAxis = 19,
  128450. /** RStickXAxis */
  128451. RStickXAxis = 20,
  128452. /** RStickYAxis */
  128453. RStickYAxis = 21
  128454. }
  128455. /**
  128456. * Enum for Xbox Gamepad
  128457. */
  128458. export enum XboxInput {
  128459. /** A */
  128460. A = 0,
  128461. /** B */
  128462. B = 1,
  128463. /** X */
  128464. X = 2,
  128465. /** Y */
  128466. Y = 3,
  128467. /** LB */
  128468. LB = 4,
  128469. /** RB */
  128470. RB = 5,
  128471. /** LT */
  128472. LT = 6,
  128473. /** RT */
  128474. RT = 7,
  128475. /** Back */
  128476. Back = 8,
  128477. /** Start */
  128478. Start = 9,
  128479. /** LS */
  128480. LS = 10,
  128481. /** RS */
  128482. RS = 11,
  128483. /** DPadUp */
  128484. DPadUp = 12,
  128485. /** DPadDown */
  128486. DPadDown = 13,
  128487. /** DPadLeft */
  128488. DPadLeft = 14,
  128489. /** DRight */
  128490. DPadRight = 15,
  128491. /** Home */
  128492. Home = 16,
  128493. /** LStickXAxis */
  128494. LStickXAxis = 17,
  128495. /** LStickYAxis */
  128496. LStickYAxis = 18,
  128497. /** RStickXAxis */
  128498. RStickXAxis = 19,
  128499. /** RStickYAxis */
  128500. RStickYAxis = 20
  128501. }
  128502. /**
  128503. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128504. */
  128505. export enum SwitchInput {
  128506. /** B */
  128507. B = 0,
  128508. /** A */
  128509. A = 1,
  128510. /** Y */
  128511. Y = 2,
  128512. /** X */
  128513. X = 3,
  128514. /** L */
  128515. L = 4,
  128516. /** R */
  128517. R = 5,
  128518. /** ZL */
  128519. ZL = 6,
  128520. /** ZR */
  128521. ZR = 7,
  128522. /** Minus */
  128523. Minus = 8,
  128524. /** Plus */
  128525. Plus = 9,
  128526. /** LS */
  128527. LS = 10,
  128528. /** RS */
  128529. RS = 11,
  128530. /** DPadUp */
  128531. DPadUp = 12,
  128532. /** DPadDown */
  128533. DPadDown = 13,
  128534. /** DPadLeft */
  128535. DPadLeft = 14,
  128536. /** DRight */
  128537. DPadRight = 15,
  128538. /** Home */
  128539. Home = 16,
  128540. /** Capture */
  128541. Capture = 17,
  128542. /** LStickXAxis */
  128543. LStickXAxis = 18,
  128544. /** LStickYAxis */
  128545. LStickYAxis = 19,
  128546. /** RStickXAxis */
  128547. RStickXAxis = 20,
  128548. /** RStickYAxis */
  128549. RStickYAxis = 21
  128550. }
  128551. }
  128552. declare module BABYLON {
  128553. /**
  128554. * This class will take all inputs from Keyboard, Pointer, and
  128555. * any Gamepads and provide a polling system that all devices
  128556. * will use. This class assumes that there will only be one
  128557. * pointer device and one keyboard.
  128558. */
  128559. export class DeviceInputSystem implements IDisposable {
  128560. /**
  128561. * Callback to be triggered when a device is connected
  128562. */
  128563. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128564. /**
  128565. * Callback to be triggered when a device is disconnected
  128566. */
  128567. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128568. /**
  128569. * Callback to be triggered when event driven input is updated
  128570. */
  128571. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128572. private _inputs;
  128573. private _gamepads;
  128574. private _keyboardActive;
  128575. private _pointerActive;
  128576. private _elementToAttachTo;
  128577. private _keyboardDownEvent;
  128578. private _keyboardUpEvent;
  128579. private _pointerMoveEvent;
  128580. private _pointerDownEvent;
  128581. private _pointerUpEvent;
  128582. private _gamepadConnectedEvent;
  128583. private _gamepadDisconnectedEvent;
  128584. private static _MAX_KEYCODES;
  128585. private static _MAX_POINTER_INPUTS;
  128586. private constructor();
  128587. /**
  128588. * Creates a new DeviceInputSystem instance
  128589. * @param engine Engine to pull input element from
  128590. * @returns The new instance
  128591. */
  128592. static Create(engine: Engine): DeviceInputSystem;
  128593. /**
  128594. * Checks for current device input value, given an id and input index
  128595. * @param deviceName Id of connected device
  128596. * @param inputIndex Index of device input
  128597. * @returns Current value of input
  128598. */
  128599. /**
  128600. * Checks for current device input value, given an id and input index
  128601. * @param deviceType Enum specifiying device type
  128602. * @param deviceSlot "Slot" or index that device is referenced in
  128603. * @param inputIndex Id of input to be checked
  128604. * @returns Current value of input
  128605. */
  128606. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128607. /**
  128608. * Dispose of all the eventlisteners
  128609. */
  128610. dispose(): void;
  128611. /**
  128612. * Add device and inputs to device array
  128613. * @param deviceType Enum specifiying device type
  128614. * @param deviceSlot "Slot" or index that device is referenced in
  128615. * @param numberOfInputs Number of input entries to create for given device
  128616. */
  128617. private _registerDevice;
  128618. /**
  128619. * Given a specific device name, remove that device from the device map
  128620. * @param deviceType Enum specifiying device type
  128621. * @param deviceSlot "Slot" or index that device is referenced in
  128622. */
  128623. private _unregisterDevice;
  128624. /**
  128625. * Handle all actions that come from keyboard interaction
  128626. */
  128627. private _handleKeyActions;
  128628. /**
  128629. * Handle all actions that come from pointer interaction
  128630. */
  128631. private _handlePointerActions;
  128632. /**
  128633. * Handle all actions that come from gamepad interaction
  128634. */
  128635. private _handleGamepadActions;
  128636. /**
  128637. * Update all non-event based devices with each frame
  128638. * @param deviceType Enum specifiying device type
  128639. * @param deviceSlot "Slot" or index that device is referenced in
  128640. * @param inputIndex Id of input to be checked
  128641. */
  128642. private _updateDevice;
  128643. /**
  128644. * Gets DeviceType from the device name
  128645. * @param deviceName Name of Device from DeviceInputSystem
  128646. * @returns DeviceType enum value
  128647. */
  128648. private _getGamepadDeviceType;
  128649. }
  128650. }
  128651. declare module BABYLON {
  128652. /**
  128653. * Type to handle enforcement of inputs
  128654. */
  128655. 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;
  128656. }
  128657. declare module BABYLON {
  128658. /**
  128659. * Class that handles all input for a specific device
  128660. */
  128661. export class DeviceSource<T extends DeviceType> {
  128662. /** Type of device */
  128663. readonly deviceType: DeviceType;
  128664. /** "Slot" or index that device is referenced in */
  128665. readonly deviceSlot: number;
  128666. /**
  128667. * Observable to handle device input changes per device
  128668. */
  128669. readonly onInputChangedObservable: Observable<{
  128670. inputIndex: DeviceInput<T>;
  128671. previousState: Nullable<number>;
  128672. currentState: Nullable<number>;
  128673. }>;
  128674. private readonly _deviceInputSystem;
  128675. /**
  128676. * Default Constructor
  128677. * @param deviceInputSystem Reference to DeviceInputSystem
  128678. * @param deviceType Type of device
  128679. * @param deviceSlot "Slot" or index that device is referenced in
  128680. */
  128681. constructor(deviceInputSystem: DeviceInputSystem,
  128682. /** Type of device */
  128683. deviceType: DeviceType,
  128684. /** "Slot" or index that device is referenced in */
  128685. deviceSlot?: number);
  128686. /**
  128687. * Get input for specific input
  128688. * @param inputIndex index of specific input on device
  128689. * @returns Input value from DeviceInputSystem
  128690. */
  128691. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128692. }
  128693. /**
  128694. * Class to keep track of devices
  128695. */
  128696. export class DeviceSourceManager implements IDisposable {
  128697. /**
  128698. * Observable to be triggered when before a device is connected
  128699. */
  128700. readonly onBeforeDeviceConnectedObservable: Observable<{
  128701. deviceType: DeviceType;
  128702. deviceSlot: number;
  128703. }>;
  128704. /**
  128705. * Observable to be triggered when before a device is disconnected
  128706. */
  128707. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128708. deviceType: DeviceType;
  128709. deviceSlot: number;
  128710. }>;
  128711. /**
  128712. * Observable to be triggered when after a device is connected
  128713. */
  128714. readonly onAfterDeviceConnectedObservable: Observable<{
  128715. deviceType: DeviceType;
  128716. deviceSlot: number;
  128717. }>;
  128718. /**
  128719. * Observable to be triggered when after a device is disconnected
  128720. */
  128721. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128722. deviceType: DeviceType;
  128723. deviceSlot: number;
  128724. }>;
  128725. private readonly _devices;
  128726. private readonly _firstDevice;
  128727. private readonly _deviceInputSystem;
  128728. /**
  128729. * Default Constructor
  128730. * @param engine engine to pull input element from
  128731. */
  128732. constructor(engine: Engine);
  128733. /**
  128734. * Gets a DeviceSource, given a type and slot
  128735. * @param deviceType Enum specifying device type
  128736. * @param deviceSlot "Slot" or index that device is referenced in
  128737. * @returns DeviceSource object
  128738. */
  128739. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128740. /**
  128741. * Gets an array of DeviceSource objects for a given device type
  128742. * @param deviceType Enum specifying device type
  128743. * @returns Array of DeviceSource objects
  128744. */
  128745. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128746. /**
  128747. * Dispose of DeviceInputSystem and other parts
  128748. */
  128749. dispose(): void;
  128750. /**
  128751. * Function to add device name to device list
  128752. * @param deviceType Enum specifying device type
  128753. * @param deviceSlot "Slot" or index that device is referenced in
  128754. */
  128755. private _addDevice;
  128756. /**
  128757. * Function to remove device name to device list
  128758. * @param deviceType Enum specifying device type
  128759. * @param deviceSlot "Slot" or index that device is referenced in
  128760. */
  128761. private _removeDevice;
  128762. /**
  128763. * Updates array storing first connected device of each type
  128764. * @param type Type of Device
  128765. */
  128766. private _updateFirstDevices;
  128767. }
  128768. }
  128769. declare module BABYLON {
  128770. /**
  128771. * Options to create the null engine
  128772. */
  128773. export class NullEngineOptions {
  128774. /**
  128775. * Render width (Default: 512)
  128776. */
  128777. renderWidth: number;
  128778. /**
  128779. * Render height (Default: 256)
  128780. */
  128781. renderHeight: number;
  128782. /**
  128783. * Texture size (Default: 512)
  128784. */
  128785. textureSize: number;
  128786. /**
  128787. * If delta time between frames should be constant
  128788. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128789. */
  128790. deterministicLockstep: boolean;
  128791. /**
  128792. * Maximum about of steps between frames (Default: 4)
  128793. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128794. */
  128795. lockstepMaxSteps: number;
  128796. }
  128797. /**
  128798. * The null engine class provides support for headless version of babylon.js.
  128799. * This can be used in server side scenario or for testing purposes
  128800. */
  128801. export class NullEngine extends Engine {
  128802. private _options;
  128803. /**
  128804. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128805. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128806. * @returns true if engine is in deterministic lock step mode
  128807. */
  128808. isDeterministicLockStep(): boolean;
  128809. /**
  128810. * Gets the max steps when engine is running in deterministic lock step
  128811. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128812. * @returns the max steps
  128813. */
  128814. getLockstepMaxSteps(): number;
  128815. /**
  128816. * Gets the current hardware scaling level.
  128817. * By default the hardware scaling level is computed from the window device ratio.
  128818. * 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.
  128819. * @returns a number indicating the current hardware scaling level
  128820. */
  128821. getHardwareScalingLevel(): number;
  128822. constructor(options?: NullEngineOptions);
  128823. /**
  128824. * Creates a vertex buffer
  128825. * @param vertices the data for the vertex buffer
  128826. * @returns the new WebGL static buffer
  128827. */
  128828. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128829. /**
  128830. * Creates a new index buffer
  128831. * @param indices defines the content of the index buffer
  128832. * @param updatable defines if the index buffer must be updatable
  128833. * @returns a new webGL buffer
  128834. */
  128835. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128836. /**
  128837. * Clear the current render buffer or the current render target (if any is set up)
  128838. * @param color defines the color to use
  128839. * @param backBuffer defines if the back buffer must be cleared
  128840. * @param depth defines if the depth buffer must be cleared
  128841. * @param stencil defines if the stencil buffer must be cleared
  128842. */
  128843. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128844. /**
  128845. * Gets the current render width
  128846. * @param useScreen defines if screen size must be used (or the current render target if any)
  128847. * @returns a number defining the current render width
  128848. */
  128849. getRenderWidth(useScreen?: boolean): number;
  128850. /**
  128851. * Gets the current render height
  128852. * @param useScreen defines if screen size must be used (or the current render target if any)
  128853. * @returns a number defining the current render height
  128854. */
  128855. getRenderHeight(useScreen?: boolean): number;
  128856. /**
  128857. * Set the WebGL's viewport
  128858. * @param viewport defines the viewport element to be used
  128859. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128860. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128861. */
  128862. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128863. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128864. /**
  128865. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128866. * @param pipelineContext defines the pipeline context to use
  128867. * @param uniformsNames defines the list of uniform names
  128868. * @returns an array of webGL uniform locations
  128869. */
  128870. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128871. /**
  128872. * Gets the lsit of active attributes for a given webGL program
  128873. * @param pipelineContext defines the pipeline context to use
  128874. * @param attributesNames defines the list of attribute names to get
  128875. * @returns an array of indices indicating the offset of each attribute
  128876. */
  128877. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128878. /**
  128879. * Binds an effect to the webGL context
  128880. * @param effect defines the effect to bind
  128881. */
  128882. bindSamplers(effect: Effect): void;
  128883. /**
  128884. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128885. * @param effect defines the effect to activate
  128886. */
  128887. enableEffect(effect: Effect): void;
  128888. /**
  128889. * Set various states to the webGL context
  128890. * @param culling defines backface culling state
  128891. * @param zOffset defines the value to apply to zOffset (0 by default)
  128892. * @param force defines if states must be applied even if cache is up to date
  128893. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128894. */
  128895. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128896. /**
  128897. * Set the value of an uniform to an array of int32
  128898. * @param uniform defines the webGL uniform location where to store the value
  128899. * @param array defines the array of int32 to store
  128900. */
  128901. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128902. /**
  128903. * Set the value of an uniform to an array of int32 (stored as vec2)
  128904. * @param uniform defines the webGL uniform location where to store the value
  128905. * @param array defines the array of int32 to store
  128906. */
  128907. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128908. /**
  128909. * Set the value of an uniform to an array of int32 (stored as vec3)
  128910. * @param uniform defines the webGL uniform location where to store the value
  128911. * @param array defines the array of int32 to store
  128912. */
  128913. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128914. /**
  128915. * Set the value of an uniform to an array of int32 (stored as vec4)
  128916. * @param uniform defines the webGL uniform location where to store the value
  128917. * @param array defines the array of int32 to store
  128918. */
  128919. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128920. /**
  128921. * Set the value of an uniform to an array of float32
  128922. * @param uniform defines the webGL uniform location where to store the value
  128923. * @param array defines the array of float32 to store
  128924. */
  128925. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128926. /**
  128927. * Set the value of an uniform to an array of float32 (stored as vec2)
  128928. * @param uniform defines the webGL uniform location where to store the value
  128929. * @param array defines the array of float32 to store
  128930. */
  128931. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128932. /**
  128933. * Set the value of an uniform to an array of float32 (stored as vec3)
  128934. * @param uniform defines the webGL uniform location where to store the value
  128935. * @param array defines the array of float32 to store
  128936. */
  128937. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128938. /**
  128939. * Set the value of an uniform to an array of float32 (stored as vec4)
  128940. * @param uniform defines the webGL uniform location where to store the value
  128941. * @param array defines the array of float32 to store
  128942. */
  128943. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128944. /**
  128945. * Set the value of an uniform to an array of number
  128946. * @param uniform defines the webGL uniform location where to store the value
  128947. * @param array defines the array of number to store
  128948. */
  128949. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128950. /**
  128951. * Set the value of an uniform to an array of number (stored as vec2)
  128952. * @param uniform defines the webGL uniform location where to store the value
  128953. * @param array defines the array of number to store
  128954. */
  128955. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128956. /**
  128957. * Set the value of an uniform to an array of number (stored as vec3)
  128958. * @param uniform defines the webGL uniform location where to store the value
  128959. * @param array defines the array of number to store
  128960. */
  128961. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128962. /**
  128963. * Set the value of an uniform to an array of number (stored as vec4)
  128964. * @param uniform defines the webGL uniform location where to store the value
  128965. * @param array defines the array of number to store
  128966. */
  128967. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128968. /**
  128969. * Set the value of an uniform to an array of float32 (stored as matrices)
  128970. * @param uniform defines the webGL uniform location where to store the value
  128971. * @param matrices defines the array of float32 to store
  128972. */
  128973. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128974. /**
  128975. * Set the value of an uniform to a matrix (3x3)
  128976. * @param uniform defines the webGL uniform location where to store the value
  128977. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128978. */
  128979. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128980. /**
  128981. * Set the value of an uniform to a matrix (2x2)
  128982. * @param uniform defines the webGL uniform location where to store the value
  128983. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128984. */
  128985. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128986. /**
  128987. * Set the value of an uniform to a number (float)
  128988. * @param uniform defines the webGL uniform location where to store the value
  128989. * @param value defines the float number to store
  128990. */
  128991. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128992. /**
  128993. * Set the value of an uniform to a vec2
  128994. * @param uniform defines the webGL uniform location where to store the value
  128995. * @param x defines the 1st component of the value
  128996. * @param y defines the 2nd component of the value
  128997. */
  128998. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128999. /**
  129000. * Set the value of an uniform to a vec3
  129001. * @param uniform defines the webGL uniform location where to store the value
  129002. * @param x defines the 1st component of the value
  129003. * @param y defines the 2nd component of the value
  129004. * @param z defines the 3rd component of the value
  129005. */
  129006. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129007. /**
  129008. * Set the value of an uniform to a boolean
  129009. * @param uniform defines the webGL uniform location where to store the value
  129010. * @param bool defines the boolean to store
  129011. */
  129012. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129013. /**
  129014. * Set the value of an uniform to a vec4
  129015. * @param uniform defines the webGL uniform location where to store the value
  129016. * @param x defines the 1st component of the value
  129017. * @param y defines the 2nd component of the value
  129018. * @param z defines the 3rd component of the value
  129019. * @param w defines the 4th component of the value
  129020. */
  129021. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129022. /**
  129023. * Sets the current alpha mode
  129024. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129025. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129026. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129027. */
  129028. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129029. /**
  129030. * Bind webGl buffers directly to the webGL context
  129031. * @param vertexBuffers defines the vertex buffer to bind
  129032. * @param indexBuffer defines the index buffer to bind
  129033. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129034. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129035. * @param effect defines the effect associated with the vertex buffer
  129036. */
  129037. bindBuffers(vertexBuffers: {
  129038. [key: string]: VertexBuffer;
  129039. }, indexBuffer: DataBuffer, effect: Effect): void;
  129040. /**
  129041. * Force the entire cache to be cleared
  129042. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129043. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129044. */
  129045. wipeCaches(bruteForce?: boolean): void;
  129046. /**
  129047. * Send a draw order
  129048. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129049. * @param indexStart defines the starting index
  129050. * @param indexCount defines the number of index to draw
  129051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129052. */
  129053. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129054. /**
  129055. * Draw a list of indexed primitives
  129056. * @param fillMode defines the primitive to use
  129057. * @param indexStart defines the starting index
  129058. * @param indexCount defines the number of index to draw
  129059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129060. */
  129061. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129062. /**
  129063. * Draw a list of unindexed primitives
  129064. * @param fillMode defines the primitive to use
  129065. * @param verticesStart defines the index of first vertex to draw
  129066. * @param verticesCount defines the count of vertices to draw
  129067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129068. */
  129069. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129070. /** @hidden */
  129071. _createTexture(): WebGLTexture;
  129072. /** @hidden */
  129073. _releaseTexture(texture: InternalTexture): void;
  129074. /**
  129075. * Usually called from Texture.ts.
  129076. * Passed information to create a WebGLTexture
  129077. * @param urlArg defines a value which contains one of the following:
  129078. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129079. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129080. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129081. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129082. * @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)
  129083. * @param scene needed for loading to the correct scene
  129084. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129085. * @param onLoad optional callback to be called upon successful completion
  129086. * @param onError optional callback to be called upon failure
  129087. * @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
  129088. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129089. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129090. * @param forcedExtension defines the extension to use to pick the right loader
  129091. * @param mimeType defines an optional mime type
  129092. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129093. */
  129094. 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;
  129095. /**
  129096. * Creates a new render target texture
  129097. * @param size defines the size of the texture
  129098. * @param options defines the options used to create the texture
  129099. * @returns a new render target texture stored in an InternalTexture
  129100. */
  129101. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129102. /**
  129103. * Update the sampling mode of a given texture
  129104. * @param samplingMode defines the required sampling mode
  129105. * @param texture defines the texture to update
  129106. */
  129107. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129108. /**
  129109. * Binds the frame buffer to the specified texture.
  129110. * @param texture The texture to render to or null for the default canvas
  129111. * @param faceIndex The face of the texture to render to in case of cube texture
  129112. * @param requiredWidth The width of the target to render to
  129113. * @param requiredHeight The height of the target to render to
  129114. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129115. * @param lodLevel defines le lod level to bind to the frame buffer
  129116. */
  129117. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129118. /**
  129119. * Unbind the current render target texture from the webGL context
  129120. * @param texture defines the render target texture to unbind
  129121. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129122. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129123. */
  129124. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129125. /**
  129126. * Creates a dynamic vertex buffer
  129127. * @param vertices the data for the dynamic vertex buffer
  129128. * @returns the new WebGL dynamic buffer
  129129. */
  129130. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129131. /**
  129132. * Update the content of a dynamic texture
  129133. * @param texture defines the texture to update
  129134. * @param canvas defines the canvas containing the source
  129135. * @param invertY defines if data must be stored with Y axis inverted
  129136. * @param premulAlpha defines if alpha is stored as premultiplied
  129137. * @param format defines the format of the data
  129138. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129139. */
  129140. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129141. /**
  129142. * Gets a boolean indicating if all created effects are ready
  129143. * @returns true if all effects are ready
  129144. */
  129145. areAllEffectsReady(): boolean;
  129146. /**
  129147. * @hidden
  129148. * Get the current error code of the webGL context
  129149. * @returns the error code
  129150. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129151. */
  129152. getError(): number;
  129153. /** @hidden */
  129154. _getUnpackAlignement(): number;
  129155. /** @hidden */
  129156. _unpackFlipY(value: boolean): void;
  129157. /**
  129158. * Update a dynamic index buffer
  129159. * @param indexBuffer defines the target index buffer
  129160. * @param indices defines the data to update
  129161. * @param offset defines the offset in the target index buffer where update should start
  129162. */
  129163. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129164. /**
  129165. * Updates a dynamic vertex buffer.
  129166. * @param vertexBuffer the vertex buffer to update
  129167. * @param vertices the data used to update the vertex buffer
  129168. * @param byteOffset the byte offset of the data (optional)
  129169. * @param byteLength the byte length of the data (optional)
  129170. */
  129171. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129172. /** @hidden */
  129173. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129174. /** @hidden */
  129175. _bindTexture(channel: number, texture: InternalTexture): void;
  129176. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129177. /**
  129178. * 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
  129179. */
  129180. releaseEffects(): void;
  129181. displayLoadingUI(): void;
  129182. hideLoadingUI(): void;
  129183. /** @hidden */
  129184. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129185. /** @hidden */
  129186. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129187. /** @hidden */
  129188. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129189. /** @hidden */
  129190. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129191. }
  129192. }
  129193. declare module BABYLON {
  129194. /**
  129195. * @hidden
  129196. **/
  129197. export class _TimeToken {
  129198. _startTimeQuery: Nullable<WebGLQuery>;
  129199. _endTimeQuery: Nullable<WebGLQuery>;
  129200. _timeElapsedQuery: Nullable<WebGLQuery>;
  129201. _timeElapsedQueryEnded: boolean;
  129202. }
  129203. }
  129204. declare module BABYLON {
  129205. /** @hidden */
  129206. export class _OcclusionDataStorage {
  129207. /** @hidden */
  129208. occlusionInternalRetryCounter: number;
  129209. /** @hidden */
  129210. isOcclusionQueryInProgress: boolean;
  129211. /** @hidden */
  129212. isOccluded: boolean;
  129213. /** @hidden */
  129214. occlusionRetryCount: number;
  129215. /** @hidden */
  129216. occlusionType: number;
  129217. /** @hidden */
  129218. occlusionQueryAlgorithmType: number;
  129219. }
  129220. interface Engine {
  129221. /**
  129222. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129223. * @return the new query
  129224. */
  129225. createQuery(): WebGLQuery;
  129226. /**
  129227. * Delete and release a webGL query
  129228. * @param query defines the query to delete
  129229. * @return the current engine
  129230. */
  129231. deleteQuery(query: WebGLQuery): Engine;
  129232. /**
  129233. * Check if a given query has resolved and got its value
  129234. * @param query defines the query to check
  129235. * @returns true if the query got its value
  129236. */
  129237. isQueryResultAvailable(query: WebGLQuery): boolean;
  129238. /**
  129239. * Gets the value of a given query
  129240. * @param query defines the query to check
  129241. * @returns the value of the query
  129242. */
  129243. getQueryResult(query: WebGLQuery): number;
  129244. /**
  129245. * Initiates an occlusion query
  129246. * @param algorithmType defines the algorithm to use
  129247. * @param query defines the query to use
  129248. * @returns the current engine
  129249. * @see https://doc.babylonjs.com/features/occlusionquery
  129250. */
  129251. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129252. /**
  129253. * Ends an occlusion query
  129254. * @see https://doc.babylonjs.com/features/occlusionquery
  129255. * @param algorithmType defines the algorithm to use
  129256. * @returns the current engine
  129257. */
  129258. endOcclusionQuery(algorithmType: number): Engine;
  129259. /**
  129260. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129261. * Please note that only one query can be issued at a time
  129262. * @returns a time token used to track the time span
  129263. */
  129264. startTimeQuery(): Nullable<_TimeToken>;
  129265. /**
  129266. * Ends a time query
  129267. * @param token defines the token used to measure the time span
  129268. * @returns the time spent (in ns)
  129269. */
  129270. endTimeQuery(token: _TimeToken): int;
  129271. /** @hidden */
  129272. _currentNonTimestampToken: Nullable<_TimeToken>;
  129273. /** @hidden */
  129274. _createTimeQuery(): WebGLQuery;
  129275. /** @hidden */
  129276. _deleteTimeQuery(query: WebGLQuery): void;
  129277. /** @hidden */
  129278. _getGlAlgorithmType(algorithmType: number): number;
  129279. /** @hidden */
  129280. _getTimeQueryResult(query: WebGLQuery): any;
  129281. /** @hidden */
  129282. _getTimeQueryAvailability(query: WebGLQuery): any;
  129283. }
  129284. interface AbstractMesh {
  129285. /**
  129286. * Backing filed
  129287. * @hidden
  129288. */
  129289. __occlusionDataStorage: _OcclusionDataStorage;
  129290. /**
  129291. * Access property
  129292. * @hidden
  129293. */
  129294. _occlusionDataStorage: _OcclusionDataStorage;
  129295. /**
  129296. * 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.
  129297. * The default value is -1 which means don't break the query and wait till the result
  129298. * @see https://doc.babylonjs.com/features/occlusionquery
  129299. */
  129300. occlusionRetryCount: number;
  129301. /**
  129302. * 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:
  129303. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129304. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129305. * * 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.
  129306. * @see https://doc.babylonjs.com/features/occlusionquery
  129307. */
  129308. occlusionType: number;
  129309. /**
  129310. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129311. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129312. * * 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.
  129313. * @see https://doc.babylonjs.com/features/occlusionquery
  129314. */
  129315. occlusionQueryAlgorithmType: number;
  129316. /**
  129317. * 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
  129318. * @see https://doc.babylonjs.com/features/occlusionquery
  129319. */
  129320. isOccluded: boolean;
  129321. /**
  129322. * Flag to check the progress status of the query
  129323. * @see https://doc.babylonjs.com/features/occlusionquery
  129324. */
  129325. isOcclusionQueryInProgress: boolean;
  129326. }
  129327. }
  129328. declare module BABYLON {
  129329. /** @hidden */
  129330. export var _forceTransformFeedbackToBundle: boolean;
  129331. interface Engine {
  129332. /**
  129333. * Creates a webGL transform feedback object
  129334. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129335. * @returns the webGL transform feedback object
  129336. */
  129337. createTransformFeedback(): WebGLTransformFeedback;
  129338. /**
  129339. * Delete a webGL transform feedback object
  129340. * @param value defines the webGL transform feedback object to delete
  129341. */
  129342. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129343. /**
  129344. * Bind a webGL transform feedback object to the webgl context
  129345. * @param value defines the webGL transform feedback object to bind
  129346. */
  129347. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129348. /**
  129349. * Begins a transform feedback operation
  129350. * @param usePoints defines if points or triangles must be used
  129351. */
  129352. beginTransformFeedback(usePoints: boolean): void;
  129353. /**
  129354. * Ends a transform feedback operation
  129355. */
  129356. endTransformFeedback(): void;
  129357. /**
  129358. * Specify the varyings to use with transform feedback
  129359. * @param program defines the associated webGL program
  129360. * @param value defines the list of strings representing the varying names
  129361. */
  129362. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129363. /**
  129364. * Bind a webGL buffer for a transform feedback operation
  129365. * @param value defines the webGL buffer to bind
  129366. */
  129367. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129368. }
  129369. }
  129370. declare module BABYLON {
  129371. /**
  129372. * Creation options of the multi render target texture.
  129373. */
  129374. export interface IMultiRenderTargetOptions {
  129375. /**
  129376. * Define if the texture needs to create mip maps after render.
  129377. */
  129378. generateMipMaps?: boolean;
  129379. /**
  129380. * Define the types of all the draw buffers we want to create
  129381. */
  129382. types?: number[];
  129383. /**
  129384. * Define the sampling modes of all the draw buffers we want to create
  129385. */
  129386. samplingModes?: number[];
  129387. /**
  129388. * Define if a depth buffer is required
  129389. */
  129390. generateDepthBuffer?: boolean;
  129391. /**
  129392. * Define if a stencil buffer is required
  129393. */
  129394. generateStencilBuffer?: boolean;
  129395. /**
  129396. * Define if a depth texture is required instead of a depth buffer
  129397. */
  129398. generateDepthTexture?: boolean;
  129399. /**
  129400. * Define the number of desired draw buffers
  129401. */
  129402. textureCount?: number;
  129403. /**
  129404. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129405. */
  129406. doNotChangeAspectRatio?: boolean;
  129407. /**
  129408. * Define the default type of the buffers we are creating
  129409. */
  129410. defaultType?: number;
  129411. }
  129412. /**
  129413. * A multi render target, like a render target provides the ability to render to a texture.
  129414. * Unlike the render target, it can render to several draw buffers in one draw.
  129415. * This is specially interesting in deferred rendering or for any effects requiring more than
  129416. * just one color from a single pass.
  129417. */
  129418. export class MultiRenderTarget extends RenderTargetTexture {
  129419. private _internalTextures;
  129420. private _textures;
  129421. private _multiRenderTargetOptions;
  129422. private _count;
  129423. /**
  129424. * Get if draw buffers are currently supported by the used hardware and browser.
  129425. */
  129426. get isSupported(): boolean;
  129427. /**
  129428. * Get the list of textures generated by the multi render target.
  129429. */
  129430. get textures(): Texture[];
  129431. /**
  129432. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129433. */
  129434. get count(): number;
  129435. /**
  129436. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129437. */
  129438. get depthTexture(): Texture;
  129439. /**
  129440. * Set the wrapping mode on U of all the textures we are rendering to.
  129441. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129442. */
  129443. set wrapU(wrap: number);
  129444. /**
  129445. * Set the wrapping mode on V of all the textures we are rendering to.
  129446. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129447. */
  129448. set wrapV(wrap: number);
  129449. /**
  129450. * Instantiate a new multi render target texture.
  129451. * A multi render target, like a render target provides the ability to render to a texture.
  129452. * Unlike the render target, it can render to several draw buffers in one draw.
  129453. * This is specially interesting in deferred rendering or for any effects requiring more than
  129454. * just one color from a single pass.
  129455. * @param name Define the name of the texture
  129456. * @param size Define the size of the buffers to render to
  129457. * @param count Define the number of target we are rendering into
  129458. * @param scene Define the scene the texture belongs to
  129459. * @param options Define the options used to create the multi render target
  129460. */
  129461. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129462. /** @hidden */
  129463. _rebuild(): void;
  129464. private _createInternalTextures;
  129465. private _createTextures;
  129466. /**
  129467. * Define the number of samples used if MSAA is enabled.
  129468. */
  129469. get samples(): number;
  129470. set samples(value: number);
  129471. /**
  129472. * Resize all the textures in the multi render target.
  129473. * Be carrefull as it will recreate all the data in the new texture.
  129474. * @param size Define the new size
  129475. */
  129476. resize(size: any): void;
  129477. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129478. /**
  129479. * Dispose the render targets and their associated resources
  129480. */
  129481. dispose(): void;
  129482. /**
  129483. * Release all the underlying texture used as draw buffers.
  129484. */
  129485. releaseInternalTextures(): void;
  129486. }
  129487. }
  129488. declare module BABYLON {
  129489. interface ThinEngine {
  129490. /**
  129491. * Unbind a list of render target textures from the webGL context
  129492. * This is used only when drawBuffer extension or webGL2 are active
  129493. * @param textures defines the render target textures to unbind
  129494. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129495. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129496. */
  129497. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129498. /**
  129499. * Create a multi render target texture
  129500. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129501. * @param size defines the size of the texture
  129502. * @param options defines the creation options
  129503. * @returns the cube texture as an InternalTexture
  129504. */
  129505. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129506. /**
  129507. * Update the sample count for a given multiple render target texture
  129508. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129509. * @param textures defines the textures to update
  129510. * @param samples defines the sample count to set
  129511. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129512. */
  129513. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129514. /**
  129515. * Select a subsets of attachments to draw to.
  129516. * @param attachments gl attachments
  129517. */
  129518. bindAttachments(attachments: number[]): void;
  129519. }
  129520. }
  129521. declare module BABYLON {
  129522. /**
  129523. * Class used to define an additional view for the engine
  129524. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129525. */
  129526. export class EngineView {
  129527. /** Defines the canvas where to render the view */
  129528. target: HTMLCanvasElement;
  129529. /** Defines an optional camera used to render the view (will use active camera else) */
  129530. camera?: Camera;
  129531. }
  129532. interface Engine {
  129533. /**
  129534. * Gets or sets the HTML element to use for attaching events
  129535. */
  129536. inputElement: Nullable<HTMLElement>;
  129537. /**
  129538. * Gets the current engine view
  129539. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129540. */
  129541. activeView: Nullable<EngineView>;
  129542. /** Gets or sets the list of views */
  129543. views: EngineView[];
  129544. /**
  129545. * Register a new child canvas
  129546. * @param canvas defines the canvas to register
  129547. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129548. * @returns the associated view
  129549. */
  129550. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129551. /**
  129552. * Remove a registered child canvas
  129553. * @param canvas defines the canvas to remove
  129554. * @returns the current engine
  129555. */
  129556. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129557. }
  129558. }
  129559. declare module BABYLON {
  129560. interface Engine {
  129561. /** @hidden */
  129562. _excludedCompressedTextures: string[];
  129563. /** @hidden */
  129564. _textureFormatInUse: string;
  129565. /**
  129566. * Gets the list of texture formats supported
  129567. */
  129568. readonly texturesSupported: Array<string>;
  129569. /**
  129570. * Gets the texture format in use
  129571. */
  129572. readonly textureFormatInUse: Nullable<string>;
  129573. /**
  129574. * Set the compressed texture extensions or file names to skip.
  129575. *
  129576. * @param skippedFiles defines the list of those texture files you want to skip
  129577. * Example: [".dds", ".env", "myfile.png"]
  129578. */
  129579. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129580. /**
  129581. * Set the compressed texture format to use, based on the formats you have, and the formats
  129582. * supported by the hardware / browser.
  129583. *
  129584. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129585. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129586. * to API arguments needed to compressed textures. This puts the burden on the container
  129587. * generator to house the arcane code for determining these for current & future formats.
  129588. *
  129589. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129590. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129591. *
  129592. * Note: The result of this call is not taken into account when a texture is base64.
  129593. *
  129594. * @param formatsAvailable defines the list of those format families you have created
  129595. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129596. *
  129597. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129598. * @returns The extension selected.
  129599. */
  129600. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129601. }
  129602. }
  129603. declare module BABYLON {
  129604. /**
  129605. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129606. */
  129607. export interface CubeMapInfo {
  129608. /**
  129609. * The pixel array for the front face.
  129610. * This is stored in format, left to right, up to down format.
  129611. */
  129612. front: Nullable<ArrayBufferView>;
  129613. /**
  129614. * The pixel array for the back face.
  129615. * This is stored in format, left to right, up to down format.
  129616. */
  129617. back: Nullable<ArrayBufferView>;
  129618. /**
  129619. * The pixel array for the left face.
  129620. * This is stored in format, left to right, up to down format.
  129621. */
  129622. left: Nullable<ArrayBufferView>;
  129623. /**
  129624. * The pixel array for the right face.
  129625. * This is stored in format, left to right, up to down format.
  129626. */
  129627. right: Nullable<ArrayBufferView>;
  129628. /**
  129629. * The pixel array for the up face.
  129630. * This is stored in format, left to right, up to down format.
  129631. */
  129632. up: Nullable<ArrayBufferView>;
  129633. /**
  129634. * The pixel array for the down face.
  129635. * This is stored in format, left to right, up to down format.
  129636. */
  129637. down: Nullable<ArrayBufferView>;
  129638. /**
  129639. * The size of the cubemap stored.
  129640. *
  129641. * Each faces will be size * size pixels.
  129642. */
  129643. size: number;
  129644. /**
  129645. * The format of the texture.
  129646. *
  129647. * RGBA, RGB.
  129648. */
  129649. format: number;
  129650. /**
  129651. * The type of the texture data.
  129652. *
  129653. * UNSIGNED_INT, FLOAT.
  129654. */
  129655. type: number;
  129656. /**
  129657. * Specifies whether the texture is in gamma space.
  129658. */
  129659. gammaSpace: boolean;
  129660. }
  129661. /**
  129662. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129663. */
  129664. export class PanoramaToCubeMapTools {
  129665. private static FACE_LEFT;
  129666. private static FACE_RIGHT;
  129667. private static FACE_FRONT;
  129668. private static FACE_BACK;
  129669. private static FACE_DOWN;
  129670. private static FACE_UP;
  129671. /**
  129672. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129673. *
  129674. * @param float32Array The source data.
  129675. * @param inputWidth The width of the input panorama.
  129676. * @param inputHeight The height of the input panorama.
  129677. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129678. * @return The cubemap data
  129679. */
  129680. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129681. private static CreateCubemapTexture;
  129682. private static CalcProjectionSpherical;
  129683. }
  129684. }
  129685. declare module BABYLON {
  129686. /**
  129687. * Helper class dealing with the extraction of spherical polynomial dataArray
  129688. * from a cube map.
  129689. */
  129690. export class CubeMapToSphericalPolynomialTools {
  129691. private static FileFaces;
  129692. /**
  129693. * Converts a texture to the according Spherical Polynomial data.
  129694. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129695. *
  129696. * @param texture The texture to extract the information from.
  129697. * @return The Spherical Polynomial data.
  129698. */
  129699. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129700. /**
  129701. * Converts a cubemap to the according Spherical Polynomial data.
  129702. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129703. *
  129704. * @param cubeInfo The Cube map to extract the information from.
  129705. * @return The Spherical Polynomial data.
  129706. */
  129707. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129708. }
  129709. }
  129710. declare module BABYLON {
  129711. interface BaseTexture {
  129712. /**
  129713. * Get the polynomial representation of the texture data.
  129714. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129715. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129716. */
  129717. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129718. }
  129719. }
  129720. declare module BABYLON {
  129721. /** @hidden */
  129722. export var rgbdEncodePixelShader: {
  129723. name: string;
  129724. shader: string;
  129725. };
  129726. }
  129727. declare module BABYLON {
  129728. /** @hidden */
  129729. export var rgbdDecodePixelShader: {
  129730. name: string;
  129731. shader: string;
  129732. };
  129733. }
  129734. declare module BABYLON {
  129735. /**
  129736. * Raw texture data and descriptor sufficient for WebGL texture upload
  129737. */
  129738. export interface EnvironmentTextureInfo {
  129739. /**
  129740. * Version of the environment map
  129741. */
  129742. version: number;
  129743. /**
  129744. * Width of image
  129745. */
  129746. width: number;
  129747. /**
  129748. * Irradiance information stored in the file.
  129749. */
  129750. irradiance: any;
  129751. /**
  129752. * Specular information stored in the file.
  129753. */
  129754. specular: any;
  129755. }
  129756. /**
  129757. * Defines One Image in the file. It requires only the position in the file
  129758. * as well as the length.
  129759. */
  129760. interface BufferImageData {
  129761. /**
  129762. * Length of the image data.
  129763. */
  129764. length: number;
  129765. /**
  129766. * Position of the data from the null terminator delimiting the end of the JSON.
  129767. */
  129768. position: number;
  129769. }
  129770. /**
  129771. * Defines the specular data enclosed in the file.
  129772. * This corresponds to the version 1 of the data.
  129773. */
  129774. export interface EnvironmentTextureSpecularInfoV1 {
  129775. /**
  129776. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129777. */
  129778. specularDataPosition?: number;
  129779. /**
  129780. * This contains all the images data needed to reconstruct the cubemap.
  129781. */
  129782. mipmaps: Array<BufferImageData>;
  129783. /**
  129784. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129785. */
  129786. lodGenerationScale: number;
  129787. }
  129788. /**
  129789. * Sets of helpers addressing the serialization and deserialization of environment texture
  129790. * stored in a BabylonJS env file.
  129791. * Those files are usually stored as .env files.
  129792. */
  129793. export class EnvironmentTextureTools {
  129794. /**
  129795. * Magic number identifying the env file.
  129796. */
  129797. private static _MagicBytes;
  129798. /**
  129799. * Gets the environment info from an env file.
  129800. * @param data The array buffer containing the .env bytes.
  129801. * @returns the environment file info (the json header) if successfully parsed.
  129802. */
  129803. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129804. /**
  129805. * Creates an environment texture from a loaded cube texture.
  129806. * @param texture defines the cube texture to convert in env file
  129807. * @return a promise containing the environment data if succesfull.
  129808. */
  129809. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129810. /**
  129811. * Creates a JSON representation of the spherical data.
  129812. * @param texture defines the texture containing the polynomials
  129813. * @return the JSON representation of the spherical info
  129814. */
  129815. private static _CreateEnvTextureIrradiance;
  129816. /**
  129817. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129818. * @param data the image data
  129819. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129820. * @return the views described by info providing access to the underlying buffer
  129821. */
  129822. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129823. /**
  129824. * Uploads the texture info contained in the env file to the GPU.
  129825. * @param texture defines the internal texture to upload to
  129826. * @param data defines the data to load
  129827. * @param info defines the texture info retrieved through the GetEnvInfo method
  129828. * @returns a promise
  129829. */
  129830. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129831. private static _OnImageReadyAsync;
  129832. /**
  129833. * Uploads the levels of image data to the GPU.
  129834. * @param texture defines the internal texture to upload to
  129835. * @param imageData defines the array buffer views of image data [mipmap][face]
  129836. * @returns a promise
  129837. */
  129838. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129839. /**
  129840. * Uploads spherical polynomials information to the texture.
  129841. * @param texture defines the texture we are trying to upload the information to
  129842. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129843. */
  129844. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129845. /** @hidden */
  129846. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129847. }
  129848. }
  129849. declare module BABYLON {
  129850. /**
  129851. * Class used to inline functions in shader code
  129852. */
  129853. export class ShaderCodeInliner {
  129854. private static readonly _RegexpFindFunctionNameAndType;
  129855. private _sourceCode;
  129856. private _functionDescr;
  129857. private _numMaxIterations;
  129858. /** Gets or sets the token used to mark the functions to inline */
  129859. inlineToken: string;
  129860. /** Gets or sets the debug mode */
  129861. debug: boolean;
  129862. /** Gets the code after the inlining process */
  129863. get code(): string;
  129864. /**
  129865. * Initializes the inliner
  129866. * @param sourceCode shader code source to inline
  129867. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129868. */
  129869. constructor(sourceCode: string, numMaxIterations?: number);
  129870. /**
  129871. * Start the processing of the shader code
  129872. */
  129873. processCode(): void;
  129874. private _collectFunctions;
  129875. private _processInlining;
  129876. private _extractBetweenMarkers;
  129877. private _skipWhitespaces;
  129878. private _removeComments;
  129879. private _replaceFunctionCallsByCode;
  129880. private _findBackward;
  129881. private _escapeRegExp;
  129882. private _replaceNames;
  129883. }
  129884. }
  129885. declare module BABYLON {
  129886. /**
  129887. * Container for accessors for natively-stored mesh data buffers.
  129888. */
  129889. class NativeDataBuffer extends DataBuffer {
  129890. /**
  129891. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129892. */
  129893. nativeIndexBuffer?: any;
  129894. /**
  129895. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129896. */
  129897. nativeVertexBuffer?: any;
  129898. }
  129899. /** @hidden */
  129900. class NativeTexture extends InternalTexture {
  129901. getInternalTexture(): InternalTexture;
  129902. getViewCount(): number;
  129903. }
  129904. /** @hidden */
  129905. export class NativeEngine extends Engine {
  129906. private readonly _native;
  129907. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129908. private readonly INVALID_HANDLE;
  129909. getHardwareScalingLevel(): number;
  129910. constructor();
  129911. dispose(): void;
  129912. /**
  129913. * Can be used to override the current requestAnimationFrame requester.
  129914. * @hidden
  129915. */
  129916. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129917. /**
  129918. * Override default engine behavior.
  129919. * @param color
  129920. * @param backBuffer
  129921. * @param depth
  129922. * @param stencil
  129923. */
  129924. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129925. /**
  129926. * Gets host document
  129927. * @returns the host document object
  129928. */
  129929. getHostDocument(): Nullable<Document>;
  129930. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129931. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129932. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129933. recordVertexArrayObject(vertexBuffers: {
  129934. [key: string]: VertexBuffer;
  129935. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129936. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129937. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129938. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129939. /**
  129940. * Draw a list of indexed primitives
  129941. * @param fillMode defines the primitive to use
  129942. * @param indexStart defines the starting index
  129943. * @param indexCount defines the number of index to draw
  129944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129945. */
  129946. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129947. /**
  129948. * Draw a list of unindexed primitives
  129949. * @param fillMode defines the primitive to use
  129950. * @param verticesStart defines the index of first vertex to draw
  129951. * @param verticesCount defines the count of vertices to draw
  129952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129953. */
  129954. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129955. createPipelineContext(): IPipelineContext;
  129956. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129957. /** @hidden */
  129958. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129959. /** @hidden */
  129960. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129961. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129962. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129963. protected _setProgram(program: WebGLProgram): void;
  129964. _releaseEffect(effect: Effect): void;
  129965. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129966. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129967. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129968. bindSamplers(effect: Effect): void;
  129969. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129970. getRenderWidth(useScreen?: boolean): number;
  129971. getRenderHeight(useScreen?: boolean): number;
  129972. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129973. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129974. /**
  129975. * Set the z offset to apply to current rendering
  129976. * @param value defines the offset to apply
  129977. */
  129978. setZOffset(value: number): void;
  129979. /**
  129980. * Gets the current value of the zOffset
  129981. * @returns the current zOffset state
  129982. */
  129983. getZOffset(): number;
  129984. /**
  129985. * Enable or disable depth buffering
  129986. * @param enable defines the state to set
  129987. */
  129988. setDepthBuffer(enable: boolean): void;
  129989. /**
  129990. * Gets a boolean indicating if depth writing is enabled
  129991. * @returns the current depth writing state
  129992. */
  129993. getDepthWrite(): boolean;
  129994. /**
  129995. * Enable or disable depth writing
  129996. * @param enable defines the state to set
  129997. */
  129998. setDepthWrite(enable: boolean): void;
  129999. /**
  130000. * Enable or disable color writing
  130001. * @param enable defines the state to set
  130002. */
  130003. setColorWrite(enable: boolean): void;
  130004. /**
  130005. * Gets a boolean indicating if color writing is enabled
  130006. * @returns the current color writing state
  130007. */
  130008. getColorWrite(): boolean;
  130009. /**
  130010. * Sets alpha constants used by some alpha blending modes
  130011. * @param r defines the red component
  130012. * @param g defines the green component
  130013. * @param b defines the blue component
  130014. * @param a defines the alpha component
  130015. */
  130016. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130017. /**
  130018. * Sets the current alpha mode
  130019. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130020. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130021. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130022. */
  130023. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130024. /**
  130025. * Gets the current alpha mode
  130026. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130027. * @returns the current alpha mode
  130028. */
  130029. getAlphaMode(): number;
  130030. setInt(uniform: WebGLUniformLocation, int: number): void;
  130031. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130032. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130033. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130034. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130035. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130036. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130037. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130038. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130039. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130040. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130041. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130042. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130043. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130044. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130045. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130046. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130047. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130048. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130049. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130050. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130051. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130052. wipeCaches(bruteForce?: boolean): void;
  130053. _createTexture(): WebGLTexture;
  130054. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130055. /**
  130056. * Usually called from Texture.ts.
  130057. * Passed information to create a WebGLTexture
  130058. * @param url defines a value which contains one of the following:
  130059. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130060. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130061. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130062. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130063. * @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)
  130064. * @param scene needed for loading to the correct scene
  130065. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130066. * @param onLoad optional callback to be called upon successful completion
  130067. * @param onError optional callback to be called upon failure
  130068. * @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
  130069. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130070. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130071. * @param forcedExtension defines the extension to use to pick the right loader
  130072. * @param mimeType defines an optional mime type
  130073. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130074. */
  130075. 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;
  130076. /**
  130077. * Creates a cube texture
  130078. * @param rootUrl defines the url where the files to load is located
  130079. * @param scene defines the current scene
  130080. * @param files defines the list of files to load (1 per face)
  130081. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130082. * @param onLoad defines an optional callback raised when the texture is loaded
  130083. * @param onError defines an optional callback raised if there is an issue to load the texture
  130084. * @param format defines the format of the data
  130085. * @param forcedExtension defines the extension to use to pick the right loader
  130086. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130087. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130088. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130089. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130090. * @returns the cube texture as an InternalTexture
  130091. */
  130092. 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;
  130093. private _getSamplingFilter;
  130094. private static _GetNativeTextureFormat;
  130095. createRenderTargetTexture(size: number | {
  130096. width: number;
  130097. height: number;
  130098. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130099. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130100. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130101. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130102. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130103. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130104. /**
  130105. * Updates a dynamic vertex buffer.
  130106. * @param vertexBuffer the vertex buffer to update
  130107. * @param data the data used to update the vertex buffer
  130108. * @param byteOffset the byte offset of the data (optional)
  130109. * @param byteLength the byte length of the data (optional)
  130110. */
  130111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130112. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130113. private _updateAnisotropicLevel;
  130114. private _getAddressMode;
  130115. /** @hidden */
  130116. _bindTexture(channel: number, texture: InternalTexture): void;
  130117. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130118. releaseEffects(): void;
  130119. /** @hidden */
  130120. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130121. /** @hidden */
  130122. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130123. /** @hidden */
  130124. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130125. /** @hidden */
  130126. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130127. }
  130128. }
  130129. declare module BABYLON {
  130130. /**
  130131. * Gather the list of clipboard event types as constants.
  130132. */
  130133. export class ClipboardEventTypes {
  130134. /**
  130135. * The clipboard event is fired when a copy command is active (pressed).
  130136. */
  130137. static readonly COPY: number;
  130138. /**
  130139. * The clipboard event is fired when a cut command is active (pressed).
  130140. */
  130141. static readonly CUT: number;
  130142. /**
  130143. * The clipboard event is fired when a paste command is active (pressed).
  130144. */
  130145. static readonly PASTE: number;
  130146. }
  130147. /**
  130148. * This class is used to store clipboard related info for the onClipboardObservable event.
  130149. */
  130150. export class ClipboardInfo {
  130151. /**
  130152. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130153. */
  130154. type: number;
  130155. /**
  130156. * Defines the related dom event
  130157. */
  130158. event: ClipboardEvent;
  130159. /**
  130160. *Creates an instance of ClipboardInfo.
  130161. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130162. * @param event Defines the related dom event
  130163. */
  130164. constructor(
  130165. /**
  130166. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130167. */
  130168. type: number,
  130169. /**
  130170. * Defines the related dom event
  130171. */
  130172. event: ClipboardEvent);
  130173. /**
  130174. * Get the clipboard event's type from the keycode.
  130175. * @param keyCode Defines the keyCode for the current keyboard event.
  130176. * @return {number}
  130177. */
  130178. static GetTypeFromCharacter(keyCode: number): number;
  130179. }
  130180. }
  130181. declare module BABYLON {
  130182. /**
  130183. * Google Daydream controller
  130184. */
  130185. export class DaydreamController extends WebVRController {
  130186. /**
  130187. * Base Url for the controller model.
  130188. */
  130189. static MODEL_BASE_URL: string;
  130190. /**
  130191. * File name for the controller model.
  130192. */
  130193. static MODEL_FILENAME: string;
  130194. /**
  130195. * Gamepad Id prefix used to identify Daydream Controller.
  130196. */
  130197. static readonly GAMEPAD_ID_PREFIX: string;
  130198. /**
  130199. * Creates a new DaydreamController from a gamepad
  130200. * @param vrGamepad the gamepad that the controller should be created from
  130201. */
  130202. constructor(vrGamepad: any);
  130203. /**
  130204. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130205. * @param scene scene in which to add meshes
  130206. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130207. */
  130208. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130209. /**
  130210. * Called once for each button that changed state since the last frame
  130211. * @param buttonIdx Which button index changed
  130212. * @param state New state of the button
  130213. * @param changes Which properties on the state changed since last frame
  130214. */
  130215. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130216. }
  130217. }
  130218. declare module BABYLON {
  130219. /**
  130220. * Gear VR Controller
  130221. */
  130222. export class GearVRController extends WebVRController {
  130223. /**
  130224. * Base Url for the controller model.
  130225. */
  130226. static MODEL_BASE_URL: string;
  130227. /**
  130228. * File name for the controller model.
  130229. */
  130230. static MODEL_FILENAME: string;
  130231. /**
  130232. * Gamepad Id prefix used to identify this controller.
  130233. */
  130234. static readonly GAMEPAD_ID_PREFIX: string;
  130235. private readonly _buttonIndexToObservableNameMap;
  130236. /**
  130237. * Creates a new GearVRController from a gamepad
  130238. * @param vrGamepad the gamepad that the controller should be created from
  130239. */
  130240. constructor(vrGamepad: any);
  130241. /**
  130242. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130243. * @param scene scene in which to add meshes
  130244. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130245. */
  130246. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130247. /**
  130248. * Called once for each button that changed state since the last frame
  130249. * @param buttonIdx Which button index changed
  130250. * @param state New state of the button
  130251. * @param changes Which properties on the state changed since last frame
  130252. */
  130253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130254. }
  130255. }
  130256. declare module BABYLON {
  130257. /**
  130258. * Generic Controller
  130259. */
  130260. export class GenericController extends WebVRController {
  130261. /**
  130262. * Base Url for the controller model.
  130263. */
  130264. static readonly MODEL_BASE_URL: string;
  130265. /**
  130266. * File name for the controller model.
  130267. */
  130268. static readonly MODEL_FILENAME: string;
  130269. /**
  130270. * Creates a new GenericController from a gamepad
  130271. * @param vrGamepad the gamepad that the controller should be created from
  130272. */
  130273. constructor(vrGamepad: any);
  130274. /**
  130275. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130276. * @param scene scene in which to add meshes
  130277. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130278. */
  130279. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130280. /**
  130281. * Called once for each button that changed state since the last frame
  130282. * @param buttonIdx Which button index changed
  130283. * @param state New state of the button
  130284. * @param changes Which properties on the state changed since last frame
  130285. */
  130286. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130287. }
  130288. }
  130289. declare module BABYLON {
  130290. /**
  130291. * Oculus Touch Controller
  130292. */
  130293. export class OculusTouchController extends WebVRController {
  130294. /**
  130295. * Base Url for the controller model.
  130296. */
  130297. static MODEL_BASE_URL: string;
  130298. /**
  130299. * File name for the left controller model.
  130300. */
  130301. static MODEL_LEFT_FILENAME: string;
  130302. /**
  130303. * File name for the right controller model.
  130304. */
  130305. static MODEL_RIGHT_FILENAME: string;
  130306. /**
  130307. * Base Url for the Quest controller model.
  130308. */
  130309. static QUEST_MODEL_BASE_URL: string;
  130310. /**
  130311. * @hidden
  130312. * If the controllers are running on a device that needs the updated Quest controller models
  130313. */
  130314. static _IsQuest: boolean;
  130315. /**
  130316. * Fired when the secondary trigger on this controller is modified
  130317. */
  130318. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130319. /**
  130320. * Fired when the thumb rest on this controller is modified
  130321. */
  130322. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130323. /**
  130324. * Creates a new OculusTouchController from a gamepad
  130325. * @param vrGamepad the gamepad that the controller should be created from
  130326. */
  130327. constructor(vrGamepad: any);
  130328. /**
  130329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130330. * @param scene scene in which to add meshes
  130331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130332. */
  130333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130334. /**
  130335. * Fired when the A button on this controller is modified
  130336. */
  130337. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130338. /**
  130339. * Fired when the B button on this controller is modified
  130340. */
  130341. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130342. /**
  130343. * Fired when the X button on this controller is modified
  130344. */
  130345. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130346. /**
  130347. * Fired when the Y button on this controller is modified
  130348. */
  130349. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130350. /**
  130351. * Called once for each button that changed state since the last frame
  130352. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130353. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130354. * 2) secondary trigger (same)
  130355. * 3) A (right) X (left), touch, pressed = value
  130356. * 4) B / Y
  130357. * 5) thumb rest
  130358. * @param buttonIdx Which button index changed
  130359. * @param state New state of the button
  130360. * @param changes Which properties on the state changed since last frame
  130361. */
  130362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130363. }
  130364. }
  130365. declare module BABYLON {
  130366. /**
  130367. * Vive Controller
  130368. */
  130369. export class ViveController extends WebVRController {
  130370. /**
  130371. * Base Url for the controller model.
  130372. */
  130373. static MODEL_BASE_URL: string;
  130374. /**
  130375. * File name for the controller model.
  130376. */
  130377. static MODEL_FILENAME: string;
  130378. /**
  130379. * Creates a new ViveController from a gamepad
  130380. * @param vrGamepad the gamepad that the controller should be created from
  130381. */
  130382. constructor(vrGamepad: any);
  130383. /**
  130384. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130385. * @param scene scene in which to add meshes
  130386. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130387. */
  130388. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130389. /**
  130390. * Fired when the left button on this controller is modified
  130391. */
  130392. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130393. /**
  130394. * Fired when the right button on this controller is modified
  130395. */
  130396. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130397. /**
  130398. * Fired when the menu button on this controller is modified
  130399. */
  130400. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130401. /**
  130402. * Called once for each button that changed state since the last frame
  130403. * Vive mapping:
  130404. * 0: touchpad
  130405. * 1: trigger
  130406. * 2: left AND right buttons
  130407. * 3: menu button
  130408. * @param buttonIdx Which button index changed
  130409. * @param state New state of the button
  130410. * @param changes Which properties on the state changed since last frame
  130411. */
  130412. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130413. }
  130414. }
  130415. declare module BABYLON {
  130416. /**
  130417. * Defines the WindowsMotionController object that the state of the windows motion controller
  130418. */
  130419. export class WindowsMotionController extends WebVRController {
  130420. /**
  130421. * The base url used to load the left and right controller models
  130422. */
  130423. static MODEL_BASE_URL: string;
  130424. /**
  130425. * The name of the left controller model file
  130426. */
  130427. static MODEL_LEFT_FILENAME: string;
  130428. /**
  130429. * The name of the right controller model file
  130430. */
  130431. static MODEL_RIGHT_FILENAME: string;
  130432. /**
  130433. * The controller name prefix for this controller type
  130434. */
  130435. static readonly GAMEPAD_ID_PREFIX: string;
  130436. /**
  130437. * The controller id pattern for this controller type
  130438. */
  130439. private static readonly GAMEPAD_ID_PATTERN;
  130440. private _loadedMeshInfo;
  130441. protected readonly _mapping: {
  130442. buttons: string[];
  130443. buttonMeshNames: {
  130444. trigger: string;
  130445. menu: string;
  130446. grip: string;
  130447. thumbstick: string;
  130448. trackpad: string;
  130449. };
  130450. buttonObservableNames: {
  130451. trigger: string;
  130452. menu: string;
  130453. grip: string;
  130454. thumbstick: string;
  130455. trackpad: string;
  130456. };
  130457. axisMeshNames: string[];
  130458. pointingPoseMeshName: string;
  130459. };
  130460. /**
  130461. * Fired when the trackpad on this controller is clicked
  130462. */
  130463. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130464. /**
  130465. * Fired when the trackpad on this controller is modified
  130466. */
  130467. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130468. /**
  130469. * The current x and y values of this controller's trackpad
  130470. */
  130471. trackpad: StickValues;
  130472. /**
  130473. * Creates a new WindowsMotionController from a gamepad
  130474. * @param vrGamepad the gamepad that the controller should be created from
  130475. */
  130476. constructor(vrGamepad: any);
  130477. /**
  130478. * Fired when the trigger on this controller is modified
  130479. */
  130480. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130481. /**
  130482. * Fired when the menu button on this controller is modified
  130483. */
  130484. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130485. /**
  130486. * Fired when the grip button on this controller is modified
  130487. */
  130488. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130489. /**
  130490. * Fired when the thumbstick button on this controller is modified
  130491. */
  130492. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130493. /**
  130494. * Fired when the touchpad button on this controller is modified
  130495. */
  130496. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130497. /**
  130498. * Fired when the touchpad values on this controller are modified
  130499. */
  130500. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130501. protected _updateTrackpad(): void;
  130502. /**
  130503. * Called once per frame by the engine.
  130504. */
  130505. update(): void;
  130506. /**
  130507. * Called once for each button that changed state since the last frame
  130508. * @param buttonIdx Which button index changed
  130509. * @param state New state of the button
  130510. * @param changes Which properties on the state changed since last frame
  130511. */
  130512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130513. /**
  130514. * Moves the buttons on the controller mesh based on their current state
  130515. * @param buttonName the name of the button to move
  130516. * @param buttonValue the value of the button which determines the buttons new position
  130517. */
  130518. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130519. /**
  130520. * Moves the axis on the controller mesh based on its current state
  130521. * @param axis the index of the axis
  130522. * @param axisValue the value of the axis which determines the meshes new position
  130523. * @hidden
  130524. */
  130525. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130526. /**
  130527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130528. * @param scene scene in which to add meshes
  130529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130530. */
  130531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130532. /**
  130533. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130534. * can be transformed by button presses and axes values, based on this._mapping.
  130535. *
  130536. * @param scene scene in which the meshes exist
  130537. * @param meshes list of meshes that make up the controller model to process
  130538. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130539. */
  130540. private processModel;
  130541. private createMeshInfo;
  130542. /**
  130543. * Gets the ray of the controller in the direction the controller is pointing
  130544. * @param length the length the resulting ray should be
  130545. * @returns a ray in the direction the controller is pointing
  130546. */
  130547. getForwardRay(length?: number): Ray;
  130548. /**
  130549. * Disposes of the controller
  130550. */
  130551. dispose(): void;
  130552. }
  130553. /**
  130554. * This class represents a new windows motion controller in XR.
  130555. */
  130556. export class XRWindowsMotionController extends WindowsMotionController {
  130557. /**
  130558. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130559. */
  130560. protected readonly _mapping: {
  130561. buttons: string[];
  130562. buttonMeshNames: {
  130563. trigger: string;
  130564. menu: string;
  130565. grip: string;
  130566. thumbstick: string;
  130567. trackpad: string;
  130568. };
  130569. buttonObservableNames: {
  130570. trigger: string;
  130571. menu: string;
  130572. grip: string;
  130573. thumbstick: string;
  130574. trackpad: string;
  130575. };
  130576. axisMeshNames: string[];
  130577. pointingPoseMeshName: string;
  130578. };
  130579. /**
  130580. * Construct a new XR-Based windows motion controller
  130581. *
  130582. * @param gamepadInfo the gamepad object from the browser
  130583. */
  130584. constructor(gamepadInfo: any);
  130585. /**
  130586. * holds the thumbstick values (X,Y)
  130587. */
  130588. thumbstickValues: StickValues;
  130589. /**
  130590. * Fired when the thumbstick on this controller is clicked
  130591. */
  130592. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130593. /**
  130594. * Fired when the thumbstick on this controller is modified
  130595. */
  130596. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130597. /**
  130598. * Fired when the touchpad button on this controller is modified
  130599. */
  130600. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130601. /**
  130602. * Fired when the touchpad values on this controller are modified
  130603. */
  130604. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130605. /**
  130606. * Fired when the thumbstick button on this controller is modified
  130607. * here to prevent breaking changes
  130608. */
  130609. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130610. /**
  130611. * updating the thumbstick(!) and not the trackpad.
  130612. * This is named this way due to the difference between WebVR and XR and to avoid
  130613. * changing the parent class.
  130614. */
  130615. protected _updateTrackpad(): void;
  130616. /**
  130617. * Disposes the class with joy
  130618. */
  130619. dispose(): void;
  130620. }
  130621. }
  130622. declare module BABYLON {
  130623. /**
  130624. * Class containing static functions to help procedurally build meshes
  130625. */
  130626. export class PolyhedronBuilder {
  130627. /**
  130628. * Creates a polyhedron mesh
  130629. * * 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
  130630. * * The parameter `size` (positive float, default 1) sets the polygon size
  130631. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130632. * * 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`
  130633. * * 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
  130634. * * 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)`)
  130635. * * 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
  130636. * * 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
  130637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130638. * * 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
  130639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130640. * @param name defines the name of the mesh
  130641. * @param options defines the options used to create the mesh
  130642. * @param scene defines the hosting scene
  130643. * @returns the polyhedron mesh
  130644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130645. */
  130646. static CreatePolyhedron(name: string, options: {
  130647. type?: number;
  130648. size?: number;
  130649. sizeX?: number;
  130650. sizeY?: number;
  130651. sizeZ?: number;
  130652. custom?: any;
  130653. faceUV?: Vector4[];
  130654. faceColors?: Color4[];
  130655. flat?: boolean;
  130656. updatable?: boolean;
  130657. sideOrientation?: number;
  130658. frontUVs?: Vector4;
  130659. backUVs?: Vector4;
  130660. }, scene?: Nullable<Scene>): Mesh;
  130661. }
  130662. }
  130663. declare module BABYLON {
  130664. /**
  130665. * Gizmo that enables scaling a mesh along 3 axis
  130666. */
  130667. export class ScaleGizmo extends Gizmo {
  130668. /**
  130669. * Internal gizmo used for interactions on the x axis
  130670. */
  130671. xGizmo: AxisScaleGizmo;
  130672. /**
  130673. * Internal gizmo used for interactions on the y axis
  130674. */
  130675. yGizmo: AxisScaleGizmo;
  130676. /**
  130677. * Internal gizmo used for interactions on the z axis
  130678. */
  130679. zGizmo: AxisScaleGizmo;
  130680. /**
  130681. * Internal gizmo used to scale all axis equally
  130682. */
  130683. uniformScaleGizmo: AxisScaleGizmo;
  130684. private _meshAttached;
  130685. private _updateGizmoRotationToMatchAttachedMesh;
  130686. private _snapDistance;
  130687. private _scaleRatio;
  130688. private _uniformScalingMesh;
  130689. private _octahedron;
  130690. private _sensitivity;
  130691. /** Fires an event when any of it's sub gizmos are dragged */
  130692. onDragStartObservable: Observable<unknown>;
  130693. /** Fires an event when any of it's sub gizmos are released from dragging */
  130694. onDragEndObservable: Observable<unknown>;
  130695. get attachedMesh(): Nullable<AbstractMesh>;
  130696. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130697. /**
  130698. * Creates a ScaleGizmo
  130699. * @param gizmoLayer The utility layer the gizmo will be added to
  130700. */
  130701. constructor(gizmoLayer?: UtilityLayerRenderer);
  130702. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130703. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130704. /**
  130705. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130706. */
  130707. set snapDistance(value: number);
  130708. get snapDistance(): number;
  130709. /**
  130710. * Ratio for the scale of the gizmo (Default: 1)
  130711. */
  130712. set scaleRatio(value: number);
  130713. get scaleRatio(): number;
  130714. /**
  130715. * Sensitivity factor for dragging (Default: 1)
  130716. */
  130717. set sensitivity(value: number);
  130718. get sensitivity(): number;
  130719. /**
  130720. * Disposes of the gizmo
  130721. */
  130722. dispose(): void;
  130723. }
  130724. }
  130725. declare module BABYLON {
  130726. /**
  130727. * Single axis scale gizmo
  130728. */
  130729. export class AxisScaleGizmo extends Gizmo {
  130730. /**
  130731. * Drag behavior responsible for the gizmos dragging interactions
  130732. */
  130733. dragBehavior: PointerDragBehavior;
  130734. private _pointerObserver;
  130735. /**
  130736. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130737. */
  130738. snapDistance: number;
  130739. /**
  130740. * Event that fires each time the gizmo snaps to a new location.
  130741. * * snapDistance is the the change in distance
  130742. */
  130743. onSnapObservable: Observable<{
  130744. snapDistance: number;
  130745. }>;
  130746. /**
  130747. * If the scaling operation should be done on all axis (default: false)
  130748. */
  130749. uniformScaling: boolean;
  130750. /**
  130751. * Custom sensitivity value for the drag strength
  130752. */
  130753. sensitivity: number;
  130754. private _isEnabled;
  130755. private _parent;
  130756. private _arrow;
  130757. private _coloredMaterial;
  130758. private _hoverMaterial;
  130759. /**
  130760. * Creates an AxisScaleGizmo
  130761. * @param gizmoLayer The utility layer the gizmo will be added to
  130762. * @param dragAxis The axis which the gizmo will be able to scale on
  130763. * @param color The color of the gizmo
  130764. */
  130765. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130766. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130767. /**
  130768. * If the gizmo is enabled
  130769. */
  130770. set isEnabled(value: boolean);
  130771. get isEnabled(): boolean;
  130772. /**
  130773. * Disposes of the gizmo
  130774. */
  130775. dispose(): void;
  130776. /**
  130777. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130778. * @param mesh The mesh to replace the default mesh of the gizmo
  130779. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130780. */
  130781. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130782. }
  130783. }
  130784. declare module BABYLON {
  130785. /**
  130786. * Bounding box gizmo
  130787. */
  130788. export class BoundingBoxGizmo extends Gizmo {
  130789. private _lineBoundingBox;
  130790. private _rotateSpheresParent;
  130791. private _scaleBoxesParent;
  130792. private _boundingDimensions;
  130793. private _renderObserver;
  130794. private _pointerObserver;
  130795. private _scaleDragSpeed;
  130796. private _tmpQuaternion;
  130797. private _tmpVector;
  130798. private _tmpRotationMatrix;
  130799. /**
  130800. * 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)
  130801. */
  130802. ignoreChildren: boolean;
  130803. /**
  130804. * 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)
  130805. */
  130806. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130807. /**
  130808. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130809. */
  130810. rotationSphereSize: number;
  130811. /**
  130812. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130813. */
  130814. scaleBoxSize: number;
  130815. /**
  130816. * 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)
  130817. */
  130818. fixedDragMeshScreenSize: boolean;
  130819. /**
  130820. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130821. */
  130822. fixedDragMeshScreenSizeDistanceFactor: number;
  130823. /**
  130824. * Fired when a rotation sphere or scale box is dragged
  130825. */
  130826. onDragStartObservable: Observable<{}>;
  130827. /**
  130828. * Fired when a scale box is dragged
  130829. */
  130830. onScaleBoxDragObservable: Observable<{}>;
  130831. /**
  130832. * Fired when a scale box drag is ended
  130833. */
  130834. onScaleBoxDragEndObservable: Observable<{}>;
  130835. /**
  130836. * Fired when a rotation sphere is dragged
  130837. */
  130838. onRotationSphereDragObservable: Observable<{}>;
  130839. /**
  130840. * Fired when a rotation sphere drag is ended
  130841. */
  130842. onRotationSphereDragEndObservable: Observable<{}>;
  130843. /**
  130844. * 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)
  130845. */
  130846. scalePivot: Nullable<Vector3>;
  130847. /**
  130848. * Mesh used as a pivot to rotate the attached mesh
  130849. */
  130850. private _anchorMesh;
  130851. private _existingMeshScale;
  130852. private _dragMesh;
  130853. private pointerDragBehavior;
  130854. private coloredMaterial;
  130855. private hoverColoredMaterial;
  130856. /**
  130857. * Sets the color of the bounding box gizmo
  130858. * @param color the color to set
  130859. */
  130860. setColor(color: Color3): void;
  130861. /**
  130862. * Creates an BoundingBoxGizmo
  130863. * @param gizmoLayer The utility layer the gizmo will be added to
  130864. * @param color The color of the gizmo
  130865. */
  130866. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130868. private _selectNode;
  130869. /**
  130870. * Updates the bounding box information for the Gizmo
  130871. */
  130872. updateBoundingBox(): void;
  130873. private _updateRotationSpheres;
  130874. private _updateScaleBoxes;
  130875. /**
  130876. * Enables rotation on the specified axis and disables rotation on the others
  130877. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130878. */
  130879. setEnabledRotationAxis(axis: string): void;
  130880. /**
  130881. * Enables/disables scaling
  130882. * @param enable if scaling should be enabled
  130883. * @param homogeneousScaling defines if scaling should only be homogeneous
  130884. */
  130885. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130886. private _updateDummy;
  130887. /**
  130888. * Enables a pointer drag behavior on the bounding box of the gizmo
  130889. */
  130890. enableDragBehavior(): void;
  130891. /**
  130892. * Disposes of the gizmo
  130893. */
  130894. dispose(): void;
  130895. /**
  130896. * 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)
  130897. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130898. * @returns the bounding box mesh with the passed in mesh as a child
  130899. */
  130900. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130901. /**
  130902. * CustomMeshes are not supported by this gizmo
  130903. * @param mesh The mesh to replace the default mesh of the gizmo
  130904. */
  130905. setCustomMesh(mesh: Mesh): void;
  130906. }
  130907. }
  130908. declare module BABYLON {
  130909. /**
  130910. * Single plane rotation gizmo
  130911. */
  130912. export class PlaneRotationGizmo extends Gizmo {
  130913. /**
  130914. * Drag behavior responsible for the gizmos dragging interactions
  130915. */
  130916. dragBehavior: PointerDragBehavior;
  130917. private _pointerObserver;
  130918. /**
  130919. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130920. */
  130921. snapDistance: number;
  130922. /**
  130923. * Event that fires each time the gizmo snaps to a new location.
  130924. * * snapDistance is the the change in distance
  130925. */
  130926. onSnapObservable: Observable<{
  130927. snapDistance: number;
  130928. }>;
  130929. private _isEnabled;
  130930. private _parent;
  130931. /**
  130932. * Creates a PlaneRotationGizmo
  130933. * @param gizmoLayer The utility layer the gizmo will be added to
  130934. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130935. * @param color The color of the gizmo
  130936. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130937. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130938. */
  130939. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130941. /**
  130942. * If the gizmo is enabled
  130943. */
  130944. set isEnabled(value: boolean);
  130945. get isEnabled(): boolean;
  130946. /**
  130947. * Disposes of the gizmo
  130948. */
  130949. dispose(): void;
  130950. }
  130951. }
  130952. declare module BABYLON {
  130953. /**
  130954. * Gizmo that enables rotating a mesh along 3 axis
  130955. */
  130956. export class RotationGizmo extends Gizmo {
  130957. /**
  130958. * Internal gizmo used for interactions on the x axis
  130959. */
  130960. xGizmo: PlaneRotationGizmo;
  130961. /**
  130962. * Internal gizmo used for interactions on the y axis
  130963. */
  130964. yGizmo: PlaneRotationGizmo;
  130965. /**
  130966. * Internal gizmo used for interactions on the z axis
  130967. */
  130968. zGizmo: PlaneRotationGizmo;
  130969. /** Fires an event when any of it's sub gizmos are dragged */
  130970. onDragStartObservable: Observable<unknown>;
  130971. /** Fires an event when any of it's sub gizmos are released from dragging */
  130972. onDragEndObservable: Observable<unknown>;
  130973. private _meshAttached;
  130974. get attachedMesh(): Nullable<AbstractMesh>;
  130975. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130976. /**
  130977. * Creates a RotationGizmo
  130978. * @param gizmoLayer The utility layer the gizmo will be added to
  130979. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130980. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130981. */
  130982. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130983. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130984. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130985. /**
  130986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130987. */
  130988. set snapDistance(value: number);
  130989. get snapDistance(): number;
  130990. /**
  130991. * Ratio for the scale of the gizmo (Default: 1)
  130992. */
  130993. set scaleRatio(value: number);
  130994. get scaleRatio(): number;
  130995. /**
  130996. * Disposes of the gizmo
  130997. */
  130998. dispose(): void;
  130999. /**
  131000. * CustomMeshes are not supported by this gizmo
  131001. * @param mesh The mesh to replace the default mesh of the gizmo
  131002. */
  131003. setCustomMesh(mesh: Mesh): void;
  131004. }
  131005. }
  131006. declare module BABYLON {
  131007. /**
  131008. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131009. */
  131010. export class GizmoManager implements IDisposable {
  131011. private scene;
  131012. /**
  131013. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131014. */
  131015. gizmos: {
  131016. positionGizmo: Nullable<PositionGizmo>;
  131017. rotationGizmo: Nullable<RotationGizmo>;
  131018. scaleGizmo: Nullable<ScaleGizmo>;
  131019. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131020. };
  131021. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131022. clearGizmoOnEmptyPointerEvent: boolean;
  131023. /** Fires an event when the manager is attached to a mesh */
  131024. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131025. private _gizmosEnabled;
  131026. private _pointerObserver;
  131027. private _attachedMesh;
  131028. private _boundingBoxColor;
  131029. private _defaultUtilityLayer;
  131030. private _defaultKeepDepthUtilityLayer;
  131031. /**
  131032. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131033. */
  131034. boundingBoxDragBehavior: SixDofDragBehavior;
  131035. /**
  131036. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131037. */
  131038. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131039. /**
  131040. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131041. */
  131042. usePointerToAttachGizmos: boolean;
  131043. /**
  131044. * Utility layer that the bounding box gizmo belongs to
  131045. */
  131046. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131047. /**
  131048. * Utility layer that all gizmos besides bounding box belong to
  131049. */
  131050. get utilityLayer(): UtilityLayerRenderer;
  131051. /**
  131052. * Instatiates a gizmo manager
  131053. * @param scene the scene to overlay the gizmos on top of
  131054. */
  131055. constructor(scene: Scene);
  131056. /**
  131057. * Attaches a set of gizmos to the specified mesh
  131058. * @param mesh The mesh the gizmo's should be attached to
  131059. */
  131060. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131061. /**
  131062. * If the position gizmo is enabled
  131063. */
  131064. set positionGizmoEnabled(value: boolean);
  131065. get positionGizmoEnabled(): boolean;
  131066. /**
  131067. * If the rotation gizmo is enabled
  131068. */
  131069. set rotationGizmoEnabled(value: boolean);
  131070. get rotationGizmoEnabled(): boolean;
  131071. /**
  131072. * If the scale gizmo is enabled
  131073. */
  131074. set scaleGizmoEnabled(value: boolean);
  131075. get scaleGizmoEnabled(): boolean;
  131076. /**
  131077. * If the boundingBox gizmo is enabled
  131078. */
  131079. set boundingBoxGizmoEnabled(value: boolean);
  131080. get boundingBoxGizmoEnabled(): boolean;
  131081. /**
  131082. * Disposes of the gizmo manager
  131083. */
  131084. dispose(): void;
  131085. }
  131086. }
  131087. declare module BABYLON {
  131088. /**
  131089. * A directional light is defined by a direction (what a surprise!).
  131090. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131091. * 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.
  131092. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131093. */
  131094. export class DirectionalLight extends ShadowLight {
  131095. private _shadowFrustumSize;
  131096. /**
  131097. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131098. */
  131099. get shadowFrustumSize(): number;
  131100. /**
  131101. * Specifies a fix frustum size for the shadow generation.
  131102. */
  131103. set shadowFrustumSize(value: number);
  131104. private _shadowOrthoScale;
  131105. /**
  131106. * Gets the shadow projection scale against the optimal computed one.
  131107. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131108. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131109. */
  131110. get shadowOrthoScale(): number;
  131111. /**
  131112. * Sets the shadow projection scale against the optimal computed one.
  131113. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131114. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131115. */
  131116. set shadowOrthoScale(value: number);
  131117. /**
  131118. * Automatically compute the projection matrix to best fit (including all the casters)
  131119. * on each frame.
  131120. */
  131121. autoUpdateExtends: boolean;
  131122. /**
  131123. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131124. * on each frame. autoUpdateExtends must be set to true for this to work
  131125. */
  131126. autoCalcShadowZBounds: boolean;
  131127. private _orthoLeft;
  131128. private _orthoRight;
  131129. private _orthoTop;
  131130. private _orthoBottom;
  131131. /**
  131132. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131133. * The directional light is emitted from everywhere in the given direction.
  131134. * It can cast shadows.
  131135. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131136. * @param name The friendly name of the light
  131137. * @param direction The direction of the light
  131138. * @param scene The scene the light belongs to
  131139. */
  131140. constructor(name: string, direction: Vector3, scene: Scene);
  131141. /**
  131142. * Returns the string "DirectionalLight".
  131143. * @return The class name
  131144. */
  131145. getClassName(): string;
  131146. /**
  131147. * Returns the integer 1.
  131148. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131149. */
  131150. getTypeID(): number;
  131151. /**
  131152. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131153. * Returns the DirectionalLight Shadow projection matrix.
  131154. */
  131155. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131156. /**
  131157. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131158. * Returns the DirectionalLight Shadow projection matrix.
  131159. */
  131160. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131161. /**
  131162. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131163. * Returns the DirectionalLight Shadow projection matrix.
  131164. */
  131165. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131166. protected _buildUniformLayout(): void;
  131167. /**
  131168. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131169. * @param effect The effect to update
  131170. * @param lightIndex The index of the light in the effect to update
  131171. * @returns The directional light
  131172. */
  131173. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131174. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131175. /**
  131176. * Gets the minZ used for shadow according to both the scene and the light.
  131177. *
  131178. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131179. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131180. * @param activeCamera The camera we are returning the min for
  131181. * @returns the depth min z
  131182. */
  131183. getDepthMinZ(activeCamera: Camera): number;
  131184. /**
  131185. * Gets the maxZ used for shadow according to both the scene and the light.
  131186. *
  131187. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131188. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131189. * @param activeCamera The camera we are returning the max for
  131190. * @returns the depth max z
  131191. */
  131192. getDepthMaxZ(activeCamera: Camera): number;
  131193. /**
  131194. * Prepares the list of defines specific to the light type.
  131195. * @param defines the list of defines
  131196. * @param lightIndex defines the index of the light for the effect
  131197. */
  131198. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131199. }
  131200. }
  131201. declare module BABYLON {
  131202. /**
  131203. * Class containing static functions to help procedurally build meshes
  131204. */
  131205. export class HemisphereBuilder {
  131206. /**
  131207. * Creates a hemisphere mesh
  131208. * @param name defines the name of the mesh
  131209. * @param options defines the options used to create the mesh
  131210. * @param scene defines the hosting scene
  131211. * @returns the hemisphere mesh
  131212. */
  131213. static CreateHemisphere(name: string, options: {
  131214. segments?: number;
  131215. diameter?: number;
  131216. sideOrientation?: number;
  131217. }, scene: any): Mesh;
  131218. }
  131219. }
  131220. declare module BABYLON {
  131221. /**
  131222. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131223. * These values define a cone of light starting from the position, emitting toward the direction.
  131224. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131225. * and the exponent defines the speed of the decay of the light with distance (reach).
  131226. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131227. */
  131228. export class SpotLight extends ShadowLight {
  131229. private _angle;
  131230. private _innerAngle;
  131231. private _cosHalfAngle;
  131232. private _lightAngleScale;
  131233. private _lightAngleOffset;
  131234. /**
  131235. * Gets the cone angle of the spot light in Radians.
  131236. */
  131237. get angle(): number;
  131238. /**
  131239. * Sets the cone angle of the spot light in Radians.
  131240. */
  131241. set angle(value: number);
  131242. /**
  131243. * Only used in gltf falloff mode, this defines the angle where
  131244. * the directional falloff will start before cutting at angle which could be seen
  131245. * as outer angle.
  131246. */
  131247. get innerAngle(): number;
  131248. /**
  131249. * Only used in gltf falloff mode, this defines the angle where
  131250. * the directional falloff will start before cutting at angle which could be seen
  131251. * as outer angle.
  131252. */
  131253. set innerAngle(value: number);
  131254. private _shadowAngleScale;
  131255. /**
  131256. * Allows scaling the angle of the light for shadow generation only.
  131257. */
  131258. get shadowAngleScale(): number;
  131259. /**
  131260. * Allows scaling the angle of the light for shadow generation only.
  131261. */
  131262. set shadowAngleScale(value: number);
  131263. /**
  131264. * The light decay speed with the distance from the emission spot.
  131265. */
  131266. exponent: number;
  131267. private _projectionTextureMatrix;
  131268. /**
  131269. * Allows reading the projecton texture
  131270. */
  131271. get projectionTextureMatrix(): Matrix;
  131272. protected _projectionTextureLightNear: number;
  131273. /**
  131274. * Gets the near clip of the Spotlight for texture projection.
  131275. */
  131276. get projectionTextureLightNear(): number;
  131277. /**
  131278. * Sets the near clip of the Spotlight for texture projection.
  131279. */
  131280. set projectionTextureLightNear(value: number);
  131281. protected _projectionTextureLightFar: number;
  131282. /**
  131283. * Gets the far clip of the Spotlight for texture projection.
  131284. */
  131285. get projectionTextureLightFar(): number;
  131286. /**
  131287. * Sets the far clip of the Spotlight for texture projection.
  131288. */
  131289. set projectionTextureLightFar(value: number);
  131290. protected _projectionTextureUpDirection: Vector3;
  131291. /**
  131292. * Gets the Up vector of the Spotlight for texture projection.
  131293. */
  131294. get projectionTextureUpDirection(): Vector3;
  131295. /**
  131296. * Sets the Up vector of the Spotlight for texture projection.
  131297. */
  131298. set projectionTextureUpDirection(value: Vector3);
  131299. private _projectionTexture;
  131300. /**
  131301. * Gets the projection texture of the light.
  131302. */
  131303. get projectionTexture(): Nullable<BaseTexture>;
  131304. /**
  131305. * Sets the projection texture of the light.
  131306. */
  131307. set projectionTexture(value: Nullable<BaseTexture>);
  131308. private _projectionTextureViewLightDirty;
  131309. private _projectionTextureProjectionLightDirty;
  131310. private _projectionTextureDirty;
  131311. private _projectionTextureViewTargetVector;
  131312. private _projectionTextureViewLightMatrix;
  131313. private _projectionTextureProjectionLightMatrix;
  131314. private _projectionTextureScalingMatrix;
  131315. /**
  131316. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131317. * It can cast shadows.
  131318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131319. * @param name The light friendly name
  131320. * @param position The position of the spot light in the scene
  131321. * @param direction The direction of the light in the scene
  131322. * @param angle The cone angle of the light in Radians
  131323. * @param exponent The light decay speed with the distance from the emission spot
  131324. * @param scene The scene the lights belongs to
  131325. */
  131326. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131327. /**
  131328. * Returns the string "SpotLight".
  131329. * @returns the class name
  131330. */
  131331. getClassName(): string;
  131332. /**
  131333. * Returns the integer 2.
  131334. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131335. */
  131336. getTypeID(): number;
  131337. /**
  131338. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131339. */
  131340. protected _setDirection(value: Vector3): void;
  131341. /**
  131342. * Overrides the position setter to recompute the projection texture view light Matrix.
  131343. */
  131344. protected _setPosition(value: Vector3): void;
  131345. /**
  131346. * 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.
  131347. * Returns the SpotLight.
  131348. */
  131349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131350. protected _computeProjectionTextureViewLightMatrix(): void;
  131351. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131352. /**
  131353. * Main function for light texture projection matrix computing.
  131354. */
  131355. protected _computeProjectionTextureMatrix(): void;
  131356. protected _buildUniformLayout(): void;
  131357. private _computeAngleValues;
  131358. /**
  131359. * Sets the passed Effect "effect" with the Light textures.
  131360. * @param effect The effect to update
  131361. * @param lightIndex The index of the light in the effect to update
  131362. * @returns The light
  131363. */
  131364. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131365. /**
  131366. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131367. * @param effect The effect to update
  131368. * @param lightIndex The index of the light in the effect to update
  131369. * @returns The spot light
  131370. */
  131371. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131373. /**
  131374. * Disposes the light and the associated resources.
  131375. */
  131376. dispose(): void;
  131377. /**
  131378. * Prepares the list of defines specific to the light type.
  131379. * @param defines the list of defines
  131380. * @param lightIndex defines the index of the light for the effect
  131381. */
  131382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131383. }
  131384. }
  131385. declare module BABYLON {
  131386. /**
  131387. * Gizmo that enables viewing a light
  131388. */
  131389. export class LightGizmo extends Gizmo {
  131390. private _lightMesh;
  131391. private _material;
  131392. private _cachedPosition;
  131393. private _cachedForward;
  131394. private _attachedMeshParent;
  131395. /**
  131396. * Creates a LightGizmo
  131397. * @param gizmoLayer The utility layer the gizmo will be added to
  131398. */
  131399. constructor(gizmoLayer?: UtilityLayerRenderer);
  131400. private _light;
  131401. /**
  131402. * The light that the gizmo is attached to
  131403. */
  131404. set light(light: Nullable<Light>);
  131405. get light(): Nullable<Light>;
  131406. /**
  131407. * Gets the material used to render the light gizmo
  131408. */
  131409. get material(): StandardMaterial;
  131410. /**
  131411. * @hidden
  131412. * Updates the gizmo to match the attached mesh's position/rotation
  131413. */
  131414. protected _update(): void;
  131415. private static _Scale;
  131416. /**
  131417. * Creates the lines for a light mesh
  131418. */
  131419. private static _CreateLightLines;
  131420. /**
  131421. * Disposes of the light gizmo
  131422. */
  131423. dispose(): void;
  131424. private static _CreateHemisphericLightMesh;
  131425. private static _CreatePointLightMesh;
  131426. private static _CreateSpotLightMesh;
  131427. private static _CreateDirectionalLightMesh;
  131428. }
  131429. }
  131430. declare module BABYLON {
  131431. /** @hidden */
  131432. export var backgroundFragmentDeclaration: {
  131433. name: string;
  131434. shader: string;
  131435. };
  131436. }
  131437. declare module BABYLON {
  131438. /** @hidden */
  131439. export var backgroundUboDeclaration: {
  131440. name: string;
  131441. shader: string;
  131442. };
  131443. }
  131444. declare module BABYLON {
  131445. /** @hidden */
  131446. export var backgroundPixelShader: {
  131447. name: string;
  131448. shader: string;
  131449. };
  131450. }
  131451. declare module BABYLON {
  131452. /** @hidden */
  131453. export var backgroundVertexDeclaration: {
  131454. name: string;
  131455. shader: string;
  131456. };
  131457. }
  131458. declare module BABYLON {
  131459. /** @hidden */
  131460. export var backgroundVertexShader: {
  131461. name: string;
  131462. shader: string;
  131463. };
  131464. }
  131465. declare module BABYLON {
  131466. /**
  131467. * Background material used to create an efficient environement around your scene.
  131468. */
  131469. export class BackgroundMaterial extends PushMaterial {
  131470. /**
  131471. * Standard reflectance value at parallel view angle.
  131472. */
  131473. static StandardReflectance0: number;
  131474. /**
  131475. * Standard reflectance value at grazing angle.
  131476. */
  131477. static StandardReflectance90: number;
  131478. protected _primaryColor: Color3;
  131479. /**
  131480. * Key light Color (multiply against the environement texture)
  131481. */
  131482. primaryColor: Color3;
  131483. protected __perceptualColor: Nullable<Color3>;
  131484. /**
  131485. * Experimental Internal Use Only.
  131486. *
  131487. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131488. * This acts as a helper to set the primary color to a more "human friendly" value.
  131489. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131490. * output color as close as possible from the chosen value.
  131491. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131492. * part of lighting setup.)
  131493. */
  131494. get _perceptualColor(): Nullable<Color3>;
  131495. set _perceptualColor(value: Nullable<Color3>);
  131496. protected _primaryColorShadowLevel: float;
  131497. /**
  131498. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131499. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131500. */
  131501. get primaryColorShadowLevel(): float;
  131502. set primaryColorShadowLevel(value: float);
  131503. protected _primaryColorHighlightLevel: float;
  131504. /**
  131505. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131506. * The primary color is used at the level chosen to define what the white area would look.
  131507. */
  131508. get primaryColorHighlightLevel(): float;
  131509. set primaryColorHighlightLevel(value: float);
  131510. protected _reflectionTexture: Nullable<BaseTexture>;
  131511. /**
  131512. * Reflection Texture used in the material.
  131513. * Should be author in a specific way for the best result (refer to the documentation).
  131514. */
  131515. reflectionTexture: Nullable<BaseTexture>;
  131516. protected _reflectionBlur: float;
  131517. /**
  131518. * Reflection Texture level of blur.
  131519. *
  131520. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131521. * texture twice.
  131522. */
  131523. reflectionBlur: float;
  131524. protected _diffuseTexture: Nullable<BaseTexture>;
  131525. /**
  131526. * Diffuse Texture used in the material.
  131527. * Should be author in a specific way for the best result (refer to the documentation).
  131528. */
  131529. diffuseTexture: Nullable<BaseTexture>;
  131530. protected _shadowLights: Nullable<IShadowLight[]>;
  131531. /**
  131532. * Specify the list of lights casting shadow on the material.
  131533. * All scene shadow lights will be included if null.
  131534. */
  131535. shadowLights: Nullable<IShadowLight[]>;
  131536. protected _shadowLevel: float;
  131537. /**
  131538. * Helps adjusting the shadow to a softer level if required.
  131539. * 0 means black shadows and 1 means no shadows.
  131540. */
  131541. shadowLevel: float;
  131542. protected _sceneCenter: Vector3;
  131543. /**
  131544. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131545. * It is usually zero but might be interesting to modify according to your setup.
  131546. */
  131547. sceneCenter: Vector3;
  131548. protected _opacityFresnel: boolean;
  131549. /**
  131550. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131551. * This helps ensuring a nice transition when the camera goes under the ground.
  131552. */
  131553. opacityFresnel: boolean;
  131554. protected _reflectionFresnel: boolean;
  131555. /**
  131556. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131557. * This helps adding a mirror texture on the ground.
  131558. */
  131559. reflectionFresnel: boolean;
  131560. protected _reflectionFalloffDistance: number;
  131561. /**
  131562. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131563. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131564. */
  131565. reflectionFalloffDistance: number;
  131566. protected _reflectionAmount: number;
  131567. /**
  131568. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131569. */
  131570. reflectionAmount: number;
  131571. protected _reflectionReflectance0: number;
  131572. /**
  131573. * This specifies the weight of the reflection at grazing angle.
  131574. */
  131575. reflectionReflectance0: number;
  131576. protected _reflectionReflectance90: number;
  131577. /**
  131578. * This specifies the weight of the reflection at a perpendicular point of view.
  131579. */
  131580. reflectionReflectance90: number;
  131581. /**
  131582. * Sets the reflection reflectance fresnel values according to the default standard
  131583. * empirically know to work well :-)
  131584. */
  131585. set reflectionStandardFresnelWeight(value: number);
  131586. protected _useRGBColor: boolean;
  131587. /**
  131588. * Helps to directly use the maps channels instead of their level.
  131589. */
  131590. useRGBColor: boolean;
  131591. protected _enableNoise: boolean;
  131592. /**
  131593. * This helps reducing the banding effect that could occur on the background.
  131594. */
  131595. enableNoise: boolean;
  131596. /**
  131597. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131598. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131599. * Recommended to be keep at 1.0 except for special cases.
  131600. */
  131601. get fovMultiplier(): number;
  131602. set fovMultiplier(value: number);
  131603. private _fovMultiplier;
  131604. /**
  131605. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131606. */
  131607. useEquirectangularFOV: boolean;
  131608. private _maxSimultaneousLights;
  131609. /**
  131610. * Number of Simultaneous lights allowed on the material.
  131611. */
  131612. maxSimultaneousLights: int;
  131613. private _shadowOnly;
  131614. /**
  131615. * Make the material only render shadows
  131616. */
  131617. shadowOnly: boolean;
  131618. /**
  131619. * Default configuration related to image processing available in the Background Material.
  131620. */
  131621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131622. /**
  131623. * Keep track of the image processing observer to allow dispose and replace.
  131624. */
  131625. private _imageProcessingObserver;
  131626. /**
  131627. * Attaches a new image processing configuration to the PBR Material.
  131628. * @param configuration (if null the scene configuration will be use)
  131629. */
  131630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131631. /**
  131632. * Gets the image processing configuration used either in this material.
  131633. */
  131634. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131635. /**
  131636. * Sets the Default image processing configuration used either in the this material.
  131637. *
  131638. * If sets to null, the scene one is in use.
  131639. */
  131640. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131641. /**
  131642. * Gets wether the color curves effect is enabled.
  131643. */
  131644. get cameraColorCurvesEnabled(): boolean;
  131645. /**
  131646. * Sets wether the color curves effect is enabled.
  131647. */
  131648. set cameraColorCurvesEnabled(value: boolean);
  131649. /**
  131650. * Gets wether the color grading effect is enabled.
  131651. */
  131652. get cameraColorGradingEnabled(): boolean;
  131653. /**
  131654. * Gets wether the color grading effect is enabled.
  131655. */
  131656. set cameraColorGradingEnabled(value: boolean);
  131657. /**
  131658. * Gets wether tonemapping is enabled or not.
  131659. */
  131660. get cameraToneMappingEnabled(): boolean;
  131661. /**
  131662. * Sets wether tonemapping is enabled or not
  131663. */
  131664. set cameraToneMappingEnabled(value: boolean);
  131665. /**
  131666. * The camera exposure used on this material.
  131667. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131668. * This corresponds to a photographic exposure.
  131669. */
  131670. get cameraExposure(): float;
  131671. /**
  131672. * The camera exposure used on this material.
  131673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131674. * This corresponds to a photographic exposure.
  131675. */
  131676. set cameraExposure(value: float);
  131677. /**
  131678. * Gets The camera contrast used on this material.
  131679. */
  131680. get cameraContrast(): float;
  131681. /**
  131682. * Sets The camera contrast used on this material.
  131683. */
  131684. set cameraContrast(value: float);
  131685. /**
  131686. * Gets the Color Grading 2D Lookup Texture.
  131687. */
  131688. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131689. /**
  131690. * Sets the Color Grading 2D Lookup Texture.
  131691. */
  131692. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131693. /**
  131694. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131695. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131696. * 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;
  131697. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131698. */
  131699. get cameraColorCurves(): Nullable<ColorCurves>;
  131700. /**
  131701. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131702. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131703. * 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;
  131704. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131705. */
  131706. set cameraColorCurves(value: Nullable<ColorCurves>);
  131707. /**
  131708. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131709. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131710. */
  131711. switchToBGR: boolean;
  131712. private _renderTargets;
  131713. private _reflectionControls;
  131714. private _white;
  131715. private _primaryShadowColor;
  131716. private _primaryHighlightColor;
  131717. /**
  131718. * Instantiates a Background Material in the given scene
  131719. * @param name The friendly name of the material
  131720. * @param scene The scene to add the material to
  131721. */
  131722. constructor(name: string, scene: Scene);
  131723. /**
  131724. * Gets a boolean indicating that current material needs to register RTT
  131725. */
  131726. get hasRenderTargetTextures(): boolean;
  131727. /**
  131728. * The entire material has been created in order to prevent overdraw.
  131729. * @returns false
  131730. */
  131731. needAlphaTesting(): boolean;
  131732. /**
  131733. * The entire material has been created in order to prevent overdraw.
  131734. * @returns true if blending is enable
  131735. */
  131736. needAlphaBlending(): boolean;
  131737. /**
  131738. * Checks wether the material is ready to be rendered for a given mesh.
  131739. * @param mesh The mesh to render
  131740. * @param subMesh The submesh to check against
  131741. * @param useInstances Specify wether or not the material is used with instances
  131742. * @returns true if all the dependencies are ready (Textures, Effects...)
  131743. */
  131744. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131745. /**
  131746. * Compute the primary color according to the chosen perceptual color.
  131747. */
  131748. private _computePrimaryColorFromPerceptualColor;
  131749. /**
  131750. * Compute the highlights and shadow colors according to their chosen levels.
  131751. */
  131752. private _computePrimaryColors;
  131753. /**
  131754. * Build the uniform buffer used in the material.
  131755. */
  131756. buildUniformLayout(): void;
  131757. /**
  131758. * Unbind the material.
  131759. */
  131760. unbind(): void;
  131761. /**
  131762. * Bind only the world matrix to the material.
  131763. * @param world The world matrix to bind.
  131764. */
  131765. bindOnlyWorldMatrix(world: Matrix): void;
  131766. /**
  131767. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131768. * @param world The world matrix to bind.
  131769. * @param subMesh The submesh to bind for.
  131770. */
  131771. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131772. /**
  131773. * Checks to see if a texture is used in the material.
  131774. * @param texture - Base texture to use.
  131775. * @returns - Boolean specifying if a texture is used in the material.
  131776. */
  131777. hasTexture(texture: BaseTexture): boolean;
  131778. /**
  131779. * Dispose the material.
  131780. * @param forceDisposeEffect Force disposal of the associated effect.
  131781. * @param forceDisposeTextures Force disposal of the associated textures.
  131782. */
  131783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131784. /**
  131785. * Clones the material.
  131786. * @param name The cloned name.
  131787. * @returns The cloned material.
  131788. */
  131789. clone(name: string): BackgroundMaterial;
  131790. /**
  131791. * Serializes the current material to its JSON representation.
  131792. * @returns The JSON representation.
  131793. */
  131794. serialize(): any;
  131795. /**
  131796. * Gets the class name of the material
  131797. * @returns "BackgroundMaterial"
  131798. */
  131799. getClassName(): string;
  131800. /**
  131801. * Parse a JSON input to create back a background material.
  131802. * @param source The JSON data to parse
  131803. * @param scene The scene to create the parsed material in
  131804. * @param rootUrl The root url of the assets the material depends upon
  131805. * @returns the instantiated BackgroundMaterial.
  131806. */
  131807. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131808. }
  131809. }
  131810. declare module BABYLON {
  131811. /**
  131812. * Represents the different options available during the creation of
  131813. * a Environment helper.
  131814. *
  131815. * This can control the default ground, skybox and image processing setup of your scene.
  131816. */
  131817. export interface IEnvironmentHelperOptions {
  131818. /**
  131819. * Specifies whether or not to create a ground.
  131820. * True by default.
  131821. */
  131822. createGround: boolean;
  131823. /**
  131824. * Specifies the ground size.
  131825. * 15 by default.
  131826. */
  131827. groundSize: number;
  131828. /**
  131829. * The texture used on the ground for the main color.
  131830. * Comes from the BabylonJS CDN by default.
  131831. *
  131832. * Remarks: Can be either a texture or a url.
  131833. */
  131834. groundTexture: string | BaseTexture;
  131835. /**
  131836. * The color mixed in the ground texture by default.
  131837. * BabylonJS clearColor by default.
  131838. */
  131839. groundColor: Color3;
  131840. /**
  131841. * Specifies the ground opacity.
  131842. * 1 by default.
  131843. */
  131844. groundOpacity: number;
  131845. /**
  131846. * Enables the ground to receive shadows.
  131847. * True by default.
  131848. */
  131849. enableGroundShadow: boolean;
  131850. /**
  131851. * Helps preventing the shadow to be fully black on the ground.
  131852. * 0.5 by default.
  131853. */
  131854. groundShadowLevel: number;
  131855. /**
  131856. * Creates a mirror texture attach to the ground.
  131857. * false by default.
  131858. */
  131859. enableGroundMirror: boolean;
  131860. /**
  131861. * Specifies the ground mirror size ratio.
  131862. * 0.3 by default as the default kernel is 64.
  131863. */
  131864. groundMirrorSizeRatio: number;
  131865. /**
  131866. * Specifies the ground mirror blur kernel size.
  131867. * 64 by default.
  131868. */
  131869. groundMirrorBlurKernel: number;
  131870. /**
  131871. * Specifies the ground mirror visibility amount.
  131872. * 1 by default
  131873. */
  131874. groundMirrorAmount: number;
  131875. /**
  131876. * Specifies the ground mirror reflectance weight.
  131877. * This uses the standard weight of the background material to setup the fresnel effect
  131878. * of the mirror.
  131879. * 1 by default.
  131880. */
  131881. groundMirrorFresnelWeight: number;
  131882. /**
  131883. * Specifies the ground mirror Falloff distance.
  131884. * This can helps reducing the size of the reflection.
  131885. * 0 by Default.
  131886. */
  131887. groundMirrorFallOffDistance: number;
  131888. /**
  131889. * Specifies the ground mirror texture type.
  131890. * Unsigned Int by Default.
  131891. */
  131892. groundMirrorTextureType: number;
  131893. /**
  131894. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131895. * the shown objects.
  131896. */
  131897. groundYBias: number;
  131898. /**
  131899. * Specifies whether or not to create a skybox.
  131900. * True by default.
  131901. */
  131902. createSkybox: boolean;
  131903. /**
  131904. * Specifies the skybox size.
  131905. * 20 by default.
  131906. */
  131907. skyboxSize: number;
  131908. /**
  131909. * The texture used on the skybox for the main color.
  131910. * Comes from the BabylonJS CDN by default.
  131911. *
  131912. * Remarks: Can be either a texture or a url.
  131913. */
  131914. skyboxTexture: string | BaseTexture;
  131915. /**
  131916. * The color mixed in the skybox texture by default.
  131917. * BabylonJS clearColor by default.
  131918. */
  131919. skyboxColor: Color3;
  131920. /**
  131921. * The background rotation around the Y axis of the scene.
  131922. * This helps aligning the key lights of your scene with the background.
  131923. * 0 by default.
  131924. */
  131925. backgroundYRotation: number;
  131926. /**
  131927. * Compute automatically the size of the elements to best fit with the scene.
  131928. */
  131929. sizeAuto: boolean;
  131930. /**
  131931. * Default position of the rootMesh if autoSize is not true.
  131932. */
  131933. rootPosition: Vector3;
  131934. /**
  131935. * Sets up the image processing in the scene.
  131936. * true by default.
  131937. */
  131938. setupImageProcessing: boolean;
  131939. /**
  131940. * The texture used as your environment texture in the scene.
  131941. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131942. *
  131943. * Remarks: Can be either a texture or a url.
  131944. */
  131945. environmentTexture: string | BaseTexture;
  131946. /**
  131947. * The value of the exposure to apply to the scene.
  131948. * 0.6 by default if setupImageProcessing is true.
  131949. */
  131950. cameraExposure: number;
  131951. /**
  131952. * The value of the contrast to apply to the scene.
  131953. * 1.6 by default if setupImageProcessing is true.
  131954. */
  131955. cameraContrast: number;
  131956. /**
  131957. * Specifies whether or not tonemapping should be enabled in the scene.
  131958. * true by default if setupImageProcessing is true.
  131959. */
  131960. toneMappingEnabled: boolean;
  131961. }
  131962. /**
  131963. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131964. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131965. * It also helps with the default setup of your imageProcessing configuration.
  131966. */
  131967. export class EnvironmentHelper {
  131968. /**
  131969. * Default ground texture URL.
  131970. */
  131971. private static _groundTextureCDNUrl;
  131972. /**
  131973. * Default skybox texture URL.
  131974. */
  131975. private static _skyboxTextureCDNUrl;
  131976. /**
  131977. * Default environment texture URL.
  131978. */
  131979. private static _environmentTextureCDNUrl;
  131980. /**
  131981. * Creates the default options for the helper.
  131982. */
  131983. private static _getDefaultOptions;
  131984. private _rootMesh;
  131985. /**
  131986. * Gets the root mesh created by the helper.
  131987. */
  131988. get rootMesh(): Mesh;
  131989. private _skybox;
  131990. /**
  131991. * Gets the skybox created by the helper.
  131992. */
  131993. get skybox(): Nullable<Mesh>;
  131994. private _skyboxTexture;
  131995. /**
  131996. * Gets the skybox texture created by the helper.
  131997. */
  131998. get skyboxTexture(): Nullable<BaseTexture>;
  131999. private _skyboxMaterial;
  132000. /**
  132001. * Gets the skybox material created by the helper.
  132002. */
  132003. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132004. private _ground;
  132005. /**
  132006. * Gets the ground mesh created by the helper.
  132007. */
  132008. get ground(): Nullable<Mesh>;
  132009. private _groundTexture;
  132010. /**
  132011. * Gets the ground texture created by the helper.
  132012. */
  132013. get groundTexture(): Nullable<BaseTexture>;
  132014. private _groundMirror;
  132015. /**
  132016. * Gets the ground mirror created by the helper.
  132017. */
  132018. get groundMirror(): Nullable<MirrorTexture>;
  132019. /**
  132020. * Gets the ground mirror render list to helps pushing the meshes
  132021. * you wish in the ground reflection.
  132022. */
  132023. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132024. private _groundMaterial;
  132025. /**
  132026. * Gets the ground material created by the helper.
  132027. */
  132028. get groundMaterial(): Nullable<BackgroundMaterial>;
  132029. /**
  132030. * Stores the creation options.
  132031. */
  132032. private readonly _scene;
  132033. private _options;
  132034. /**
  132035. * This observable will be notified with any error during the creation of the environment,
  132036. * mainly texture creation errors.
  132037. */
  132038. onErrorObservable: Observable<{
  132039. message?: string;
  132040. exception?: any;
  132041. }>;
  132042. /**
  132043. * constructor
  132044. * @param options Defines the options we want to customize the helper
  132045. * @param scene The scene to add the material to
  132046. */
  132047. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132048. /**
  132049. * Updates the background according to the new options
  132050. * @param options
  132051. */
  132052. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132053. /**
  132054. * Sets the primary color of all the available elements.
  132055. * @param color the main color to affect to the ground and the background
  132056. */
  132057. setMainColor(color: Color3): void;
  132058. /**
  132059. * Setup the image processing according to the specified options.
  132060. */
  132061. private _setupImageProcessing;
  132062. /**
  132063. * Setup the environment texture according to the specified options.
  132064. */
  132065. private _setupEnvironmentTexture;
  132066. /**
  132067. * Setup the background according to the specified options.
  132068. */
  132069. private _setupBackground;
  132070. /**
  132071. * Get the scene sizes according to the setup.
  132072. */
  132073. private _getSceneSize;
  132074. /**
  132075. * Setup the ground according to the specified options.
  132076. */
  132077. private _setupGround;
  132078. /**
  132079. * Setup the ground material according to the specified options.
  132080. */
  132081. private _setupGroundMaterial;
  132082. /**
  132083. * Setup the ground diffuse texture according to the specified options.
  132084. */
  132085. private _setupGroundDiffuseTexture;
  132086. /**
  132087. * Setup the ground mirror texture according to the specified options.
  132088. */
  132089. private _setupGroundMirrorTexture;
  132090. /**
  132091. * Setup the ground to receive the mirror texture.
  132092. */
  132093. private _setupMirrorInGroundMaterial;
  132094. /**
  132095. * Setup the skybox according to the specified options.
  132096. */
  132097. private _setupSkybox;
  132098. /**
  132099. * Setup the skybox material according to the specified options.
  132100. */
  132101. private _setupSkyboxMaterial;
  132102. /**
  132103. * Setup the skybox reflection texture according to the specified options.
  132104. */
  132105. private _setupSkyboxReflectionTexture;
  132106. private _errorHandler;
  132107. /**
  132108. * Dispose all the elements created by the Helper.
  132109. */
  132110. dispose(): void;
  132111. }
  132112. }
  132113. declare module BABYLON {
  132114. /**
  132115. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132116. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132117. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132118. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132119. */
  132120. export class PhotoDome extends TransformNode {
  132121. /**
  132122. * Define the image as a Monoscopic panoramic 360 image.
  132123. */
  132124. static readonly MODE_MONOSCOPIC: number;
  132125. /**
  132126. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132127. */
  132128. static readonly MODE_TOPBOTTOM: number;
  132129. /**
  132130. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132131. */
  132132. static readonly MODE_SIDEBYSIDE: number;
  132133. private _useDirectMapping;
  132134. /**
  132135. * The texture being displayed on the sphere
  132136. */
  132137. protected _photoTexture: Texture;
  132138. /**
  132139. * Gets or sets the texture being displayed on the sphere
  132140. */
  132141. get photoTexture(): Texture;
  132142. set photoTexture(value: Texture);
  132143. /**
  132144. * Observable raised when an error occured while loading the 360 image
  132145. */
  132146. onLoadErrorObservable: Observable<string>;
  132147. /**
  132148. * The skybox material
  132149. */
  132150. protected _material: BackgroundMaterial;
  132151. /**
  132152. * The surface used for the skybox
  132153. */
  132154. protected _mesh: Mesh;
  132155. /**
  132156. * Gets the mesh used for the skybox.
  132157. */
  132158. get mesh(): Mesh;
  132159. /**
  132160. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132161. * Also see the options.resolution property.
  132162. */
  132163. get fovMultiplier(): number;
  132164. set fovMultiplier(value: number);
  132165. private _imageMode;
  132166. /**
  132167. * Gets or set the current video mode for the video. It can be:
  132168. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132169. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132170. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132171. */
  132172. get imageMode(): number;
  132173. set imageMode(value: number);
  132174. /**
  132175. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132176. * @param name Element's name, child elements will append suffixes for their own names.
  132177. * @param urlsOfPhoto defines the url of the photo to display
  132178. * @param options defines an object containing optional or exposed sub element properties
  132179. * @param onError defines a callback called when an error occured while loading the texture
  132180. */
  132181. constructor(name: string, urlOfPhoto: string, options: {
  132182. resolution?: number;
  132183. size?: number;
  132184. useDirectMapping?: boolean;
  132185. faceForward?: boolean;
  132186. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132187. private _onBeforeCameraRenderObserver;
  132188. private _changeImageMode;
  132189. /**
  132190. * Releases resources associated with this node.
  132191. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132192. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132193. */
  132194. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132195. }
  132196. }
  132197. declare module BABYLON {
  132198. /**
  132199. * Class used to host RGBD texture specific utilities
  132200. */
  132201. export class RGBDTextureTools {
  132202. /**
  132203. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132204. * @param texture the texture to expand.
  132205. */
  132206. static ExpandRGBDTexture(texture: Texture): void;
  132207. }
  132208. }
  132209. declare module BABYLON {
  132210. /**
  132211. * Class used to host texture specific utilities
  132212. */
  132213. export class BRDFTextureTools {
  132214. /**
  132215. * Prevents texture cache collision
  132216. */
  132217. private static _instanceNumber;
  132218. /**
  132219. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132220. * @param scene defines the hosting scene
  132221. * @returns the environment BRDF texture
  132222. */
  132223. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132224. private static _environmentBRDFBase64Texture;
  132225. }
  132226. }
  132227. declare module BABYLON {
  132228. /**
  132229. * @hidden
  132230. */
  132231. export interface IMaterialClearCoatDefines {
  132232. CLEARCOAT: boolean;
  132233. CLEARCOAT_DEFAULTIOR: boolean;
  132234. CLEARCOAT_TEXTURE: boolean;
  132235. CLEARCOAT_TEXTUREDIRECTUV: number;
  132236. CLEARCOAT_BUMP: boolean;
  132237. CLEARCOAT_BUMPDIRECTUV: number;
  132238. CLEARCOAT_TINT: boolean;
  132239. CLEARCOAT_TINT_TEXTURE: boolean;
  132240. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132241. /** @hidden */
  132242. _areTexturesDirty: boolean;
  132243. }
  132244. /**
  132245. * Define the code related to the clear coat parameters of the pbr material.
  132246. */
  132247. export class PBRClearCoatConfiguration {
  132248. /**
  132249. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132250. * The default fits with a polyurethane material.
  132251. */
  132252. private static readonly _DefaultIndexOfRefraction;
  132253. private _isEnabled;
  132254. /**
  132255. * Defines if the clear coat is enabled in the material.
  132256. */
  132257. isEnabled: boolean;
  132258. /**
  132259. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132260. */
  132261. intensity: number;
  132262. /**
  132263. * Defines the clear coat layer roughness.
  132264. */
  132265. roughness: number;
  132266. private _indexOfRefraction;
  132267. /**
  132268. * Defines the index of refraction of the clear coat.
  132269. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132270. * The default fits with a polyurethane material.
  132271. * Changing the default value is more performance intensive.
  132272. */
  132273. indexOfRefraction: number;
  132274. private _texture;
  132275. /**
  132276. * Stores the clear coat values in a texture.
  132277. */
  132278. texture: Nullable<BaseTexture>;
  132279. private _bumpTexture;
  132280. /**
  132281. * Define the clear coat specific bump texture.
  132282. */
  132283. bumpTexture: Nullable<BaseTexture>;
  132284. private _isTintEnabled;
  132285. /**
  132286. * Defines if the clear coat tint is enabled in the material.
  132287. */
  132288. isTintEnabled: boolean;
  132289. /**
  132290. * Defines the clear coat tint of the material.
  132291. * This is only use if tint is enabled
  132292. */
  132293. tintColor: Color3;
  132294. /**
  132295. * Defines the distance at which the tint color should be found in the
  132296. * clear coat media.
  132297. * This is only use if tint is enabled
  132298. */
  132299. tintColorAtDistance: number;
  132300. /**
  132301. * Defines the clear coat layer thickness.
  132302. * This is only use if tint is enabled
  132303. */
  132304. tintThickness: number;
  132305. private _tintTexture;
  132306. /**
  132307. * Stores the clear tint values in a texture.
  132308. * rgb is tint
  132309. * a is a thickness factor
  132310. */
  132311. tintTexture: Nullable<BaseTexture>;
  132312. /** @hidden */
  132313. private _internalMarkAllSubMeshesAsTexturesDirty;
  132314. /** @hidden */
  132315. _markAllSubMeshesAsTexturesDirty(): void;
  132316. /**
  132317. * Instantiate a new istance of clear coat configuration.
  132318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132319. */
  132320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132321. /**
  132322. * Gets wehter the submesh is ready to be used or not.
  132323. * @param defines the list of "defines" to update.
  132324. * @param scene defines the scene the material belongs to.
  132325. * @param engine defines the engine the material belongs to.
  132326. * @param disableBumpMap defines wether the material disables bump or not.
  132327. * @returns - boolean indicating that the submesh is ready or not.
  132328. */
  132329. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132330. /**
  132331. * Checks to see if a texture is used in the material.
  132332. * @param defines the list of "defines" to update.
  132333. * @param scene defines the scene to the material belongs to.
  132334. */
  132335. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132336. /**
  132337. * Binds the material data.
  132338. * @param uniformBuffer defines the Uniform buffer to fill in.
  132339. * @param scene defines the scene the material belongs to.
  132340. * @param engine defines the engine the material belongs to.
  132341. * @param disableBumpMap defines wether the material disables bump or not.
  132342. * @param isFrozen defines wether the material is frozen or not.
  132343. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132344. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132345. */
  132346. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132347. /**
  132348. * Checks to see if a texture is used in the material.
  132349. * @param texture - Base texture to use.
  132350. * @returns - Boolean specifying if a texture is used in the material.
  132351. */
  132352. hasTexture(texture: BaseTexture): boolean;
  132353. /**
  132354. * Returns an array of the actively used textures.
  132355. * @param activeTextures Array of BaseTextures
  132356. */
  132357. getActiveTextures(activeTextures: BaseTexture[]): void;
  132358. /**
  132359. * Returns the animatable textures.
  132360. * @param animatables Array of animatable textures.
  132361. */
  132362. getAnimatables(animatables: IAnimatable[]): void;
  132363. /**
  132364. * Disposes the resources of the material.
  132365. * @param forceDisposeTextures - Forces the disposal of all textures.
  132366. */
  132367. dispose(forceDisposeTextures?: boolean): void;
  132368. /**
  132369. * Get the current class name of the texture useful for serialization or dynamic coding.
  132370. * @returns "PBRClearCoatConfiguration"
  132371. */
  132372. getClassName(): string;
  132373. /**
  132374. * Add fallbacks to the effect fallbacks list.
  132375. * @param defines defines the Base texture to use.
  132376. * @param fallbacks defines the current fallback list.
  132377. * @param currentRank defines the current fallback rank.
  132378. * @returns the new fallback rank.
  132379. */
  132380. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132381. /**
  132382. * Add the required uniforms to the current list.
  132383. * @param uniforms defines the current uniform list.
  132384. */
  132385. static AddUniforms(uniforms: string[]): void;
  132386. /**
  132387. * Add the required samplers to the current list.
  132388. * @param samplers defines the current sampler list.
  132389. */
  132390. static AddSamplers(samplers: string[]): void;
  132391. /**
  132392. * Add the required uniforms to the current buffer.
  132393. * @param uniformBuffer defines the current uniform buffer.
  132394. */
  132395. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132396. /**
  132397. * Makes a duplicate of the current configuration into another one.
  132398. * @param clearCoatConfiguration define the config where to copy the info
  132399. */
  132400. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132401. /**
  132402. * Serializes this clear coat configuration.
  132403. * @returns - An object with the serialized config.
  132404. */
  132405. serialize(): any;
  132406. /**
  132407. * Parses a anisotropy Configuration from a serialized object.
  132408. * @param source - Serialized object.
  132409. * @param scene Defines the scene we are parsing for
  132410. * @param rootUrl Defines the rootUrl to load from
  132411. */
  132412. parse(source: any, scene: Scene, rootUrl: string): void;
  132413. }
  132414. }
  132415. declare module BABYLON {
  132416. /**
  132417. * @hidden
  132418. */
  132419. export interface IMaterialAnisotropicDefines {
  132420. ANISOTROPIC: boolean;
  132421. ANISOTROPIC_TEXTURE: boolean;
  132422. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132423. MAINUV1: boolean;
  132424. _areTexturesDirty: boolean;
  132425. _needUVs: boolean;
  132426. }
  132427. /**
  132428. * Define the code related to the anisotropic parameters of the pbr material.
  132429. */
  132430. export class PBRAnisotropicConfiguration {
  132431. private _isEnabled;
  132432. /**
  132433. * Defines if the anisotropy is enabled in the material.
  132434. */
  132435. isEnabled: boolean;
  132436. /**
  132437. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132438. */
  132439. intensity: number;
  132440. /**
  132441. * Defines if the effect is along the tangents, bitangents or in between.
  132442. * By default, the effect is "strectching" the highlights along the tangents.
  132443. */
  132444. direction: Vector2;
  132445. private _texture;
  132446. /**
  132447. * Stores the anisotropy values in a texture.
  132448. * rg is direction (like normal from -1 to 1)
  132449. * b is a intensity
  132450. */
  132451. texture: Nullable<BaseTexture>;
  132452. /** @hidden */
  132453. private _internalMarkAllSubMeshesAsTexturesDirty;
  132454. /** @hidden */
  132455. _markAllSubMeshesAsTexturesDirty(): void;
  132456. /**
  132457. * Instantiate a new istance of anisotropy configuration.
  132458. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132459. */
  132460. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132461. /**
  132462. * Specifies that the submesh is ready to be used.
  132463. * @param defines the list of "defines" to update.
  132464. * @param scene defines the scene the material belongs to.
  132465. * @returns - boolean indicating that the submesh is ready or not.
  132466. */
  132467. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132468. /**
  132469. * Checks to see if a texture is used in the material.
  132470. * @param defines the list of "defines" to update.
  132471. * @param mesh the mesh we are preparing the defines for.
  132472. * @param scene defines the scene the material belongs to.
  132473. */
  132474. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132475. /**
  132476. * Binds the material data.
  132477. * @param uniformBuffer defines the Uniform buffer to fill in.
  132478. * @param scene defines the scene the material belongs to.
  132479. * @param isFrozen defines wether the material is frozen or not.
  132480. */
  132481. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132482. /**
  132483. * Checks to see if a texture is used in the material.
  132484. * @param texture - Base texture to use.
  132485. * @returns - Boolean specifying if a texture is used in the material.
  132486. */
  132487. hasTexture(texture: BaseTexture): boolean;
  132488. /**
  132489. * Returns an array of the actively used textures.
  132490. * @param activeTextures Array of BaseTextures
  132491. */
  132492. getActiveTextures(activeTextures: BaseTexture[]): void;
  132493. /**
  132494. * Returns the animatable textures.
  132495. * @param animatables Array of animatable textures.
  132496. */
  132497. getAnimatables(animatables: IAnimatable[]): void;
  132498. /**
  132499. * Disposes the resources of the material.
  132500. * @param forceDisposeTextures - Forces the disposal of all textures.
  132501. */
  132502. dispose(forceDisposeTextures?: boolean): void;
  132503. /**
  132504. * Get the current class name of the texture useful for serialization or dynamic coding.
  132505. * @returns "PBRAnisotropicConfiguration"
  132506. */
  132507. getClassName(): string;
  132508. /**
  132509. * Add fallbacks to the effect fallbacks list.
  132510. * @param defines defines the Base texture to use.
  132511. * @param fallbacks defines the current fallback list.
  132512. * @param currentRank defines the current fallback rank.
  132513. * @returns the new fallback rank.
  132514. */
  132515. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132516. /**
  132517. * Add the required uniforms to the current list.
  132518. * @param uniforms defines the current uniform list.
  132519. */
  132520. static AddUniforms(uniforms: string[]): void;
  132521. /**
  132522. * Add the required uniforms to the current buffer.
  132523. * @param uniformBuffer defines the current uniform buffer.
  132524. */
  132525. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132526. /**
  132527. * Add the required samplers to the current list.
  132528. * @param samplers defines the current sampler list.
  132529. */
  132530. static AddSamplers(samplers: string[]): void;
  132531. /**
  132532. * Makes a duplicate of the current configuration into another one.
  132533. * @param anisotropicConfiguration define the config where to copy the info
  132534. */
  132535. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132536. /**
  132537. * Serializes this anisotropy configuration.
  132538. * @returns - An object with the serialized config.
  132539. */
  132540. serialize(): any;
  132541. /**
  132542. * Parses a anisotropy Configuration from a serialized object.
  132543. * @param source - Serialized object.
  132544. * @param scene Defines the scene we are parsing for
  132545. * @param rootUrl Defines the rootUrl to load from
  132546. */
  132547. parse(source: any, scene: Scene, rootUrl: string): void;
  132548. }
  132549. }
  132550. declare module BABYLON {
  132551. /**
  132552. * @hidden
  132553. */
  132554. export interface IMaterialBRDFDefines {
  132555. BRDF_V_HEIGHT_CORRELATED: boolean;
  132556. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132557. SPHERICAL_HARMONICS: boolean;
  132558. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132559. /** @hidden */
  132560. _areMiscDirty: boolean;
  132561. }
  132562. /**
  132563. * Define the code related to the BRDF parameters of the pbr material.
  132564. */
  132565. export class PBRBRDFConfiguration {
  132566. /**
  132567. * Default value used for the energy conservation.
  132568. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132569. */
  132570. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132571. /**
  132572. * Default value used for the Smith Visibility Height Correlated mode.
  132573. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132574. */
  132575. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132576. /**
  132577. * Default value used for the IBL diffuse part.
  132578. * This can help switching back to the polynomials mode globally which is a tiny bit
  132579. * less GPU intensive at the drawback of a lower quality.
  132580. */
  132581. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132582. /**
  132583. * Default value used for activating energy conservation for the specular workflow.
  132584. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132585. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132586. */
  132587. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132588. private _useEnergyConservation;
  132589. /**
  132590. * Defines if the material uses energy conservation.
  132591. */
  132592. useEnergyConservation: boolean;
  132593. private _useSmithVisibilityHeightCorrelated;
  132594. /**
  132595. * LEGACY Mode set to false
  132596. * Defines if the material uses height smith correlated visibility term.
  132597. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132598. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132599. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132600. * Not relying on height correlated will also disable energy conservation.
  132601. */
  132602. useSmithVisibilityHeightCorrelated: boolean;
  132603. private _useSphericalHarmonics;
  132604. /**
  132605. * LEGACY Mode set to false
  132606. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132607. * diffuse part of the IBL.
  132608. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132609. * to the ground truth.
  132610. */
  132611. useSphericalHarmonics: boolean;
  132612. private _useSpecularGlossinessInputEnergyConservation;
  132613. /**
  132614. * Defines if the material uses energy conservation, when the specular workflow is active.
  132615. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132616. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132617. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132618. */
  132619. useSpecularGlossinessInputEnergyConservation: boolean;
  132620. /** @hidden */
  132621. private _internalMarkAllSubMeshesAsMiscDirty;
  132622. /** @hidden */
  132623. _markAllSubMeshesAsMiscDirty(): void;
  132624. /**
  132625. * Instantiate a new istance of clear coat configuration.
  132626. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132627. */
  132628. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132629. /**
  132630. * Checks to see if a texture is used in the material.
  132631. * @param defines the list of "defines" to update.
  132632. */
  132633. prepareDefines(defines: IMaterialBRDFDefines): void;
  132634. /**
  132635. * Get the current class name of the texture useful for serialization or dynamic coding.
  132636. * @returns "PBRClearCoatConfiguration"
  132637. */
  132638. getClassName(): string;
  132639. /**
  132640. * Makes a duplicate of the current configuration into another one.
  132641. * @param brdfConfiguration define the config where to copy the info
  132642. */
  132643. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132644. /**
  132645. * Serializes this BRDF configuration.
  132646. * @returns - An object with the serialized config.
  132647. */
  132648. serialize(): any;
  132649. /**
  132650. * Parses a anisotropy Configuration from a serialized object.
  132651. * @param source - Serialized object.
  132652. * @param scene Defines the scene we are parsing for
  132653. * @param rootUrl Defines the rootUrl to load from
  132654. */
  132655. parse(source: any, scene: Scene, rootUrl: string): void;
  132656. }
  132657. }
  132658. declare module BABYLON {
  132659. /**
  132660. * @hidden
  132661. */
  132662. export interface IMaterialSheenDefines {
  132663. SHEEN: boolean;
  132664. SHEEN_TEXTURE: boolean;
  132665. SHEEN_TEXTUREDIRECTUV: number;
  132666. SHEEN_LINKWITHALBEDO: boolean;
  132667. SHEEN_ROUGHNESS: boolean;
  132668. SHEEN_ALBEDOSCALING: boolean;
  132669. /** @hidden */
  132670. _areTexturesDirty: boolean;
  132671. }
  132672. /**
  132673. * Define the code related to the Sheen parameters of the pbr material.
  132674. */
  132675. export class PBRSheenConfiguration {
  132676. private _isEnabled;
  132677. /**
  132678. * Defines if the material uses sheen.
  132679. */
  132680. isEnabled: boolean;
  132681. private _linkSheenWithAlbedo;
  132682. /**
  132683. * Defines if the sheen is linked to the sheen color.
  132684. */
  132685. linkSheenWithAlbedo: boolean;
  132686. /**
  132687. * Defines the sheen intensity.
  132688. */
  132689. intensity: number;
  132690. /**
  132691. * Defines the sheen color.
  132692. */
  132693. color: Color3;
  132694. private _texture;
  132695. /**
  132696. * Stores the sheen tint values in a texture.
  132697. * rgb is tint
  132698. * a is a intensity or roughness if roughness has been defined
  132699. */
  132700. texture: Nullable<BaseTexture>;
  132701. private _roughness;
  132702. /**
  132703. * Defines the sheen roughness.
  132704. * It is not taken into account if linkSheenWithAlbedo is true.
  132705. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132706. */
  132707. roughness: Nullable<number>;
  132708. private _albedoScaling;
  132709. /**
  132710. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132711. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132712. * making it easier to setup and tweak the effect
  132713. */
  132714. albedoScaling: boolean;
  132715. /** @hidden */
  132716. private _internalMarkAllSubMeshesAsTexturesDirty;
  132717. /** @hidden */
  132718. _markAllSubMeshesAsTexturesDirty(): void;
  132719. /**
  132720. * Instantiate a new istance of clear coat configuration.
  132721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132722. */
  132723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132724. /**
  132725. * Specifies that the submesh is ready to be used.
  132726. * @param defines the list of "defines" to update.
  132727. * @param scene defines the scene the material belongs to.
  132728. * @returns - boolean indicating that the submesh is ready or not.
  132729. */
  132730. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132731. /**
  132732. * Checks to see if a texture is used in the material.
  132733. * @param defines the list of "defines" to update.
  132734. * @param scene defines the scene the material belongs to.
  132735. */
  132736. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132737. /**
  132738. * Binds the material data.
  132739. * @param uniformBuffer defines the Uniform buffer to fill in.
  132740. * @param scene defines the scene the material belongs to.
  132741. * @param isFrozen defines wether the material is frozen or not.
  132742. */
  132743. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132744. /**
  132745. * Checks to see if a texture is used in the material.
  132746. * @param texture - Base texture to use.
  132747. * @returns - Boolean specifying if a texture is used in the material.
  132748. */
  132749. hasTexture(texture: BaseTexture): boolean;
  132750. /**
  132751. * Returns an array of the actively used textures.
  132752. * @param activeTextures Array of BaseTextures
  132753. */
  132754. getActiveTextures(activeTextures: BaseTexture[]): void;
  132755. /**
  132756. * Returns the animatable textures.
  132757. * @param animatables Array of animatable textures.
  132758. */
  132759. getAnimatables(animatables: IAnimatable[]): void;
  132760. /**
  132761. * Disposes the resources of the material.
  132762. * @param forceDisposeTextures - Forces the disposal of all textures.
  132763. */
  132764. dispose(forceDisposeTextures?: boolean): void;
  132765. /**
  132766. * Get the current class name of the texture useful for serialization or dynamic coding.
  132767. * @returns "PBRSheenConfiguration"
  132768. */
  132769. getClassName(): string;
  132770. /**
  132771. * Add fallbacks to the effect fallbacks list.
  132772. * @param defines defines the Base texture to use.
  132773. * @param fallbacks defines the current fallback list.
  132774. * @param currentRank defines the current fallback rank.
  132775. * @returns the new fallback rank.
  132776. */
  132777. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132778. /**
  132779. * Add the required uniforms to the current list.
  132780. * @param uniforms defines the current uniform list.
  132781. */
  132782. static AddUniforms(uniforms: string[]): void;
  132783. /**
  132784. * Add the required uniforms to the current buffer.
  132785. * @param uniformBuffer defines the current uniform buffer.
  132786. */
  132787. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132788. /**
  132789. * Add the required samplers to the current list.
  132790. * @param samplers defines the current sampler list.
  132791. */
  132792. static AddSamplers(samplers: string[]): void;
  132793. /**
  132794. * Makes a duplicate of the current configuration into another one.
  132795. * @param sheenConfiguration define the config where to copy the info
  132796. */
  132797. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132798. /**
  132799. * Serializes this BRDF configuration.
  132800. * @returns - An object with the serialized config.
  132801. */
  132802. serialize(): any;
  132803. /**
  132804. * Parses a anisotropy Configuration from a serialized object.
  132805. * @param source - Serialized object.
  132806. * @param scene Defines the scene we are parsing for
  132807. * @param rootUrl Defines the rootUrl to load from
  132808. */
  132809. parse(source: any, scene: Scene, rootUrl: string): void;
  132810. }
  132811. }
  132812. declare module BABYLON {
  132813. /**
  132814. * @hidden
  132815. */
  132816. export interface IMaterialSubSurfaceDefines {
  132817. SUBSURFACE: boolean;
  132818. SS_REFRACTION: boolean;
  132819. SS_TRANSLUCENCY: boolean;
  132820. SS_SCATTERING: boolean;
  132821. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132822. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132823. SS_REFRACTIONMAP_3D: boolean;
  132824. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132825. SS_LODINREFRACTIONALPHA: boolean;
  132826. SS_GAMMAREFRACTION: boolean;
  132827. SS_RGBDREFRACTION: boolean;
  132828. SS_LINEARSPECULARREFRACTION: boolean;
  132829. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132830. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132831. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132832. /** @hidden */
  132833. _areTexturesDirty: boolean;
  132834. }
  132835. /**
  132836. * Define the code related to the sub surface parameters of the pbr material.
  132837. */
  132838. export class PBRSubSurfaceConfiguration {
  132839. private _isRefractionEnabled;
  132840. /**
  132841. * Defines if the refraction is enabled in the material.
  132842. */
  132843. isRefractionEnabled: boolean;
  132844. private _isTranslucencyEnabled;
  132845. /**
  132846. * Defines if the translucency is enabled in the material.
  132847. */
  132848. isTranslucencyEnabled: boolean;
  132849. private _isScatteringEnabled;
  132850. /**
  132851. * Defines if the sub surface scattering is enabled in the material.
  132852. */
  132853. isScatteringEnabled: boolean;
  132854. private _scatteringDiffusionProfileIndex;
  132855. /**
  132856. * Diffusion profile for subsurface scattering.
  132857. * Useful for better scattering in the skins or foliages.
  132858. */
  132859. get scatteringDiffusionProfile(): Nullable<Color3>;
  132860. set scatteringDiffusionProfile(c: Nullable<Color3>);
  132861. /**
  132862. * Defines the refraction intensity of the material.
  132863. * The refraction when enabled replaces the Diffuse part of the material.
  132864. * The intensity helps transitionning between diffuse and refraction.
  132865. */
  132866. refractionIntensity: number;
  132867. /**
  132868. * Defines the translucency intensity of the material.
  132869. * When translucency has been enabled, this defines how much of the "translucency"
  132870. * is addded to the diffuse part of the material.
  132871. */
  132872. translucencyIntensity: number;
  132873. /**
  132874. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132875. */
  132876. useAlbedoToTintRefraction: boolean;
  132877. private _thicknessTexture;
  132878. /**
  132879. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132880. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132881. * 0 would mean minimumThickness
  132882. * 1 would mean maximumThickness
  132883. * The other channels might be use as a mask to vary the different effects intensity.
  132884. */
  132885. thicknessTexture: Nullable<BaseTexture>;
  132886. private _refractionTexture;
  132887. /**
  132888. * Defines the texture to use for refraction.
  132889. */
  132890. refractionTexture: Nullable<BaseTexture>;
  132891. private _indexOfRefraction;
  132892. /**
  132893. * Index of refraction of the material base layer.
  132894. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132895. *
  132896. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132897. *
  132898. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132899. */
  132900. indexOfRefraction: number;
  132901. private _volumeIndexOfRefraction;
  132902. /**
  132903. * Index of refraction of the material's volume.
  132904. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132905. *
  132906. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132907. * the volume will use the same IOR as the surface.
  132908. */
  132909. get volumeIndexOfRefraction(): number;
  132910. set volumeIndexOfRefraction(value: number);
  132911. private _invertRefractionY;
  132912. /**
  132913. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132914. */
  132915. invertRefractionY: boolean;
  132916. private _linkRefractionWithTransparency;
  132917. /**
  132918. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132919. * Materials half opaque for instance using refraction could benefit from this control.
  132920. */
  132921. linkRefractionWithTransparency: boolean;
  132922. /**
  132923. * Defines the minimum thickness stored in the thickness map.
  132924. * If no thickness map is defined, this value will be used to simulate thickness.
  132925. */
  132926. minimumThickness: number;
  132927. /**
  132928. * Defines the maximum thickness stored in the thickness map.
  132929. */
  132930. maximumThickness: number;
  132931. /**
  132932. * Defines the volume tint of the material.
  132933. * This is used for both translucency and scattering.
  132934. */
  132935. tintColor: Color3;
  132936. /**
  132937. * Defines the distance at which the tint color should be found in the media.
  132938. * This is used for refraction only.
  132939. */
  132940. tintColorAtDistance: number;
  132941. /**
  132942. * Defines how far each channel transmit through the media.
  132943. * It is defined as a color to simplify it selection.
  132944. */
  132945. diffusionDistance: Color3;
  132946. private _useMaskFromThicknessTexture;
  132947. /**
  132948. * Stores the intensity of the different subsurface effects in the thickness texture.
  132949. * * the green channel is the translucency intensity.
  132950. * * the blue channel is the scattering intensity.
  132951. * * the alpha channel is the refraction intensity.
  132952. */
  132953. useMaskFromThicknessTexture: boolean;
  132954. private _scene;
  132955. /** @hidden */
  132956. private _internalMarkAllSubMeshesAsTexturesDirty;
  132957. private _internalMarkScenePrePassDirty;
  132958. /** @hidden */
  132959. _markAllSubMeshesAsTexturesDirty(): void;
  132960. /** @hidden */
  132961. _markScenePrePassDirty(): void;
  132962. /**
  132963. * Instantiate a new istance of sub surface configuration.
  132964. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132965. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  132966. * @param scene The scene
  132967. */
  132968. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  132969. /**
  132970. * Gets wehter the submesh is ready to be used or not.
  132971. * @param defines the list of "defines" to update.
  132972. * @param scene defines the scene the material belongs to.
  132973. * @returns - boolean indicating that the submesh is ready or not.
  132974. */
  132975. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132976. /**
  132977. * Checks to see if a texture is used in the material.
  132978. * @param defines the list of "defines" to update.
  132979. * @param scene defines the scene to the material belongs to.
  132980. */
  132981. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132982. /**
  132983. * Binds the material data.
  132984. * @param uniformBuffer defines the Uniform buffer to fill in.
  132985. * @param scene defines the scene the material belongs to.
  132986. * @param engine defines the engine the material belongs to.
  132987. * @param isFrozen defines whether the material is frozen or not.
  132988. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132989. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132990. */
  132991. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132992. /**
  132993. * Unbinds the material from the mesh.
  132994. * @param activeEffect defines the effect that should be unbound from.
  132995. * @returns true if unbound, otherwise false
  132996. */
  132997. unbind(activeEffect: Effect): boolean;
  132998. /**
  132999. * Returns the texture used for refraction or null if none is used.
  133000. * @param scene defines the scene the material belongs to.
  133001. * @returns - Refraction texture if present. If no refraction texture and refraction
  133002. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133003. */
  133004. private _getRefractionTexture;
  133005. /**
  133006. * Returns true if alpha blending should be disabled.
  133007. */
  133008. get disableAlphaBlending(): boolean;
  133009. /**
  133010. * Fills the list of render target textures.
  133011. * @param renderTargets the list of render targets to update
  133012. */
  133013. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133014. /**
  133015. * Checks to see if a texture is used in the material.
  133016. * @param texture - Base texture to use.
  133017. * @returns - Boolean specifying if a texture is used in the material.
  133018. */
  133019. hasTexture(texture: BaseTexture): boolean;
  133020. /**
  133021. * Gets a boolean indicating that current material needs to register RTT
  133022. * @returns true if this uses a render target otherwise false.
  133023. */
  133024. hasRenderTargetTextures(): boolean;
  133025. /**
  133026. * Returns an array of the actively used textures.
  133027. * @param activeTextures Array of BaseTextures
  133028. */
  133029. getActiveTextures(activeTextures: BaseTexture[]): void;
  133030. /**
  133031. * Returns the animatable textures.
  133032. * @param animatables Array of animatable textures.
  133033. */
  133034. getAnimatables(animatables: IAnimatable[]): void;
  133035. /**
  133036. * Disposes the resources of the material.
  133037. * @param forceDisposeTextures - Forces the disposal of all textures.
  133038. */
  133039. dispose(forceDisposeTextures?: boolean): void;
  133040. /**
  133041. * Get the current class name of the texture useful for serialization or dynamic coding.
  133042. * @returns "PBRSubSurfaceConfiguration"
  133043. */
  133044. getClassName(): string;
  133045. /**
  133046. * Add fallbacks to the effect fallbacks list.
  133047. * @param defines defines the Base texture to use.
  133048. * @param fallbacks defines the current fallback list.
  133049. * @param currentRank defines the current fallback rank.
  133050. * @returns the new fallback rank.
  133051. */
  133052. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133053. /**
  133054. * Add the required uniforms to the current list.
  133055. * @param uniforms defines the current uniform list.
  133056. */
  133057. static AddUniforms(uniforms: string[]): void;
  133058. /**
  133059. * Add the required samplers to the current list.
  133060. * @param samplers defines the current sampler list.
  133061. */
  133062. static AddSamplers(samplers: string[]): void;
  133063. /**
  133064. * Add the required uniforms to the current buffer.
  133065. * @param uniformBuffer defines the current uniform buffer.
  133066. */
  133067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133068. /**
  133069. * Makes a duplicate of the current configuration into another one.
  133070. * @param configuration define the config where to copy the info
  133071. */
  133072. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133073. /**
  133074. * Serializes this Sub Surface configuration.
  133075. * @returns - An object with the serialized config.
  133076. */
  133077. serialize(): any;
  133078. /**
  133079. * Parses a anisotropy Configuration from a serialized object.
  133080. * @param source - Serialized object.
  133081. * @param scene Defines the scene we are parsing for
  133082. * @param rootUrl Defines the rootUrl to load from
  133083. */
  133084. parse(source: any, scene: Scene, rootUrl: string): void;
  133085. }
  133086. }
  133087. declare module BABYLON {
  133088. /** @hidden */
  133089. export var prePassDeclaration: {
  133090. name: string;
  133091. shader: string;
  133092. };
  133093. }
  133094. declare module BABYLON {
  133095. /** @hidden */
  133096. export var pbrFragmentDeclaration: {
  133097. name: string;
  133098. shader: string;
  133099. };
  133100. }
  133101. declare module BABYLON {
  133102. /** @hidden */
  133103. export var pbrUboDeclaration: {
  133104. name: string;
  133105. shader: string;
  133106. };
  133107. }
  133108. declare module BABYLON {
  133109. /** @hidden */
  133110. export var pbrFragmentExtraDeclaration: {
  133111. name: string;
  133112. shader: string;
  133113. };
  133114. }
  133115. declare module BABYLON {
  133116. /** @hidden */
  133117. export var pbrFragmentSamplersDeclaration: {
  133118. name: string;
  133119. shader: string;
  133120. };
  133121. }
  133122. declare module BABYLON {
  133123. /** @hidden */
  133124. export var subSurfaceScatteringFunctions: {
  133125. name: string;
  133126. shader: string;
  133127. };
  133128. }
  133129. declare module BABYLON {
  133130. /** @hidden */
  133131. export var importanceSampling: {
  133132. name: string;
  133133. shader: string;
  133134. };
  133135. }
  133136. declare module BABYLON {
  133137. /** @hidden */
  133138. export var pbrHelperFunctions: {
  133139. name: string;
  133140. shader: string;
  133141. };
  133142. }
  133143. declare module BABYLON {
  133144. /** @hidden */
  133145. export var harmonicsFunctions: {
  133146. name: string;
  133147. shader: string;
  133148. };
  133149. }
  133150. declare module BABYLON {
  133151. /** @hidden */
  133152. export var pbrDirectLightingSetupFunctions: {
  133153. name: string;
  133154. shader: string;
  133155. };
  133156. }
  133157. declare module BABYLON {
  133158. /** @hidden */
  133159. export var pbrDirectLightingFalloffFunctions: {
  133160. name: string;
  133161. shader: string;
  133162. };
  133163. }
  133164. declare module BABYLON {
  133165. /** @hidden */
  133166. export var pbrBRDFFunctions: {
  133167. name: string;
  133168. shader: string;
  133169. };
  133170. }
  133171. declare module BABYLON {
  133172. /** @hidden */
  133173. export var hdrFilteringFunctions: {
  133174. name: string;
  133175. shader: string;
  133176. };
  133177. }
  133178. declare module BABYLON {
  133179. /** @hidden */
  133180. export var pbrDirectLightingFunctions: {
  133181. name: string;
  133182. shader: string;
  133183. };
  133184. }
  133185. declare module BABYLON {
  133186. /** @hidden */
  133187. export var pbrIBLFunctions: {
  133188. name: string;
  133189. shader: string;
  133190. };
  133191. }
  133192. declare module BABYLON {
  133193. /** @hidden */
  133194. export var pbrBlockAlbedoOpacity: {
  133195. name: string;
  133196. shader: string;
  133197. };
  133198. }
  133199. declare module BABYLON {
  133200. /** @hidden */
  133201. export var pbrBlockReflectivity: {
  133202. name: string;
  133203. shader: string;
  133204. };
  133205. }
  133206. declare module BABYLON {
  133207. /** @hidden */
  133208. export var pbrBlockAmbientOcclusion: {
  133209. name: string;
  133210. shader: string;
  133211. };
  133212. }
  133213. declare module BABYLON {
  133214. /** @hidden */
  133215. export var pbrBlockAlphaFresnel: {
  133216. name: string;
  133217. shader: string;
  133218. };
  133219. }
  133220. declare module BABYLON {
  133221. /** @hidden */
  133222. export var pbrBlockAnisotropic: {
  133223. name: string;
  133224. shader: string;
  133225. };
  133226. }
  133227. declare module BABYLON {
  133228. /** @hidden */
  133229. export var pbrBlockReflection: {
  133230. name: string;
  133231. shader: string;
  133232. };
  133233. }
  133234. declare module BABYLON {
  133235. /** @hidden */
  133236. export var pbrBlockSheen: {
  133237. name: string;
  133238. shader: string;
  133239. };
  133240. }
  133241. declare module BABYLON {
  133242. /** @hidden */
  133243. export var pbrBlockClearcoat: {
  133244. name: string;
  133245. shader: string;
  133246. };
  133247. }
  133248. declare module BABYLON {
  133249. /** @hidden */
  133250. export var pbrBlockSubSurface: {
  133251. name: string;
  133252. shader: string;
  133253. };
  133254. }
  133255. declare module BABYLON {
  133256. /** @hidden */
  133257. export var pbrBlockNormalGeometric: {
  133258. name: string;
  133259. shader: string;
  133260. };
  133261. }
  133262. declare module BABYLON {
  133263. /** @hidden */
  133264. export var pbrBlockNormalFinal: {
  133265. name: string;
  133266. shader: string;
  133267. };
  133268. }
  133269. declare module BABYLON {
  133270. /** @hidden */
  133271. export var pbrBlockGeometryInfo: {
  133272. name: string;
  133273. shader: string;
  133274. };
  133275. }
  133276. declare module BABYLON {
  133277. /** @hidden */
  133278. export var pbrBlockReflectance0: {
  133279. name: string;
  133280. shader: string;
  133281. };
  133282. }
  133283. declare module BABYLON {
  133284. /** @hidden */
  133285. export var pbrBlockReflectance: {
  133286. name: string;
  133287. shader: string;
  133288. };
  133289. }
  133290. declare module BABYLON {
  133291. /** @hidden */
  133292. export var pbrBlockDirectLighting: {
  133293. name: string;
  133294. shader: string;
  133295. };
  133296. }
  133297. declare module BABYLON {
  133298. /** @hidden */
  133299. export var pbrBlockFinalLitComponents: {
  133300. name: string;
  133301. shader: string;
  133302. };
  133303. }
  133304. declare module BABYLON {
  133305. /** @hidden */
  133306. export var pbrBlockFinalUnlitComponents: {
  133307. name: string;
  133308. shader: string;
  133309. };
  133310. }
  133311. declare module BABYLON {
  133312. /** @hidden */
  133313. export var pbrBlockFinalColorComposition: {
  133314. name: string;
  133315. shader: string;
  133316. };
  133317. }
  133318. declare module BABYLON {
  133319. /** @hidden */
  133320. export var pbrBlockImageProcessing: {
  133321. name: string;
  133322. shader: string;
  133323. };
  133324. }
  133325. declare module BABYLON {
  133326. /** @hidden */
  133327. export var pbrDebug: {
  133328. name: string;
  133329. shader: string;
  133330. };
  133331. }
  133332. declare module BABYLON {
  133333. /** @hidden */
  133334. export var pbrPixelShader: {
  133335. name: string;
  133336. shader: string;
  133337. };
  133338. }
  133339. declare module BABYLON {
  133340. /** @hidden */
  133341. export var pbrVertexDeclaration: {
  133342. name: string;
  133343. shader: string;
  133344. };
  133345. }
  133346. declare module BABYLON {
  133347. /** @hidden */
  133348. export var pbrVertexShader: {
  133349. name: string;
  133350. shader: string;
  133351. };
  133352. }
  133353. declare module BABYLON {
  133354. /**
  133355. * Manages the defines for the PBR Material.
  133356. * @hidden
  133357. */
  133358. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133359. PBR: boolean;
  133360. NUM_SAMPLES: string;
  133361. REALTIME_FILTERING: boolean;
  133362. MAINUV1: boolean;
  133363. MAINUV2: boolean;
  133364. UV1: boolean;
  133365. UV2: boolean;
  133366. ALBEDO: boolean;
  133367. GAMMAALBEDO: boolean;
  133368. ALBEDODIRECTUV: number;
  133369. VERTEXCOLOR: boolean;
  133370. DETAIL: boolean;
  133371. DETAILDIRECTUV: number;
  133372. DETAIL_NORMALBLENDMETHOD: number;
  133373. AMBIENT: boolean;
  133374. AMBIENTDIRECTUV: number;
  133375. AMBIENTINGRAYSCALE: boolean;
  133376. OPACITY: boolean;
  133377. VERTEXALPHA: boolean;
  133378. OPACITYDIRECTUV: number;
  133379. OPACITYRGB: boolean;
  133380. ALPHATEST: boolean;
  133381. DEPTHPREPASS: boolean;
  133382. ALPHABLEND: boolean;
  133383. ALPHAFROMALBEDO: boolean;
  133384. ALPHATESTVALUE: string;
  133385. SPECULAROVERALPHA: boolean;
  133386. RADIANCEOVERALPHA: boolean;
  133387. ALPHAFRESNEL: boolean;
  133388. LINEARALPHAFRESNEL: boolean;
  133389. PREMULTIPLYALPHA: boolean;
  133390. EMISSIVE: boolean;
  133391. EMISSIVEDIRECTUV: number;
  133392. REFLECTIVITY: boolean;
  133393. REFLECTIVITYDIRECTUV: number;
  133394. SPECULARTERM: boolean;
  133395. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133396. MICROSURFACEAUTOMATIC: boolean;
  133397. LODBASEDMICROSFURACE: boolean;
  133398. MICROSURFACEMAP: boolean;
  133399. MICROSURFACEMAPDIRECTUV: number;
  133400. METALLICWORKFLOW: boolean;
  133401. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133402. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133403. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133404. AOSTOREINMETALMAPRED: boolean;
  133405. METALLIC_REFLECTANCE: boolean;
  133406. METALLIC_REFLECTANCEDIRECTUV: number;
  133407. ENVIRONMENTBRDF: boolean;
  133408. ENVIRONMENTBRDF_RGBD: boolean;
  133409. NORMAL: boolean;
  133410. TANGENT: boolean;
  133411. BUMP: boolean;
  133412. BUMPDIRECTUV: number;
  133413. OBJECTSPACE_NORMALMAP: boolean;
  133414. PARALLAX: boolean;
  133415. PARALLAXOCCLUSION: boolean;
  133416. NORMALXYSCALE: boolean;
  133417. LIGHTMAP: boolean;
  133418. LIGHTMAPDIRECTUV: number;
  133419. USELIGHTMAPASSHADOWMAP: boolean;
  133420. GAMMALIGHTMAP: boolean;
  133421. RGBDLIGHTMAP: boolean;
  133422. REFLECTION: boolean;
  133423. REFLECTIONMAP_3D: boolean;
  133424. REFLECTIONMAP_SPHERICAL: boolean;
  133425. REFLECTIONMAP_PLANAR: boolean;
  133426. REFLECTIONMAP_CUBIC: boolean;
  133427. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133428. REFLECTIONMAP_PROJECTION: boolean;
  133429. REFLECTIONMAP_SKYBOX: boolean;
  133430. REFLECTIONMAP_EXPLICIT: boolean;
  133431. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133432. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133433. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133434. INVERTCUBICMAP: boolean;
  133435. USESPHERICALFROMREFLECTIONMAP: boolean;
  133436. USEIRRADIANCEMAP: boolean;
  133437. SPHERICAL_HARMONICS: boolean;
  133438. USESPHERICALINVERTEX: boolean;
  133439. REFLECTIONMAP_OPPOSITEZ: boolean;
  133440. LODINREFLECTIONALPHA: boolean;
  133441. GAMMAREFLECTION: boolean;
  133442. RGBDREFLECTION: boolean;
  133443. LINEARSPECULARREFLECTION: boolean;
  133444. RADIANCEOCCLUSION: boolean;
  133445. HORIZONOCCLUSION: boolean;
  133446. INSTANCES: boolean;
  133447. THIN_INSTANCES: boolean;
  133448. PREPASS: boolean;
  133449. SCENE_MRT_COUNT: number;
  133450. NUM_BONE_INFLUENCERS: number;
  133451. BonesPerMesh: number;
  133452. BONETEXTURE: boolean;
  133453. NONUNIFORMSCALING: boolean;
  133454. MORPHTARGETS: boolean;
  133455. MORPHTARGETS_NORMAL: boolean;
  133456. MORPHTARGETS_TANGENT: boolean;
  133457. MORPHTARGETS_UV: boolean;
  133458. NUM_MORPH_INFLUENCERS: number;
  133459. IMAGEPROCESSING: boolean;
  133460. VIGNETTE: boolean;
  133461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133462. VIGNETTEBLENDMODEOPAQUE: boolean;
  133463. TONEMAPPING: boolean;
  133464. TONEMAPPING_ACES: boolean;
  133465. CONTRAST: boolean;
  133466. COLORCURVES: boolean;
  133467. COLORGRADING: boolean;
  133468. COLORGRADING3D: boolean;
  133469. SAMPLER3DGREENDEPTH: boolean;
  133470. SAMPLER3DBGRMAP: boolean;
  133471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133472. EXPOSURE: boolean;
  133473. MULTIVIEW: boolean;
  133474. USEPHYSICALLIGHTFALLOFF: boolean;
  133475. USEGLTFLIGHTFALLOFF: boolean;
  133476. TWOSIDEDLIGHTING: boolean;
  133477. SHADOWFLOAT: boolean;
  133478. CLIPPLANE: boolean;
  133479. CLIPPLANE2: boolean;
  133480. CLIPPLANE3: boolean;
  133481. CLIPPLANE4: boolean;
  133482. CLIPPLANE5: boolean;
  133483. CLIPPLANE6: boolean;
  133484. POINTSIZE: boolean;
  133485. FOG: boolean;
  133486. LOGARITHMICDEPTH: boolean;
  133487. FORCENORMALFORWARD: boolean;
  133488. SPECULARAA: boolean;
  133489. CLEARCOAT: boolean;
  133490. CLEARCOAT_DEFAULTIOR: boolean;
  133491. CLEARCOAT_TEXTURE: boolean;
  133492. CLEARCOAT_TEXTUREDIRECTUV: number;
  133493. CLEARCOAT_BUMP: boolean;
  133494. CLEARCOAT_BUMPDIRECTUV: number;
  133495. CLEARCOAT_TINT: boolean;
  133496. CLEARCOAT_TINT_TEXTURE: boolean;
  133497. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133498. ANISOTROPIC: boolean;
  133499. ANISOTROPIC_TEXTURE: boolean;
  133500. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133501. BRDF_V_HEIGHT_CORRELATED: boolean;
  133502. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133503. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133504. SHEEN: boolean;
  133505. SHEEN_TEXTURE: boolean;
  133506. SHEEN_TEXTUREDIRECTUV: number;
  133507. SHEEN_LINKWITHALBEDO: boolean;
  133508. SHEEN_ROUGHNESS: boolean;
  133509. SHEEN_ALBEDOSCALING: boolean;
  133510. SUBSURFACE: boolean;
  133511. SS_REFRACTION: boolean;
  133512. SS_TRANSLUCENCY: boolean;
  133513. SS_SCATTERING: boolean;
  133514. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133515. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133516. SS_REFRACTIONMAP_3D: boolean;
  133517. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133518. SS_LODINREFRACTIONALPHA: boolean;
  133519. SS_GAMMAREFRACTION: boolean;
  133520. SS_RGBDREFRACTION: boolean;
  133521. SS_LINEARSPECULARREFRACTION: boolean;
  133522. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133523. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133524. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133525. UNLIT: boolean;
  133526. DEBUGMODE: number;
  133527. /**
  133528. * Initializes the PBR Material defines.
  133529. */
  133530. constructor();
  133531. /**
  133532. * Resets the PBR Material defines.
  133533. */
  133534. reset(): void;
  133535. }
  133536. /**
  133537. * The Physically based material base class of BJS.
  133538. *
  133539. * This offers the main features of a standard PBR material.
  133540. * For more information, please refer to the documentation :
  133541. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133542. */
  133543. export abstract class PBRBaseMaterial extends PushMaterial {
  133544. /**
  133545. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133546. */
  133547. static readonly PBRMATERIAL_OPAQUE: number;
  133548. /**
  133549. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133550. */
  133551. static readonly PBRMATERIAL_ALPHATEST: number;
  133552. /**
  133553. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133554. */
  133555. static readonly PBRMATERIAL_ALPHABLEND: number;
  133556. /**
  133557. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133558. * They are also discarded below the alpha cutoff threshold to improve performances.
  133559. */
  133560. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133561. /**
  133562. * Defines the default value of how much AO map is occluding the analytical lights
  133563. * (point spot...).
  133564. */
  133565. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133566. /**
  133567. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133568. */
  133569. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133570. /**
  133571. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133572. * to enhance interoperability with other engines.
  133573. */
  133574. static readonly LIGHTFALLOFF_GLTF: number;
  133575. /**
  133576. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133577. * to enhance interoperability with other materials.
  133578. */
  133579. static readonly LIGHTFALLOFF_STANDARD: number;
  133580. /**
  133581. * Intensity of the direct lights e.g. the four lights available in your scene.
  133582. * This impacts both the direct diffuse and specular highlights.
  133583. */
  133584. protected _directIntensity: number;
  133585. /**
  133586. * Intensity of the emissive part of the material.
  133587. * This helps controlling the emissive effect without modifying the emissive color.
  133588. */
  133589. protected _emissiveIntensity: number;
  133590. /**
  133591. * Intensity of the environment e.g. how much the environment will light the object
  133592. * either through harmonics for rough material or through the refelction for shiny ones.
  133593. */
  133594. protected _environmentIntensity: number;
  133595. /**
  133596. * This is a special control allowing the reduction of the specular highlights coming from the
  133597. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133598. */
  133599. protected _specularIntensity: number;
  133600. /**
  133601. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133602. */
  133603. private _lightingInfos;
  133604. /**
  133605. * Debug Control allowing disabling the bump map on this material.
  133606. */
  133607. protected _disableBumpMap: boolean;
  133608. /**
  133609. * AKA Diffuse Texture in standard nomenclature.
  133610. */
  133611. protected _albedoTexture: Nullable<BaseTexture>;
  133612. /**
  133613. * AKA Occlusion Texture in other nomenclature.
  133614. */
  133615. protected _ambientTexture: Nullable<BaseTexture>;
  133616. /**
  133617. * AKA Occlusion Texture Intensity in other nomenclature.
  133618. */
  133619. protected _ambientTextureStrength: number;
  133620. /**
  133621. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133622. * 1 means it completely occludes it
  133623. * 0 mean it has no impact
  133624. */
  133625. protected _ambientTextureImpactOnAnalyticalLights: number;
  133626. /**
  133627. * Stores the alpha values in a texture.
  133628. */
  133629. protected _opacityTexture: Nullable<BaseTexture>;
  133630. /**
  133631. * Stores the reflection values in a texture.
  133632. */
  133633. protected _reflectionTexture: Nullable<BaseTexture>;
  133634. /**
  133635. * Stores the emissive values in a texture.
  133636. */
  133637. protected _emissiveTexture: Nullable<BaseTexture>;
  133638. /**
  133639. * AKA Specular texture in other nomenclature.
  133640. */
  133641. protected _reflectivityTexture: Nullable<BaseTexture>;
  133642. /**
  133643. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133644. */
  133645. protected _metallicTexture: Nullable<BaseTexture>;
  133646. /**
  133647. * Specifies the metallic scalar of the metallic/roughness workflow.
  133648. * Can also be used to scale the metalness values of the metallic texture.
  133649. */
  133650. protected _metallic: Nullable<number>;
  133651. /**
  133652. * Specifies the roughness scalar of the metallic/roughness workflow.
  133653. * Can also be used to scale the roughness values of the metallic texture.
  133654. */
  133655. protected _roughness: Nullable<number>;
  133656. /**
  133657. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133658. * By default the indexOfrefraction is used to compute F0;
  133659. *
  133660. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133661. *
  133662. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133663. * F90 = metallicReflectanceColor;
  133664. */
  133665. protected _metallicF0Factor: number;
  133666. /**
  133667. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133668. * By default the F90 is always 1;
  133669. *
  133670. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133671. *
  133672. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133673. * F90 = metallicReflectanceColor;
  133674. */
  133675. protected _metallicReflectanceColor: Color3;
  133676. /**
  133677. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133678. * This is multiply against the scalar values defined in the material.
  133679. */
  133680. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133681. /**
  133682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133684. */
  133685. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133686. /**
  133687. * Stores surface normal data used to displace a mesh in a texture.
  133688. */
  133689. protected _bumpTexture: Nullable<BaseTexture>;
  133690. /**
  133691. * Stores the pre-calculated light information of a mesh in a texture.
  133692. */
  133693. protected _lightmapTexture: Nullable<BaseTexture>;
  133694. /**
  133695. * The color of a material in ambient lighting.
  133696. */
  133697. protected _ambientColor: Color3;
  133698. /**
  133699. * AKA Diffuse Color in other nomenclature.
  133700. */
  133701. protected _albedoColor: Color3;
  133702. /**
  133703. * AKA Specular Color in other nomenclature.
  133704. */
  133705. protected _reflectivityColor: Color3;
  133706. /**
  133707. * The color applied when light is reflected from a material.
  133708. */
  133709. protected _reflectionColor: Color3;
  133710. /**
  133711. * The color applied when light is emitted from a material.
  133712. */
  133713. protected _emissiveColor: Color3;
  133714. /**
  133715. * AKA Glossiness in other nomenclature.
  133716. */
  133717. protected _microSurface: number;
  133718. /**
  133719. * Specifies that the material will use the light map as a show map.
  133720. */
  133721. protected _useLightmapAsShadowmap: boolean;
  133722. /**
  133723. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133724. * makes the reflect vector face the model (under horizon).
  133725. */
  133726. protected _useHorizonOcclusion: boolean;
  133727. /**
  133728. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133729. * too much the area relying on ambient texture to define their ambient occlusion.
  133730. */
  133731. protected _useRadianceOcclusion: boolean;
  133732. /**
  133733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133734. */
  133735. protected _useAlphaFromAlbedoTexture: boolean;
  133736. /**
  133737. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133738. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133739. */
  133740. protected _useSpecularOverAlpha: boolean;
  133741. /**
  133742. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133743. */
  133744. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133745. /**
  133746. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133747. */
  133748. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133749. /**
  133750. * Specifies if the metallic texture contains the roughness information in its green channel.
  133751. */
  133752. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133753. /**
  133754. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133755. */
  133756. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133757. /**
  133758. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133759. */
  133760. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133761. /**
  133762. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133763. */
  133764. protected _useAmbientInGrayScale: boolean;
  133765. /**
  133766. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133767. * The material will try to infer what glossiness each pixel should be.
  133768. */
  133769. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133770. /**
  133771. * Defines the falloff type used in this material.
  133772. * It by default is Physical.
  133773. */
  133774. protected _lightFalloff: number;
  133775. /**
  133776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133778. */
  133779. protected _useRadianceOverAlpha: boolean;
  133780. /**
  133781. * Allows using an object space normal map (instead of tangent space).
  133782. */
  133783. protected _useObjectSpaceNormalMap: boolean;
  133784. /**
  133785. * Allows using the bump map in parallax mode.
  133786. */
  133787. protected _useParallax: boolean;
  133788. /**
  133789. * Allows using the bump map in parallax occlusion mode.
  133790. */
  133791. protected _useParallaxOcclusion: boolean;
  133792. /**
  133793. * Controls the scale bias of the parallax mode.
  133794. */
  133795. protected _parallaxScaleBias: number;
  133796. /**
  133797. * If sets to true, disables all the lights affecting the material.
  133798. */
  133799. protected _disableLighting: boolean;
  133800. /**
  133801. * Number of Simultaneous lights allowed on the material.
  133802. */
  133803. protected _maxSimultaneousLights: number;
  133804. /**
  133805. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133806. */
  133807. protected _invertNormalMapX: boolean;
  133808. /**
  133809. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133810. */
  133811. protected _invertNormalMapY: boolean;
  133812. /**
  133813. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133814. */
  133815. protected _twoSidedLighting: boolean;
  133816. /**
  133817. * Defines the alpha limits in alpha test mode.
  133818. */
  133819. protected _alphaCutOff: number;
  133820. /**
  133821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133822. */
  133823. protected _forceAlphaTest: boolean;
  133824. /**
  133825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133826. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133827. */
  133828. protected _useAlphaFresnel: boolean;
  133829. /**
  133830. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133831. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133832. */
  133833. protected _useLinearAlphaFresnel: boolean;
  133834. /**
  133835. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133836. * from cos thetav and roughness:
  133837. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133838. */
  133839. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133840. /**
  133841. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133842. */
  133843. protected _forceIrradianceInFragment: boolean;
  133844. private _realTimeFiltering;
  133845. /**
  133846. * Enables realtime filtering on the texture.
  133847. */
  133848. get realTimeFiltering(): boolean;
  133849. set realTimeFiltering(b: boolean);
  133850. private _realTimeFilteringQuality;
  133851. /**
  133852. * Quality switch for realtime filtering
  133853. */
  133854. get realTimeFilteringQuality(): number;
  133855. set realTimeFilteringQuality(n: number);
  133856. /**
  133857. * Should this material render to several textures at once
  133858. */
  133859. get shouldRenderToMRT(): boolean;
  133860. /**
  133861. * Force normal to face away from face.
  133862. */
  133863. protected _forceNormalForward: boolean;
  133864. /**
  133865. * Enables specular anti aliasing in the PBR shader.
  133866. * It will both interacts on the Geometry for analytical and IBL lighting.
  133867. * It also prefilter the roughness map based on the bump values.
  133868. */
  133869. protected _enableSpecularAntiAliasing: boolean;
  133870. /**
  133871. * Default configuration related to image processing available in the PBR Material.
  133872. */
  133873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133874. /**
  133875. * Keep track of the image processing observer to allow dispose and replace.
  133876. */
  133877. private _imageProcessingObserver;
  133878. /**
  133879. * Attaches a new image processing configuration to the PBR Material.
  133880. * @param configuration
  133881. */
  133882. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133883. /**
  133884. * Stores the available render targets.
  133885. */
  133886. private _renderTargets;
  133887. /**
  133888. * Sets the global ambient color for the material used in lighting calculations.
  133889. */
  133890. private _globalAmbientColor;
  133891. /**
  133892. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133893. */
  133894. private _useLogarithmicDepth;
  133895. /**
  133896. * If set to true, no lighting calculations will be applied.
  133897. */
  133898. private _unlit;
  133899. private _debugMode;
  133900. /**
  133901. * @hidden
  133902. * This is reserved for the inspector.
  133903. * Defines the material debug mode.
  133904. * It helps seeing only some components of the material while troubleshooting.
  133905. */
  133906. debugMode: number;
  133907. /**
  133908. * @hidden
  133909. * This is reserved for the inspector.
  133910. * Specify from where on screen the debug mode should start.
  133911. * The value goes from -1 (full screen) to 1 (not visible)
  133912. * It helps with side by side comparison against the final render
  133913. * This defaults to -1
  133914. */
  133915. private debugLimit;
  133916. /**
  133917. * @hidden
  133918. * This is reserved for the inspector.
  133919. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133920. * You can use the factor to better multiply the final value.
  133921. */
  133922. private debugFactor;
  133923. /**
  133924. * Defines the clear coat layer parameters for the material.
  133925. */
  133926. readonly clearCoat: PBRClearCoatConfiguration;
  133927. /**
  133928. * Defines the anisotropic parameters for the material.
  133929. */
  133930. readonly anisotropy: PBRAnisotropicConfiguration;
  133931. /**
  133932. * Defines the BRDF parameters for the material.
  133933. */
  133934. readonly brdf: PBRBRDFConfiguration;
  133935. /**
  133936. * Defines the Sheen parameters for the material.
  133937. */
  133938. readonly sheen: PBRSheenConfiguration;
  133939. /**
  133940. * Defines the SubSurface parameters for the material.
  133941. */
  133942. readonly subSurface: PBRSubSurfaceConfiguration;
  133943. /**
  133944. * Defines the detail map parameters for the material.
  133945. */
  133946. readonly detailMap: DetailMapConfiguration;
  133947. protected _rebuildInParallel: boolean;
  133948. /**
  133949. * Instantiates a new PBRMaterial instance.
  133950. *
  133951. * @param name The material name
  133952. * @param scene The scene the material will be use in.
  133953. */
  133954. constructor(name: string, scene: Scene);
  133955. /**
  133956. * Gets a boolean indicating that current material needs to register RTT
  133957. */
  133958. get hasRenderTargetTextures(): boolean;
  133959. /**
  133960. * Gets the name of the material class.
  133961. */
  133962. getClassName(): string;
  133963. /**
  133964. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133965. */
  133966. get useLogarithmicDepth(): boolean;
  133967. /**
  133968. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133969. */
  133970. set useLogarithmicDepth(value: boolean);
  133971. /**
  133972. * Returns true if alpha blending should be disabled.
  133973. */
  133974. protected get _disableAlphaBlending(): boolean;
  133975. /**
  133976. * Specifies whether or not this material should be rendered in alpha blend mode.
  133977. */
  133978. needAlphaBlending(): boolean;
  133979. /**
  133980. * Specifies whether or not this material should be rendered in alpha test mode.
  133981. */
  133982. needAlphaTesting(): boolean;
  133983. /**
  133984. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133985. */
  133986. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133987. /**
  133988. * Gets the texture used for the alpha test.
  133989. */
  133990. getAlphaTestTexture(): Nullable<BaseTexture>;
  133991. /**
  133992. * Specifies that the submesh is ready to be used.
  133993. * @param mesh - BJS mesh.
  133994. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133995. * @param useInstances - Specifies that instances should be used.
  133996. * @returns - boolean indicating that the submesh is ready or not.
  133997. */
  133998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133999. /**
  134000. * Specifies if the material uses metallic roughness workflow.
  134001. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134002. */
  134003. isMetallicWorkflow(): boolean;
  134004. private _prepareEffect;
  134005. private _prepareDefines;
  134006. /**
  134007. * Force shader compilation
  134008. */
  134009. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134010. /**
  134011. * Initializes the uniform buffer layout for the shader.
  134012. */
  134013. buildUniformLayout(): void;
  134014. /**
  134015. * Unbinds the material from the mesh
  134016. */
  134017. unbind(): void;
  134018. /**
  134019. * Binds the submesh data.
  134020. * @param world - The world matrix.
  134021. * @param mesh - The BJS mesh.
  134022. * @param subMesh - A submesh of the BJS mesh.
  134023. */
  134024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134025. /**
  134026. * Returns the animatable textures.
  134027. * @returns - Array of animatable textures.
  134028. */
  134029. getAnimatables(): IAnimatable[];
  134030. /**
  134031. * Returns the texture used for reflections.
  134032. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134033. */
  134034. private _getReflectionTexture;
  134035. /**
  134036. * Returns an array of the actively used textures.
  134037. * @returns - Array of BaseTextures
  134038. */
  134039. getActiveTextures(): BaseTexture[];
  134040. /**
  134041. * Checks to see if a texture is used in the material.
  134042. * @param texture - Base texture to use.
  134043. * @returns - Boolean specifying if a texture is used in the material.
  134044. */
  134045. hasTexture(texture: BaseTexture): boolean;
  134046. /**
  134047. * Disposes the resources of the material.
  134048. * @param forceDisposeEffect - Forces the disposal of effects.
  134049. * @param forceDisposeTextures - Forces the disposal of all textures.
  134050. */
  134051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134052. }
  134053. }
  134054. declare module BABYLON {
  134055. /**
  134056. * The Physically based material of BJS.
  134057. *
  134058. * This offers the main features of a standard PBR material.
  134059. * For more information, please refer to the documentation :
  134060. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134061. */
  134062. export class PBRMaterial extends PBRBaseMaterial {
  134063. /**
  134064. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134065. */
  134066. static readonly PBRMATERIAL_OPAQUE: number;
  134067. /**
  134068. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134069. */
  134070. static readonly PBRMATERIAL_ALPHATEST: number;
  134071. /**
  134072. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134073. */
  134074. static readonly PBRMATERIAL_ALPHABLEND: number;
  134075. /**
  134076. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134077. * They are also discarded below the alpha cutoff threshold to improve performances.
  134078. */
  134079. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134080. /**
  134081. * Defines the default value of how much AO map is occluding the analytical lights
  134082. * (point spot...).
  134083. */
  134084. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134085. /**
  134086. * Intensity of the direct lights e.g. the four lights available in your scene.
  134087. * This impacts both the direct diffuse and specular highlights.
  134088. */
  134089. directIntensity: number;
  134090. /**
  134091. * Intensity of the emissive part of the material.
  134092. * This helps controlling the emissive effect without modifying the emissive color.
  134093. */
  134094. emissiveIntensity: number;
  134095. /**
  134096. * Intensity of the environment e.g. how much the environment will light the object
  134097. * either through harmonics for rough material or through the refelction for shiny ones.
  134098. */
  134099. environmentIntensity: number;
  134100. /**
  134101. * This is a special control allowing the reduction of the specular highlights coming from the
  134102. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134103. */
  134104. specularIntensity: number;
  134105. /**
  134106. * Debug Control allowing disabling the bump map on this material.
  134107. */
  134108. disableBumpMap: boolean;
  134109. /**
  134110. * AKA Diffuse Texture in standard nomenclature.
  134111. */
  134112. albedoTexture: BaseTexture;
  134113. /**
  134114. * AKA Occlusion Texture in other nomenclature.
  134115. */
  134116. ambientTexture: BaseTexture;
  134117. /**
  134118. * AKA Occlusion Texture Intensity in other nomenclature.
  134119. */
  134120. ambientTextureStrength: number;
  134121. /**
  134122. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134123. * 1 means it completely occludes it
  134124. * 0 mean it has no impact
  134125. */
  134126. ambientTextureImpactOnAnalyticalLights: number;
  134127. /**
  134128. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134129. */
  134130. opacityTexture: BaseTexture;
  134131. /**
  134132. * Stores the reflection values in a texture.
  134133. */
  134134. reflectionTexture: Nullable<BaseTexture>;
  134135. /**
  134136. * Stores the emissive values in a texture.
  134137. */
  134138. emissiveTexture: BaseTexture;
  134139. /**
  134140. * AKA Specular texture in other nomenclature.
  134141. */
  134142. reflectivityTexture: BaseTexture;
  134143. /**
  134144. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134145. */
  134146. metallicTexture: BaseTexture;
  134147. /**
  134148. * Specifies the metallic scalar of the metallic/roughness workflow.
  134149. * Can also be used to scale the metalness values of the metallic texture.
  134150. */
  134151. metallic: Nullable<number>;
  134152. /**
  134153. * Specifies the roughness scalar of the metallic/roughness workflow.
  134154. * Can also be used to scale the roughness values of the metallic texture.
  134155. */
  134156. roughness: Nullable<number>;
  134157. /**
  134158. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134159. * By default the indexOfrefraction is used to compute F0;
  134160. *
  134161. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134162. *
  134163. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134164. * F90 = metallicReflectanceColor;
  134165. */
  134166. metallicF0Factor: number;
  134167. /**
  134168. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134169. * By default the F90 is always 1;
  134170. *
  134171. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134172. *
  134173. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134174. * F90 = metallicReflectanceColor;
  134175. */
  134176. metallicReflectanceColor: Color3;
  134177. /**
  134178. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134179. * This is multiply against the scalar values defined in the material.
  134180. */
  134181. metallicReflectanceTexture: Nullable<BaseTexture>;
  134182. /**
  134183. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134184. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134185. */
  134186. microSurfaceTexture: BaseTexture;
  134187. /**
  134188. * Stores surface normal data used to displace a mesh in a texture.
  134189. */
  134190. bumpTexture: BaseTexture;
  134191. /**
  134192. * Stores the pre-calculated light information of a mesh in a texture.
  134193. */
  134194. lightmapTexture: BaseTexture;
  134195. /**
  134196. * Stores the refracted light information in a texture.
  134197. */
  134198. get refractionTexture(): Nullable<BaseTexture>;
  134199. set refractionTexture(value: Nullable<BaseTexture>);
  134200. /**
  134201. * The color of a material in ambient lighting.
  134202. */
  134203. ambientColor: Color3;
  134204. /**
  134205. * AKA Diffuse Color in other nomenclature.
  134206. */
  134207. albedoColor: Color3;
  134208. /**
  134209. * AKA Specular Color in other nomenclature.
  134210. */
  134211. reflectivityColor: Color3;
  134212. /**
  134213. * The color reflected from the material.
  134214. */
  134215. reflectionColor: Color3;
  134216. /**
  134217. * The color emitted from the material.
  134218. */
  134219. emissiveColor: Color3;
  134220. /**
  134221. * AKA Glossiness in other nomenclature.
  134222. */
  134223. microSurface: number;
  134224. /**
  134225. * Index of refraction of the material base layer.
  134226. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134227. *
  134228. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134229. *
  134230. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134231. */
  134232. get indexOfRefraction(): number;
  134233. set indexOfRefraction(value: number);
  134234. /**
  134235. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134236. */
  134237. get invertRefractionY(): boolean;
  134238. set invertRefractionY(value: boolean);
  134239. /**
  134240. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134241. * Materials half opaque for instance using refraction could benefit from this control.
  134242. */
  134243. get linkRefractionWithTransparency(): boolean;
  134244. set linkRefractionWithTransparency(value: boolean);
  134245. /**
  134246. * If true, the light map contains occlusion information instead of lighting info.
  134247. */
  134248. useLightmapAsShadowmap: boolean;
  134249. /**
  134250. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134251. */
  134252. useAlphaFromAlbedoTexture: boolean;
  134253. /**
  134254. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134255. */
  134256. forceAlphaTest: boolean;
  134257. /**
  134258. * Defines the alpha limits in alpha test mode.
  134259. */
  134260. alphaCutOff: number;
  134261. /**
  134262. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134263. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134264. */
  134265. useSpecularOverAlpha: boolean;
  134266. /**
  134267. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134268. */
  134269. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134270. /**
  134271. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134272. */
  134273. useRoughnessFromMetallicTextureAlpha: boolean;
  134274. /**
  134275. * Specifies if the metallic texture contains the roughness information in its green channel.
  134276. */
  134277. useRoughnessFromMetallicTextureGreen: boolean;
  134278. /**
  134279. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134280. */
  134281. useMetallnessFromMetallicTextureBlue: boolean;
  134282. /**
  134283. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134284. */
  134285. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134286. /**
  134287. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134288. */
  134289. useAmbientInGrayScale: boolean;
  134290. /**
  134291. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134292. * The material will try to infer what glossiness each pixel should be.
  134293. */
  134294. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134295. /**
  134296. * BJS is using an harcoded light falloff based on a manually sets up range.
  134297. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134298. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134299. */
  134300. get usePhysicalLightFalloff(): boolean;
  134301. /**
  134302. * BJS is using an harcoded light falloff based on a manually sets up range.
  134303. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134304. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134305. */
  134306. set usePhysicalLightFalloff(value: boolean);
  134307. /**
  134308. * In order to support the falloff compatibility with gltf, a special mode has been added
  134309. * to reproduce the gltf light falloff.
  134310. */
  134311. get useGLTFLightFalloff(): boolean;
  134312. /**
  134313. * In order to support the falloff compatibility with gltf, a special mode has been added
  134314. * to reproduce the gltf light falloff.
  134315. */
  134316. set useGLTFLightFalloff(value: boolean);
  134317. /**
  134318. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134319. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134320. */
  134321. useRadianceOverAlpha: boolean;
  134322. /**
  134323. * Allows using an object space normal map (instead of tangent space).
  134324. */
  134325. useObjectSpaceNormalMap: boolean;
  134326. /**
  134327. * Allows using the bump map in parallax mode.
  134328. */
  134329. useParallax: boolean;
  134330. /**
  134331. * Allows using the bump map in parallax occlusion mode.
  134332. */
  134333. useParallaxOcclusion: boolean;
  134334. /**
  134335. * Controls the scale bias of the parallax mode.
  134336. */
  134337. parallaxScaleBias: number;
  134338. /**
  134339. * If sets to true, disables all the lights affecting the material.
  134340. */
  134341. disableLighting: boolean;
  134342. /**
  134343. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134344. */
  134345. forceIrradianceInFragment: boolean;
  134346. /**
  134347. * Number of Simultaneous lights allowed on the material.
  134348. */
  134349. maxSimultaneousLights: number;
  134350. /**
  134351. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134352. */
  134353. invertNormalMapX: boolean;
  134354. /**
  134355. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134356. */
  134357. invertNormalMapY: boolean;
  134358. /**
  134359. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134360. */
  134361. twoSidedLighting: boolean;
  134362. /**
  134363. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134364. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134365. */
  134366. useAlphaFresnel: boolean;
  134367. /**
  134368. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134369. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134370. */
  134371. useLinearAlphaFresnel: boolean;
  134372. /**
  134373. * Let user defines the brdf lookup texture used for IBL.
  134374. * A default 8bit version is embedded but you could point at :
  134375. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134376. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134377. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134378. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134379. */
  134380. environmentBRDFTexture: Nullable<BaseTexture>;
  134381. /**
  134382. * Force normal to face away from face.
  134383. */
  134384. forceNormalForward: boolean;
  134385. /**
  134386. * Enables specular anti aliasing in the PBR shader.
  134387. * It will both interacts on the Geometry for analytical and IBL lighting.
  134388. * It also prefilter the roughness map based on the bump values.
  134389. */
  134390. enableSpecularAntiAliasing: boolean;
  134391. /**
  134392. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134393. * makes the reflect vector face the model (under horizon).
  134394. */
  134395. useHorizonOcclusion: boolean;
  134396. /**
  134397. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134398. * too much the area relying on ambient texture to define their ambient occlusion.
  134399. */
  134400. useRadianceOcclusion: boolean;
  134401. /**
  134402. * If set to true, no lighting calculations will be applied.
  134403. */
  134404. unlit: boolean;
  134405. /**
  134406. * Gets the image processing configuration used either in this material.
  134407. */
  134408. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134409. /**
  134410. * Sets the Default image processing configuration used either in the this material.
  134411. *
  134412. * If sets to null, the scene one is in use.
  134413. */
  134414. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134415. /**
  134416. * Gets wether the color curves effect is enabled.
  134417. */
  134418. get cameraColorCurvesEnabled(): boolean;
  134419. /**
  134420. * Sets wether the color curves effect is enabled.
  134421. */
  134422. set cameraColorCurvesEnabled(value: boolean);
  134423. /**
  134424. * Gets wether the color grading effect is enabled.
  134425. */
  134426. get cameraColorGradingEnabled(): boolean;
  134427. /**
  134428. * Gets wether the color grading effect is enabled.
  134429. */
  134430. set cameraColorGradingEnabled(value: boolean);
  134431. /**
  134432. * Gets wether tonemapping is enabled or not.
  134433. */
  134434. get cameraToneMappingEnabled(): boolean;
  134435. /**
  134436. * Sets wether tonemapping is enabled or not
  134437. */
  134438. set cameraToneMappingEnabled(value: boolean);
  134439. /**
  134440. * The camera exposure used on this material.
  134441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134442. * This corresponds to a photographic exposure.
  134443. */
  134444. get cameraExposure(): number;
  134445. /**
  134446. * The camera exposure used on this material.
  134447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134448. * This corresponds to a photographic exposure.
  134449. */
  134450. set cameraExposure(value: number);
  134451. /**
  134452. * Gets The camera contrast used on this material.
  134453. */
  134454. get cameraContrast(): number;
  134455. /**
  134456. * Sets The camera contrast used on this material.
  134457. */
  134458. set cameraContrast(value: number);
  134459. /**
  134460. * Gets the Color Grading 2D Lookup Texture.
  134461. */
  134462. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134463. /**
  134464. * Sets the Color Grading 2D Lookup Texture.
  134465. */
  134466. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134467. /**
  134468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134470. * 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;
  134471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134472. */
  134473. get cameraColorCurves(): Nullable<ColorCurves>;
  134474. /**
  134475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134477. * 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;
  134478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134479. */
  134480. set cameraColorCurves(value: Nullable<ColorCurves>);
  134481. /**
  134482. * Instantiates a new PBRMaterial instance.
  134483. *
  134484. * @param name The material name
  134485. * @param scene The scene the material will be use in.
  134486. */
  134487. constructor(name: string, scene: Scene);
  134488. /**
  134489. * Returns the name of this material class.
  134490. */
  134491. getClassName(): string;
  134492. /**
  134493. * Makes a duplicate of the current material.
  134494. * @param name - name to use for the new material.
  134495. */
  134496. clone(name: string): PBRMaterial;
  134497. /**
  134498. * Serializes this PBR Material.
  134499. * @returns - An object with the serialized material.
  134500. */
  134501. serialize(): any;
  134502. /**
  134503. * Parses a PBR Material from a serialized object.
  134504. * @param source - Serialized object.
  134505. * @param scene - BJS scene instance.
  134506. * @param rootUrl - url for the scene object
  134507. * @returns - PBRMaterial
  134508. */
  134509. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134510. }
  134511. }
  134512. declare module BABYLON {
  134513. /**
  134514. * Direct draw surface info
  134515. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134516. */
  134517. export interface DDSInfo {
  134518. /**
  134519. * Width of the texture
  134520. */
  134521. width: number;
  134522. /**
  134523. * Width of the texture
  134524. */
  134525. height: number;
  134526. /**
  134527. * Number of Mipmaps for the texture
  134528. * @see https://en.wikipedia.org/wiki/Mipmap
  134529. */
  134530. mipmapCount: number;
  134531. /**
  134532. * If the textures format is a known fourCC format
  134533. * @see https://www.fourcc.org/
  134534. */
  134535. isFourCC: boolean;
  134536. /**
  134537. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134538. */
  134539. isRGB: boolean;
  134540. /**
  134541. * If the texture is a lumincance format
  134542. */
  134543. isLuminance: boolean;
  134544. /**
  134545. * If this is a cube texture
  134546. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134547. */
  134548. isCube: boolean;
  134549. /**
  134550. * If the texture is a compressed format eg. FOURCC_DXT1
  134551. */
  134552. isCompressed: boolean;
  134553. /**
  134554. * The dxgiFormat of the texture
  134555. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134556. */
  134557. dxgiFormat: number;
  134558. /**
  134559. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134560. */
  134561. textureType: number;
  134562. /**
  134563. * Sphericle polynomial created for the dds texture
  134564. */
  134565. sphericalPolynomial?: SphericalPolynomial;
  134566. }
  134567. /**
  134568. * Class used to provide DDS decompression tools
  134569. */
  134570. export class DDSTools {
  134571. /**
  134572. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134573. */
  134574. static StoreLODInAlphaChannel: boolean;
  134575. /**
  134576. * Gets DDS information from an array buffer
  134577. * @param data defines the array buffer view to read data from
  134578. * @returns the DDS information
  134579. */
  134580. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134581. private static _FloatView;
  134582. private static _Int32View;
  134583. private static _ToHalfFloat;
  134584. private static _FromHalfFloat;
  134585. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134586. private static _GetHalfFloatRGBAArrayBuffer;
  134587. private static _GetFloatRGBAArrayBuffer;
  134588. private static _GetFloatAsUIntRGBAArrayBuffer;
  134589. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134590. private static _GetRGBAArrayBuffer;
  134591. private static _ExtractLongWordOrder;
  134592. private static _GetRGBArrayBuffer;
  134593. private static _GetLuminanceArrayBuffer;
  134594. /**
  134595. * Uploads DDS Levels to a Babylon Texture
  134596. * @hidden
  134597. */
  134598. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134599. }
  134600. interface ThinEngine {
  134601. /**
  134602. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134603. * @param rootUrl defines the url where the file to load is located
  134604. * @param scene defines the current scene
  134605. * @param lodScale defines scale to apply to the mip map selection
  134606. * @param lodOffset defines offset to apply to the mip map selection
  134607. * @param onLoad defines an optional callback raised when the texture is loaded
  134608. * @param onError defines an optional callback raised if there is an issue to load the texture
  134609. * @param format defines the format of the data
  134610. * @param forcedExtension defines the extension to use to pick the right loader
  134611. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134612. * @returns the cube texture as an InternalTexture
  134613. */
  134614. 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;
  134615. }
  134616. }
  134617. declare module BABYLON {
  134618. /**
  134619. * Implementation of the DDS Texture Loader.
  134620. * @hidden
  134621. */
  134622. export class _DDSTextureLoader implements IInternalTextureLoader {
  134623. /**
  134624. * Defines wether the loader supports cascade loading the different faces.
  134625. */
  134626. readonly supportCascades: boolean;
  134627. /**
  134628. * This returns if the loader support the current file information.
  134629. * @param extension defines the file extension of the file being loaded
  134630. * @returns true if the loader can load the specified file
  134631. */
  134632. canLoad(extension: string): boolean;
  134633. /**
  134634. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134635. * @param data contains the texture data
  134636. * @param texture defines the BabylonJS internal texture
  134637. * @param createPolynomials will be true if polynomials have been requested
  134638. * @param onLoad defines the callback to trigger once the texture is ready
  134639. * @param onError defines the callback to trigger in case of error
  134640. */
  134641. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134642. /**
  134643. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134644. * @param data contains the texture data
  134645. * @param texture defines the BabylonJS internal texture
  134646. * @param callback defines the method to call once ready to upload
  134647. */
  134648. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134649. }
  134650. }
  134651. declare module BABYLON {
  134652. /**
  134653. * Implementation of the ENV Texture Loader.
  134654. * @hidden
  134655. */
  134656. export class _ENVTextureLoader implements IInternalTextureLoader {
  134657. /**
  134658. * Defines wether the loader supports cascade loading the different faces.
  134659. */
  134660. readonly supportCascades: boolean;
  134661. /**
  134662. * This returns if the loader support the current file information.
  134663. * @param extension defines the file extension of the file being loaded
  134664. * @returns true if the loader can load the specified file
  134665. */
  134666. canLoad(extension: string): boolean;
  134667. /**
  134668. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134669. * @param data contains the texture data
  134670. * @param texture defines the BabylonJS internal texture
  134671. * @param createPolynomials will be true if polynomials have been requested
  134672. * @param onLoad defines the callback to trigger once the texture is ready
  134673. * @param onError defines the callback to trigger in case of error
  134674. */
  134675. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134676. /**
  134677. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134678. * @param data contains the texture data
  134679. * @param texture defines the BabylonJS internal texture
  134680. * @param callback defines the method to call once ready to upload
  134681. */
  134682. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134683. }
  134684. }
  134685. declare module BABYLON {
  134686. /**
  134687. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134688. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134689. */
  134690. export class KhronosTextureContainer {
  134691. /** contents of the KTX container file */
  134692. data: ArrayBufferView;
  134693. private static HEADER_LEN;
  134694. private static COMPRESSED_2D;
  134695. private static COMPRESSED_3D;
  134696. private static TEX_2D;
  134697. private static TEX_3D;
  134698. /**
  134699. * Gets the openGL type
  134700. */
  134701. glType: number;
  134702. /**
  134703. * Gets the openGL type size
  134704. */
  134705. glTypeSize: number;
  134706. /**
  134707. * Gets the openGL format
  134708. */
  134709. glFormat: number;
  134710. /**
  134711. * Gets the openGL internal format
  134712. */
  134713. glInternalFormat: number;
  134714. /**
  134715. * Gets the base internal format
  134716. */
  134717. glBaseInternalFormat: number;
  134718. /**
  134719. * Gets image width in pixel
  134720. */
  134721. pixelWidth: number;
  134722. /**
  134723. * Gets image height in pixel
  134724. */
  134725. pixelHeight: number;
  134726. /**
  134727. * Gets image depth in pixels
  134728. */
  134729. pixelDepth: number;
  134730. /**
  134731. * Gets the number of array elements
  134732. */
  134733. numberOfArrayElements: number;
  134734. /**
  134735. * Gets the number of faces
  134736. */
  134737. numberOfFaces: number;
  134738. /**
  134739. * Gets the number of mipmap levels
  134740. */
  134741. numberOfMipmapLevels: number;
  134742. /**
  134743. * Gets the bytes of key value data
  134744. */
  134745. bytesOfKeyValueData: number;
  134746. /**
  134747. * Gets the load type
  134748. */
  134749. loadType: number;
  134750. /**
  134751. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134752. */
  134753. isInvalid: boolean;
  134754. /**
  134755. * Creates a new KhronosTextureContainer
  134756. * @param data contents of the KTX container file
  134757. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134758. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134759. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134760. */
  134761. constructor(
  134762. /** contents of the KTX container file */
  134763. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134764. /**
  134765. * Uploads KTX content to a Babylon Texture.
  134766. * It is assumed that the texture has already been created & is currently bound
  134767. * @hidden
  134768. */
  134769. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134770. private _upload2DCompressedLevels;
  134771. /**
  134772. * Checks if the given data starts with a KTX file identifier.
  134773. * @param data the data to check
  134774. * @returns true if the data is a KTX file or false otherwise
  134775. */
  134776. static IsValid(data: ArrayBufferView): boolean;
  134777. }
  134778. }
  134779. declare module BABYLON {
  134780. /**
  134781. * Class for loading KTX2 files
  134782. * !!! Experimental Extension Subject to Changes !!!
  134783. * @hidden
  134784. */
  134785. export class KhronosTextureContainer2 {
  134786. private static _ModulePromise;
  134787. private static _TranscodeFormat;
  134788. constructor(engine: ThinEngine);
  134789. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134790. private _determineTranscodeFormat;
  134791. /**
  134792. * Checks if the given data starts with a KTX2 file identifier.
  134793. * @param data the data to check
  134794. * @returns true if the data is a KTX2 file or false otherwise
  134795. */
  134796. static IsValid(data: ArrayBufferView): boolean;
  134797. }
  134798. }
  134799. declare module BABYLON {
  134800. /**
  134801. * Implementation of the KTX Texture Loader.
  134802. * @hidden
  134803. */
  134804. export class _KTXTextureLoader implements IInternalTextureLoader {
  134805. /**
  134806. * Defines wether the loader supports cascade loading the different faces.
  134807. */
  134808. readonly supportCascades: boolean;
  134809. /**
  134810. * This returns if the loader support the current file information.
  134811. * @param extension defines the file extension of the file being loaded
  134812. * @param mimeType defines the optional mime type of the file being loaded
  134813. * @returns true if the loader can load the specified file
  134814. */
  134815. canLoad(extension: string, mimeType?: string): boolean;
  134816. /**
  134817. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134818. * @param data contains the texture data
  134819. * @param texture defines the BabylonJS internal texture
  134820. * @param createPolynomials will be true if polynomials have been requested
  134821. * @param onLoad defines the callback to trigger once the texture is ready
  134822. * @param onError defines the callback to trigger in case of error
  134823. */
  134824. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134825. /**
  134826. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134827. * @param data contains the texture data
  134828. * @param texture defines the BabylonJS internal texture
  134829. * @param callback defines the method to call once ready to upload
  134830. */
  134831. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134832. }
  134833. }
  134834. declare module BABYLON {
  134835. /** @hidden */
  134836. export var _forceSceneHelpersToBundle: boolean;
  134837. interface Scene {
  134838. /**
  134839. * Creates a default light for the scene.
  134840. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134841. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134842. */
  134843. createDefaultLight(replace?: boolean): void;
  134844. /**
  134845. * Creates a default camera for the scene.
  134846. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134848. * @param replace has default false, when true replaces the active camera in the scene
  134849. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134850. */
  134851. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134852. /**
  134853. * Creates a default camera and a default light.
  134854. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134855. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134856. * @param replace has the default false, when true replaces the active camera/light in the scene
  134857. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134858. */
  134859. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134860. /**
  134861. * Creates a new sky box
  134862. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134863. * @param environmentTexture defines the texture to use as environment texture
  134864. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134865. * @param scale defines the overall scale of the skybox
  134866. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134867. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134868. * @returns a new mesh holding the sky box
  134869. */
  134870. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134871. /**
  134872. * Creates a new environment
  134873. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134874. * @param options defines the options you can use to configure the environment
  134875. * @returns the new EnvironmentHelper
  134876. */
  134877. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134878. /**
  134879. * Creates a new VREXperienceHelper
  134880. * @see https://doc.babylonjs.com/how_to/webvr_helper
  134881. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134882. * @returns a new VREXperienceHelper
  134883. */
  134884. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134885. /**
  134886. * Creates a new WebXRDefaultExperience
  134887. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  134888. * @param options experience options
  134889. * @returns a promise for a new WebXRDefaultExperience
  134890. */
  134891. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134892. }
  134893. }
  134894. declare module BABYLON {
  134895. /**
  134896. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134897. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134898. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134899. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134900. */
  134901. export class VideoDome extends TransformNode {
  134902. /**
  134903. * Define the video source as a Monoscopic panoramic 360 video.
  134904. */
  134905. static readonly MODE_MONOSCOPIC: number;
  134906. /**
  134907. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134908. */
  134909. static readonly MODE_TOPBOTTOM: number;
  134910. /**
  134911. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134912. */
  134913. static readonly MODE_SIDEBYSIDE: number;
  134914. private _halfDome;
  134915. private _useDirectMapping;
  134916. /**
  134917. * The video texture being displayed on the sphere
  134918. */
  134919. protected _videoTexture: VideoTexture;
  134920. /**
  134921. * Gets the video texture being displayed on the sphere
  134922. */
  134923. get videoTexture(): VideoTexture;
  134924. /**
  134925. * The skybox material
  134926. */
  134927. protected _material: BackgroundMaterial;
  134928. /**
  134929. * The surface used for the skybox
  134930. */
  134931. protected _mesh: Mesh;
  134932. /**
  134933. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134934. */
  134935. private _halfDomeMask;
  134936. /**
  134937. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134938. * Also see the options.resolution property.
  134939. */
  134940. get fovMultiplier(): number;
  134941. set fovMultiplier(value: number);
  134942. private _videoMode;
  134943. /**
  134944. * Gets or set the current video mode for the video. It can be:
  134945. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134946. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134947. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134948. */
  134949. get videoMode(): number;
  134950. set videoMode(value: number);
  134951. /**
  134952. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134953. *
  134954. */
  134955. get halfDome(): boolean;
  134956. /**
  134957. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134958. */
  134959. set halfDome(enabled: boolean);
  134960. /**
  134961. * Oberserver used in Stereoscopic VR Mode.
  134962. */
  134963. private _onBeforeCameraRenderObserver;
  134964. /**
  134965. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134966. * @param name Element's name, child elements will append suffixes for their own names.
  134967. * @param urlsOrVideo defines the url(s) or the video element to use
  134968. * @param options An object containing optional or exposed sub element properties
  134969. */
  134970. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134971. resolution?: number;
  134972. clickToPlay?: boolean;
  134973. autoPlay?: boolean;
  134974. loop?: boolean;
  134975. size?: number;
  134976. poster?: string;
  134977. faceForward?: boolean;
  134978. useDirectMapping?: boolean;
  134979. halfDomeMode?: boolean;
  134980. }, scene: Scene);
  134981. private _changeVideoMode;
  134982. /**
  134983. * Releases resources associated with this node.
  134984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134986. */
  134987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134988. }
  134989. }
  134990. declare module BABYLON {
  134991. /**
  134992. * This class can be used to get instrumentation data from a Babylon engine
  134993. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134994. */
  134995. export class EngineInstrumentation implements IDisposable {
  134996. /**
  134997. * Define the instrumented engine.
  134998. */
  134999. engine: Engine;
  135000. private _captureGPUFrameTime;
  135001. private _gpuFrameTimeToken;
  135002. private _gpuFrameTime;
  135003. private _captureShaderCompilationTime;
  135004. private _shaderCompilationTime;
  135005. private _onBeginFrameObserver;
  135006. private _onEndFrameObserver;
  135007. private _onBeforeShaderCompilationObserver;
  135008. private _onAfterShaderCompilationObserver;
  135009. /**
  135010. * Gets the perf counter used for GPU frame time
  135011. */
  135012. get gpuFrameTimeCounter(): PerfCounter;
  135013. /**
  135014. * Gets the GPU frame time capture status
  135015. */
  135016. get captureGPUFrameTime(): boolean;
  135017. /**
  135018. * Enable or disable the GPU frame time capture
  135019. */
  135020. set captureGPUFrameTime(value: boolean);
  135021. /**
  135022. * Gets the perf counter used for shader compilation time
  135023. */
  135024. get shaderCompilationTimeCounter(): PerfCounter;
  135025. /**
  135026. * Gets the shader compilation time capture status
  135027. */
  135028. get captureShaderCompilationTime(): boolean;
  135029. /**
  135030. * Enable or disable the shader compilation time capture
  135031. */
  135032. set captureShaderCompilationTime(value: boolean);
  135033. /**
  135034. * Instantiates a new engine instrumentation.
  135035. * This class can be used to get instrumentation data from a Babylon engine
  135036. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135037. * @param engine Defines the engine to instrument
  135038. */
  135039. constructor(
  135040. /**
  135041. * Define the instrumented engine.
  135042. */
  135043. engine: Engine);
  135044. /**
  135045. * Dispose and release associated resources.
  135046. */
  135047. dispose(): void;
  135048. }
  135049. }
  135050. declare module BABYLON {
  135051. /**
  135052. * This class can be used to get instrumentation data from a Babylon engine
  135053. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135054. */
  135055. export class SceneInstrumentation implements IDisposable {
  135056. /**
  135057. * Defines the scene to instrument
  135058. */
  135059. scene: Scene;
  135060. private _captureActiveMeshesEvaluationTime;
  135061. private _activeMeshesEvaluationTime;
  135062. private _captureRenderTargetsRenderTime;
  135063. private _renderTargetsRenderTime;
  135064. private _captureFrameTime;
  135065. private _frameTime;
  135066. private _captureRenderTime;
  135067. private _renderTime;
  135068. private _captureInterFrameTime;
  135069. private _interFrameTime;
  135070. private _captureParticlesRenderTime;
  135071. private _particlesRenderTime;
  135072. private _captureSpritesRenderTime;
  135073. private _spritesRenderTime;
  135074. private _capturePhysicsTime;
  135075. private _physicsTime;
  135076. private _captureAnimationsTime;
  135077. private _animationsTime;
  135078. private _captureCameraRenderTime;
  135079. private _cameraRenderTime;
  135080. private _onBeforeActiveMeshesEvaluationObserver;
  135081. private _onAfterActiveMeshesEvaluationObserver;
  135082. private _onBeforeRenderTargetsRenderObserver;
  135083. private _onAfterRenderTargetsRenderObserver;
  135084. private _onAfterRenderObserver;
  135085. private _onBeforeDrawPhaseObserver;
  135086. private _onAfterDrawPhaseObserver;
  135087. private _onBeforeAnimationsObserver;
  135088. private _onBeforeParticlesRenderingObserver;
  135089. private _onAfterParticlesRenderingObserver;
  135090. private _onBeforeSpritesRenderingObserver;
  135091. private _onAfterSpritesRenderingObserver;
  135092. private _onBeforePhysicsObserver;
  135093. private _onAfterPhysicsObserver;
  135094. private _onAfterAnimationsObserver;
  135095. private _onBeforeCameraRenderObserver;
  135096. private _onAfterCameraRenderObserver;
  135097. /**
  135098. * Gets the perf counter used for active meshes evaluation time
  135099. */
  135100. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135101. /**
  135102. * Gets the active meshes evaluation time capture status
  135103. */
  135104. get captureActiveMeshesEvaluationTime(): boolean;
  135105. /**
  135106. * Enable or disable the active meshes evaluation time capture
  135107. */
  135108. set captureActiveMeshesEvaluationTime(value: boolean);
  135109. /**
  135110. * Gets the perf counter used for render targets render time
  135111. */
  135112. get renderTargetsRenderTimeCounter(): PerfCounter;
  135113. /**
  135114. * Gets the render targets render time capture status
  135115. */
  135116. get captureRenderTargetsRenderTime(): boolean;
  135117. /**
  135118. * Enable or disable the render targets render time capture
  135119. */
  135120. set captureRenderTargetsRenderTime(value: boolean);
  135121. /**
  135122. * Gets the perf counter used for particles render time
  135123. */
  135124. get particlesRenderTimeCounter(): PerfCounter;
  135125. /**
  135126. * Gets the particles render time capture status
  135127. */
  135128. get captureParticlesRenderTime(): boolean;
  135129. /**
  135130. * Enable or disable the particles render time capture
  135131. */
  135132. set captureParticlesRenderTime(value: boolean);
  135133. /**
  135134. * Gets the perf counter used for sprites render time
  135135. */
  135136. get spritesRenderTimeCounter(): PerfCounter;
  135137. /**
  135138. * Gets the sprites render time capture status
  135139. */
  135140. get captureSpritesRenderTime(): boolean;
  135141. /**
  135142. * Enable or disable the sprites render time capture
  135143. */
  135144. set captureSpritesRenderTime(value: boolean);
  135145. /**
  135146. * Gets the perf counter used for physics time
  135147. */
  135148. get physicsTimeCounter(): PerfCounter;
  135149. /**
  135150. * Gets the physics time capture status
  135151. */
  135152. get capturePhysicsTime(): boolean;
  135153. /**
  135154. * Enable or disable the physics time capture
  135155. */
  135156. set capturePhysicsTime(value: boolean);
  135157. /**
  135158. * Gets the perf counter used for animations time
  135159. */
  135160. get animationsTimeCounter(): PerfCounter;
  135161. /**
  135162. * Gets the animations time capture status
  135163. */
  135164. get captureAnimationsTime(): boolean;
  135165. /**
  135166. * Enable or disable the animations time capture
  135167. */
  135168. set captureAnimationsTime(value: boolean);
  135169. /**
  135170. * Gets the perf counter used for frame time capture
  135171. */
  135172. get frameTimeCounter(): PerfCounter;
  135173. /**
  135174. * Gets the frame time capture status
  135175. */
  135176. get captureFrameTime(): boolean;
  135177. /**
  135178. * Enable or disable the frame time capture
  135179. */
  135180. set captureFrameTime(value: boolean);
  135181. /**
  135182. * Gets the perf counter used for inter-frames time capture
  135183. */
  135184. get interFrameTimeCounter(): PerfCounter;
  135185. /**
  135186. * Gets the inter-frames time capture status
  135187. */
  135188. get captureInterFrameTime(): boolean;
  135189. /**
  135190. * Enable or disable the inter-frames time capture
  135191. */
  135192. set captureInterFrameTime(value: boolean);
  135193. /**
  135194. * Gets the perf counter used for render time capture
  135195. */
  135196. get renderTimeCounter(): PerfCounter;
  135197. /**
  135198. * Gets the render time capture status
  135199. */
  135200. get captureRenderTime(): boolean;
  135201. /**
  135202. * Enable or disable the render time capture
  135203. */
  135204. set captureRenderTime(value: boolean);
  135205. /**
  135206. * Gets the perf counter used for camera render time capture
  135207. */
  135208. get cameraRenderTimeCounter(): PerfCounter;
  135209. /**
  135210. * Gets the camera render time capture status
  135211. */
  135212. get captureCameraRenderTime(): boolean;
  135213. /**
  135214. * Enable or disable the camera render time capture
  135215. */
  135216. set captureCameraRenderTime(value: boolean);
  135217. /**
  135218. * Gets the perf counter used for draw calls
  135219. */
  135220. get drawCallsCounter(): PerfCounter;
  135221. /**
  135222. * Instantiates a new scene instrumentation.
  135223. * This class can be used to get instrumentation data from a Babylon engine
  135224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135225. * @param scene Defines the scene to instrument
  135226. */
  135227. constructor(
  135228. /**
  135229. * Defines the scene to instrument
  135230. */
  135231. scene: Scene);
  135232. /**
  135233. * Dispose and release associated resources.
  135234. */
  135235. dispose(): void;
  135236. }
  135237. }
  135238. declare module BABYLON {
  135239. /** @hidden */
  135240. export var glowMapGenerationPixelShader: {
  135241. name: string;
  135242. shader: string;
  135243. };
  135244. }
  135245. declare module BABYLON {
  135246. /** @hidden */
  135247. export var glowMapGenerationVertexShader: {
  135248. name: string;
  135249. shader: string;
  135250. };
  135251. }
  135252. declare module BABYLON {
  135253. /**
  135254. * Effect layer options. This helps customizing the behaviour
  135255. * of the effect layer.
  135256. */
  135257. export interface IEffectLayerOptions {
  135258. /**
  135259. * Multiplication factor apply to the canvas size to compute the render target size
  135260. * used to generated the objects (the smaller the faster).
  135261. */
  135262. mainTextureRatio: number;
  135263. /**
  135264. * Enforces a fixed size texture to ensure effect stability across devices.
  135265. */
  135266. mainTextureFixedSize?: number;
  135267. /**
  135268. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135269. */
  135270. alphaBlendingMode: number;
  135271. /**
  135272. * The camera attached to the layer.
  135273. */
  135274. camera: Nullable<Camera>;
  135275. /**
  135276. * The rendering group to draw the layer in.
  135277. */
  135278. renderingGroupId: number;
  135279. }
  135280. /**
  135281. * The effect layer Helps adding post process effect blended with the main pass.
  135282. *
  135283. * This can be for instance use to generate glow or higlight effects on the scene.
  135284. *
  135285. * The effect layer class can not be used directly and is intented to inherited from to be
  135286. * customized per effects.
  135287. */
  135288. export abstract class EffectLayer {
  135289. private _vertexBuffers;
  135290. private _indexBuffer;
  135291. private _cachedDefines;
  135292. private _effectLayerMapGenerationEffect;
  135293. private _effectLayerOptions;
  135294. private _mergeEffect;
  135295. protected _scene: Scene;
  135296. protected _engine: Engine;
  135297. protected _maxSize: number;
  135298. protected _mainTextureDesiredSize: ISize;
  135299. protected _mainTexture: RenderTargetTexture;
  135300. protected _shouldRender: boolean;
  135301. protected _postProcesses: PostProcess[];
  135302. protected _textures: BaseTexture[];
  135303. protected _emissiveTextureAndColor: {
  135304. texture: Nullable<BaseTexture>;
  135305. color: Color4;
  135306. };
  135307. /**
  135308. * The name of the layer
  135309. */
  135310. name: string;
  135311. /**
  135312. * The clear color of the texture used to generate the glow map.
  135313. */
  135314. neutralColor: Color4;
  135315. /**
  135316. * Specifies whether the highlight layer is enabled or not.
  135317. */
  135318. isEnabled: boolean;
  135319. /**
  135320. * Gets the camera attached to the layer.
  135321. */
  135322. get camera(): Nullable<Camera>;
  135323. /**
  135324. * Gets the rendering group id the layer should render in.
  135325. */
  135326. get renderingGroupId(): number;
  135327. set renderingGroupId(renderingGroupId: number);
  135328. /**
  135329. * An event triggered when the effect layer has been disposed.
  135330. */
  135331. onDisposeObservable: Observable<EffectLayer>;
  135332. /**
  135333. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135334. */
  135335. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135336. /**
  135337. * An event triggered when the generated texture is being merged in the scene.
  135338. */
  135339. onBeforeComposeObservable: Observable<EffectLayer>;
  135340. /**
  135341. * An event triggered when the mesh is rendered into the effect render target.
  135342. */
  135343. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135344. /**
  135345. * An event triggered after the mesh has been rendered into the effect render target.
  135346. */
  135347. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135348. /**
  135349. * An event triggered when the generated texture has been merged in the scene.
  135350. */
  135351. onAfterComposeObservable: Observable<EffectLayer>;
  135352. /**
  135353. * An event triggered when the efffect layer changes its size.
  135354. */
  135355. onSizeChangedObservable: Observable<EffectLayer>;
  135356. /** @hidden */
  135357. static _SceneComponentInitialization: (scene: Scene) => void;
  135358. /**
  135359. * Instantiates a new effect Layer and references it in the scene.
  135360. * @param name The name of the layer
  135361. * @param scene The scene to use the layer in
  135362. */
  135363. constructor(
  135364. /** The Friendly of the effect in the scene */
  135365. name: string, scene: Scene);
  135366. /**
  135367. * Get the effect name of the layer.
  135368. * @return The effect name
  135369. */
  135370. abstract getEffectName(): string;
  135371. /**
  135372. * Checks for the readiness of the element composing the layer.
  135373. * @param subMesh the mesh to check for
  135374. * @param useInstances specify whether or not to use instances to render the mesh
  135375. * @return true if ready otherwise, false
  135376. */
  135377. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135378. /**
  135379. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135380. * @returns true if the effect requires stencil during the main canvas render pass.
  135381. */
  135382. abstract needStencil(): boolean;
  135383. /**
  135384. * Create the merge effect. This is the shader use to blit the information back
  135385. * to the main canvas at the end of the scene rendering.
  135386. * @returns The effect containing the shader used to merge the effect on the main canvas
  135387. */
  135388. protected abstract _createMergeEffect(): Effect;
  135389. /**
  135390. * Creates the render target textures and post processes used in the effect layer.
  135391. */
  135392. protected abstract _createTextureAndPostProcesses(): void;
  135393. /**
  135394. * Implementation specific of rendering the generating effect on the main canvas.
  135395. * @param effect The effect used to render through
  135396. */
  135397. protected abstract _internalRender(effect: Effect): void;
  135398. /**
  135399. * Sets the required values for both the emissive texture and and the main color.
  135400. */
  135401. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135402. /**
  135403. * Free any resources and references associated to a mesh.
  135404. * Internal use
  135405. * @param mesh The mesh to free.
  135406. */
  135407. abstract _disposeMesh(mesh: Mesh): void;
  135408. /**
  135409. * Serializes this layer (Glow or Highlight for example)
  135410. * @returns a serialized layer object
  135411. */
  135412. abstract serialize?(): any;
  135413. /**
  135414. * Initializes the effect layer with the required options.
  135415. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135416. */
  135417. protected _init(options: Partial<IEffectLayerOptions>): void;
  135418. /**
  135419. * Generates the index buffer of the full screen quad blending to the main canvas.
  135420. */
  135421. private _generateIndexBuffer;
  135422. /**
  135423. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135424. */
  135425. private _generateVertexBuffer;
  135426. /**
  135427. * Sets the main texture desired size which is the closest power of two
  135428. * of the engine canvas size.
  135429. */
  135430. private _setMainTextureSize;
  135431. /**
  135432. * Creates the main texture for the effect layer.
  135433. */
  135434. protected _createMainTexture(): void;
  135435. /**
  135436. * Adds specific effects defines.
  135437. * @param defines The defines to add specifics to.
  135438. */
  135439. protected _addCustomEffectDefines(defines: string[]): void;
  135440. /**
  135441. * Checks for the readiness of the element composing the layer.
  135442. * @param subMesh the mesh to check for
  135443. * @param useInstances specify whether or not to use instances to render the mesh
  135444. * @param emissiveTexture the associated emissive texture used to generate the glow
  135445. * @return true if ready otherwise, false
  135446. */
  135447. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135448. /**
  135449. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135450. */
  135451. render(): void;
  135452. /**
  135453. * Determine if a given mesh will be used in the current effect.
  135454. * @param mesh mesh to test
  135455. * @returns true if the mesh will be used
  135456. */
  135457. hasMesh(mesh: AbstractMesh): boolean;
  135458. /**
  135459. * Returns true if the layer contains information to display, otherwise false.
  135460. * @returns true if the glow layer should be rendered
  135461. */
  135462. shouldRender(): boolean;
  135463. /**
  135464. * Returns true if the mesh should render, otherwise false.
  135465. * @param mesh The mesh to render
  135466. * @returns true if it should render otherwise false
  135467. */
  135468. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135469. /**
  135470. * Returns true if the mesh can be rendered, otherwise false.
  135471. * @param mesh The mesh to render
  135472. * @param material The material used on the mesh
  135473. * @returns true if it can be rendered otherwise false
  135474. */
  135475. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135476. /**
  135477. * Returns true if the mesh should render, otherwise false.
  135478. * @param mesh The mesh to render
  135479. * @returns true if it should render otherwise false
  135480. */
  135481. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135482. /**
  135483. * Renders the submesh passed in parameter to the generation map.
  135484. */
  135485. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135486. /**
  135487. * Defines whether the current material of the mesh should be use to render the effect.
  135488. * @param mesh defines the current mesh to render
  135489. */
  135490. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135491. /**
  135492. * Rebuild the required buffers.
  135493. * @hidden Internal use only.
  135494. */
  135495. _rebuild(): void;
  135496. /**
  135497. * Dispose only the render target textures and post process.
  135498. */
  135499. private _disposeTextureAndPostProcesses;
  135500. /**
  135501. * Dispose the highlight layer and free resources.
  135502. */
  135503. dispose(): void;
  135504. /**
  135505. * Gets the class name of the effect layer
  135506. * @returns the string with the class name of the effect layer
  135507. */
  135508. getClassName(): string;
  135509. /**
  135510. * Creates an effect layer from parsed effect layer data
  135511. * @param parsedEffectLayer defines effect layer data
  135512. * @param scene defines the current scene
  135513. * @param rootUrl defines the root URL containing the effect layer information
  135514. * @returns a parsed effect Layer
  135515. */
  135516. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135517. }
  135518. }
  135519. declare module BABYLON {
  135520. interface AbstractScene {
  135521. /**
  135522. * The list of effect layers (highlights/glow) added to the scene
  135523. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135524. * @see https://doc.babylonjs.com/how_to/glow_layer
  135525. */
  135526. effectLayers: Array<EffectLayer>;
  135527. /**
  135528. * Removes the given effect layer from this scene.
  135529. * @param toRemove defines the effect layer to remove
  135530. * @returns the index of the removed effect layer
  135531. */
  135532. removeEffectLayer(toRemove: EffectLayer): number;
  135533. /**
  135534. * Adds the given effect layer to this scene
  135535. * @param newEffectLayer defines the effect layer to add
  135536. */
  135537. addEffectLayer(newEffectLayer: EffectLayer): void;
  135538. }
  135539. /**
  135540. * Defines the layer scene component responsible to manage any effect layers
  135541. * in a given scene.
  135542. */
  135543. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135544. /**
  135545. * The component name helpfull to identify the component in the list of scene components.
  135546. */
  135547. readonly name: string;
  135548. /**
  135549. * The scene the component belongs to.
  135550. */
  135551. scene: Scene;
  135552. private _engine;
  135553. private _renderEffects;
  135554. private _needStencil;
  135555. private _previousStencilState;
  135556. /**
  135557. * Creates a new instance of the component for the given scene
  135558. * @param scene Defines the scene to register the component in
  135559. */
  135560. constructor(scene: Scene);
  135561. /**
  135562. * Registers the component in a given scene
  135563. */
  135564. register(): void;
  135565. /**
  135566. * Rebuilds the elements related to this component in case of
  135567. * context lost for instance.
  135568. */
  135569. rebuild(): void;
  135570. /**
  135571. * Serializes the component data to the specified json object
  135572. * @param serializationObject The object to serialize to
  135573. */
  135574. serialize(serializationObject: any): void;
  135575. /**
  135576. * Adds all the elements from the container to the scene
  135577. * @param container the container holding the elements
  135578. */
  135579. addFromContainer(container: AbstractScene): void;
  135580. /**
  135581. * Removes all the elements in the container from the scene
  135582. * @param container contains the elements to remove
  135583. * @param dispose if the removed element should be disposed (default: false)
  135584. */
  135585. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135586. /**
  135587. * Disposes the component and the associated ressources.
  135588. */
  135589. dispose(): void;
  135590. private _isReadyForMesh;
  135591. private _renderMainTexture;
  135592. private _setStencil;
  135593. private _setStencilBack;
  135594. private _draw;
  135595. private _drawCamera;
  135596. private _drawRenderingGroup;
  135597. }
  135598. }
  135599. declare module BABYLON {
  135600. /** @hidden */
  135601. export var glowMapMergePixelShader: {
  135602. name: string;
  135603. shader: string;
  135604. };
  135605. }
  135606. declare module BABYLON {
  135607. /** @hidden */
  135608. export var glowMapMergeVertexShader: {
  135609. name: string;
  135610. shader: string;
  135611. };
  135612. }
  135613. declare module BABYLON {
  135614. interface AbstractScene {
  135615. /**
  135616. * Return a the first highlight layer of the scene with a given name.
  135617. * @param name The name of the highlight layer to look for.
  135618. * @return The highlight layer if found otherwise null.
  135619. */
  135620. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135621. }
  135622. /**
  135623. * Glow layer options. This helps customizing the behaviour
  135624. * of the glow layer.
  135625. */
  135626. export interface IGlowLayerOptions {
  135627. /**
  135628. * Multiplication factor apply to the canvas size to compute the render target size
  135629. * used to generated the glowing objects (the smaller the faster).
  135630. */
  135631. mainTextureRatio: number;
  135632. /**
  135633. * Enforces a fixed size texture to ensure resize independant blur.
  135634. */
  135635. mainTextureFixedSize?: number;
  135636. /**
  135637. * How big is the kernel of the blur texture.
  135638. */
  135639. blurKernelSize: number;
  135640. /**
  135641. * The camera attached to the layer.
  135642. */
  135643. camera: Nullable<Camera>;
  135644. /**
  135645. * Enable MSAA by chosing the number of samples.
  135646. */
  135647. mainTextureSamples?: number;
  135648. /**
  135649. * The rendering group to draw the layer in.
  135650. */
  135651. renderingGroupId: number;
  135652. }
  135653. /**
  135654. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135655. *
  135656. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135657. *
  135658. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135659. */
  135660. export class GlowLayer extends EffectLayer {
  135661. /**
  135662. * Effect Name of the layer.
  135663. */
  135664. static readonly EffectName: string;
  135665. /**
  135666. * The default blur kernel size used for the glow.
  135667. */
  135668. static DefaultBlurKernelSize: number;
  135669. /**
  135670. * The default texture size ratio used for the glow.
  135671. */
  135672. static DefaultTextureRatio: number;
  135673. /**
  135674. * Sets the kernel size of the blur.
  135675. */
  135676. set blurKernelSize(value: number);
  135677. /**
  135678. * Gets the kernel size of the blur.
  135679. */
  135680. get blurKernelSize(): number;
  135681. /**
  135682. * Sets the glow intensity.
  135683. */
  135684. set intensity(value: number);
  135685. /**
  135686. * Gets the glow intensity.
  135687. */
  135688. get intensity(): number;
  135689. private _options;
  135690. private _intensity;
  135691. private _horizontalBlurPostprocess1;
  135692. private _verticalBlurPostprocess1;
  135693. private _horizontalBlurPostprocess2;
  135694. private _verticalBlurPostprocess2;
  135695. private _blurTexture1;
  135696. private _blurTexture2;
  135697. private _postProcesses1;
  135698. private _postProcesses2;
  135699. private _includedOnlyMeshes;
  135700. private _excludedMeshes;
  135701. private _meshesUsingTheirOwnMaterials;
  135702. /**
  135703. * Callback used to let the user override the color selection on a per mesh basis
  135704. */
  135705. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135706. /**
  135707. * Callback used to let the user override the texture selection on a per mesh basis
  135708. */
  135709. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135710. /**
  135711. * Instantiates a new glow Layer and references it to the scene.
  135712. * @param name The name of the layer
  135713. * @param scene The scene to use the layer in
  135714. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135715. */
  135716. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135717. /**
  135718. * Get the effect name of the layer.
  135719. * @return The effect name
  135720. */
  135721. getEffectName(): string;
  135722. /**
  135723. * Create the merge effect. This is the shader use to blit the information back
  135724. * to the main canvas at the end of the scene rendering.
  135725. */
  135726. protected _createMergeEffect(): Effect;
  135727. /**
  135728. * Creates the render target textures and post processes used in the glow layer.
  135729. */
  135730. protected _createTextureAndPostProcesses(): void;
  135731. /**
  135732. * Checks for the readiness of the element composing the layer.
  135733. * @param subMesh the mesh to check for
  135734. * @param useInstances specify wether or not to use instances to render the mesh
  135735. * @param emissiveTexture the associated emissive texture used to generate the glow
  135736. * @return true if ready otherwise, false
  135737. */
  135738. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135739. /**
  135740. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135741. */
  135742. needStencil(): boolean;
  135743. /**
  135744. * Returns true if the mesh can be rendered, otherwise false.
  135745. * @param mesh The mesh to render
  135746. * @param material The material used on the mesh
  135747. * @returns true if it can be rendered otherwise false
  135748. */
  135749. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135750. /**
  135751. * Implementation specific of rendering the generating effect on the main canvas.
  135752. * @param effect The effect used to render through
  135753. */
  135754. protected _internalRender(effect: Effect): void;
  135755. /**
  135756. * Sets the required values for both the emissive texture and and the main color.
  135757. */
  135758. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135759. /**
  135760. * Returns true if the mesh should render, otherwise false.
  135761. * @param mesh The mesh to render
  135762. * @returns true if it should render otherwise false
  135763. */
  135764. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135765. /**
  135766. * Adds specific effects defines.
  135767. * @param defines The defines to add specifics to.
  135768. */
  135769. protected _addCustomEffectDefines(defines: string[]): void;
  135770. /**
  135771. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135772. * @param mesh The mesh to exclude from the glow layer
  135773. */
  135774. addExcludedMesh(mesh: Mesh): void;
  135775. /**
  135776. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135777. * @param mesh The mesh to remove
  135778. */
  135779. removeExcludedMesh(mesh: Mesh): void;
  135780. /**
  135781. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135782. * @param mesh The mesh to include in the glow layer
  135783. */
  135784. addIncludedOnlyMesh(mesh: Mesh): void;
  135785. /**
  135786. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135787. * @param mesh The mesh to remove
  135788. */
  135789. removeIncludedOnlyMesh(mesh: Mesh): void;
  135790. /**
  135791. * Determine if a given mesh will be used in the glow layer
  135792. * @param mesh The mesh to test
  135793. * @returns true if the mesh will be highlighted by the current glow layer
  135794. */
  135795. hasMesh(mesh: AbstractMesh): boolean;
  135796. /**
  135797. * Defines whether the current material of the mesh should be use to render the effect.
  135798. * @param mesh defines the current mesh to render
  135799. */
  135800. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135801. /**
  135802. * Add a mesh to be rendered through its own material and not with emissive only.
  135803. * @param mesh The mesh for which we need to use its material
  135804. */
  135805. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135806. /**
  135807. * Remove a mesh from being rendered through its own material and not with emissive only.
  135808. * @param mesh The mesh for which we need to not use its material
  135809. */
  135810. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135811. /**
  135812. * Free any resources and references associated to a mesh.
  135813. * Internal use
  135814. * @param mesh The mesh to free.
  135815. * @hidden
  135816. */
  135817. _disposeMesh(mesh: Mesh): void;
  135818. /**
  135819. * Gets the class name of the effect layer
  135820. * @returns the string with the class name of the effect layer
  135821. */
  135822. getClassName(): string;
  135823. /**
  135824. * Serializes this glow layer
  135825. * @returns a serialized glow layer object
  135826. */
  135827. serialize(): any;
  135828. /**
  135829. * Creates a Glow Layer from parsed glow layer data
  135830. * @param parsedGlowLayer defines glow layer data
  135831. * @param scene defines the current scene
  135832. * @param rootUrl defines the root URL containing the glow layer information
  135833. * @returns a parsed Glow Layer
  135834. */
  135835. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135836. }
  135837. }
  135838. declare module BABYLON {
  135839. /** @hidden */
  135840. export var glowBlurPostProcessPixelShader: {
  135841. name: string;
  135842. shader: string;
  135843. };
  135844. }
  135845. declare module BABYLON {
  135846. interface AbstractScene {
  135847. /**
  135848. * Return a the first highlight layer of the scene with a given name.
  135849. * @param name The name of the highlight layer to look for.
  135850. * @return The highlight layer if found otherwise null.
  135851. */
  135852. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135853. }
  135854. /**
  135855. * Highlight layer options. This helps customizing the behaviour
  135856. * of the highlight layer.
  135857. */
  135858. export interface IHighlightLayerOptions {
  135859. /**
  135860. * Multiplication factor apply to the canvas size to compute the render target size
  135861. * used to generated the glowing objects (the smaller the faster).
  135862. */
  135863. mainTextureRatio: number;
  135864. /**
  135865. * Enforces a fixed size texture to ensure resize independant blur.
  135866. */
  135867. mainTextureFixedSize?: number;
  135868. /**
  135869. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135870. * of the picture to blur (the smaller the faster).
  135871. */
  135872. blurTextureSizeRatio: number;
  135873. /**
  135874. * How big in texel of the blur texture is the vertical blur.
  135875. */
  135876. blurVerticalSize: number;
  135877. /**
  135878. * How big in texel of the blur texture is the horizontal blur.
  135879. */
  135880. blurHorizontalSize: number;
  135881. /**
  135882. * Alpha blending mode used to apply the blur. Default is combine.
  135883. */
  135884. alphaBlendingMode: number;
  135885. /**
  135886. * The camera attached to the layer.
  135887. */
  135888. camera: Nullable<Camera>;
  135889. /**
  135890. * Should we display highlight as a solid stroke?
  135891. */
  135892. isStroke?: boolean;
  135893. /**
  135894. * The rendering group to draw the layer in.
  135895. */
  135896. renderingGroupId: number;
  135897. }
  135898. /**
  135899. * The highlight layer Helps adding a glow effect around a mesh.
  135900. *
  135901. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135902. * glowy meshes to your scene.
  135903. *
  135904. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135905. */
  135906. export class HighlightLayer extends EffectLayer {
  135907. name: string;
  135908. /**
  135909. * Effect Name of the highlight layer.
  135910. */
  135911. static readonly EffectName: string;
  135912. /**
  135913. * The neutral color used during the preparation of the glow effect.
  135914. * This is black by default as the blend operation is a blend operation.
  135915. */
  135916. static NeutralColor: Color4;
  135917. /**
  135918. * Stencil value used for glowing meshes.
  135919. */
  135920. static GlowingMeshStencilReference: number;
  135921. /**
  135922. * Stencil value used for the other meshes in the scene.
  135923. */
  135924. static NormalMeshStencilReference: number;
  135925. /**
  135926. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135927. */
  135928. innerGlow: boolean;
  135929. /**
  135930. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135931. */
  135932. outerGlow: boolean;
  135933. /**
  135934. * Specifies the horizontal size of the blur.
  135935. */
  135936. set blurHorizontalSize(value: number);
  135937. /**
  135938. * Specifies the vertical size of the blur.
  135939. */
  135940. set blurVerticalSize(value: number);
  135941. /**
  135942. * Gets the horizontal size of the blur.
  135943. */
  135944. get blurHorizontalSize(): number;
  135945. /**
  135946. * Gets the vertical size of the blur.
  135947. */
  135948. get blurVerticalSize(): number;
  135949. /**
  135950. * An event triggered when the highlight layer is being blurred.
  135951. */
  135952. onBeforeBlurObservable: Observable<HighlightLayer>;
  135953. /**
  135954. * An event triggered when the highlight layer has been blurred.
  135955. */
  135956. onAfterBlurObservable: Observable<HighlightLayer>;
  135957. private _instanceGlowingMeshStencilReference;
  135958. private _options;
  135959. private _downSamplePostprocess;
  135960. private _horizontalBlurPostprocess;
  135961. private _verticalBlurPostprocess;
  135962. private _blurTexture;
  135963. private _meshes;
  135964. private _excludedMeshes;
  135965. /**
  135966. * Instantiates a new highlight Layer and references it to the scene..
  135967. * @param name The name of the layer
  135968. * @param scene The scene to use the layer in
  135969. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135970. */
  135971. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135972. /**
  135973. * Get the effect name of the layer.
  135974. * @return The effect name
  135975. */
  135976. getEffectName(): string;
  135977. /**
  135978. * Create the merge effect. This is the shader use to blit the information back
  135979. * to the main canvas at the end of the scene rendering.
  135980. */
  135981. protected _createMergeEffect(): Effect;
  135982. /**
  135983. * Creates the render target textures and post processes used in the highlight layer.
  135984. */
  135985. protected _createTextureAndPostProcesses(): void;
  135986. /**
  135987. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135988. */
  135989. needStencil(): boolean;
  135990. /**
  135991. * Checks for the readiness of the element composing the layer.
  135992. * @param subMesh the mesh to check for
  135993. * @param useInstances specify wether or not to use instances to render the mesh
  135994. * @param emissiveTexture the associated emissive texture used to generate the glow
  135995. * @return true if ready otherwise, false
  135996. */
  135997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135998. /**
  135999. * Implementation specific of rendering the generating effect on the main canvas.
  136000. * @param effect The effect used to render through
  136001. */
  136002. protected _internalRender(effect: Effect): void;
  136003. /**
  136004. * Returns true if the layer contains information to display, otherwise false.
  136005. */
  136006. shouldRender(): boolean;
  136007. /**
  136008. * Returns true if the mesh should render, otherwise false.
  136009. * @param mesh The mesh to render
  136010. * @returns true if it should render otherwise false
  136011. */
  136012. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136013. /**
  136014. * Returns true if the mesh can be rendered, otherwise false.
  136015. * @param mesh The mesh to render
  136016. * @param material The material used on the mesh
  136017. * @returns true if it can be rendered otherwise false
  136018. */
  136019. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136020. /**
  136021. * Adds specific effects defines.
  136022. * @param defines The defines to add specifics to.
  136023. */
  136024. protected _addCustomEffectDefines(defines: string[]): void;
  136025. /**
  136026. * Sets the required values for both the emissive texture and and the main color.
  136027. */
  136028. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136029. /**
  136030. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136031. * @param mesh The mesh to exclude from the highlight layer
  136032. */
  136033. addExcludedMesh(mesh: Mesh): void;
  136034. /**
  136035. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136036. * @param mesh The mesh to highlight
  136037. */
  136038. removeExcludedMesh(mesh: Mesh): void;
  136039. /**
  136040. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136041. * @param mesh mesh to test
  136042. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136043. */
  136044. hasMesh(mesh: AbstractMesh): boolean;
  136045. /**
  136046. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136047. * @param mesh The mesh to highlight
  136048. * @param color The color of the highlight
  136049. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136050. */
  136051. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136052. /**
  136053. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136054. * @param mesh The mesh to highlight
  136055. */
  136056. removeMesh(mesh: Mesh): void;
  136057. /**
  136058. * Remove all the meshes currently referenced in the highlight layer
  136059. */
  136060. removeAllMeshes(): void;
  136061. /**
  136062. * Force the stencil to the normal expected value for none glowing parts
  136063. */
  136064. private _defaultStencilReference;
  136065. /**
  136066. * Free any resources and references associated to a mesh.
  136067. * Internal use
  136068. * @param mesh The mesh to free.
  136069. * @hidden
  136070. */
  136071. _disposeMesh(mesh: Mesh): void;
  136072. /**
  136073. * Dispose the highlight layer and free resources.
  136074. */
  136075. dispose(): void;
  136076. /**
  136077. * Gets the class name of the effect layer
  136078. * @returns the string with the class name of the effect layer
  136079. */
  136080. getClassName(): string;
  136081. /**
  136082. * Serializes this Highlight layer
  136083. * @returns a serialized Highlight layer object
  136084. */
  136085. serialize(): any;
  136086. /**
  136087. * Creates a Highlight layer from parsed Highlight layer data
  136088. * @param parsedHightlightLayer defines the Highlight layer data
  136089. * @param scene defines the current scene
  136090. * @param rootUrl defines the root URL containing the Highlight layer information
  136091. * @returns a parsed Highlight layer
  136092. */
  136093. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136094. }
  136095. }
  136096. declare module BABYLON {
  136097. interface AbstractScene {
  136098. /**
  136099. * The list of layers (background and foreground) of the scene
  136100. */
  136101. layers: Array<Layer>;
  136102. }
  136103. /**
  136104. * Defines the layer scene component responsible to manage any layers
  136105. * in a given scene.
  136106. */
  136107. export class LayerSceneComponent implements ISceneComponent {
  136108. /**
  136109. * The component name helpfull to identify the component in the list of scene components.
  136110. */
  136111. readonly name: string;
  136112. /**
  136113. * The scene the component belongs to.
  136114. */
  136115. scene: Scene;
  136116. private _engine;
  136117. /**
  136118. * Creates a new instance of the component for the given scene
  136119. * @param scene Defines the scene to register the component in
  136120. */
  136121. constructor(scene: Scene);
  136122. /**
  136123. * Registers the component in a given scene
  136124. */
  136125. register(): void;
  136126. /**
  136127. * Rebuilds the elements related to this component in case of
  136128. * context lost for instance.
  136129. */
  136130. rebuild(): void;
  136131. /**
  136132. * Disposes the component and the associated ressources.
  136133. */
  136134. dispose(): void;
  136135. private _draw;
  136136. private _drawCameraPredicate;
  136137. private _drawCameraBackground;
  136138. private _drawCameraForeground;
  136139. private _drawRenderTargetPredicate;
  136140. private _drawRenderTargetBackground;
  136141. private _drawRenderTargetForeground;
  136142. /**
  136143. * Adds all the elements from the container to the scene
  136144. * @param container the container holding the elements
  136145. */
  136146. addFromContainer(container: AbstractScene): void;
  136147. /**
  136148. * Removes all the elements in the container from the scene
  136149. * @param container contains the elements to remove
  136150. * @param dispose if the removed element should be disposed (default: false)
  136151. */
  136152. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136153. }
  136154. }
  136155. declare module BABYLON {
  136156. /** @hidden */
  136157. export var layerPixelShader: {
  136158. name: string;
  136159. shader: string;
  136160. };
  136161. }
  136162. declare module BABYLON {
  136163. /** @hidden */
  136164. export var layerVertexShader: {
  136165. name: string;
  136166. shader: string;
  136167. };
  136168. }
  136169. declare module BABYLON {
  136170. /**
  136171. * This represents a full screen 2d layer.
  136172. * This can be useful to display a picture in the background of your scene for instance.
  136173. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136174. */
  136175. export class Layer {
  136176. /**
  136177. * Define the name of the layer.
  136178. */
  136179. name: string;
  136180. /**
  136181. * Define the texture the layer should display.
  136182. */
  136183. texture: Nullable<Texture>;
  136184. /**
  136185. * Is the layer in background or foreground.
  136186. */
  136187. isBackground: boolean;
  136188. /**
  136189. * Define the color of the layer (instead of texture).
  136190. */
  136191. color: Color4;
  136192. /**
  136193. * Define the scale of the layer in order to zoom in out of the texture.
  136194. */
  136195. scale: Vector2;
  136196. /**
  136197. * Define an offset for the layer in order to shift the texture.
  136198. */
  136199. offset: Vector2;
  136200. /**
  136201. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136202. */
  136203. alphaBlendingMode: number;
  136204. /**
  136205. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136206. * Alpha test will not mix with the background color in case of transparency.
  136207. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136208. */
  136209. alphaTest: boolean;
  136210. /**
  136211. * Define a mask to restrict the layer to only some of the scene cameras.
  136212. */
  136213. layerMask: number;
  136214. /**
  136215. * Define the list of render target the layer is visible into.
  136216. */
  136217. renderTargetTextures: RenderTargetTexture[];
  136218. /**
  136219. * Define if the layer is only used in renderTarget or if it also
  136220. * renders in the main frame buffer of the canvas.
  136221. */
  136222. renderOnlyInRenderTargetTextures: boolean;
  136223. private _scene;
  136224. private _vertexBuffers;
  136225. private _indexBuffer;
  136226. private _effect;
  136227. private _previousDefines;
  136228. /**
  136229. * An event triggered when the layer is disposed.
  136230. */
  136231. onDisposeObservable: Observable<Layer>;
  136232. private _onDisposeObserver;
  136233. /**
  136234. * Back compatibility with callback before the onDisposeObservable existed.
  136235. * The set callback will be triggered when the layer has been disposed.
  136236. */
  136237. set onDispose(callback: () => void);
  136238. /**
  136239. * An event triggered before rendering the scene
  136240. */
  136241. onBeforeRenderObservable: Observable<Layer>;
  136242. private _onBeforeRenderObserver;
  136243. /**
  136244. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136245. * The set callback will be triggered just before rendering the layer.
  136246. */
  136247. set onBeforeRender(callback: () => void);
  136248. /**
  136249. * An event triggered after rendering the scene
  136250. */
  136251. onAfterRenderObservable: Observable<Layer>;
  136252. private _onAfterRenderObserver;
  136253. /**
  136254. * Back compatibility with callback before the onAfterRenderObservable existed.
  136255. * The set callback will be triggered just after rendering the layer.
  136256. */
  136257. set onAfterRender(callback: () => void);
  136258. /**
  136259. * Instantiates a new layer.
  136260. * This represents a full screen 2d layer.
  136261. * This can be useful to display a picture in the background of your scene for instance.
  136262. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136263. * @param name Define the name of the layer in the scene
  136264. * @param imgUrl Define the url of the texture to display in the layer
  136265. * @param scene Define the scene the layer belongs to
  136266. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136267. * @param color Defines a color for the layer
  136268. */
  136269. constructor(
  136270. /**
  136271. * Define the name of the layer.
  136272. */
  136273. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136274. private _createIndexBuffer;
  136275. /** @hidden */
  136276. _rebuild(): void;
  136277. /**
  136278. * Renders the layer in the scene.
  136279. */
  136280. render(): void;
  136281. /**
  136282. * Disposes and releases the associated ressources.
  136283. */
  136284. dispose(): void;
  136285. }
  136286. }
  136287. declare module BABYLON {
  136288. /** @hidden */
  136289. export var lensFlarePixelShader: {
  136290. name: string;
  136291. shader: string;
  136292. };
  136293. }
  136294. declare module BABYLON {
  136295. /** @hidden */
  136296. export var lensFlareVertexShader: {
  136297. name: string;
  136298. shader: string;
  136299. };
  136300. }
  136301. declare module BABYLON {
  136302. /**
  136303. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136304. * It is usually composed of several `lensFlare`.
  136305. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136306. */
  136307. export class LensFlareSystem {
  136308. /**
  136309. * Define the name of the lens flare system
  136310. */
  136311. name: string;
  136312. /**
  136313. * List of lens flares used in this system.
  136314. */
  136315. lensFlares: LensFlare[];
  136316. /**
  136317. * Define a limit from the border the lens flare can be visible.
  136318. */
  136319. borderLimit: number;
  136320. /**
  136321. * Define a viewport border we do not want to see the lens flare in.
  136322. */
  136323. viewportBorder: number;
  136324. /**
  136325. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136326. */
  136327. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136328. /**
  136329. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136330. */
  136331. layerMask: number;
  136332. /**
  136333. * Define the id of the lens flare system in the scene.
  136334. * (equal to name by default)
  136335. */
  136336. id: string;
  136337. private _scene;
  136338. private _emitter;
  136339. private _vertexBuffers;
  136340. private _indexBuffer;
  136341. private _effect;
  136342. private _positionX;
  136343. private _positionY;
  136344. private _isEnabled;
  136345. /** @hidden */
  136346. static _SceneComponentInitialization: (scene: Scene) => void;
  136347. /**
  136348. * Instantiates a lens flare system.
  136349. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136350. * It is usually composed of several `lensFlare`.
  136351. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136352. * @param name Define the name of the lens flare system in the scene
  136353. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136354. * @param scene Define the scene the lens flare system belongs to
  136355. */
  136356. constructor(
  136357. /**
  136358. * Define the name of the lens flare system
  136359. */
  136360. name: string, emitter: any, scene: Scene);
  136361. /**
  136362. * Define if the lens flare system is enabled.
  136363. */
  136364. get isEnabled(): boolean;
  136365. set isEnabled(value: boolean);
  136366. /**
  136367. * Get the scene the effects belongs to.
  136368. * @returns the scene holding the lens flare system
  136369. */
  136370. getScene(): Scene;
  136371. /**
  136372. * Get the emitter of the lens flare system.
  136373. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136374. * @returns the emitter of the lens flare system
  136375. */
  136376. getEmitter(): any;
  136377. /**
  136378. * Set the emitter of the lens flare system.
  136379. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136380. * @param newEmitter Define the new emitter of the system
  136381. */
  136382. setEmitter(newEmitter: any): void;
  136383. /**
  136384. * Get the lens flare system emitter position.
  136385. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136386. * @returns the position
  136387. */
  136388. getEmitterPosition(): Vector3;
  136389. /**
  136390. * @hidden
  136391. */
  136392. computeEffectivePosition(globalViewport: Viewport): boolean;
  136393. /** @hidden */
  136394. _isVisible(): boolean;
  136395. /**
  136396. * @hidden
  136397. */
  136398. render(): boolean;
  136399. /**
  136400. * Dispose and release the lens flare with its associated resources.
  136401. */
  136402. dispose(): void;
  136403. /**
  136404. * Parse a lens flare system from a JSON repressentation
  136405. * @param parsedLensFlareSystem Define the JSON to parse
  136406. * @param scene Define the scene the parsed system should be instantiated in
  136407. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136408. * @returns the parsed system
  136409. */
  136410. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136411. /**
  136412. * Serialize the current Lens Flare System into a JSON representation.
  136413. * @returns the serialized JSON
  136414. */
  136415. serialize(): any;
  136416. }
  136417. }
  136418. declare module BABYLON {
  136419. /**
  136420. * This represents one of the lens effect in a `lensFlareSystem`.
  136421. * It controls one of the indiviual texture used in the effect.
  136422. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136423. */
  136424. export class LensFlare {
  136425. /**
  136426. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136427. */
  136428. size: number;
  136429. /**
  136430. * 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.
  136431. */
  136432. position: number;
  136433. /**
  136434. * Define the lens color.
  136435. */
  136436. color: Color3;
  136437. /**
  136438. * Define the lens texture.
  136439. */
  136440. texture: Nullable<Texture>;
  136441. /**
  136442. * Define the alpha mode to render this particular lens.
  136443. */
  136444. alphaMode: number;
  136445. private _system;
  136446. /**
  136447. * Creates a new Lens Flare.
  136448. * This represents one of the lens effect in a `lensFlareSystem`.
  136449. * It controls one of the indiviual texture used in the effect.
  136450. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136451. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136452. * @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.
  136453. * @param color Define the lens color
  136454. * @param imgUrl Define the lens texture url
  136455. * @param system Define the `lensFlareSystem` this flare is part of
  136456. * @returns The newly created Lens Flare
  136457. */
  136458. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136459. /**
  136460. * Instantiates a new Lens Flare.
  136461. * This represents one of the lens effect in a `lensFlareSystem`.
  136462. * It controls one of the indiviual texture used in the effect.
  136463. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136464. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136465. * @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.
  136466. * @param color Define the lens color
  136467. * @param imgUrl Define the lens texture url
  136468. * @param system Define the `lensFlareSystem` this flare is part of
  136469. */
  136470. constructor(
  136471. /**
  136472. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136473. */
  136474. size: number,
  136475. /**
  136476. * 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.
  136477. */
  136478. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136479. /**
  136480. * Dispose and release the lens flare with its associated resources.
  136481. */
  136482. dispose(): void;
  136483. }
  136484. }
  136485. declare module BABYLON {
  136486. interface AbstractScene {
  136487. /**
  136488. * The list of lens flare system added to the scene
  136489. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136490. */
  136491. lensFlareSystems: Array<LensFlareSystem>;
  136492. /**
  136493. * Removes the given lens flare system from this scene.
  136494. * @param toRemove The lens flare system to remove
  136495. * @returns The index of the removed lens flare system
  136496. */
  136497. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136498. /**
  136499. * Adds the given lens flare system to this scene
  136500. * @param newLensFlareSystem The lens flare system to add
  136501. */
  136502. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136503. /**
  136504. * Gets a lens flare system using its name
  136505. * @param name defines the name to look for
  136506. * @returns the lens flare system or null if not found
  136507. */
  136508. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136509. /**
  136510. * Gets a lens flare system using its id
  136511. * @param id defines the id to look for
  136512. * @returns the lens flare system or null if not found
  136513. */
  136514. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136515. }
  136516. /**
  136517. * Defines the lens flare scene component responsible to manage any lens flares
  136518. * in a given scene.
  136519. */
  136520. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136521. /**
  136522. * The component name helpfull to identify the component in the list of scene components.
  136523. */
  136524. readonly name: string;
  136525. /**
  136526. * The scene the component belongs to.
  136527. */
  136528. scene: Scene;
  136529. /**
  136530. * Creates a new instance of the component for the given scene
  136531. * @param scene Defines the scene to register the component in
  136532. */
  136533. constructor(scene: Scene);
  136534. /**
  136535. * Registers the component in a given scene
  136536. */
  136537. register(): void;
  136538. /**
  136539. * Rebuilds the elements related to this component in case of
  136540. * context lost for instance.
  136541. */
  136542. rebuild(): void;
  136543. /**
  136544. * Adds all the elements from the container to the scene
  136545. * @param container the container holding the elements
  136546. */
  136547. addFromContainer(container: AbstractScene): void;
  136548. /**
  136549. * Removes all the elements in the container from the scene
  136550. * @param container contains the elements to remove
  136551. * @param dispose if the removed element should be disposed (default: false)
  136552. */
  136553. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136554. /**
  136555. * Serializes the component data to the specified json object
  136556. * @param serializationObject The object to serialize to
  136557. */
  136558. serialize(serializationObject: any): void;
  136559. /**
  136560. * Disposes the component and the associated ressources.
  136561. */
  136562. dispose(): void;
  136563. private _draw;
  136564. }
  136565. }
  136566. declare module BABYLON {
  136567. /** @hidden */
  136568. export var depthPixelShader: {
  136569. name: string;
  136570. shader: string;
  136571. };
  136572. }
  136573. declare module BABYLON {
  136574. /** @hidden */
  136575. export var depthVertexShader: {
  136576. name: string;
  136577. shader: string;
  136578. };
  136579. }
  136580. declare module BABYLON {
  136581. /**
  136582. * This represents a depth renderer in Babylon.
  136583. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136584. */
  136585. export class DepthRenderer {
  136586. private _scene;
  136587. private _depthMap;
  136588. private _effect;
  136589. private readonly _storeNonLinearDepth;
  136590. private readonly _clearColor;
  136591. /** Get if the depth renderer is using packed depth or not */
  136592. readonly isPacked: boolean;
  136593. private _cachedDefines;
  136594. private _camera;
  136595. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136596. enabled: boolean;
  136597. /**
  136598. * Specifiess that the depth renderer will only be used within
  136599. * the camera it is created for.
  136600. * This can help forcing its rendering during the camera processing.
  136601. */
  136602. useOnlyInActiveCamera: boolean;
  136603. /** @hidden */
  136604. static _SceneComponentInitialization: (scene: Scene) => void;
  136605. /**
  136606. * Instantiates a depth renderer
  136607. * @param scene The scene the renderer belongs to
  136608. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136609. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136610. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136611. */
  136612. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136613. /**
  136614. * Creates the depth rendering effect and checks if the effect is ready.
  136615. * @param subMesh The submesh to be used to render the depth map of
  136616. * @param useInstances If multiple world instances should be used
  136617. * @returns if the depth renderer is ready to render the depth map
  136618. */
  136619. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136620. /**
  136621. * Gets the texture which the depth map will be written to.
  136622. * @returns The depth map texture
  136623. */
  136624. getDepthMap(): RenderTargetTexture;
  136625. /**
  136626. * Disposes of the depth renderer.
  136627. */
  136628. dispose(): void;
  136629. }
  136630. }
  136631. declare module BABYLON {
  136632. /** @hidden */
  136633. export var minmaxReduxPixelShader: {
  136634. name: string;
  136635. shader: string;
  136636. };
  136637. }
  136638. declare module BABYLON {
  136639. /**
  136640. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136641. * and maximum values from all values of the texture.
  136642. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136643. * The source values are read from the red channel of the texture.
  136644. */
  136645. export class MinMaxReducer {
  136646. /**
  136647. * Observable triggered when the computation has been performed
  136648. */
  136649. onAfterReductionPerformed: Observable<{
  136650. min: number;
  136651. max: number;
  136652. }>;
  136653. protected _camera: Camera;
  136654. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136655. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136656. protected _postProcessManager: PostProcessManager;
  136657. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136658. protected _forceFullscreenViewport: boolean;
  136659. /**
  136660. * Creates a min/max reducer
  136661. * @param camera The camera to use for the post processes
  136662. */
  136663. constructor(camera: Camera);
  136664. /**
  136665. * Gets the texture used to read the values from.
  136666. */
  136667. get sourceTexture(): Nullable<RenderTargetTexture>;
  136668. /**
  136669. * Sets the source texture to read the values from.
  136670. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136671. * because in such textures '1' value must not be taken into account to compute the maximum
  136672. * as this value is used to clear the texture.
  136673. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136674. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136675. * @param depthRedux Indicates if the texture is a depth texture or not
  136676. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136677. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136678. */
  136679. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136680. /**
  136681. * Defines the refresh rate of the computation.
  136682. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136683. */
  136684. get refreshRate(): number;
  136685. set refreshRate(value: number);
  136686. protected _activated: boolean;
  136687. /**
  136688. * Gets the activation status of the reducer
  136689. */
  136690. get activated(): boolean;
  136691. /**
  136692. * Activates the reduction computation.
  136693. * When activated, the observers registered in onAfterReductionPerformed are
  136694. * called after the compuation is performed
  136695. */
  136696. activate(): void;
  136697. /**
  136698. * Deactivates the reduction computation.
  136699. */
  136700. deactivate(): void;
  136701. /**
  136702. * Disposes the min/max reducer
  136703. * @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.
  136704. */
  136705. dispose(disposeAll?: boolean): void;
  136706. }
  136707. }
  136708. declare module BABYLON {
  136709. /**
  136710. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136711. */
  136712. export class DepthReducer extends MinMaxReducer {
  136713. private _depthRenderer;
  136714. private _depthRendererId;
  136715. /**
  136716. * Gets the depth renderer used for the computation.
  136717. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136718. */
  136719. get depthRenderer(): Nullable<DepthRenderer>;
  136720. /**
  136721. * Creates a depth reducer
  136722. * @param camera The camera used to render the depth texture
  136723. */
  136724. constructor(camera: Camera);
  136725. /**
  136726. * Sets the depth renderer to use to generate the depth map
  136727. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136728. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136729. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136730. */
  136731. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136732. /** @hidden */
  136733. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136734. /**
  136735. * Activates the reduction computation.
  136736. * When activated, the observers registered in onAfterReductionPerformed are
  136737. * called after the compuation is performed
  136738. */
  136739. activate(): void;
  136740. /**
  136741. * Deactivates the reduction computation.
  136742. */
  136743. deactivate(): void;
  136744. /**
  136745. * Disposes the depth reducer
  136746. * @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.
  136747. */
  136748. dispose(disposeAll?: boolean): void;
  136749. }
  136750. }
  136751. declare module BABYLON {
  136752. /**
  136753. * A CSM implementation allowing casting shadows on large scenes.
  136754. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136755. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136756. */
  136757. export class CascadedShadowGenerator extends ShadowGenerator {
  136758. private static readonly frustumCornersNDCSpace;
  136759. /**
  136760. * Name of the CSM class
  136761. */
  136762. static CLASSNAME: string;
  136763. /**
  136764. * Defines the default number of cascades used by the CSM.
  136765. */
  136766. static readonly DEFAULT_CASCADES_COUNT: number;
  136767. /**
  136768. * Defines the minimum number of cascades used by the CSM.
  136769. */
  136770. static readonly MIN_CASCADES_COUNT: number;
  136771. /**
  136772. * Defines the maximum number of cascades used by the CSM.
  136773. */
  136774. static readonly MAX_CASCADES_COUNT: number;
  136775. protected _validateFilter(filter: number): number;
  136776. /**
  136777. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136778. */
  136779. penumbraDarkness: number;
  136780. private _numCascades;
  136781. /**
  136782. * Gets or set the number of cascades used by the CSM.
  136783. */
  136784. get numCascades(): number;
  136785. set numCascades(value: number);
  136786. /**
  136787. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136788. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136789. */
  136790. stabilizeCascades: boolean;
  136791. private _freezeShadowCastersBoundingInfo;
  136792. private _freezeShadowCastersBoundingInfoObservable;
  136793. /**
  136794. * Enables or disables the shadow casters bounding info computation.
  136795. * If your shadow casters don't move, you can disable this feature.
  136796. * If it is enabled, the bounding box computation is done every frame.
  136797. */
  136798. get freezeShadowCastersBoundingInfo(): boolean;
  136799. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136800. private _scbiMin;
  136801. private _scbiMax;
  136802. protected _computeShadowCastersBoundingInfo(): void;
  136803. protected _shadowCastersBoundingInfo: BoundingInfo;
  136804. /**
  136805. * Gets or sets the shadow casters bounding info.
  136806. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136807. * so that the system won't overwrite the bounds you provide
  136808. */
  136809. get shadowCastersBoundingInfo(): BoundingInfo;
  136810. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136811. protected _breaksAreDirty: boolean;
  136812. protected _minDistance: number;
  136813. protected _maxDistance: number;
  136814. /**
  136815. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136816. *
  136817. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136818. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136819. * @param min minimal distance for the breaks (default to 0.)
  136820. * @param max maximal distance for the breaks (default to 1.)
  136821. */
  136822. setMinMaxDistance(min: number, max: number): void;
  136823. /** Gets the minimal distance used in the cascade break computation */
  136824. get minDistance(): number;
  136825. /** Gets the maximal distance used in the cascade break computation */
  136826. get maxDistance(): number;
  136827. /**
  136828. * Gets the class name of that object
  136829. * @returns "CascadedShadowGenerator"
  136830. */
  136831. getClassName(): string;
  136832. private _cascadeMinExtents;
  136833. private _cascadeMaxExtents;
  136834. /**
  136835. * Gets a cascade minimum extents
  136836. * @param cascadeIndex index of the cascade
  136837. * @returns the minimum cascade extents
  136838. */
  136839. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136840. /**
  136841. * Gets a cascade maximum extents
  136842. * @param cascadeIndex index of the cascade
  136843. * @returns the maximum cascade extents
  136844. */
  136845. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136846. private _cascades;
  136847. private _currentLayer;
  136848. private _viewSpaceFrustumsZ;
  136849. private _viewMatrices;
  136850. private _projectionMatrices;
  136851. private _transformMatrices;
  136852. private _transformMatricesAsArray;
  136853. private _frustumLengths;
  136854. private _lightSizeUVCorrection;
  136855. private _depthCorrection;
  136856. private _frustumCornersWorldSpace;
  136857. private _frustumCenter;
  136858. private _shadowCameraPos;
  136859. private _shadowMaxZ;
  136860. /**
  136861. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136862. * It defaults to camera.maxZ
  136863. */
  136864. get shadowMaxZ(): number;
  136865. /**
  136866. * Sets the shadow max z distance.
  136867. */
  136868. set shadowMaxZ(value: number);
  136869. protected _debug: boolean;
  136870. /**
  136871. * Gets or sets the debug flag.
  136872. * When enabled, the cascades are materialized by different colors on the screen.
  136873. */
  136874. get debug(): boolean;
  136875. set debug(dbg: boolean);
  136876. private _depthClamp;
  136877. /**
  136878. * Gets or sets the depth clamping value.
  136879. *
  136880. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136881. * to account for the shadow casters far away.
  136882. *
  136883. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136884. */
  136885. get depthClamp(): boolean;
  136886. set depthClamp(value: boolean);
  136887. private _cascadeBlendPercentage;
  136888. /**
  136889. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136890. * It defaults to 0.1 (10% blending).
  136891. */
  136892. get cascadeBlendPercentage(): number;
  136893. set cascadeBlendPercentage(value: number);
  136894. private _lambda;
  136895. /**
  136896. * Gets or set the lambda parameter.
  136897. * This parameter is used to split the camera frustum and create the cascades.
  136898. * 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.
  136899. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136900. */
  136901. get lambda(): number;
  136902. set lambda(value: number);
  136903. /**
  136904. * Gets the view matrix corresponding to a given cascade
  136905. * @param cascadeNum cascade to retrieve the view matrix from
  136906. * @returns the cascade view matrix
  136907. */
  136908. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136909. /**
  136910. * Gets the projection matrix corresponding to a given cascade
  136911. * @param cascadeNum cascade to retrieve the projection matrix from
  136912. * @returns the cascade projection matrix
  136913. */
  136914. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136915. /**
  136916. * Gets the transformation matrix corresponding to a given cascade
  136917. * @param cascadeNum cascade to retrieve the transformation matrix from
  136918. * @returns the cascade transformation matrix
  136919. */
  136920. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136921. private _depthRenderer;
  136922. /**
  136923. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136924. *
  136925. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136926. *
  136927. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136928. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136929. * @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
  136930. */
  136931. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136932. private _depthReducer;
  136933. private _autoCalcDepthBounds;
  136934. /**
  136935. * Gets or sets the autoCalcDepthBounds property.
  136936. *
  136937. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136938. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136939. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136940. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136941. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136942. */
  136943. get autoCalcDepthBounds(): boolean;
  136944. set autoCalcDepthBounds(value: boolean);
  136945. /**
  136946. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136947. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136948. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136949. * for setting the refresh rate on the renderer yourself!
  136950. */
  136951. get autoCalcDepthBoundsRefreshRate(): number;
  136952. set autoCalcDepthBoundsRefreshRate(value: number);
  136953. /**
  136954. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136955. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136956. * you change the camera near/far planes!
  136957. */
  136958. splitFrustum(): void;
  136959. private _splitFrustum;
  136960. private _computeMatrices;
  136961. private _computeFrustumInWorldSpace;
  136962. private _computeCascadeFrustum;
  136963. /**
  136964. * Support test.
  136965. */
  136966. static get IsSupported(): boolean;
  136967. /** @hidden */
  136968. static _SceneComponentInitialization: (scene: Scene) => void;
  136969. /**
  136970. * Creates a Cascaded Shadow Generator object.
  136971. * A ShadowGenerator is the required tool to use the shadows.
  136972. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136973. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136974. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136975. * @param light The directional light object generating the shadows.
  136976. * @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.
  136977. */
  136978. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136979. protected _initializeGenerator(): void;
  136980. protected _createTargetRenderTexture(): void;
  136981. protected _initializeShadowMap(): void;
  136982. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136983. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136984. /**
  136985. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136986. * @param defines Defines of the material we want to update
  136987. * @param lightIndex Index of the light in the enabled light list of the material
  136988. */
  136989. prepareDefines(defines: any, lightIndex: number): void;
  136990. /**
  136991. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136992. * defined in the generator but impacting the effect).
  136993. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136994. * @param effect The effect we are binfing the information for
  136995. */
  136996. bindShadowLight(lightIndex: string, effect: Effect): void;
  136997. /**
  136998. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136999. * (eq to view projection * shadow projection matrices)
  137000. * @returns The transform matrix used to create the shadow map
  137001. */
  137002. getTransformMatrix(): Matrix;
  137003. /**
  137004. * Disposes the ShadowGenerator.
  137005. * Returns nothing.
  137006. */
  137007. dispose(): void;
  137008. /**
  137009. * Serializes the shadow generator setup to a json object.
  137010. * @returns The serialized JSON object
  137011. */
  137012. serialize(): any;
  137013. /**
  137014. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137015. * @param parsedShadowGenerator The JSON object to parse
  137016. * @param scene The scene to create the shadow map for
  137017. * @returns The parsed shadow generator
  137018. */
  137019. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137020. }
  137021. }
  137022. declare module BABYLON {
  137023. /**
  137024. * Defines the shadow generator component responsible to manage any shadow generators
  137025. * in a given scene.
  137026. */
  137027. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137028. /**
  137029. * The component name helpfull to identify the component in the list of scene components.
  137030. */
  137031. readonly name: string;
  137032. /**
  137033. * The scene the component belongs to.
  137034. */
  137035. scene: Scene;
  137036. /**
  137037. * Creates a new instance of the component for the given scene
  137038. * @param scene Defines the scene to register the component in
  137039. */
  137040. constructor(scene: Scene);
  137041. /**
  137042. * Registers the component in a given scene
  137043. */
  137044. register(): void;
  137045. /**
  137046. * Rebuilds the elements related to this component in case of
  137047. * context lost for instance.
  137048. */
  137049. rebuild(): void;
  137050. /**
  137051. * Serializes the component data to the specified json object
  137052. * @param serializationObject The object to serialize to
  137053. */
  137054. serialize(serializationObject: any): void;
  137055. /**
  137056. * Adds all the elements from the container to the scene
  137057. * @param container the container holding the elements
  137058. */
  137059. addFromContainer(container: AbstractScene): void;
  137060. /**
  137061. * Removes all the elements in the container from the scene
  137062. * @param container contains the elements to remove
  137063. * @param dispose if the removed element should be disposed (default: false)
  137064. */
  137065. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137066. /**
  137067. * Rebuilds the elements related to this component in case of
  137068. * context lost for instance.
  137069. */
  137070. dispose(): void;
  137071. private _gatherRenderTargets;
  137072. }
  137073. }
  137074. declare module BABYLON {
  137075. /**
  137076. * A point light is a light defined by an unique point in world space.
  137077. * The light is emitted in every direction from this point.
  137078. * A good example of a point light is a standard light bulb.
  137079. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137080. */
  137081. export class PointLight extends ShadowLight {
  137082. private _shadowAngle;
  137083. /**
  137084. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137085. * This specifies what angle the shadow will use to be created.
  137086. *
  137087. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137088. */
  137089. get shadowAngle(): number;
  137090. /**
  137091. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137092. * This specifies what angle the shadow will use to be created.
  137093. *
  137094. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137095. */
  137096. set shadowAngle(value: number);
  137097. /**
  137098. * Gets the direction if it has been set.
  137099. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137100. */
  137101. get direction(): Vector3;
  137102. /**
  137103. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137104. */
  137105. set direction(value: Vector3);
  137106. /**
  137107. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137108. * A PointLight emits the light in every direction.
  137109. * It can cast shadows.
  137110. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137111. * ```javascript
  137112. * var pointLight = new PointLight("pl", camera.position, scene);
  137113. * ```
  137114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137115. * @param name The light friendly name
  137116. * @param position The position of the point light in the scene
  137117. * @param scene The scene the lights belongs to
  137118. */
  137119. constructor(name: string, position: Vector3, scene: Scene);
  137120. /**
  137121. * Returns the string "PointLight"
  137122. * @returns the class name
  137123. */
  137124. getClassName(): string;
  137125. /**
  137126. * Returns the integer 0.
  137127. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137128. */
  137129. getTypeID(): number;
  137130. /**
  137131. * Specifies wether or not the shadowmap should be a cube texture.
  137132. * @returns true if the shadowmap needs to be a cube texture.
  137133. */
  137134. needCube(): boolean;
  137135. /**
  137136. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137139. */
  137140. getShadowDirection(faceIndex?: number): Vector3;
  137141. /**
  137142. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137143. * - fov = PI / 2
  137144. * - aspect ratio : 1.0
  137145. * - z-near and far equal to the active camera minZ and maxZ.
  137146. * Returns the PointLight.
  137147. */
  137148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137149. protected _buildUniformLayout(): void;
  137150. /**
  137151. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137152. * @param effect The effect to update
  137153. * @param lightIndex The index of the light in the effect to update
  137154. * @returns The point light
  137155. */
  137156. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137157. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137158. /**
  137159. * Prepares the list of defines specific to the light type.
  137160. * @param defines the list of defines
  137161. * @param lightIndex defines the index of the light for the effect
  137162. */
  137163. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137164. }
  137165. }
  137166. declare module BABYLON {
  137167. /**
  137168. * Header information of HDR texture files.
  137169. */
  137170. export interface HDRInfo {
  137171. /**
  137172. * The height of the texture in pixels.
  137173. */
  137174. height: number;
  137175. /**
  137176. * The width of the texture in pixels.
  137177. */
  137178. width: number;
  137179. /**
  137180. * The index of the beginning of the data in the binary file.
  137181. */
  137182. dataPosition: number;
  137183. }
  137184. /**
  137185. * This groups tools to convert HDR texture to native colors array.
  137186. */
  137187. export class HDRTools {
  137188. private static Ldexp;
  137189. private static Rgbe2float;
  137190. private static readStringLine;
  137191. /**
  137192. * Reads header information from an RGBE texture stored in a native array.
  137193. * More information on this format are available here:
  137194. * https://en.wikipedia.org/wiki/RGBE_image_format
  137195. *
  137196. * @param uint8array The binary file stored in native array.
  137197. * @return The header information.
  137198. */
  137199. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137200. /**
  137201. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137202. * This RGBE texture needs to store the information as a panorama.
  137203. *
  137204. * More information on this format are available here:
  137205. * https://en.wikipedia.org/wiki/RGBE_image_format
  137206. *
  137207. * @param buffer The binary file stored in an array buffer.
  137208. * @param size The expected size of the extracted cubemap.
  137209. * @return The Cube Map information.
  137210. */
  137211. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137212. /**
  137213. * Returns the pixels data extracted from an RGBE texture.
  137214. * This pixels will be stored left to right up to down in the R G B order in one array.
  137215. *
  137216. * More information on this format are available here:
  137217. * https://en.wikipedia.org/wiki/RGBE_image_format
  137218. *
  137219. * @param uint8array The binary file stored in an array buffer.
  137220. * @param hdrInfo The header information of the file.
  137221. * @return The pixels data in RGB right to left up to down order.
  137222. */
  137223. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137224. private static RGBE_ReadPixels_RLE;
  137225. }
  137226. }
  137227. declare module BABYLON {
  137228. /**
  137229. * Effect Render Options
  137230. */
  137231. export interface IEffectRendererOptions {
  137232. /**
  137233. * Defines the vertices positions.
  137234. */
  137235. positions?: number[];
  137236. /**
  137237. * Defines the indices.
  137238. */
  137239. indices?: number[];
  137240. }
  137241. /**
  137242. * Helper class to render one or more effects.
  137243. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137244. */
  137245. export class EffectRenderer {
  137246. private engine;
  137247. private static _DefaultOptions;
  137248. private _vertexBuffers;
  137249. private _indexBuffer;
  137250. private _fullscreenViewport;
  137251. /**
  137252. * Creates an effect renderer
  137253. * @param engine the engine to use for rendering
  137254. * @param options defines the options of the effect renderer
  137255. */
  137256. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137257. /**
  137258. * Sets the current viewport in normalized coordinates 0-1
  137259. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137260. */
  137261. setViewport(viewport?: Viewport): void;
  137262. /**
  137263. * Binds the embedded attributes buffer to the effect.
  137264. * @param effect Defines the effect to bind the attributes for
  137265. */
  137266. bindBuffers(effect: Effect): void;
  137267. /**
  137268. * Sets the current effect wrapper to use during draw.
  137269. * The effect needs to be ready before calling this api.
  137270. * This also sets the default full screen position attribute.
  137271. * @param effectWrapper Defines the effect to draw with
  137272. */
  137273. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137274. /**
  137275. * Restores engine states
  137276. */
  137277. restoreStates(): void;
  137278. /**
  137279. * Draws a full screen quad.
  137280. */
  137281. draw(): void;
  137282. private isRenderTargetTexture;
  137283. /**
  137284. * renders one or more effects to a specified texture
  137285. * @param effectWrapper the effect to renderer
  137286. * @param outputTexture texture to draw to, if null it will render to the screen.
  137287. */
  137288. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137289. /**
  137290. * Disposes of the effect renderer
  137291. */
  137292. dispose(): void;
  137293. }
  137294. /**
  137295. * Options to create an EffectWrapper
  137296. */
  137297. interface EffectWrapperCreationOptions {
  137298. /**
  137299. * Engine to use to create the effect
  137300. */
  137301. engine: ThinEngine;
  137302. /**
  137303. * Fragment shader for the effect
  137304. */
  137305. fragmentShader: string;
  137306. /**
  137307. * Use the shader store instead of direct source code
  137308. */
  137309. useShaderStore?: boolean;
  137310. /**
  137311. * Vertex shader for the effect
  137312. */
  137313. vertexShader?: string;
  137314. /**
  137315. * Attributes to use in the shader
  137316. */
  137317. attributeNames?: Array<string>;
  137318. /**
  137319. * Uniforms to use in the shader
  137320. */
  137321. uniformNames?: Array<string>;
  137322. /**
  137323. * Texture sampler names to use in the shader
  137324. */
  137325. samplerNames?: Array<string>;
  137326. /**
  137327. * Defines to use in the shader
  137328. */
  137329. defines?: Array<string>;
  137330. /**
  137331. * Callback when effect is compiled
  137332. */
  137333. onCompiled?: Nullable<(effect: Effect) => void>;
  137334. /**
  137335. * The friendly name of the effect displayed in Spector.
  137336. */
  137337. name?: string;
  137338. }
  137339. /**
  137340. * Wraps an effect to be used for rendering
  137341. */
  137342. export class EffectWrapper {
  137343. /**
  137344. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137345. */
  137346. onApplyObservable: Observable<{}>;
  137347. /**
  137348. * The underlying effect
  137349. */
  137350. effect: Effect;
  137351. /**
  137352. * Creates an effect to be renderer
  137353. * @param creationOptions options to create the effect
  137354. */
  137355. constructor(creationOptions: EffectWrapperCreationOptions);
  137356. /**
  137357. * Disposes of the effect wrapper
  137358. */
  137359. dispose(): void;
  137360. }
  137361. }
  137362. declare module BABYLON {
  137363. /** @hidden */
  137364. export var hdrFilteringVertexShader: {
  137365. name: string;
  137366. shader: string;
  137367. };
  137368. }
  137369. declare module BABYLON {
  137370. /** @hidden */
  137371. export var hdrFilteringPixelShader: {
  137372. name: string;
  137373. shader: string;
  137374. };
  137375. }
  137376. declare module BABYLON {
  137377. /**
  137378. * Options for texture filtering
  137379. */
  137380. interface IHDRFilteringOptions {
  137381. /**
  137382. * Scales pixel intensity for the input HDR map.
  137383. */
  137384. hdrScale?: number;
  137385. /**
  137386. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137387. */
  137388. quality?: number;
  137389. }
  137390. /**
  137391. * Filters HDR maps to get correct renderings of PBR reflections
  137392. */
  137393. export class HDRFiltering {
  137394. private _engine;
  137395. private _effectRenderer;
  137396. private _effectWrapper;
  137397. private _lodGenerationOffset;
  137398. private _lodGenerationScale;
  137399. /**
  137400. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137401. * you care about baking speed.
  137402. */
  137403. quality: number;
  137404. /**
  137405. * Scales pixel intensity for the input HDR map.
  137406. */
  137407. hdrScale: number;
  137408. /**
  137409. * Instantiates HDR filter for reflection maps
  137410. *
  137411. * @param engine Thin engine
  137412. * @param options Options
  137413. */
  137414. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137415. private _createRenderTarget;
  137416. private _prefilterInternal;
  137417. private _createEffect;
  137418. /**
  137419. * Get a value indicating if the filter is ready to be used
  137420. * @param texture Texture to filter
  137421. * @returns true if the filter is ready
  137422. */
  137423. isReady(texture: BaseTexture): boolean;
  137424. /**
  137425. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137426. * Prefiltering will be invoked at the end of next rendering pass.
  137427. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137428. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137429. * @param texture Texture to filter
  137430. * @param onFinished Callback when filtering is done
  137431. * @return Promise called when prefiltering is done
  137432. */
  137433. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137434. }
  137435. }
  137436. declare module BABYLON {
  137437. /**
  137438. * This represents a texture coming from an HDR input.
  137439. *
  137440. * The only supported format is currently panorama picture stored in RGBE format.
  137441. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137442. */
  137443. export class HDRCubeTexture extends BaseTexture {
  137444. private static _facesMapping;
  137445. private _generateHarmonics;
  137446. private _noMipmap;
  137447. private _prefilterOnLoad;
  137448. private _textureMatrix;
  137449. private _size;
  137450. private _onLoad;
  137451. private _onError;
  137452. /**
  137453. * The texture URL.
  137454. */
  137455. url: string;
  137456. /**
  137457. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137458. */
  137459. coordinatesMode: number;
  137460. protected _isBlocking: boolean;
  137461. /**
  137462. * Sets wether or not the texture is blocking during loading.
  137463. */
  137464. set isBlocking(value: boolean);
  137465. /**
  137466. * Gets wether or not the texture is blocking during loading.
  137467. */
  137468. get isBlocking(): boolean;
  137469. protected _rotationY: number;
  137470. /**
  137471. * Sets texture matrix rotation angle around Y axis in radians.
  137472. */
  137473. set rotationY(value: number);
  137474. /**
  137475. * Gets texture matrix rotation angle around Y axis radians.
  137476. */
  137477. get rotationY(): number;
  137478. /**
  137479. * Gets or sets the center of the bounding box associated with the cube texture
  137480. * It must define where the camera used to render the texture was set
  137481. */
  137482. boundingBoxPosition: Vector3;
  137483. private _boundingBoxSize;
  137484. /**
  137485. * Gets or sets the size of the bounding box associated with the cube texture
  137486. * When defined, the cubemap will switch to local mode
  137487. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137488. * @example https://www.babylonjs-playground.com/#RNASML
  137489. */
  137490. set boundingBoxSize(value: Vector3);
  137491. get boundingBoxSize(): Vector3;
  137492. /**
  137493. * Instantiates an HDRTexture from the following parameters.
  137494. *
  137495. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137496. * @param sceneOrEngine The scene or engine the texture will be used in
  137497. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137498. * @param noMipmap Forces to not generate the mipmap if true
  137499. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137500. * @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)
  137501. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137502. */
  137503. 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>);
  137504. /**
  137505. * Get the current class name of the texture useful for serialization or dynamic coding.
  137506. * @returns "HDRCubeTexture"
  137507. */
  137508. getClassName(): string;
  137509. /**
  137510. * Occurs when the file is raw .hdr file.
  137511. */
  137512. private loadTexture;
  137513. clone(): HDRCubeTexture;
  137514. delayLoad(): void;
  137515. /**
  137516. * Get the texture reflection matrix used to rotate/transform the reflection.
  137517. * @returns the reflection matrix
  137518. */
  137519. getReflectionTextureMatrix(): Matrix;
  137520. /**
  137521. * Set the texture reflection matrix used to rotate/transform the reflection.
  137522. * @param value Define the reflection matrix to set
  137523. */
  137524. setReflectionTextureMatrix(value: Matrix): void;
  137525. /**
  137526. * Parses a JSON representation of an HDR Texture in order to create the texture
  137527. * @param parsedTexture Define the JSON representation
  137528. * @param scene Define the scene the texture should be created in
  137529. * @param rootUrl Define the root url in case we need to load relative dependencies
  137530. * @returns the newly created texture after parsing
  137531. */
  137532. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137533. serialize(): any;
  137534. }
  137535. }
  137536. declare module BABYLON {
  137537. /**
  137538. * Class used to control physics engine
  137539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137540. */
  137541. export class PhysicsEngine implements IPhysicsEngine {
  137542. private _physicsPlugin;
  137543. /**
  137544. * Global value used to control the smallest number supported by the simulation
  137545. */
  137546. static Epsilon: number;
  137547. private _impostors;
  137548. private _joints;
  137549. private _subTimeStep;
  137550. /**
  137551. * Gets the gravity vector used by the simulation
  137552. */
  137553. gravity: Vector3;
  137554. /**
  137555. * Factory used to create the default physics plugin.
  137556. * @returns The default physics plugin
  137557. */
  137558. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137559. /**
  137560. * Creates a new Physics Engine
  137561. * @param gravity defines the gravity vector used by the simulation
  137562. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137563. */
  137564. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137565. /**
  137566. * Sets the gravity vector used by the simulation
  137567. * @param gravity defines the gravity vector to use
  137568. */
  137569. setGravity(gravity: Vector3): void;
  137570. /**
  137571. * Set the time step of the physics engine.
  137572. * Default is 1/60.
  137573. * To slow it down, enter 1/600 for example.
  137574. * To speed it up, 1/30
  137575. * @param newTimeStep defines the new timestep to apply to this world.
  137576. */
  137577. setTimeStep(newTimeStep?: number): void;
  137578. /**
  137579. * Get the time step of the physics engine.
  137580. * @returns the current time step
  137581. */
  137582. getTimeStep(): number;
  137583. /**
  137584. * Set the sub time step of the physics engine.
  137585. * Default is 0 meaning there is no sub steps
  137586. * To increase physics resolution precision, set a small value (like 1 ms)
  137587. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137588. */
  137589. setSubTimeStep(subTimeStep?: number): void;
  137590. /**
  137591. * Get the sub time step of the physics engine.
  137592. * @returns the current sub time step
  137593. */
  137594. getSubTimeStep(): number;
  137595. /**
  137596. * Release all resources
  137597. */
  137598. dispose(): void;
  137599. /**
  137600. * Gets the name of the current physics plugin
  137601. * @returns the name of the plugin
  137602. */
  137603. getPhysicsPluginName(): string;
  137604. /**
  137605. * Adding a new impostor for the impostor tracking.
  137606. * This will be done by the impostor itself.
  137607. * @param impostor the impostor to add
  137608. */
  137609. addImpostor(impostor: PhysicsImpostor): void;
  137610. /**
  137611. * Remove an impostor from the engine.
  137612. * This impostor and its mesh will not longer be updated by the physics engine.
  137613. * @param impostor the impostor to remove
  137614. */
  137615. removeImpostor(impostor: PhysicsImpostor): void;
  137616. /**
  137617. * Add a joint to the physics engine
  137618. * @param mainImpostor defines the main impostor to which the joint is added.
  137619. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137620. * @param joint defines the joint that will connect both impostors.
  137621. */
  137622. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137623. /**
  137624. * Removes a joint from the simulation
  137625. * @param mainImpostor defines the impostor used with the joint
  137626. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137627. * @param joint defines the joint to remove
  137628. */
  137629. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137630. /**
  137631. * Called by the scene. No need to call it.
  137632. * @param delta defines the timespam between frames
  137633. */
  137634. _step(delta: number): void;
  137635. /**
  137636. * Gets the current plugin used to run the simulation
  137637. * @returns current plugin
  137638. */
  137639. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137640. /**
  137641. * Gets the list of physic impostors
  137642. * @returns an array of PhysicsImpostor
  137643. */
  137644. getImpostors(): Array<PhysicsImpostor>;
  137645. /**
  137646. * Gets the impostor for a physics enabled object
  137647. * @param object defines the object impersonated by the impostor
  137648. * @returns the PhysicsImpostor or null if not found
  137649. */
  137650. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137651. /**
  137652. * Gets the impostor for a physics body object
  137653. * @param body defines physics body used by the impostor
  137654. * @returns the PhysicsImpostor or null if not found
  137655. */
  137656. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137657. /**
  137658. * Does a raycast in the physics world
  137659. * @param from when should the ray start?
  137660. * @param to when should the ray end?
  137661. * @returns PhysicsRaycastResult
  137662. */
  137663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137664. }
  137665. }
  137666. declare module BABYLON {
  137667. /** @hidden */
  137668. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137669. private _useDeltaForWorldStep;
  137670. world: any;
  137671. name: string;
  137672. private _physicsMaterials;
  137673. private _fixedTimeStep;
  137674. private _cannonRaycastResult;
  137675. private _raycastResult;
  137676. private _physicsBodysToRemoveAfterStep;
  137677. private _firstFrame;
  137678. BJSCANNON: any;
  137679. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137680. setGravity(gravity: Vector3): void;
  137681. setTimeStep(timeStep: number): void;
  137682. getTimeStep(): number;
  137683. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137684. private _removeMarkedPhysicsBodiesFromWorld;
  137685. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137686. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137687. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137688. private _processChildMeshes;
  137689. removePhysicsBody(impostor: PhysicsImpostor): void;
  137690. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137691. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137692. private _addMaterial;
  137693. private _checkWithEpsilon;
  137694. private _createShape;
  137695. private _createHeightmap;
  137696. private _minus90X;
  137697. private _plus90X;
  137698. private _tmpPosition;
  137699. private _tmpDeltaPosition;
  137700. private _tmpUnityRotation;
  137701. private _updatePhysicsBodyTransformation;
  137702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137703. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137704. isSupported(): boolean;
  137705. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137706. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137707. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137708. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137709. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137710. getBodyMass(impostor: PhysicsImpostor): number;
  137711. getBodyFriction(impostor: PhysicsImpostor): number;
  137712. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137713. getBodyRestitution(impostor: PhysicsImpostor): number;
  137714. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137715. sleepBody(impostor: PhysicsImpostor): void;
  137716. wakeUpBody(impostor: PhysicsImpostor): void;
  137717. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137718. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137720. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137721. getRadius(impostor: PhysicsImpostor): number;
  137722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137723. dispose(): void;
  137724. private _extendNamespace;
  137725. /**
  137726. * Does a raycast in the physics world
  137727. * @param from when should the ray start?
  137728. * @param to when should the ray end?
  137729. * @returns PhysicsRaycastResult
  137730. */
  137731. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137732. }
  137733. }
  137734. declare module BABYLON {
  137735. /** @hidden */
  137736. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137737. private _useDeltaForWorldStep;
  137738. world: any;
  137739. name: string;
  137740. BJSOIMO: any;
  137741. private _raycastResult;
  137742. private _fixedTimeStep;
  137743. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137744. setGravity(gravity: Vector3): void;
  137745. setTimeStep(timeStep: number): void;
  137746. getTimeStep(): number;
  137747. private _tmpImpostorsArray;
  137748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137752. private _tmpPositionVector;
  137753. removePhysicsBody(impostor: PhysicsImpostor): void;
  137754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137755. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137756. isSupported(): boolean;
  137757. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137758. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137760. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137761. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137762. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137764. getBodyMass(impostor: PhysicsImpostor): number;
  137765. getBodyFriction(impostor: PhysicsImpostor): number;
  137766. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137767. getBodyRestitution(impostor: PhysicsImpostor): number;
  137768. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137769. sleepBody(impostor: PhysicsImpostor): void;
  137770. wakeUpBody(impostor: PhysicsImpostor): void;
  137771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137772. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137773. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137774. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137775. getRadius(impostor: PhysicsImpostor): number;
  137776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137777. dispose(): void;
  137778. /**
  137779. * Does a raycast in the physics world
  137780. * @param from when should the ray start?
  137781. * @param to when should the ray end?
  137782. * @returns PhysicsRaycastResult
  137783. */
  137784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137785. }
  137786. }
  137787. declare module BABYLON {
  137788. /**
  137789. * Class containing static functions to help procedurally build meshes
  137790. */
  137791. export class RibbonBuilder {
  137792. /**
  137793. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137794. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137795. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137796. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137797. * * 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
  137798. * * 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
  137799. * * 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
  137800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137801. * * 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
  137802. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137803. * * 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
  137804. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137805. * * 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
  137806. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137808. * @param name defines the name of the mesh
  137809. * @param options defines the options used to create the mesh
  137810. * @param scene defines the hosting scene
  137811. * @returns the ribbon mesh
  137812. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137814. */
  137815. static CreateRibbon(name: string, options: {
  137816. pathArray: Vector3[][];
  137817. closeArray?: boolean;
  137818. closePath?: boolean;
  137819. offset?: number;
  137820. updatable?: boolean;
  137821. sideOrientation?: number;
  137822. frontUVs?: Vector4;
  137823. backUVs?: Vector4;
  137824. instance?: Mesh;
  137825. invertUV?: boolean;
  137826. uvs?: Vector2[];
  137827. colors?: Color4[];
  137828. }, scene?: Nullable<Scene>): Mesh;
  137829. }
  137830. }
  137831. declare module BABYLON {
  137832. /**
  137833. * Class containing static functions to help procedurally build meshes
  137834. */
  137835. export class ShapeBuilder {
  137836. /**
  137837. * 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.
  137838. * * 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.
  137839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137840. * * 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.
  137841. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137842. * * 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
  137843. * * 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
  137844. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137846. * * 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
  137847. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137849. * @param name defines the name of the mesh
  137850. * @param options defines the options used to create the mesh
  137851. * @param scene defines the hosting scene
  137852. * @returns the extruded shape mesh
  137853. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137855. */
  137856. static ExtrudeShape(name: string, options: {
  137857. shape: Vector3[];
  137858. path: Vector3[];
  137859. scale?: number;
  137860. rotation?: number;
  137861. cap?: number;
  137862. updatable?: boolean;
  137863. sideOrientation?: number;
  137864. frontUVs?: Vector4;
  137865. backUVs?: Vector4;
  137866. instance?: Mesh;
  137867. invertUV?: boolean;
  137868. }, scene?: Nullable<Scene>): Mesh;
  137869. /**
  137870. * Creates an custom extruded shape mesh.
  137871. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137872. * * 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.
  137873. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137874. * * 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
  137875. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137876. * * 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
  137877. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137878. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137879. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137880. * * 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
  137881. * * 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
  137882. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137884. * * 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
  137885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137887. * @param name defines the name of the mesh
  137888. * @param options defines the options used to create the mesh
  137889. * @param scene defines the hosting scene
  137890. * @returns the custom extruded shape mesh
  137891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137894. */
  137895. static ExtrudeShapeCustom(name: string, options: {
  137896. shape: Vector3[];
  137897. path: Vector3[];
  137898. scaleFunction?: any;
  137899. rotationFunction?: any;
  137900. ribbonCloseArray?: boolean;
  137901. ribbonClosePath?: boolean;
  137902. cap?: number;
  137903. updatable?: boolean;
  137904. sideOrientation?: number;
  137905. frontUVs?: Vector4;
  137906. backUVs?: Vector4;
  137907. instance?: Mesh;
  137908. invertUV?: boolean;
  137909. }, scene?: Nullable<Scene>): Mesh;
  137910. private static _ExtrudeShapeGeneric;
  137911. }
  137912. }
  137913. declare module BABYLON {
  137914. /**
  137915. * AmmoJS Physics plugin
  137916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137917. * @see https://github.com/kripken/ammo.js/
  137918. */
  137919. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137920. private _useDeltaForWorldStep;
  137921. /**
  137922. * Reference to the Ammo library
  137923. */
  137924. bjsAMMO: any;
  137925. /**
  137926. * Created ammoJS world which physics bodies are added to
  137927. */
  137928. world: any;
  137929. /**
  137930. * Name of the plugin
  137931. */
  137932. name: string;
  137933. private _timeStep;
  137934. private _fixedTimeStep;
  137935. private _maxSteps;
  137936. private _tmpQuaternion;
  137937. private _tmpAmmoTransform;
  137938. private _tmpAmmoQuaternion;
  137939. private _tmpAmmoConcreteContactResultCallback;
  137940. private _collisionConfiguration;
  137941. private _dispatcher;
  137942. private _overlappingPairCache;
  137943. private _solver;
  137944. private _softBodySolver;
  137945. private _tmpAmmoVectorA;
  137946. private _tmpAmmoVectorB;
  137947. private _tmpAmmoVectorC;
  137948. private _tmpAmmoVectorD;
  137949. private _tmpContactCallbackResult;
  137950. private _tmpAmmoVectorRCA;
  137951. private _tmpAmmoVectorRCB;
  137952. private _raycastResult;
  137953. private static readonly DISABLE_COLLISION_FLAG;
  137954. private static readonly KINEMATIC_FLAG;
  137955. private static readonly DISABLE_DEACTIVATION_FLAG;
  137956. /**
  137957. * Initializes the ammoJS plugin
  137958. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137959. * @param ammoInjection can be used to inject your own ammo reference
  137960. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137961. */
  137962. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137963. /**
  137964. * Sets the gravity of the physics world (m/(s^2))
  137965. * @param gravity Gravity to set
  137966. */
  137967. setGravity(gravity: Vector3): void;
  137968. /**
  137969. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137970. * @param timeStep timestep to use in seconds
  137971. */
  137972. setTimeStep(timeStep: number): void;
  137973. /**
  137974. * 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)
  137975. * @param fixedTimeStep fixedTimeStep to use in seconds
  137976. */
  137977. setFixedTimeStep(fixedTimeStep: number): void;
  137978. /**
  137979. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137980. * @param maxSteps the maximum number of steps by the physics engine per frame
  137981. */
  137982. setMaxSteps(maxSteps: number): void;
  137983. /**
  137984. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137985. * @returns the current timestep in seconds
  137986. */
  137987. getTimeStep(): number;
  137988. /**
  137989. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137990. */
  137991. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137992. private _isImpostorInContact;
  137993. private _isImpostorPairInContact;
  137994. private _stepSimulation;
  137995. /**
  137996. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137997. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137998. * After the step the babylon meshes are set to the position of the physics imposters
  137999. * @param delta amount of time to step forward
  138000. * @param impostors array of imposters to update before/after the step
  138001. */
  138002. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138003. /**
  138004. * Update babylon mesh to match physics world object
  138005. * @param impostor imposter to match
  138006. */
  138007. private _afterSoftStep;
  138008. /**
  138009. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138010. * @param impostor imposter to match
  138011. */
  138012. private _ropeStep;
  138013. /**
  138014. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138015. * @param impostor imposter to match
  138016. */
  138017. private _softbodyOrClothStep;
  138018. private _tmpMatrix;
  138019. /**
  138020. * Applies an impulse on the imposter
  138021. * @param impostor imposter to apply impulse to
  138022. * @param force amount of force to be applied to the imposter
  138023. * @param contactPoint the location to apply the impulse on the imposter
  138024. */
  138025. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138026. /**
  138027. * Applies a force on the imposter
  138028. * @param impostor imposter to apply force
  138029. * @param force amount of force to be applied to the imposter
  138030. * @param contactPoint the location to apply the force on the imposter
  138031. */
  138032. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138033. /**
  138034. * Creates a physics body using the plugin
  138035. * @param impostor the imposter to create the physics body on
  138036. */
  138037. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138038. /**
  138039. * Removes the physics body from the imposter and disposes of the body's memory
  138040. * @param impostor imposter to remove the physics body from
  138041. */
  138042. removePhysicsBody(impostor: PhysicsImpostor): void;
  138043. /**
  138044. * Generates a joint
  138045. * @param impostorJoint the imposter joint to create the joint with
  138046. */
  138047. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138048. /**
  138049. * Removes a joint
  138050. * @param impostorJoint the imposter joint to remove the joint from
  138051. */
  138052. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138053. private _addMeshVerts;
  138054. /**
  138055. * Initialise the soft body vertices to match its object's (mesh) vertices
  138056. * Softbody vertices (nodes) are in world space and to match this
  138057. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138058. * @param impostor to create the softbody for
  138059. */
  138060. private _softVertexData;
  138061. /**
  138062. * Create an impostor's soft body
  138063. * @param impostor to create the softbody for
  138064. */
  138065. private _createSoftbody;
  138066. /**
  138067. * Create cloth for an impostor
  138068. * @param impostor to create the softbody for
  138069. */
  138070. private _createCloth;
  138071. /**
  138072. * Create rope for an impostor
  138073. * @param impostor to create the softbody for
  138074. */
  138075. private _createRope;
  138076. /**
  138077. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138078. * @param impostor to create the custom physics shape for
  138079. */
  138080. private _createCustom;
  138081. private _addHullVerts;
  138082. private _createShape;
  138083. /**
  138084. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138085. * @param impostor imposter containing the physics body and babylon object
  138086. */
  138087. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138088. /**
  138089. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138090. * @param impostor imposter containing the physics body and babylon object
  138091. * @param newPosition new position
  138092. * @param newRotation new rotation
  138093. */
  138094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138095. /**
  138096. * If this plugin is supported
  138097. * @returns true if its supported
  138098. */
  138099. isSupported(): boolean;
  138100. /**
  138101. * Sets the linear velocity of the physics body
  138102. * @param impostor imposter to set the velocity on
  138103. * @param velocity velocity to set
  138104. */
  138105. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138106. /**
  138107. * Sets the angular velocity of the physics body
  138108. * @param impostor imposter to set the velocity on
  138109. * @param velocity velocity to set
  138110. */
  138111. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138112. /**
  138113. * gets the linear velocity
  138114. * @param impostor imposter to get linear velocity from
  138115. * @returns linear velocity
  138116. */
  138117. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138118. /**
  138119. * gets the angular velocity
  138120. * @param impostor imposter to get angular velocity from
  138121. * @returns angular velocity
  138122. */
  138123. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138124. /**
  138125. * Sets the mass of physics body
  138126. * @param impostor imposter to set the mass on
  138127. * @param mass mass to set
  138128. */
  138129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138130. /**
  138131. * Gets the mass of the physics body
  138132. * @param impostor imposter to get the mass from
  138133. * @returns mass
  138134. */
  138135. getBodyMass(impostor: PhysicsImpostor): number;
  138136. /**
  138137. * Gets friction of the impostor
  138138. * @param impostor impostor to get friction from
  138139. * @returns friction value
  138140. */
  138141. getBodyFriction(impostor: PhysicsImpostor): number;
  138142. /**
  138143. * Sets friction of the impostor
  138144. * @param impostor impostor to set friction on
  138145. * @param friction friction value
  138146. */
  138147. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138148. /**
  138149. * Gets restitution of the impostor
  138150. * @param impostor impostor to get restitution from
  138151. * @returns restitution value
  138152. */
  138153. getBodyRestitution(impostor: PhysicsImpostor): number;
  138154. /**
  138155. * Sets resitution of the impostor
  138156. * @param impostor impostor to set resitution on
  138157. * @param restitution resitution value
  138158. */
  138159. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138160. /**
  138161. * Gets pressure inside the impostor
  138162. * @param impostor impostor to get pressure from
  138163. * @returns pressure value
  138164. */
  138165. getBodyPressure(impostor: PhysicsImpostor): number;
  138166. /**
  138167. * Sets pressure inside a soft body impostor
  138168. * Cloth and rope must remain 0 pressure
  138169. * @param impostor impostor to set pressure on
  138170. * @param pressure pressure value
  138171. */
  138172. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138173. /**
  138174. * Gets stiffness of the impostor
  138175. * @param impostor impostor to get stiffness from
  138176. * @returns pressure value
  138177. */
  138178. getBodyStiffness(impostor: PhysicsImpostor): number;
  138179. /**
  138180. * Sets stiffness of the impostor
  138181. * @param impostor impostor to set stiffness on
  138182. * @param stiffness stiffness value from 0 to 1
  138183. */
  138184. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138185. /**
  138186. * Gets velocityIterations of the impostor
  138187. * @param impostor impostor to get velocity iterations from
  138188. * @returns velocityIterations value
  138189. */
  138190. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138191. /**
  138192. * Sets velocityIterations of the impostor
  138193. * @param impostor impostor to set velocity iterations on
  138194. * @param velocityIterations velocityIterations value
  138195. */
  138196. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138197. /**
  138198. * Gets positionIterations of the impostor
  138199. * @param impostor impostor to get position iterations from
  138200. * @returns positionIterations value
  138201. */
  138202. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138203. /**
  138204. * Sets positionIterations of the impostor
  138205. * @param impostor impostor to set position on
  138206. * @param positionIterations positionIterations value
  138207. */
  138208. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138209. /**
  138210. * Append an anchor to a cloth object
  138211. * @param impostor is the cloth impostor to add anchor to
  138212. * @param otherImpostor is the rigid impostor to anchor to
  138213. * @param width ratio across width from 0 to 1
  138214. * @param height ratio up height from 0 to 1
  138215. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138216. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138217. */
  138218. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138219. /**
  138220. * Append an hook to a rope object
  138221. * @param impostor is the rope impostor to add hook to
  138222. * @param otherImpostor is the rigid impostor to hook to
  138223. * @param length ratio along the rope from 0 to 1
  138224. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138225. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138226. */
  138227. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138228. /**
  138229. * Sleeps the physics body and stops it from being active
  138230. * @param impostor impostor to sleep
  138231. */
  138232. sleepBody(impostor: PhysicsImpostor): void;
  138233. /**
  138234. * Activates the physics body
  138235. * @param impostor impostor to activate
  138236. */
  138237. wakeUpBody(impostor: PhysicsImpostor): void;
  138238. /**
  138239. * Updates the distance parameters of the joint
  138240. * @param joint joint to update
  138241. * @param maxDistance maximum distance of the joint
  138242. * @param minDistance minimum distance of the joint
  138243. */
  138244. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138245. /**
  138246. * Sets a motor on the joint
  138247. * @param joint joint to set motor on
  138248. * @param speed speed of the motor
  138249. * @param maxForce maximum force of the motor
  138250. * @param motorIndex index of the motor
  138251. */
  138252. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138253. /**
  138254. * Sets the motors limit
  138255. * @param joint joint to set limit on
  138256. * @param upperLimit upper limit
  138257. * @param lowerLimit lower limit
  138258. */
  138259. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138260. /**
  138261. * Syncs the position and rotation of a mesh with the impostor
  138262. * @param mesh mesh to sync
  138263. * @param impostor impostor to update the mesh with
  138264. */
  138265. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138266. /**
  138267. * Gets the radius of the impostor
  138268. * @param impostor impostor to get radius from
  138269. * @returns the radius
  138270. */
  138271. getRadius(impostor: PhysicsImpostor): number;
  138272. /**
  138273. * Gets the box size of the impostor
  138274. * @param impostor impostor to get box size from
  138275. * @param result the resulting box size
  138276. */
  138277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138278. /**
  138279. * Disposes of the impostor
  138280. */
  138281. dispose(): void;
  138282. /**
  138283. * Does a raycast in the physics world
  138284. * @param from when should the ray start?
  138285. * @param to when should the ray end?
  138286. * @returns PhysicsRaycastResult
  138287. */
  138288. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138289. }
  138290. }
  138291. declare module BABYLON {
  138292. interface AbstractScene {
  138293. /**
  138294. * The list of reflection probes added to the scene
  138295. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138296. */
  138297. reflectionProbes: Array<ReflectionProbe>;
  138298. /**
  138299. * Removes the given reflection probe from this scene.
  138300. * @param toRemove The reflection probe to remove
  138301. * @returns The index of the removed reflection probe
  138302. */
  138303. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138304. /**
  138305. * Adds the given reflection probe to this scene.
  138306. * @param newReflectionProbe The reflection probe to add
  138307. */
  138308. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138309. }
  138310. /**
  138311. * Class used to generate realtime reflection / refraction cube textures
  138312. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138313. */
  138314. export class ReflectionProbe {
  138315. /** defines the name of the probe */
  138316. name: string;
  138317. private _scene;
  138318. private _renderTargetTexture;
  138319. private _projectionMatrix;
  138320. private _viewMatrix;
  138321. private _target;
  138322. private _add;
  138323. private _attachedMesh;
  138324. private _invertYAxis;
  138325. /** Gets or sets probe position (center of the cube map) */
  138326. position: Vector3;
  138327. /**
  138328. * Creates a new reflection probe
  138329. * @param name defines the name of the probe
  138330. * @param size defines the texture resolution (for each face)
  138331. * @param scene defines the hosting scene
  138332. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138333. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138334. */
  138335. constructor(
  138336. /** defines the name of the probe */
  138337. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138338. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138339. get samples(): number;
  138340. set samples(value: number);
  138341. /** Gets or sets the refresh rate to use (on every frame by default) */
  138342. get refreshRate(): number;
  138343. set refreshRate(value: number);
  138344. /**
  138345. * Gets the hosting scene
  138346. * @returns a Scene
  138347. */
  138348. getScene(): Scene;
  138349. /** Gets the internal CubeTexture used to render to */
  138350. get cubeTexture(): RenderTargetTexture;
  138351. /** Gets the list of meshes to render */
  138352. get renderList(): Nullable<AbstractMesh[]>;
  138353. /**
  138354. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138355. * @param mesh defines the mesh to attach to
  138356. */
  138357. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138358. /**
  138359. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138360. * @param renderingGroupId The rendering group id corresponding to its index
  138361. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138362. */
  138363. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138364. /**
  138365. * Clean all associated resources
  138366. */
  138367. dispose(): void;
  138368. /**
  138369. * Converts the reflection probe information to a readable string for debug purpose.
  138370. * @param fullDetails Supports for multiple levels of logging within scene loading
  138371. * @returns the human readable reflection probe info
  138372. */
  138373. toString(fullDetails?: boolean): string;
  138374. /**
  138375. * Get the class name of the relfection probe.
  138376. * @returns "ReflectionProbe"
  138377. */
  138378. getClassName(): string;
  138379. /**
  138380. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138381. * @returns The JSON representation of the texture
  138382. */
  138383. serialize(): any;
  138384. /**
  138385. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138386. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138387. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138388. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138389. * @returns The parsed reflection probe if successful
  138390. */
  138391. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138392. }
  138393. }
  138394. declare module BABYLON {
  138395. /** @hidden */
  138396. export var _BabylonLoaderRegistered: boolean;
  138397. /**
  138398. * Helps setting up some configuration for the babylon file loader.
  138399. */
  138400. export class BabylonFileLoaderConfiguration {
  138401. /**
  138402. * The loader does not allow injecting custom physix engine into the plugins.
  138403. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138404. * So you could set this variable to your engine import to make it work.
  138405. */
  138406. static LoaderInjectedPhysicsEngine: any;
  138407. }
  138408. }
  138409. declare module BABYLON {
  138410. /**
  138411. * The Physically based simple base material of BJS.
  138412. *
  138413. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138414. * It is used as the base class for both the specGloss and metalRough conventions.
  138415. */
  138416. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138417. /**
  138418. * Number of Simultaneous lights allowed on the material.
  138419. */
  138420. maxSimultaneousLights: number;
  138421. /**
  138422. * If sets to true, disables all the lights affecting the material.
  138423. */
  138424. disableLighting: boolean;
  138425. /**
  138426. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138427. */
  138428. environmentTexture: BaseTexture;
  138429. /**
  138430. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138431. */
  138432. invertNormalMapX: boolean;
  138433. /**
  138434. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138435. */
  138436. invertNormalMapY: boolean;
  138437. /**
  138438. * Normal map used in the model.
  138439. */
  138440. normalTexture: BaseTexture;
  138441. /**
  138442. * Emissivie color used to self-illuminate the model.
  138443. */
  138444. emissiveColor: Color3;
  138445. /**
  138446. * Emissivie texture used to self-illuminate the model.
  138447. */
  138448. emissiveTexture: BaseTexture;
  138449. /**
  138450. * Occlusion Channel Strenght.
  138451. */
  138452. occlusionStrength: number;
  138453. /**
  138454. * Occlusion Texture of the material (adding extra occlusion effects).
  138455. */
  138456. occlusionTexture: BaseTexture;
  138457. /**
  138458. * Defines the alpha limits in alpha test mode.
  138459. */
  138460. alphaCutOff: number;
  138461. /**
  138462. * Gets the current double sided mode.
  138463. */
  138464. get doubleSided(): boolean;
  138465. /**
  138466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138467. */
  138468. set doubleSided(value: boolean);
  138469. /**
  138470. * Stores the pre-calculated light information of a mesh in a texture.
  138471. */
  138472. lightmapTexture: BaseTexture;
  138473. /**
  138474. * If true, the light map contains occlusion information instead of lighting info.
  138475. */
  138476. useLightmapAsShadowmap: boolean;
  138477. /**
  138478. * Instantiates a new PBRMaterial instance.
  138479. *
  138480. * @param name The material name
  138481. * @param scene The scene the material will be use in.
  138482. */
  138483. constructor(name: string, scene: Scene);
  138484. getClassName(): string;
  138485. }
  138486. }
  138487. declare module BABYLON {
  138488. /**
  138489. * The PBR material of BJS following the metal roughness convention.
  138490. *
  138491. * This fits to the PBR convention in the GLTF definition:
  138492. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138493. */
  138494. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138495. /**
  138496. * The base color has two different interpretations depending on the value of metalness.
  138497. * When the material is a metal, the base color is the specific measured reflectance value
  138498. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138499. * of the material.
  138500. */
  138501. baseColor: Color3;
  138502. /**
  138503. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138504. * well as opacity information in the alpha channel.
  138505. */
  138506. baseTexture: BaseTexture;
  138507. /**
  138508. * Specifies the metallic scalar value of the material.
  138509. * Can also be used to scale the metalness values of the metallic texture.
  138510. */
  138511. metallic: number;
  138512. /**
  138513. * Specifies the roughness scalar value of the material.
  138514. * Can also be used to scale the roughness values of the metallic texture.
  138515. */
  138516. roughness: number;
  138517. /**
  138518. * Texture containing both the metallic value in the B channel and the
  138519. * roughness value in the G channel to keep better precision.
  138520. */
  138521. metallicRoughnessTexture: BaseTexture;
  138522. /**
  138523. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138524. *
  138525. * @param name The material name
  138526. * @param scene The scene the material will be use in.
  138527. */
  138528. constructor(name: string, scene: Scene);
  138529. /**
  138530. * Return the currrent class name of the material.
  138531. */
  138532. getClassName(): string;
  138533. /**
  138534. * Makes a duplicate of the current material.
  138535. * @param name - name to use for the new material.
  138536. */
  138537. clone(name: string): PBRMetallicRoughnessMaterial;
  138538. /**
  138539. * Serialize the material to a parsable JSON object.
  138540. */
  138541. serialize(): any;
  138542. /**
  138543. * Parses a JSON object correponding to the serialize function.
  138544. */
  138545. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138546. }
  138547. }
  138548. declare module BABYLON {
  138549. /**
  138550. * The PBR material of BJS following the specular glossiness convention.
  138551. *
  138552. * This fits to the PBR convention in the GLTF definition:
  138553. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138554. */
  138555. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138556. /**
  138557. * Specifies the diffuse color of the material.
  138558. */
  138559. diffuseColor: Color3;
  138560. /**
  138561. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138562. * channel.
  138563. */
  138564. diffuseTexture: BaseTexture;
  138565. /**
  138566. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138567. */
  138568. specularColor: Color3;
  138569. /**
  138570. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138571. */
  138572. glossiness: number;
  138573. /**
  138574. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138575. */
  138576. specularGlossinessTexture: BaseTexture;
  138577. /**
  138578. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138579. *
  138580. * @param name The material name
  138581. * @param scene The scene the material will be use in.
  138582. */
  138583. constructor(name: string, scene: Scene);
  138584. /**
  138585. * Return the currrent class name of the material.
  138586. */
  138587. getClassName(): string;
  138588. /**
  138589. * Makes a duplicate of the current material.
  138590. * @param name - name to use for the new material.
  138591. */
  138592. clone(name: string): PBRSpecularGlossinessMaterial;
  138593. /**
  138594. * Serialize the material to a parsable JSON object.
  138595. */
  138596. serialize(): any;
  138597. /**
  138598. * Parses a JSON object correponding to the serialize function.
  138599. */
  138600. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138601. }
  138602. }
  138603. declare module BABYLON {
  138604. /**
  138605. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138606. * It can help converting any input color in a desired output one. This can then be used to create effects
  138607. * from sepia, black and white to sixties or futuristic rendering...
  138608. *
  138609. * The only supported format is currently 3dl.
  138610. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138611. */
  138612. export class ColorGradingTexture extends BaseTexture {
  138613. /**
  138614. * The texture URL.
  138615. */
  138616. url: string;
  138617. /**
  138618. * Empty line regex stored for GC.
  138619. */
  138620. private static _noneEmptyLineRegex;
  138621. private _textureMatrix;
  138622. private _onLoad;
  138623. /**
  138624. * Instantiates a ColorGradingTexture from the following parameters.
  138625. *
  138626. * @param url The location of the color gradind data (currently only supporting 3dl)
  138627. * @param sceneOrEngine The scene or engine the texture will be used in
  138628. * @param onLoad defines a callback triggered when the texture has been loaded
  138629. */
  138630. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138631. /**
  138632. * Fires the onload event from the constructor if requested.
  138633. */
  138634. private _triggerOnLoad;
  138635. /**
  138636. * Returns the texture matrix used in most of the material.
  138637. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138638. */
  138639. getTextureMatrix(): Matrix;
  138640. /**
  138641. * Occurs when the file being loaded is a .3dl LUT file.
  138642. */
  138643. private load3dlTexture;
  138644. /**
  138645. * Starts the loading process of the texture.
  138646. */
  138647. private loadTexture;
  138648. /**
  138649. * Clones the color gradind texture.
  138650. */
  138651. clone(): ColorGradingTexture;
  138652. /**
  138653. * Called during delayed load for textures.
  138654. */
  138655. delayLoad(): void;
  138656. /**
  138657. * Parses a color grading texture serialized by Babylon.
  138658. * @param parsedTexture The texture information being parsedTexture
  138659. * @param scene The scene to load the texture in
  138660. * @param rootUrl The root url of the data assets to load
  138661. * @return A color gradind texture
  138662. */
  138663. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138664. /**
  138665. * Serializes the LUT texture to json format.
  138666. */
  138667. serialize(): any;
  138668. }
  138669. }
  138670. declare module BABYLON {
  138671. /**
  138672. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138673. */
  138674. export class EquiRectangularCubeTexture extends BaseTexture {
  138675. /** The six faces of the cube. */
  138676. private static _FacesMapping;
  138677. private _noMipmap;
  138678. private _onLoad;
  138679. private _onError;
  138680. /** The size of the cubemap. */
  138681. private _size;
  138682. /** The buffer of the image. */
  138683. private _buffer;
  138684. /** The width of the input image. */
  138685. private _width;
  138686. /** The height of the input image. */
  138687. private _height;
  138688. /** The URL to the image. */
  138689. url: string;
  138690. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138691. coordinatesMode: number;
  138692. /**
  138693. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138694. * @param url The location of the image
  138695. * @param scene The scene the texture will be used in
  138696. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138697. * @param noMipmap Forces to not generate the mipmap if true
  138698. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138699. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138700. * @param onLoad — defines a callback called when texture is loaded
  138701. * @param onError — defines a callback called if there is an error
  138702. */
  138703. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138704. /**
  138705. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138706. */
  138707. private loadImage;
  138708. /**
  138709. * Convert the image buffer into a cubemap and create a CubeTexture.
  138710. */
  138711. private loadTexture;
  138712. /**
  138713. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138714. * @param buffer The ArrayBuffer that should be converted.
  138715. * @returns The buffer as Float32Array.
  138716. */
  138717. private getFloat32ArrayFromArrayBuffer;
  138718. /**
  138719. * Get the current class name of the texture useful for serialization or dynamic coding.
  138720. * @returns "EquiRectangularCubeTexture"
  138721. */
  138722. getClassName(): string;
  138723. /**
  138724. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138725. * @returns A clone of the current EquiRectangularCubeTexture.
  138726. */
  138727. clone(): EquiRectangularCubeTexture;
  138728. }
  138729. }
  138730. declare module BABYLON {
  138731. /**
  138732. * Defines the options related to the creation of an HtmlElementTexture
  138733. */
  138734. export interface IHtmlElementTextureOptions {
  138735. /**
  138736. * Defines wether mip maps should be created or not.
  138737. */
  138738. generateMipMaps?: boolean;
  138739. /**
  138740. * Defines the sampling mode of the texture.
  138741. */
  138742. samplingMode?: number;
  138743. /**
  138744. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138745. */
  138746. engine: Nullable<ThinEngine>;
  138747. /**
  138748. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138749. */
  138750. scene: Nullable<Scene>;
  138751. }
  138752. /**
  138753. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138754. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138755. * is automatically managed.
  138756. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138757. * in your application.
  138758. *
  138759. * As the update is not automatic, you need to call them manually.
  138760. */
  138761. export class HtmlElementTexture extends BaseTexture {
  138762. /**
  138763. * The texture URL.
  138764. */
  138765. element: HTMLVideoElement | HTMLCanvasElement;
  138766. private static readonly DefaultOptions;
  138767. private _textureMatrix;
  138768. private _isVideo;
  138769. private _generateMipMaps;
  138770. private _samplingMode;
  138771. /**
  138772. * Instantiates a HtmlElementTexture from the following parameters.
  138773. *
  138774. * @param name Defines the name of the texture
  138775. * @param element Defines the video or canvas the texture is filled with
  138776. * @param options Defines the other none mandatory texture creation options
  138777. */
  138778. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138779. private _createInternalTexture;
  138780. /**
  138781. * Returns the texture matrix used in most of the material.
  138782. */
  138783. getTextureMatrix(): Matrix;
  138784. /**
  138785. * Updates the content of the texture.
  138786. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138787. */
  138788. update(invertY?: Nullable<boolean>): void;
  138789. }
  138790. }
  138791. declare module BABYLON {
  138792. /**
  138793. * Based on jsTGALoader - Javascript loader for TGA file
  138794. * By Vincent Thibault
  138795. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138796. */
  138797. export class TGATools {
  138798. private static _TYPE_INDEXED;
  138799. private static _TYPE_RGB;
  138800. private static _TYPE_GREY;
  138801. private static _TYPE_RLE_INDEXED;
  138802. private static _TYPE_RLE_RGB;
  138803. private static _TYPE_RLE_GREY;
  138804. private static _ORIGIN_MASK;
  138805. private static _ORIGIN_SHIFT;
  138806. private static _ORIGIN_BL;
  138807. private static _ORIGIN_BR;
  138808. private static _ORIGIN_UL;
  138809. private static _ORIGIN_UR;
  138810. /**
  138811. * Gets the header of a TGA file
  138812. * @param data defines the TGA data
  138813. * @returns the header
  138814. */
  138815. static GetTGAHeader(data: Uint8Array): any;
  138816. /**
  138817. * Uploads TGA content to a Babylon Texture
  138818. * @hidden
  138819. */
  138820. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138821. /** @hidden */
  138822. 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;
  138823. /** @hidden */
  138824. 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;
  138825. /** @hidden */
  138826. 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;
  138827. /** @hidden */
  138828. 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;
  138829. /** @hidden */
  138830. 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;
  138831. /** @hidden */
  138832. 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;
  138833. }
  138834. }
  138835. declare module BABYLON {
  138836. /**
  138837. * Implementation of the TGA Texture Loader.
  138838. * @hidden
  138839. */
  138840. export class _TGATextureLoader implements IInternalTextureLoader {
  138841. /**
  138842. * Defines wether the loader supports cascade loading the different faces.
  138843. */
  138844. readonly supportCascades: boolean;
  138845. /**
  138846. * This returns if the loader support the current file information.
  138847. * @param extension defines the file extension of the file being loaded
  138848. * @returns true if the loader can load the specified file
  138849. */
  138850. canLoad(extension: string): boolean;
  138851. /**
  138852. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138853. * @param data contains the texture data
  138854. * @param texture defines the BabylonJS internal texture
  138855. * @param createPolynomials will be true if polynomials have been requested
  138856. * @param onLoad defines the callback to trigger once the texture is ready
  138857. * @param onError defines the callback to trigger in case of error
  138858. */
  138859. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138860. /**
  138861. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138862. * @param data contains the texture data
  138863. * @param texture defines the BabylonJS internal texture
  138864. * @param callback defines the method to call once ready to upload
  138865. */
  138866. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138867. }
  138868. }
  138869. declare module BABYLON {
  138870. /**
  138871. * Info about the .basis files
  138872. */
  138873. class BasisFileInfo {
  138874. /**
  138875. * If the file has alpha
  138876. */
  138877. hasAlpha: boolean;
  138878. /**
  138879. * Info about each image of the basis file
  138880. */
  138881. images: Array<{
  138882. levels: Array<{
  138883. width: number;
  138884. height: number;
  138885. transcodedPixels: ArrayBufferView;
  138886. }>;
  138887. }>;
  138888. }
  138889. /**
  138890. * Result of transcoding a basis file
  138891. */
  138892. class TranscodeResult {
  138893. /**
  138894. * Info about the .basis file
  138895. */
  138896. fileInfo: BasisFileInfo;
  138897. /**
  138898. * Format to use when loading the file
  138899. */
  138900. format: number;
  138901. }
  138902. /**
  138903. * Configuration options for the Basis transcoder
  138904. */
  138905. export class BasisTranscodeConfiguration {
  138906. /**
  138907. * Supported compression formats used to determine the supported output format of the transcoder
  138908. */
  138909. supportedCompressionFormats?: {
  138910. /**
  138911. * etc1 compression format
  138912. */
  138913. etc1?: boolean;
  138914. /**
  138915. * s3tc compression format
  138916. */
  138917. s3tc?: boolean;
  138918. /**
  138919. * pvrtc compression format
  138920. */
  138921. pvrtc?: boolean;
  138922. /**
  138923. * etc2 compression format
  138924. */
  138925. etc2?: boolean;
  138926. };
  138927. /**
  138928. * If mipmap levels should be loaded for transcoded images (Default: true)
  138929. */
  138930. loadMipmapLevels?: boolean;
  138931. /**
  138932. * Index of a single image to load (Default: all images)
  138933. */
  138934. loadSingleImage?: number;
  138935. }
  138936. /**
  138937. * Used to load .Basis files
  138938. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138939. */
  138940. export class BasisTools {
  138941. private static _IgnoreSupportedFormats;
  138942. /**
  138943. * URL to use when loading the basis transcoder
  138944. */
  138945. static JSModuleURL: string;
  138946. /**
  138947. * URL to use when loading the wasm module for the transcoder
  138948. */
  138949. static WasmModuleURL: string;
  138950. /**
  138951. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138952. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138953. * @returns internal format corresponding to the Basis format
  138954. */
  138955. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138956. private static _WorkerPromise;
  138957. private static _Worker;
  138958. private static _actionId;
  138959. private static _CreateWorkerAsync;
  138960. /**
  138961. * Transcodes a loaded image file to compressed pixel data
  138962. * @param data image data to transcode
  138963. * @param config configuration options for the transcoding
  138964. * @returns a promise resulting in the transcoded image
  138965. */
  138966. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138967. /**
  138968. * Loads a texture from the transcode result
  138969. * @param texture texture load to
  138970. * @param transcodeResult the result of transcoding the basis file to load from
  138971. */
  138972. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138973. }
  138974. }
  138975. declare module BABYLON {
  138976. /**
  138977. * Loader for .basis file format
  138978. */
  138979. export class _BasisTextureLoader implements IInternalTextureLoader {
  138980. /**
  138981. * Defines whether the loader supports cascade loading the different faces.
  138982. */
  138983. readonly supportCascades: boolean;
  138984. /**
  138985. * This returns if the loader support the current file information.
  138986. * @param extension defines the file extension of the file being loaded
  138987. * @returns true if the loader can load the specified file
  138988. */
  138989. canLoad(extension: string): boolean;
  138990. /**
  138991. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138992. * @param data contains the texture data
  138993. * @param texture defines the BabylonJS internal texture
  138994. * @param createPolynomials will be true if polynomials have been requested
  138995. * @param onLoad defines the callback to trigger once the texture is ready
  138996. * @param onError defines the callback to trigger in case of error
  138997. */
  138998. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138999. /**
  139000. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139001. * @param data contains the texture data
  139002. * @param texture defines the BabylonJS internal texture
  139003. * @param callback defines the method to call once ready to upload
  139004. */
  139005. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139006. }
  139007. }
  139008. declare module BABYLON {
  139009. /**
  139010. * Defines the basic options interface of a TexturePacker Frame
  139011. */
  139012. export interface ITexturePackerFrame {
  139013. /**
  139014. * The frame ID
  139015. */
  139016. id: number;
  139017. /**
  139018. * The frames Scale
  139019. */
  139020. scale: Vector2;
  139021. /**
  139022. * The Frames offset
  139023. */
  139024. offset: Vector2;
  139025. }
  139026. /**
  139027. * This is a support class for frame Data on texture packer sets.
  139028. */
  139029. export class TexturePackerFrame implements ITexturePackerFrame {
  139030. /**
  139031. * The frame ID
  139032. */
  139033. id: number;
  139034. /**
  139035. * The frames Scale
  139036. */
  139037. scale: Vector2;
  139038. /**
  139039. * The Frames offset
  139040. */
  139041. offset: Vector2;
  139042. /**
  139043. * Initializes a texture package frame.
  139044. * @param id The numerical frame identifier
  139045. * @param scale Scalar Vector2 for UV frame
  139046. * @param offset Vector2 for the frame position in UV units.
  139047. * @returns TexturePackerFrame
  139048. */
  139049. constructor(id: number, scale: Vector2, offset: Vector2);
  139050. }
  139051. }
  139052. declare module BABYLON {
  139053. /**
  139054. * Defines the basic options interface of a TexturePacker
  139055. */
  139056. export interface ITexturePackerOptions {
  139057. /**
  139058. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139059. */
  139060. map?: string[];
  139061. /**
  139062. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139063. */
  139064. uvsIn?: string;
  139065. /**
  139066. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139067. */
  139068. uvsOut?: string;
  139069. /**
  139070. * number representing the layout style. Defaults to LAYOUT_STRIP
  139071. */
  139072. layout?: number;
  139073. /**
  139074. * number of columns if using custom column count layout(2). This defaults to 4.
  139075. */
  139076. colnum?: number;
  139077. /**
  139078. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139079. */
  139080. updateInputMeshes?: boolean;
  139081. /**
  139082. * boolean flag to dispose all the source textures. Defaults to true.
  139083. */
  139084. disposeSources?: boolean;
  139085. /**
  139086. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139087. */
  139088. fillBlanks?: boolean;
  139089. /**
  139090. * string value representing the context fill style color. Defaults to 'black'.
  139091. */
  139092. customFillColor?: string;
  139093. /**
  139094. * Width and Height Value of each Frame in the TexturePacker Sets
  139095. */
  139096. frameSize?: number;
  139097. /**
  139098. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139099. */
  139100. paddingRatio?: number;
  139101. /**
  139102. * Number that declares the fill method for the padding gutter.
  139103. */
  139104. paddingMode?: number;
  139105. /**
  139106. * If in SUBUV_COLOR padding mode what color to use.
  139107. */
  139108. paddingColor?: Color3 | Color4;
  139109. }
  139110. /**
  139111. * Defines the basic interface of a TexturePacker JSON File
  139112. */
  139113. export interface ITexturePackerJSON {
  139114. /**
  139115. * The frame ID
  139116. */
  139117. name: string;
  139118. /**
  139119. * The base64 channel data
  139120. */
  139121. sets: any;
  139122. /**
  139123. * The options of the Packer
  139124. */
  139125. options: ITexturePackerOptions;
  139126. /**
  139127. * The frame data of the Packer
  139128. */
  139129. frames: Array<number>;
  139130. }
  139131. /**
  139132. * This is a support class that generates a series of packed texture sets.
  139133. * @see https://doc.babylonjs.com/babylon101/materials
  139134. */
  139135. export class TexturePacker {
  139136. /** Packer Layout Constant 0 */
  139137. static readonly LAYOUT_STRIP: number;
  139138. /** Packer Layout Constant 1 */
  139139. static readonly LAYOUT_POWER2: number;
  139140. /** Packer Layout Constant 2 */
  139141. static readonly LAYOUT_COLNUM: number;
  139142. /** Packer Layout Constant 0 */
  139143. static readonly SUBUV_WRAP: number;
  139144. /** Packer Layout Constant 1 */
  139145. static readonly SUBUV_EXTEND: number;
  139146. /** Packer Layout Constant 2 */
  139147. static readonly SUBUV_COLOR: number;
  139148. /** The Name of the Texture Package */
  139149. name: string;
  139150. /** The scene scope of the TexturePacker */
  139151. scene: Scene;
  139152. /** The Meshes to target */
  139153. meshes: AbstractMesh[];
  139154. /** Arguments passed with the Constructor */
  139155. options: ITexturePackerOptions;
  139156. /** The promise that is started upon initialization */
  139157. promise: Nullable<Promise<TexturePacker | string>>;
  139158. /** The Container object for the channel sets that are generated */
  139159. sets: object;
  139160. /** The Container array for the frames that are generated */
  139161. frames: TexturePackerFrame[];
  139162. /** The expected number of textures the system is parsing. */
  139163. private _expecting;
  139164. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139165. private _paddingValue;
  139166. /**
  139167. * Initializes a texture package series from an array of meshes or a single mesh.
  139168. * @param name The name of the package
  139169. * @param meshes The target meshes to compose the package from
  139170. * @param options The arguments that texture packer should follow while building.
  139171. * @param scene The scene which the textures are scoped to.
  139172. * @returns TexturePacker
  139173. */
  139174. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139175. /**
  139176. * Starts the package process
  139177. * @param resolve The promises resolution function
  139178. * @returns TexturePacker
  139179. */
  139180. private _createFrames;
  139181. /**
  139182. * Calculates the Size of the Channel Sets
  139183. * @returns Vector2
  139184. */
  139185. private _calculateSize;
  139186. /**
  139187. * Calculates the UV data for the frames.
  139188. * @param baseSize the base frameSize
  139189. * @param padding the base frame padding
  139190. * @param dtSize size of the Dynamic Texture for that channel
  139191. * @param dtUnits is 1/dtSize
  139192. * @param update flag to update the input meshes
  139193. */
  139194. private _calculateMeshUVFrames;
  139195. /**
  139196. * Calculates the frames Offset.
  139197. * @param index of the frame
  139198. * @returns Vector2
  139199. */
  139200. private _getFrameOffset;
  139201. /**
  139202. * Updates a Mesh to the frame data
  139203. * @param mesh that is the target
  139204. * @param frameID or the frame index
  139205. */
  139206. private _updateMeshUV;
  139207. /**
  139208. * Updates a Meshes materials to use the texture packer channels
  139209. * @param m is the mesh to target
  139210. * @param force all channels on the packer to be set.
  139211. */
  139212. private _updateTextureReferences;
  139213. /**
  139214. * Public method to set a Mesh to a frame
  139215. * @param m that is the target
  139216. * @param frameID or the frame index
  139217. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139218. */
  139219. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139220. /**
  139221. * Starts the async promise to compile the texture packer.
  139222. * @returns Promise<void>
  139223. */
  139224. processAsync(): Promise<void>;
  139225. /**
  139226. * Disposes all textures associated with this packer
  139227. */
  139228. dispose(): void;
  139229. /**
  139230. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139231. * @param imageType is the image type to use.
  139232. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139233. */
  139234. download(imageType?: string, quality?: number): void;
  139235. /**
  139236. * Public method to load a texturePacker JSON file.
  139237. * @param data of the JSON file in string format.
  139238. */
  139239. updateFromJSON(data: string): void;
  139240. }
  139241. }
  139242. declare module BABYLON {
  139243. /**
  139244. * 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.
  139245. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139246. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139247. */
  139248. export class CustomProceduralTexture extends ProceduralTexture {
  139249. private _animate;
  139250. private _time;
  139251. private _config;
  139252. private _texturePath;
  139253. /**
  139254. * Instantiates a new Custom Procedural Texture.
  139255. * 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.
  139256. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139257. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139258. * @param name Define the name of the texture
  139259. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139260. * @param size Define the size of the texture to create
  139261. * @param scene Define the scene the texture belongs to
  139262. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139263. * @param generateMipMaps Define if the texture should creates mip maps or not
  139264. */
  139265. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139266. private _loadJson;
  139267. /**
  139268. * Is the texture ready to be used ? (rendered at least once)
  139269. * @returns true if ready, otherwise, false.
  139270. */
  139271. isReady(): boolean;
  139272. /**
  139273. * Render the texture to its associated render target.
  139274. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139275. */
  139276. render(useCameraPostProcess?: boolean): void;
  139277. /**
  139278. * Update the list of dependant textures samplers in the shader.
  139279. */
  139280. updateTextures(): void;
  139281. /**
  139282. * Update the uniform values of the procedural texture in the shader.
  139283. */
  139284. updateShaderUniforms(): void;
  139285. /**
  139286. * Define if the texture animates or not.
  139287. */
  139288. get animate(): boolean;
  139289. set animate(value: boolean);
  139290. }
  139291. }
  139292. declare module BABYLON {
  139293. /** @hidden */
  139294. export var noisePixelShader: {
  139295. name: string;
  139296. shader: string;
  139297. };
  139298. }
  139299. declare module BABYLON {
  139300. /**
  139301. * Class used to generate noise procedural textures
  139302. */
  139303. export class NoiseProceduralTexture extends ProceduralTexture {
  139304. private _time;
  139305. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139306. brightness: number;
  139307. /** Defines the number of octaves to process */
  139308. octaves: number;
  139309. /** Defines the level of persistence (0.8 by default) */
  139310. persistence: number;
  139311. /** Gets or sets animation speed factor (default is 1) */
  139312. animationSpeedFactor: number;
  139313. /**
  139314. * Creates a new NoiseProceduralTexture
  139315. * @param name defines the name fo the texture
  139316. * @param size defines the size of the texture (default is 256)
  139317. * @param scene defines the hosting scene
  139318. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139319. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139320. */
  139321. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139322. private _updateShaderUniforms;
  139323. protected _getDefines(): string;
  139324. /** Generate the current state of the procedural texture */
  139325. render(useCameraPostProcess?: boolean): void;
  139326. /**
  139327. * Serializes this noise procedural texture
  139328. * @returns a serialized noise procedural texture object
  139329. */
  139330. serialize(): any;
  139331. /**
  139332. * Clone the texture.
  139333. * @returns the cloned texture
  139334. */
  139335. clone(): NoiseProceduralTexture;
  139336. /**
  139337. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139338. * @param parsedTexture defines parsed texture data
  139339. * @param scene defines the current scene
  139340. * @param rootUrl defines the root URL containing noise procedural texture information
  139341. * @returns a parsed NoiseProceduralTexture
  139342. */
  139343. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139344. }
  139345. }
  139346. declare module BABYLON {
  139347. /**
  139348. * Raw cube texture where the raw buffers are passed in
  139349. */
  139350. export class RawCubeTexture extends CubeTexture {
  139351. /**
  139352. * Creates a cube texture where the raw buffers are passed in.
  139353. * @param scene defines the scene the texture is attached to
  139354. * @param data defines the array of data to use to create each face
  139355. * @param size defines the size of the textures
  139356. * @param format defines the format of the data
  139357. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139358. * @param generateMipMaps defines if the engine should generate the mip levels
  139359. * @param invertY defines if data must be stored with Y axis inverted
  139360. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139361. * @param compression defines the compression used (null by default)
  139362. */
  139363. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139364. /**
  139365. * Updates the raw cube texture.
  139366. * @param data defines the data to store
  139367. * @param format defines the data format
  139368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139369. * @param invertY defines if data must be stored with Y axis inverted
  139370. * @param compression defines the compression used (null by default)
  139371. * @param level defines which level of the texture to update
  139372. */
  139373. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139374. /**
  139375. * Updates a raw cube texture with RGBD encoded data.
  139376. * @param data defines the array of data [mipmap][face] to use to create each face
  139377. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139378. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139379. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139380. * @returns a promsie that resolves when the operation is complete
  139381. */
  139382. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139383. /**
  139384. * Clones the raw cube texture.
  139385. * @return a new cube texture
  139386. */
  139387. clone(): CubeTexture;
  139388. /** @hidden */
  139389. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139390. }
  139391. }
  139392. declare module BABYLON {
  139393. /**
  139394. * Class used to store 2D array textures containing user data
  139395. */
  139396. export class RawTexture2DArray extends Texture {
  139397. /** Gets or sets the texture format to use */
  139398. format: number;
  139399. /**
  139400. * Create a new RawTexture2DArray
  139401. * @param data defines the data of the texture
  139402. * @param width defines the width of the texture
  139403. * @param height defines the height of the texture
  139404. * @param depth defines the number of layers of the texture
  139405. * @param format defines the texture format to use
  139406. * @param scene defines the hosting scene
  139407. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139408. * @param invertY defines if texture must be stored with Y axis inverted
  139409. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139410. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139411. */
  139412. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139413. /** Gets or sets the texture format to use */
  139414. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139415. /**
  139416. * Update the texture with new data
  139417. * @param data defines the data to store in the texture
  139418. */
  139419. update(data: ArrayBufferView): void;
  139420. }
  139421. }
  139422. declare module BABYLON {
  139423. /**
  139424. * Class used to store 3D textures containing user data
  139425. */
  139426. export class RawTexture3D extends Texture {
  139427. /** Gets or sets the texture format to use */
  139428. format: number;
  139429. /**
  139430. * Create a new RawTexture3D
  139431. * @param data defines the data of the texture
  139432. * @param width defines the width of the texture
  139433. * @param height defines the height of the texture
  139434. * @param depth defines the depth of the texture
  139435. * @param format defines the texture format to use
  139436. * @param scene defines the hosting scene
  139437. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139438. * @param invertY defines if texture must be stored with Y axis inverted
  139439. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139440. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139441. */
  139442. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139443. /** Gets or sets the texture format to use */
  139444. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139445. /**
  139446. * Update the texture with new data
  139447. * @param data defines the data to store in the texture
  139448. */
  139449. update(data: ArrayBufferView): void;
  139450. }
  139451. }
  139452. declare module BABYLON {
  139453. /**
  139454. * Creates a refraction texture used by refraction channel of the standard material.
  139455. * It is like a mirror but to see through a material.
  139456. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139457. */
  139458. export class RefractionTexture extends RenderTargetTexture {
  139459. /**
  139460. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139461. * 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.
  139462. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139463. */
  139464. refractionPlane: Plane;
  139465. /**
  139466. * Define how deep under the surface we should see.
  139467. */
  139468. depth: number;
  139469. /**
  139470. * Creates a refraction texture used by refraction channel of the standard material.
  139471. * It is like a mirror but to see through a material.
  139472. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139473. * @param name Define the texture name
  139474. * @param size Define the size of the underlying texture
  139475. * @param scene Define the scene the refraction belongs to
  139476. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139477. */
  139478. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139479. /**
  139480. * Clone the refraction texture.
  139481. * @returns the cloned texture
  139482. */
  139483. clone(): RefractionTexture;
  139484. /**
  139485. * Serialize the texture to a JSON representation you could use in Parse later on
  139486. * @returns the serialized JSON representation
  139487. */
  139488. serialize(): any;
  139489. }
  139490. }
  139491. declare module BABYLON {
  139492. /**
  139493. * Block used to add support for vertex skinning (bones)
  139494. */
  139495. export class BonesBlock extends NodeMaterialBlock {
  139496. /**
  139497. * Creates a new BonesBlock
  139498. * @param name defines the block name
  139499. */
  139500. constructor(name: string);
  139501. /**
  139502. * Initialize the block and prepare the context for build
  139503. * @param state defines the state that will be used for the build
  139504. */
  139505. initialize(state: NodeMaterialBuildState): void;
  139506. /**
  139507. * Gets the current class name
  139508. * @returns the class name
  139509. */
  139510. getClassName(): string;
  139511. /**
  139512. * Gets the matrix indices input component
  139513. */
  139514. get matricesIndices(): NodeMaterialConnectionPoint;
  139515. /**
  139516. * Gets the matrix weights input component
  139517. */
  139518. get matricesWeights(): NodeMaterialConnectionPoint;
  139519. /**
  139520. * Gets the extra matrix indices input component
  139521. */
  139522. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139523. /**
  139524. * Gets the extra matrix weights input component
  139525. */
  139526. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139527. /**
  139528. * Gets the world input component
  139529. */
  139530. get world(): NodeMaterialConnectionPoint;
  139531. /**
  139532. * Gets the output component
  139533. */
  139534. get output(): NodeMaterialConnectionPoint;
  139535. autoConfigure(material: NodeMaterial): void;
  139536. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139539. protected _buildBlock(state: NodeMaterialBuildState): this;
  139540. }
  139541. }
  139542. declare module BABYLON {
  139543. /**
  139544. * Block used to add support for instances
  139545. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139546. */
  139547. export class InstancesBlock extends NodeMaterialBlock {
  139548. /**
  139549. * Creates a new InstancesBlock
  139550. * @param name defines the block name
  139551. */
  139552. constructor(name: string);
  139553. /**
  139554. * Gets the current class name
  139555. * @returns the class name
  139556. */
  139557. getClassName(): string;
  139558. /**
  139559. * Gets the first world row input component
  139560. */
  139561. get world0(): NodeMaterialConnectionPoint;
  139562. /**
  139563. * Gets the second world row input component
  139564. */
  139565. get world1(): NodeMaterialConnectionPoint;
  139566. /**
  139567. * Gets the third world row input component
  139568. */
  139569. get world2(): NodeMaterialConnectionPoint;
  139570. /**
  139571. * Gets the forth world row input component
  139572. */
  139573. get world3(): NodeMaterialConnectionPoint;
  139574. /**
  139575. * Gets the world input component
  139576. */
  139577. get world(): NodeMaterialConnectionPoint;
  139578. /**
  139579. * Gets the output component
  139580. */
  139581. get output(): NodeMaterialConnectionPoint;
  139582. /**
  139583. * Gets the isntanceID component
  139584. */
  139585. get instanceID(): NodeMaterialConnectionPoint;
  139586. autoConfigure(material: NodeMaterial): void;
  139587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139588. protected _buildBlock(state: NodeMaterialBuildState): this;
  139589. }
  139590. }
  139591. declare module BABYLON {
  139592. /**
  139593. * Block used to add morph targets support to vertex shader
  139594. */
  139595. export class MorphTargetsBlock extends NodeMaterialBlock {
  139596. private _repeatableContentAnchor;
  139597. /**
  139598. * Create a new MorphTargetsBlock
  139599. * @param name defines the block name
  139600. */
  139601. constructor(name: string);
  139602. /**
  139603. * Gets the current class name
  139604. * @returns the class name
  139605. */
  139606. getClassName(): string;
  139607. /**
  139608. * Gets the position input component
  139609. */
  139610. get position(): NodeMaterialConnectionPoint;
  139611. /**
  139612. * Gets the normal input component
  139613. */
  139614. get normal(): NodeMaterialConnectionPoint;
  139615. /**
  139616. * Gets the tangent input component
  139617. */
  139618. get tangent(): NodeMaterialConnectionPoint;
  139619. /**
  139620. * Gets the tangent input component
  139621. */
  139622. get uv(): NodeMaterialConnectionPoint;
  139623. /**
  139624. * Gets the position output component
  139625. */
  139626. get positionOutput(): NodeMaterialConnectionPoint;
  139627. /**
  139628. * Gets the normal output component
  139629. */
  139630. get normalOutput(): NodeMaterialConnectionPoint;
  139631. /**
  139632. * Gets the tangent output component
  139633. */
  139634. get tangentOutput(): NodeMaterialConnectionPoint;
  139635. /**
  139636. * Gets the tangent output component
  139637. */
  139638. get uvOutput(): NodeMaterialConnectionPoint;
  139639. initialize(state: NodeMaterialBuildState): void;
  139640. autoConfigure(material: NodeMaterial): void;
  139641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139643. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139644. protected _buildBlock(state: NodeMaterialBuildState): this;
  139645. }
  139646. }
  139647. declare module BABYLON {
  139648. /**
  139649. * Block used to get data information from a light
  139650. */
  139651. export class LightInformationBlock extends NodeMaterialBlock {
  139652. private _lightDataUniformName;
  139653. private _lightColorUniformName;
  139654. private _lightTypeDefineName;
  139655. /**
  139656. * Gets or sets the light associated with this block
  139657. */
  139658. light: Nullable<Light>;
  139659. /**
  139660. * Creates a new LightInformationBlock
  139661. * @param name defines the block name
  139662. */
  139663. constructor(name: string);
  139664. /**
  139665. * Gets the current class name
  139666. * @returns the class name
  139667. */
  139668. getClassName(): string;
  139669. /**
  139670. * Gets the world position input component
  139671. */
  139672. get worldPosition(): NodeMaterialConnectionPoint;
  139673. /**
  139674. * Gets the direction output component
  139675. */
  139676. get direction(): NodeMaterialConnectionPoint;
  139677. /**
  139678. * Gets the direction output component
  139679. */
  139680. get color(): NodeMaterialConnectionPoint;
  139681. /**
  139682. * Gets the direction output component
  139683. */
  139684. get intensity(): NodeMaterialConnectionPoint;
  139685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139687. protected _buildBlock(state: NodeMaterialBuildState): this;
  139688. serialize(): any;
  139689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139690. }
  139691. }
  139692. declare module BABYLON {
  139693. /**
  139694. * Block used to add image processing support to fragment shader
  139695. */
  139696. export class ImageProcessingBlock extends NodeMaterialBlock {
  139697. /**
  139698. * Create a new ImageProcessingBlock
  139699. * @param name defines the block name
  139700. */
  139701. constructor(name: string);
  139702. /**
  139703. * Gets the current class name
  139704. * @returns the class name
  139705. */
  139706. getClassName(): string;
  139707. /**
  139708. * Gets the color input component
  139709. */
  139710. get color(): NodeMaterialConnectionPoint;
  139711. /**
  139712. * Gets the output component
  139713. */
  139714. get output(): NodeMaterialConnectionPoint;
  139715. /**
  139716. * Initialize the block and prepare the context for build
  139717. * @param state defines the state that will be used for the build
  139718. */
  139719. initialize(state: NodeMaterialBuildState): void;
  139720. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139722. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139723. protected _buildBlock(state: NodeMaterialBuildState): this;
  139724. }
  139725. }
  139726. declare module BABYLON {
  139727. /**
  139728. * Block used to pertub normals based on a normal map
  139729. */
  139730. export class PerturbNormalBlock extends NodeMaterialBlock {
  139731. private _tangentSpaceParameterName;
  139732. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139733. invertX: boolean;
  139734. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139735. invertY: boolean;
  139736. /**
  139737. * Create a new PerturbNormalBlock
  139738. * @param name defines the block name
  139739. */
  139740. constructor(name: string);
  139741. /**
  139742. * Gets the current class name
  139743. * @returns the class name
  139744. */
  139745. getClassName(): string;
  139746. /**
  139747. * Gets the world position input component
  139748. */
  139749. get worldPosition(): NodeMaterialConnectionPoint;
  139750. /**
  139751. * Gets the world normal input component
  139752. */
  139753. get worldNormal(): NodeMaterialConnectionPoint;
  139754. /**
  139755. * Gets the world tangent input component
  139756. */
  139757. get worldTangent(): NodeMaterialConnectionPoint;
  139758. /**
  139759. * Gets the uv input component
  139760. */
  139761. get uv(): NodeMaterialConnectionPoint;
  139762. /**
  139763. * Gets the normal map color input component
  139764. */
  139765. get normalMapColor(): NodeMaterialConnectionPoint;
  139766. /**
  139767. * Gets the strength input component
  139768. */
  139769. get strength(): NodeMaterialConnectionPoint;
  139770. /**
  139771. * Gets the output component
  139772. */
  139773. get output(): NodeMaterialConnectionPoint;
  139774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139775. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139776. autoConfigure(material: NodeMaterial): void;
  139777. protected _buildBlock(state: NodeMaterialBuildState): this;
  139778. protected _dumpPropertiesCode(): string;
  139779. serialize(): any;
  139780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139781. }
  139782. }
  139783. declare module BABYLON {
  139784. /**
  139785. * Block used to discard a pixel if a value is smaller than a cutoff
  139786. */
  139787. export class DiscardBlock extends NodeMaterialBlock {
  139788. /**
  139789. * Create a new DiscardBlock
  139790. * @param name defines the block name
  139791. */
  139792. constructor(name: string);
  139793. /**
  139794. * Gets the current class name
  139795. * @returns the class name
  139796. */
  139797. getClassName(): string;
  139798. /**
  139799. * Gets the color input component
  139800. */
  139801. get value(): NodeMaterialConnectionPoint;
  139802. /**
  139803. * Gets the cutoff input component
  139804. */
  139805. get cutoff(): NodeMaterialConnectionPoint;
  139806. protected _buildBlock(state: NodeMaterialBuildState): this;
  139807. }
  139808. }
  139809. declare module BABYLON {
  139810. /**
  139811. * Block used to test if the fragment shader is front facing
  139812. */
  139813. export class FrontFacingBlock extends NodeMaterialBlock {
  139814. /**
  139815. * Creates a new FrontFacingBlock
  139816. * @param name defines the block name
  139817. */
  139818. constructor(name: string);
  139819. /**
  139820. * Gets the current class name
  139821. * @returns the class name
  139822. */
  139823. getClassName(): string;
  139824. /**
  139825. * Gets the output component
  139826. */
  139827. get output(): NodeMaterialConnectionPoint;
  139828. protected _buildBlock(state: NodeMaterialBuildState): this;
  139829. }
  139830. }
  139831. declare module BABYLON {
  139832. /**
  139833. * Block used to get the derivative value on x and y of a given input
  139834. */
  139835. export class DerivativeBlock extends NodeMaterialBlock {
  139836. /**
  139837. * Create a new DerivativeBlock
  139838. * @param name defines the block name
  139839. */
  139840. constructor(name: string);
  139841. /**
  139842. * Gets the current class name
  139843. * @returns the class name
  139844. */
  139845. getClassName(): string;
  139846. /**
  139847. * Gets the input component
  139848. */
  139849. get input(): NodeMaterialConnectionPoint;
  139850. /**
  139851. * Gets the derivative output on x
  139852. */
  139853. get dx(): NodeMaterialConnectionPoint;
  139854. /**
  139855. * Gets the derivative output on y
  139856. */
  139857. get dy(): NodeMaterialConnectionPoint;
  139858. protected _buildBlock(state: NodeMaterialBuildState): this;
  139859. }
  139860. }
  139861. declare module BABYLON {
  139862. /**
  139863. * Block used to make gl_FragCoord available
  139864. */
  139865. export class FragCoordBlock extends NodeMaterialBlock {
  139866. /**
  139867. * Creates a new FragCoordBlock
  139868. * @param name defines the block name
  139869. */
  139870. constructor(name: string);
  139871. /**
  139872. * Gets the current class name
  139873. * @returns the class name
  139874. */
  139875. getClassName(): string;
  139876. /**
  139877. * Gets the xy component
  139878. */
  139879. get xy(): NodeMaterialConnectionPoint;
  139880. /**
  139881. * Gets the xyz component
  139882. */
  139883. get xyz(): NodeMaterialConnectionPoint;
  139884. /**
  139885. * Gets the xyzw component
  139886. */
  139887. get xyzw(): NodeMaterialConnectionPoint;
  139888. /**
  139889. * Gets the x component
  139890. */
  139891. get x(): NodeMaterialConnectionPoint;
  139892. /**
  139893. * Gets the y component
  139894. */
  139895. get y(): NodeMaterialConnectionPoint;
  139896. /**
  139897. * Gets the z component
  139898. */
  139899. get z(): NodeMaterialConnectionPoint;
  139900. /**
  139901. * Gets the w component
  139902. */
  139903. get output(): NodeMaterialConnectionPoint;
  139904. protected writeOutputs(state: NodeMaterialBuildState): string;
  139905. protected _buildBlock(state: NodeMaterialBuildState): this;
  139906. }
  139907. }
  139908. declare module BABYLON {
  139909. /**
  139910. * Block used to get the screen sizes
  139911. */
  139912. export class ScreenSizeBlock extends NodeMaterialBlock {
  139913. private _varName;
  139914. private _scene;
  139915. /**
  139916. * Creates a new ScreenSizeBlock
  139917. * @param name defines the block name
  139918. */
  139919. constructor(name: string);
  139920. /**
  139921. * Gets the current class name
  139922. * @returns the class name
  139923. */
  139924. getClassName(): string;
  139925. /**
  139926. * Gets the xy component
  139927. */
  139928. get xy(): NodeMaterialConnectionPoint;
  139929. /**
  139930. * Gets the x component
  139931. */
  139932. get x(): NodeMaterialConnectionPoint;
  139933. /**
  139934. * Gets the y component
  139935. */
  139936. get y(): NodeMaterialConnectionPoint;
  139937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139938. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139939. protected _buildBlock(state: NodeMaterialBuildState): this;
  139940. }
  139941. }
  139942. declare module BABYLON {
  139943. /**
  139944. * Block used to add support for scene fog
  139945. */
  139946. export class FogBlock extends NodeMaterialBlock {
  139947. private _fogDistanceName;
  139948. private _fogParameters;
  139949. /**
  139950. * Create a new FogBlock
  139951. * @param name defines the block name
  139952. */
  139953. constructor(name: string);
  139954. /**
  139955. * Gets the current class name
  139956. * @returns the class name
  139957. */
  139958. getClassName(): string;
  139959. /**
  139960. * Gets the world position input component
  139961. */
  139962. get worldPosition(): NodeMaterialConnectionPoint;
  139963. /**
  139964. * Gets the view input component
  139965. */
  139966. get view(): NodeMaterialConnectionPoint;
  139967. /**
  139968. * Gets the color input component
  139969. */
  139970. get input(): NodeMaterialConnectionPoint;
  139971. /**
  139972. * Gets the fog color input component
  139973. */
  139974. get fogColor(): NodeMaterialConnectionPoint;
  139975. /**
  139976. * Gets the output component
  139977. */
  139978. get output(): NodeMaterialConnectionPoint;
  139979. autoConfigure(material: NodeMaterial): void;
  139980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139982. protected _buildBlock(state: NodeMaterialBuildState): this;
  139983. }
  139984. }
  139985. declare module BABYLON {
  139986. /**
  139987. * Block used to add light in the fragment shader
  139988. */
  139989. export class LightBlock extends NodeMaterialBlock {
  139990. private _lightId;
  139991. /**
  139992. * Gets or sets the light associated with this block
  139993. */
  139994. light: Nullable<Light>;
  139995. /**
  139996. * Create a new LightBlock
  139997. * @param name defines the block name
  139998. */
  139999. constructor(name: string);
  140000. /**
  140001. * Gets the current class name
  140002. * @returns the class name
  140003. */
  140004. getClassName(): string;
  140005. /**
  140006. * Gets the world position input component
  140007. */
  140008. get worldPosition(): NodeMaterialConnectionPoint;
  140009. /**
  140010. * Gets the world normal input component
  140011. */
  140012. get worldNormal(): NodeMaterialConnectionPoint;
  140013. /**
  140014. * Gets the camera (or eye) position component
  140015. */
  140016. get cameraPosition(): NodeMaterialConnectionPoint;
  140017. /**
  140018. * Gets the glossiness component
  140019. */
  140020. get glossiness(): NodeMaterialConnectionPoint;
  140021. /**
  140022. * Gets the glossinness power component
  140023. */
  140024. get glossPower(): NodeMaterialConnectionPoint;
  140025. /**
  140026. * Gets the diffuse color component
  140027. */
  140028. get diffuseColor(): NodeMaterialConnectionPoint;
  140029. /**
  140030. * Gets the specular color component
  140031. */
  140032. get specularColor(): NodeMaterialConnectionPoint;
  140033. /**
  140034. * Gets the diffuse output component
  140035. */
  140036. get diffuseOutput(): NodeMaterialConnectionPoint;
  140037. /**
  140038. * Gets the specular output component
  140039. */
  140040. get specularOutput(): NodeMaterialConnectionPoint;
  140041. /**
  140042. * Gets the shadow output component
  140043. */
  140044. get shadow(): NodeMaterialConnectionPoint;
  140045. autoConfigure(material: NodeMaterial): void;
  140046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140047. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140049. private _injectVertexCode;
  140050. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140051. serialize(): any;
  140052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140053. }
  140054. }
  140055. declare module BABYLON {
  140056. /**
  140057. * Block used to read a reflection texture from a sampler
  140058. */
  140059. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140060. /**
  140061. * Create a new ReflectionTextureBlock
  140062. * @param name defines the block name
  140063. */
  140064. constructor(name: string);
  140065. /**
  140066. * Gets the current class name
  140067. * @returns the class name
  140068. */
  140069. getClassName(): string;
  140070. /**
  140071. * Gets the world position input component
  140072. */
  140073. get position(): NodeMaterialConnectionPoint;
  140074. /**
  140075. * Gets the world position input component
  140076. */
  140077. get worldPosition(): NodeMaterialConnectionPoint;
  140078. /**
  140079. * Gets the world normal input component
  140080. */
  140081. get worldNormal(): NodeMaterialConnectionPoint;
  140082. /**
  140083. * Gets the world input component
  140084. */
  140085. get world(): NodeMaterialConnectionPoint;
  140086. /**
  140087. * Gets the camera (or eye) position component
  140088. */
  140089. get cameraPosition(): NodeMaterialConnectionPoint;
  140090. /**
  140091. * Gets the view input component
  140092. */
  140093. get view(): NodeMaterialConnectionPoint;
  140094. /**
  140095. * Gets the rgb output component
  140096. */
  140097. get rgb(): NodeMaterialConnectionPoint;
  140098. /**
  140099. * Gets the rgba output component
  140100. */
  140101. get rgba(): NodeMaterialConnectionPoint;
  140102. /**
  140103. * Gets the r output component
  140104. */
  140105. get r(): NodeMaterialConnectionPoint;
  140106. /**
  140107. * Gets the g output component
  140108. */
  140109. get g(): NodeMaterialConnectionPoint;
  140110. /**
  140111. * Gets the b output component
  140112. */
  140113. get b(): NodeMaterialConnectionPoint;
  140114. /**
  140115. * Gets the a output component
  140116. */
  140117. get a(): NodeMaterialConnectionPoint;
  140118. autoConfigure(material: NodeMaterial): void;
  140119. protected _buildBlock(state: NodeMaterialBuildState): this;
  140120. }
  140121. }
  140122. declare module BABYLON {
  140123. /**
  140124. * Block used to add 2 vectors
  140125. */
  140126. export class AddBlock extends NodeMaterialBlock {
  140127. /**
  140128. * Creates a new AddBlock
  140129. * @param name defines the block name
  140130. */
  140131. constructor(name: string);
  140132. /**
  140133. * Gets the current class name
  140134. * @returns the class name
  140135. */
  140136. getClassName(): string;
  140137. /**
  140138. * Gets the left operand input component
  140139. */
  140140. get left(): NodeMaterialConnectionPoint;
  140141. /**
  140142. * Gets the right operand input component
  140143. */
  140144. get right(): NodeMaterialConnectionPoint;
  140145. /**
  140146. * Gets the output component
  140147. */
  140148. get output(): NodeMaterialConnectionPoint;
  140149. protected _buildBlock(state: NodeMaterialBuildState): this;
  140150. }
  140151. }
  140152. declare module BABYLON {
  140153. /**
  140154. * Block used to scale a vector by a float
  140155. */
  140156. export class ScaleBlock extends NodeMaterialBlock {
  140157. /**
  140158. * Creates a new ScaleBlock
  140159. * @param name defines the block name
  140160. */
  140161. constructor(name: string);
  140162. /**
  140163. * Gets the current class name
  140164. * @returns the class name
  140165. */
  140166. getClassName(): string;
  140167. /**
  140168. * Gets the input component
  140169. */
  140170. get input(): NodeMaterialConnectionPoint;
  140171. /**
  140172. * Gets the factor input component
  140173. */
  140174. get factor(): NodeMaterialConnectionPoint;
  140175. /**
  140176. * Gets the output component
  140177. */
  140178. get output(): NodeMaterialConnectionPoint;
  140179. protected _buildBlock(state: NodeMaterialBuildState): this;
  140180. }
  140181. }
  140182. declare module BABYLON {
  140183. /**
  140184. * Block used to clamp a float
  140185. */
  140186. export class ClampBlock extends NodeMaterialBlock {
  140187. /** Gets or sets the minimum range */
  140188. minimum: number;
  140189. /** Gets or sets the maximum range */
  140190. maximum: number;
  140191. /**
  140192. * Creates a new ClampBlock
  140193. * @param name defines the block name
  140194. */
  140195. constructor(name: string);
  140196. /**
  140197. * Gets the current class name
  140198. * @returns the class name
  140199. */
  140200. getClassName(): string;
  140201. /**
  140202. * Gets the value input component
  140203. */
  140204. get value(): NodeMaterialConnectionPoint;
  140205. /**
  140206. * Gets the output component
  140207. */
  140208. get output(): NodeMaterialConnectionPoint;
  140209. protected _buildBlock(state: NodeMaterialBuildState): this;
  140210. protected _dumpPropertiesCode(): string;
  140211. serialize(): any;
  140212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140213. }
  140214. }
  140215. declare module BABYLON {
  140216. /**
  140217. * Block used to apply a cross product between 2 vectors
  140218. */
  140219. export class CrossBlock extends NodeMaterialBlock {
  140220. /**
  140221. * Creates a new CrossBlock
  140222. * @param name defines the block name
  140223. */
  140224. constructor(name: string);
  140225. /**
  140226. * Gets the current class name
  140227. * @returns the class name
  140228. */
  140229. getClassName(): string;
  140230. /**
  140231. * Gets the left operand input component
  140232. */
  140233. get left(): NodeMaterialConnectionPoint;
  140234. /**
  140235. * Gets the right operand input component
  140236. */
  140237. get right(): NodeMaterialConnectionPoint;
  140238. /**
  140239. * Gets the output component
  140240. */
  140241. get output(): NodeMaterialConnectionPoint;
  140242. protected _buildBlock(state: NodeMaterialBuildState): this;
  140243. }
  140244. }
  140245. declare module BABYLON {
  140246. /**
  140247. * Block used to apply a dot product between 2 vectors
  140248. */
  140249. export class DotBlock extends NodeMaterialBlock {
  140250. /**
  140251. * Creates a new DotBlock
  140252. * @param name defines the block name
  140253. */
  140254. constructor(name: string);
  140255. /**
  140256. * Gets the current class name
  140257. * @returns the class name
  140258. */
  140259. getClassName(): string;
  140260. /**
  140261. * Gets the left operand input component
  140262. */
  140263. get left(): NodeMaterialConnectionPoint;
  140264. /**
  140265. * Gets the right operand input component
  140266. */
  140267. get right(): NodeMaterialConnectionPoint;
  140268. /**
  140269. * Gets the output component
  140270. */
  140271. get output(): NodeMaterialConnectionPoint;
  140272. protected _buildBlock(state: NodeMaterialBuildState): this;
  140273. }
  140274. }
  140275. declare module BABYLON {
  140276. /**
  140277. * Block used to normalize a vector
  140278. */
  140279. export class NormalizeBlock extends NodeMaterialBlock {
  140280. /**
  140281. * Creates a new NormalizeBlock
  140282. * @param name defines the block name
  140283. */
  140284. constructor(name: string);
  140285. /**
  140286. * Gets the current class name
  140287. * @returns the class name
  140288. */
  140289. getClassName(): string;
  140290. /**
  140291. * Gets the input component
  140292. */
  140293. get input(): NodeMaterialConnectionPoint;
  140294. /**
  140295. * Gets the output component
  140296. */
  140297. get output(): NodeMaterialConnectionPoint;
  140298. protected _buildBlock(state: NodeMaterialBuildState): this;
  140299. }
  140300. }
  140301. declare module BABYLON {
  140302. /**
  140303. * Operations supported by the Trigonometry block
  140304. */
  140305. export enum TrigonometryBlockOperations {
  140306. /** Cos */
  140307. Cos = 0,
  140308. /** Sin */
  140309. Sin = 1,
  140310. /** Abs */
  140311. Abs = 2,
  140312. /** Exp */
  140313. Exp = 3,
  140314. /** Exp2 */
  140315. Exp2 = 4,
  140316. /** Round */
  140317. Round = 5,
  140318. /** Floor */
  140319. Floor = 6,
  140320. /** Ceiling */
  140321. Ceiling = 7,
  140322. /** Square root */
  140323. Sqrt = 8,
  140324. /** Log */
  140325. Log = 9,
  140326. /** Tangent */
  140327. Tan = 10,
  140328. /** Arc tangent */
  140329. ArcTan = 11,
  140330. /** Arc cosinus */
  140331. ArcCos = 12,
  140332. /** Arc sinus */
  140333. ArcSin = 13,
  140334. /** Fraction */
  140335. Fract = 14,
  140336. /** Sign */
  140337. Sign = 15,
  140338. /** To radians (from degrees) */
  140339. Radians = 16,
  140340. /** To degrees (from radians) */
  140341. Degrees = 17
  140342. }
  140343. /**
  140344. * Block used to apply trigonometry operation to floats
  140345. */
  140346. export class TrigonometryBlock extends NodeMaterialBlock {
  140347. /**
  140348. * Gets or sets the operation applied by the block
  140349. */
  140350. operation: TrigonometryBlockOperations;
  140351. /**
  140352. * Creates a new TrigonometryBlock
  140353. * @param name defines the block name
  140354. */
  140355. constructor(name: string);
  140356. /**
  140357. * Gets the current class name
  140358. * @returns the class name
  140359. */
  140360. getClassName(): string;
  140361. /**
  140362. * Gets the input component
  140363. */
  140364. get input(): NodeMaterialConnectionPoint;
  140365. /**
  140366. * Gets the output component
  140367. */
  140368. get output(): NodeMaterialConnectionPoint;
  140369. protected _buildBlock(state: NodeMaterialBuildState): this;
  140370. serialize(): any;
  140371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140372. protected _dumpPropertiesCode(): string;
  140373. }
  140374. }
  140375. declare module BABYLON {
  140376. /**
  140377. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140378. */
  140379. export class ColorMergerBlock extends NodeMaterialBlock {
  140380. /**
  140381. * Create a new ColorMergerBlock
  140382. * @param name defines the block name
  140383. */
  140384. constructor(name: string);
  140385. /**
  140386. * Gets the current class name
  140387. * @returns the class name
  140388. */
  140389. getClassName(): string;
  140390. /**
  140391. * Gets the rgb component (input)
  140392. */
  140393. get rgbIn(): NodeMaterialConnectionPoint;
  140394. /**
  140395. * Gets the r component (input)
  140396. */
  140397. get r(): NodeMaterialConnectionPoint;
  140398. /**
  140399. * Gets the g component (input)
  140400. */
  140401. get g(): NodeMaterialConnectionPoint;
  140402. /**
  140403. * Gets the b component (input)
  140404. */
  140405. get b(): NodeMaterialConnectionPoint;
  140406. /**
  140407. * Gets the a component (input)
  140408. */
  140409. get a(): NodeMaterialConnectionPoint;
  140410. /**
  140411. * Gets the rgba component (output)
  140412. */
  140413. get rgba(): NodeMaterialConnectionPoint;
  140414. /**
  140415. * Gets the rgb component (output)
  140416. */
  140417. get rgbOut(): NodeMaterialConnectionPoint;
  140418. /**
  140419. * Gets the rgb component (output)
  140420. * @deprecated Please use rgbOut instead.
  140421. */
  140422. get rgb(): NodeMaterialConnectionPoint;
  140423. protected _buildBlock(state: NodeMaterialBuildState): this;
  140424. }
  140425. }
  140426. declare module BABYLON {
  140427. /**
  140428. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140429. */
  140430. export class VectorSplitterBlock extends NodeMaterialBlock {
  140431. /**
  140432. * Create a new VectorSplitterBlock
  140433. * @param name defines the block name
  140434. */
  140435. constructor(name: string);
  140436. /**
  140437. * Gets the current class name
  140438. * @returns the class name
  140439. */
  140440. getClassName(): string;
  140441. /**
  140442. * Gets the xyzw component (input)
  140443. */
  140444. get xyzw(): NodeMaterialConnectionPoint;
  140445. /**
  140446. * Gets the xyz component (input)
  140447. */
  140448. get xyzIn(): NodeMaterialConnectionPoint;
  140449. /**
  140450. * Gets the xy component (input)
  140451. */
  140452. get xyIn(): NodeMaterialConnectionPoint;
  140453. /**
  140454. * Gets the xyz component (output)
  140455. */
  140456. get xyzOut(): NodeMaterialConnectionPoint;
  140457. /**
  140458. * Gets the xy component (output)
  140459. */
  140460. get xyOut(): NodeMaterialConnectionPoint;
  140461. /**
  140462. * Gets the x component (output)
  140463. */
  140464. get x(): NodeMaterialConnectionPoint;
  140465. /**
  140466. * Gets the y component (output)
  140467. */
  140468. get y(): NodeMaterialConnectionPoint;
  140469. /**
  140470. * Gets the z component (output)
  140471. */
  140472. get z(): NodeMaterialConnectionPoint;
  140473. /**
  140474. * Gets the w component (output)
  140475. */
  140476. get w(): NodeMaterialConnectionPoint;
  140477. protected _inputRename(name: string): string;
  140478. protected _outputRename(name: string): string;
  140479. protected _buildBlock(state: NodeMaterialBuildState): this;
  140480. }
  140481. }
  140482. declare module BABYLON {
  140483. /**
  140484. * Block used to lerp between 2 values
  140485. */
  140486. export class LerpBlock extends NodeMaterialBlock {
  140487. /**
  140488. * Creates a new LerpBlock
  140489. * @param name defines the block name
  140490. */
  140491. constructor(name: string);
  140492. /**
  140493. * Gets the current class name
  140494. * @returns the class name
  140495. */
  140496. getClassName(): string;
  140497. /**
  140498. * Gets the left operand input component
  140499. */
  140500. get left(): NodeMaterialConnectionPoint;
  140501. /**
  140502. * Gets the right operand input component
  140503. */
  140504. get right(): NodeMaterialConnectionPoint;
  140505. /**
  140506. * Gets the gradient operand input component
  140507. */
  140508. get gradient(): NodeMaterialConnectionPoint;
  140509. /**
  140510. * Gets the output component
  140511. */
  140512. get output(): NodeMaterialConnectionPoint;
  140513. protected _buildBlock(state: NodeMaterialBuildState): this;
  140514. }
  140515. }
  140516. declare module BABYLON {
  140517. /**
  140518. * Block used to divide 2 vectors
  140519. */
  140520. export class DivideBlock extends NodeMaterialBlock {
  140521. /**
  140522. * Creates a new DivideBlock
  140523. * @param name defines the block name
  140524. */
  140525. constructor(name: string);
  140526. /**
  140527. * Gets the current class name
  140528. * @returns the class name
  140529. */
  140530. getClassName(): string;
  140531. /**
  140532. * Gets the left operand input component
  140533. */
  140534. get left(): NodeMaterialConnectionPoint;
  140535. /**
  140536. * Gets the right operand input component
  140537. */
  140538. get right(): NodeMaterialConnectionPoint;
  140539. /**
  140540. * Gets the output component
  140541. */
  140542. get output(): NodeMaterialConnectionPoint;
  140543. protected _buildBlock(state: NodeMaterialBuildState): this;
  140544. }
  140545. }
  140546. declare module BABYLON {
  140547. /**
  140548. * Block used to subtract 2 vectors
  140549. */
  140550. export class SubtractBlock extends NodeMaterialBlock {
  140551. /**
  140552. * Creates a new SubtractBlock
  140553. * @param name defines the block name
  140554. */
  140555. constructor(name: string);
  140556. /**
  140557. * Gets the current class name
  140558. * @returns the class name
  140559. */
  140560. getClassName(): string;
  140561. /**
  140562. * Gets the left operand input component
  140563. */
  140564. get left(): NodeMaterialConnectionPoint;
  140565. /**
  140566. * Gets the right operand input component
  140567. */
  140568. get right(): NodeMaterialConnectionPoint;
  140569. /**
  140570. * Gets the output component
  140571. */
  140572. get output(): NodeMaterialConnectionPoint;
  140573. protected _buildBlock(state: NodeMaterialBuildState): this;
  140574. }
  140575. }
  140576. declare module BABYLON {
  140577. /**
  140578. * Block used to step a value
  140579. */
  140580. export class StepBlock extends NodeMaterialBlock {
  140581. /**
  140582. * Creates a new StepBlock
  140583. * @param name defines the block name
  140584. */
  140585. constructor(name: string);
  140586. /**
  140587. * Gets the current class name
  140588. * @returns the class name
  140589. */
  140590. getClassName(): string;
  140591. /**
  140592. * Gets the value operand input component
  140593. */
  140594. get value(): NodeMaterialConnectionPoint;
  140595. /**
  140596. * Gets the edge operand input component
  140597. */
  140598. get edge(): NodeMaterialConnectionPoint;
  140599. /**
  140600. * Gets the output component
  140601. */
  140602. get output(): NodeMaterialConnectionPoint;
  140603. protected _buildBlock(state: NodeMaterialBuildState): this;
  140604. }
  140605. }
  140606. declare module BABYLON {
  140607. /**
  140608. * Block used to get the opposite (1 - x) of a value
  140609. */
  140610. export class OneMinusBlock extends NodeMaterialBlock {
  140611. /**
  140612. * Creates a new OneMinusBlock
  140613. * @param name defines the block name
  140614. */
  140615. constructor(name: string);
  140616. /**
  140617. * Gets the current class name
  140618. * @returns the class name
  140619. */
  140620. getClassName(): string;
  140621. /**
  140622. * Gets the input component
  140623. */
  140624. get input(): NodeMaterialConnectionPoint;
  140625. /**
  140626. * Gets the output component
  140627. */
  140628. get output(): NodeMaterialConnectionPoint;
  140629. protected _buildBlock(state: NodeMaterialBuildState): this;
  140630. }
  140631. }
  140632. declare module BABYLON {
  140633. /**
  140634. * Block used to get the view direction
  140635. */
  140636. export class ViewDirectionBlock extends NodeMaterialBlock {
  140637. /**
  140638. * Creates a new ViewDirectionBlock
  140639. * @param name defines the block name
  140640. */
  140641. constructor(name: string);
  140642. /**
  140643. * Gets the current class name
  140644. * @returns the class name
  140645. */
  140646. getClassName(): string;
  140647. /**
  140648. * Gets the world position component
  140649. */
  140650. get worldPosition(): NodeMaterialConnectionPoint;
  140651. /**
  140652. * Gets the camera position component
  140653. */
  140654. get cameraPosition(): NodeMaterialConnectionPoint;
  140655. /**
  140656. * Gets the output component
  140657. */
  140658. get output(): NodeMaterialConnectionPoint;
  140659. autoConfigure(material: NodeMaterial): void;
  140660. protected _buildBlock(state: NodeMaterialBuildState): this;
  140661. }
  140662. }
  140663. declare module BABYLON {
  140664. /**
  140665. * Block used to compute fresnel value
  140666. */
  140667. export class FresnelBlock extends NodeMaterialBlock {
  140668. /**
  140669. * Create a new FresnelBlock
  140670. * @param name defines the block name
  140671. */
  140672. constructor(name: string);
  140673. /**
  140674. * Gets the current class name
  140675. * @returns the class name
  140676. */
  140677. getClassName(): string;
  140678. /**
  140679. * Gets the world normal input component
  140680. */
  140681. get worldNormal(): NodeMaterialConnectionPoint;
  140682. /**
  140683. * Gets the view direction input component
  140684. */
  140685. get viewDirection(): NodeMaterialConnectionPoint;
  140686. /**
  140687. * Gets the bias input component
  140688. */
  140689. get bias(): NodeMaterialConnectionPoint;
  140690. /**
  140691. * Gets the camera (or eye) position component
  140692. */
  140693. get power(): NodeMaterialConnectionPoint;
  140694. /**
  140695. * Gets the fresnel output component
  140696. */
  140697. get fresnel(): NodeMaterialConnectionPoint;
  140698. autoConfigure(material: NodeMaterial): void;
  140699. protected _buildBlock(state: NodeMaterialBuildState): this;
  140700. }
  140701. }
  140702. declare module BABYLON {
  140703. /**
  140704. * Block used to get the max of 2 values
  140705. */
  140706. export class MaxBlock extends NodeMaterialBlock {
  140707. /**
  140708. * Creates a new MaxBlock
  140709. * @param name defines the block name
  140710. */
  140711. constructor(name: string);
  140712. /**
  140713. * Gets the current class name
  140714. * @returns the class name
  140715. */
  140716. getClassName(): string;
  140717. /**
  140718. * Gets the left operand input component
  140719. */
  140720. get left(): NodeMaterialConnectionPoint;
  140721. /**
  140722. * Gets the right operand input component
  140723. */
  140724. get right(): NodeMaterialConnectionPoint;
  140725. /**
  140726. * Gets the output component
  140727. */
  140728. get output(): NodeMaterialConnectionPoint;
  140729. protected _buildBlock(state: NodeMaterialBuildState): this;
  140730. }
  140731. }
  140732. declare module BABYLON {
  140733. /**
  140734. * Block used to get the min of 2 values
  140735. */
  140736. export class MinBlock extends NodeMaterialBlock {
  140737. /**
  140738. * Creates a new MinBlock
  140739. * @param name defines the block name
  140740. */
  140741. constructor(name: string);
  140742. /**
  140743. * Gets the current class name
  140744. * @returns the class name
  140745. */
  140746. getClassName(): string;
  140747. /**
  140748. * Gets the left operand input component
  140749. */
  140750. get left(): NodeMaterialConnectionPoint;
  140751. /**
  140752. * Gets the right operand input component
  140753. */
  140754. get right(): NodeMaterialConnectionPoint;
  140755. /**
  140756. * Gets the output component
  140757. */
  140758. get output(): NodeMaterialConnectionPoint;
  140759. protected _buildBlock(state: NodeMaterialBuildState): this;
  140760. }
  140761. }
  140762. declare module BABYLON {
  140763. /**
  140764. * Block used to get the distance between 2 values
  140765. */
  140766. export class DistanceBlock extends NodeMaterialBlock {
  140767. /**
  140768. * Creates a new DistanceBlock
  140769. * @param name defines the block name
  140770. */
  140771. constructor(name: string);
  140772. /**
  140773. * Gets the current class name
  140774. * @returns the class name
  140775. */
  140776. getClassName(): string;
  140777. /**
  140778. * Gets the left operand input component
  140779. */
  140780. get left(): NodeMaterialConnectionPoint;
  140781. /**
  140782. * Gets the right operand input component
  140783. */
  140784. get right(): NodeMaterialConnectionPoint;
  140785. /**
  140786. * Gets the output component
  140787. */
  140788. get output(): NodeMaterialConnectionPoint;
  140789. protected _buildBlock(state: NodeMaterialBuildState): this;
  140790. }
  140791. }
  140792. declare module BABYLON {
  140793. /**
  140794. * Block used to get the length of a vector
  140795. */
  140796. export class LengthBlock extends NodeMaterialBlock {
  140797. /**
  140798. * Creates a new LengthBlock
  140799. * @param name defines the block name
  140800. */
  140801. constructor(name: string);
  140802. /**
  140803. * Gets the current class name
  140804. * @returns the class name
  140805. */
  140806. getClassName(): string;
  140807. /**
  140808. * Gets the value input component
  140809. */
  140810. get value(): NodeMaterialConnectionPoint;
  140811. /**
  140812. * Gets the output component
  140813. */
  140814. get output(): NodeMaterialConnectionPoint;
  140815. protected _buildBlock(state: NodeMaterialBuildState): this;
  140816. }
  140817. }
  140818. declare module BABYLON {
  140819. /**
  140820. * Block used to get negative version of a value (i.e. x * -1)
  140821. */
  140822. export class NegateBlock extends NodeMaterialBlock {
  140823. /**
  140824. * Creates a new NegateBlock
  140825. * @param name defines the block name
  140826. */
  140827. constructor(name: string);
  140828. /**
  140829. * Gets the current class name
  140830. * @returns the class name
  140831. */
  140832. getClassName(): string;
  140833. /**
  140834. * Gets the value input component
  140835. */
  140836. get value(): NodeMaterialConnectionPoint;
  140837. /**
  140838. * Gets the output component
  140839. */
  140840. get output(): NodeMaterialConnectionPoint;
  140841. protected _buildBlock(state: NodeMaterialBuildState): this;
  140842. }
  140843. }
  140844. declare module BABYLON {
  140845. /**
  140846. * Block used to get the value of the first parameter raised to the power of the second
  140847. */
  140848. export class PowBlock extends NodeMaterialBlock {
  140849. /**
  140850. * Creates a new PowBlock
  140851. * @param name defines the block name
  140852. */
  140853. constructor(name: string);
  140854. /**
  140855. * Gets the current class name
  140856. * @returns the class name
  140857. */
  140858. getClassName(): string;
  140859. /**
  140860. * Gets the value operand input component
  140861. */
  140862. get value(): NodeMaterialConnectionPoint;
  140863. /**
  140864. * Gets the power operand input component
  140865. */
  140866. get power(): NodeMaterialConnectionPoint;
  140867. /**
  140868. * Gets the output component
  140869. */
  140870. get output(): NodeMaterialConnectionPoint;
  140871. protected _buildBlock(state: NodeMaterialBuildState): this;
  140872. }
  140873. }
  140874. declare module BABYLON {
  140875. /**
  140876. * Block used to get a random number
  140877. */
  140878. export class RandomNumberBlock extends NodeMaterialBlock {
  140879. /**
  140880. * Creates a new RandomNumberBlock
  140881. * @param name defines the block name
  140882. */
  140883. constructor(name: string);
  140884. /**
  140885. * Gets the current class name
  140886. * @returns the class name
  140887. */
  140888. getClassName(): string;
  140889. /**
  140890. * Gets the seed input component
  140891. */
  140892. get seed(): NodeMaterialConnectionPoint;
  140893. /**
  140894. * Gets the output component
  140895. */
  140896. get output(): NodeMaterialConnectionPoint;
  140897. protected _buildBlock(state: NodeMaterialBuildState): this;
  140898. }
  140899. }
  140900. declare module BABYLON {
  140901. /**
  140902. * Block used to compute arc tangent of 2 values
  140903. */
  140904. export class ArcTan2Block extends NodeMaterialBlock {
  140905. /**
  140906. * Creates a new ArcTan2Block
  140907. * @param name defines the block name
  140908. */
  140909. constructor(name: string);
  140910. /**
  140911. * Gets the current class name
  140912. * @returns the class name
  140913. */
  140914. getClassName(): string;
  140915. /**
  140916. * Gets the x operand input component
  140917. */
  140918. get x(): NodeMaterialConnectionPoint;
  140919. /**
  140920. * Gets the y operand input component
  140921. */
  140922. get y(): NodeMaterialConnectionPoint;
  140923. /**
  140924. * Gets the output component
  140925. */
  140926. get output(): NodeMaterialConnectionPoint;
  140927. protected _buildBlock(state: NodeMaterialBuildState): this;
  140928. }
  140929. }
  140930. declare module BABYLON {
  140931. /**
  140932. * Block used to smooth step a value
  140933. */
  140934. export class SmoothStepBlock extends NodeMaterialBlock {
  140935. /**
  140936. * Creates a new SmoothStepBlock
  140937. * @param name defines the block name
  140938. */
  140939. constructor(name: string);
  140940. /**
  140941. * Gets the current class name
  140942. * @returns the class name
  140943. */
  140944. getClassName(): string;
  140945. /**
  140946. * Gets the value operand input component
  140947. */
  140948. get value(): NodeMaterialConnectionPoint;
  140949. /**
  140950. * Gets the first edge operand input component
  140951. */
  140952. get edge0(): NodeMaterialConnectionPoint;
  140953. /**
  140954. * Gets the second edge operand input component
  140955. */
  140956. get edge1(): NodeMaterialConnectionPoint;
  140957. /**
  140958. * Gets the output component
  140959. */
  140960. get output(): NodeMaterialConnectionPoint;
  140961. protected _buildBlock(state: NodeMaterialBuildState): this;
  140962. }
  140963. }
  140964. declare module BABYLON {
  140965. /**
  140966. * Block used to get the reciprocal (1 / x) of a value
  140967. */
  140968. export class ReciprocalBlock extends NodeMaterialBlock {
  140969. /**
  140970. * Creates a new ReciprocalBlock
  140971. * @param name defines the block name
  140972. */
  140973. constructor(name: string);
  140974. /**
  140975. * Gets the current class name
  140976. * @returns the class name
  140977. */
  140978. getClassName(): string;
  140979. /**
  140980. * Gets the input component
  140981. */
  140982. get input(): NodeMaterialConnectionPoint;
  140983. /**
  140984. * Gets the output component
  140985. */
  140986. get output(): NodeMaterialConnectionPoint;
  140987. protected _buildBlock(state: NodeMaterialBuildState): this;
  140988. }
  140989. }
  140990. declare module BABYLON {
  140991. /**
  140992. * Block used to replace a color by another one
  140993. */
  140994. export class ReplaceColorBlock extends NodeMaterialBlock {
  140995. /**
  140996. * Creates a new ReplaceColorBlock
  140997. * @param name defines the block name
  140998. */
  140999. constructor(name: string);
  141000. /**
  141001. * Gets the current class name
  141002. * @returns the class name
  141003. */
  141004. getClassName(): string;
  141005. /**
  141006. * Gets the value input component
  141007. */
  141008. get value(): NodeMaterialConnectionPoint;
  141009. /**
  141010. * Gets the reference input component
  141011. */
  141012. get reference(): NodeMaterialConnectionPoint;
  141013. /**
  141014. * Gets the distance input component
  141015. */
  141016. get distance(): NodeMaterialConnectionPoint;
  141017. /**
  141018. * Gets the replacement input component
  141019. */
  141020. get replacement(): NodeMaterialConnectionPoint;
  141021. /**
  141022. * Gets the output component
  141023. */
  141024. get output(): NodeMaterialConnectionPoint;
  141025. protected _buildBlock(state: NodeMaterialBuildState): this;
  141026. }
  141027. }
  141028. declare module BABYLON {
  141029. /**
  141030. * Block used to posterize a value
  141031. * @see https://en.wikipedia.org/wiki/Posterization
  141032. */
  141033. export class PosterizeBlock extends NodeMaterialBlock {
  141034. /**
  141035. * Creates a new PosterizeBlock
  141036. * @param name defines the block name
  141037. */
  141038. constructor(name: string);
  141039. /**
  141040. * Gets the current class name
  141041. * @returns the class name
  141042. */
  141043. getClassName(): string;
  141044. /**
  141045. * Gets the value input component
  141046. */
  141047. get value(): NodeMaterialConnectionPoint;
  141048. /**
  141049. * Gets the steps input component
  141050. */
  141051. get steps(): NodeMaterialConnectionPoint;
  141052. /**
  141053. * Gets the output component
  141054. */
  141055. get output(): NodeMaterialConnectionPoint;
  141056. protected _buildBlock(state: NodeMaterialBuildState): this;
  141057. }
  141058. }
  141059. declare module BABYLON {
  141060. /**
  141061. * Operations supported by the Wave block
  141062. */
  141063. export enum WaveBlockKind {
  141064. /** SawTooth */
  141065. SawTooth = 0,
  141066. /** Square */
  141067. Square = 1,
  141068. /** Triangle */
  141069. Triangle = 2
  141070. }
  141071. /**
  141072. * Block used to apply wave operation to floats
  141073. */
  141074. export class WaveBlock extends NodeMaterialBlock {
  141075. /**
  141076. * Gets or sets the kibnd of wave to be applied by the block
  141077. */
  141078. kind: WaveBlockKind;
  141079. /**
  141080. * Creates a new WaveBlock
  141081. * @param name defines the block name
  141082. */
  141083. constructor(name: string);
  141084. /**
  141085. * Gets the current class name
  141086. * @returns the class name
  141087. */
  141088. getClassName(): string;
  141089. /**
  141090. * Gets the input component
  141091. */
  141092. get input(): NodeMaterialConnectionPoint;
  141093. /**
  141094. * Gets the output component
  141095. */
  141096. get output(): NodeMaterialConnectionPoint;
  141097. protected _buildBlock(state: NodeMaterialBuildState): this;
  141098. serialize(): any;
  141099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141100. }
  141101. }
  141102. declare module BABYLON {
  141103. /**
  141104. * Class used to store a color step for the GradientBlock
  141105. */
  141106. export class GradientBlockColorStep {
  141107. /**
  141108. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141109. */
  141110. step: number;
  141111. /**
  141112. * Gets or sets the color associated with this step
  141113. */
  141114. color: Color3;
  141115. /**
  141116. * Creates a new GradientBlockColorStep
  141117. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141118. * @param color defines the color associated with this step
  141119. */
  141120. constructor(
  141121. /**
  141122. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141123. */
  141124. step: number,
  141125. /**
  141126. * Gets or sets the color associated with this step
  141127. */
  141128. color: Color3);
  141129. }
  141130. /**
  141131. * Block used to return a color from a gradient based on an input value between 0 and 1
  141132. */
  141133. export class GradientBlock extends NodeMaterialBlock {
  141134. /**
  141135. * Gets or sets the list of color steps
  141136. */
  141137. colorSteps: GradientBlockColorStep[];
  141138. /**
  141139. * Creates a new GradientBlock
  141140. * @param name defines the block name
  141141. */
  141142. constructor(name: string);
  141143. /**
  141144. * Gets the current class name
  141145. * @returns the class name
  141146. */
  141147. getClassName(): string;
  141148. /**
  141149. * Gets the gradient input component
  141150. */
  141151. get gradient(): NodeMaterialConnectionPoint;
  141152. /**
  141153. * Gets the output component
  141154. */
  141155. get output(): NodeMaterialConnectionPoint;
  141156. private _writeColorConstant;
  141157. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141158. serialize(): any;
  141159. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141160. protected _dumpPropertiesCode(): string;
  141161. }
  141162. }
  141163. declare module BABYLON {
  141164. /**
  141165. * Block used to normalize lerp between 2 values
  141166. */
  141167. export class NLerpBlock extends NodeMaterialBlock {
  141168. /**
  141169. * Creates a new NLerpBlock
  141170. * @param name defines the block name
  141171. */
  141172. constructor(name: string);
  141173. /**
  141174. * Gets the current class name
  141175. * @returns the class name
  141176. */
  141177. getClassName(): string;
  141178. /**
  141179. * Gets the left operand input component
  141180. */
  141181. get left(): NodeMaterialConnectionPoint;
  141182. /**
  141183. * Gets the right operand input component
  141184. */
  141185. get right(): NodeMaterialConnectionPoint;
  141186. /**
  141187. * Gets the gradient operand input component
  141188. */
  141189. get gradient(): NodeMaterialConnectionPoint;
  141190. /**
  141191. * Gets the output component
  141192. */
  141193. get output(): NodeMaterialConnectionPoint;
  141194. protected _buildBlock(state: NodeMaterialBuildState): this;
  141195. }
  141196. }
  141197. declare module BABYLON {
  141198. /**
  141199. * block used to Generate a Worley Noise 3D Noise Pattern
  141200. */
  141201. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141202. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141203. manhattanDistance: boolean;
  141204. /**
  141205. * Creates a new WorleyNoise3DBlock
  141206. * @param name defines the block name
  141207. */
  141208. constructor(name: string);
  141209. /**
  141210. * Gets the current class name
  141211. * @returns the class name
  141212. */
  141213. getClassName(): string;
  141214. /**
  141215. * Gets the seed input component
  141216. */
  141217. get seed(): NodeMaterialConnectionPoint;
  141218. /**
  141219. * Gets the jitter input component
  141220. */
  141221. get jitter(): NodeMaterialConnectionPoint;
  141222. /**
  141223. * Gets the output component
  141224. */
  141225. get output(): NodeMaterialConnectionPoint;
  141226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141227. /**
  141228. * Exposes the properties to the UI?
  141229. */
  141230. protected _dumpPropertiesCode(): string;
  141231. /**
  141232. * Exposes the properties to the Seralize?
  141233. */
  141234. serialize(): any;
  141235. /**
  141236. * Exposes the properties to the deseralize?
  141237. */
  141238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141239. }
  141240. }
  141241. declare module BABYLON {
  141242. /**
  141243. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141244. */
  141245. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141246. /**
  141247. * Creates a new SimplexPerlin3DBlock
  141248. * @param name defines the block name
  141249. */
  141250. constructor(name: string);
  141251. /**
  141252. * Gets the current class name
  141253. * @returns the class name
  141254. */
  141255. getClassName(): string;
  141256. /**
  141257. * Gets the seed operand input component
  141258. */
  141259. get seed(): NodeMaterialConnectionPoint;
  141260. /**
  141261. * Gets the output component
  141262. */
  141263. get output(): NodeMaterialConnectionPoint;
  141264. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141265. }
  141266. }
  141267. declare module BABYLON {
  141268. /**
  141269. * Block used to blend normals
  141270. */
  141271. export class NormalBlendBlock extends NodeMaterialBlock {
  141272. /**
  141273. * Creates a new NormalBlendBlock
  141274. * @param name defines the block name
  141275. */
  141276. constructor(name: string);
  141277. /**
  141278. * Gets the current class name
  141279. * @returns the class name
  141280. */
  141281. getClassName(): string;
  141282. /**
  141283. * Gets the first input component
  141284. */
  141285. get normalMap0(): NodeMaterialConnectionPoint;
  141286. /**
  141287. * Gets the second input component
  141288. */
  141289. get normalMap1(): NodeMaterialConnectionPoint;
  141290. /**
  141291. * Gets the output component
  141292. */
  141293. get output(): NodeMaterialConnectionPoint;
  141294. protected _buildBlock(state: NodeMaterialBuildState): this;
  141295. }
  141296. }
  141297. declare module BABYLON {
  141298. /**
  141299. * Block used to rotate a 2d vector by a given angle
  141300. */
  141301. export class Rotate2dBlock extends NodeMaterialBlock {
  141302. /**
  141303. * Creates a new Rotate2dBlock
  141304. * @param name defines the block name
  141305. */
  141306. constructor(name: string);
  141307. /**
  141308. * Gets the current class name
  141309. * @returns the class name
  141310. */
  141311. getClassName(): string;
  141312. /**
  141313. * Gets the input vector
  141314. */
  141315. get input(): NodeMaterialConnectionPoint;
  141316. /**
  141317. * Gets the input angle
  141318. */
  141319. get angle(): NodeMaterialConnectionPoint;
  141320. /**
  141321. * Gets the output component
  141322. */
  141323. get output(): NodeMaterialConnectionPoint;
  141324. autoConfigure(material: NodeMaterial): void;
  141325. protected _buildBlock(state: NodeMaterialBuildState): this;
  141326. }
  141327. }
  141328. declare module BABYLON {
  141329. /**
  141330. * Block used to get the reflected vector from a direction and a normal
  141331. */
  141332. export class ReflectBlock extends NodeMaterialBlock {
  141333. /**
  141334. * Creates a new ReflectBlock
  141335. * @param name defines the block name
  141336. */
  141337. constructor(name: string);
  141338. /**
  141339. * Gets the current class name
  141340. * @returns the class name
  141341. */
  141342. getClassName(): string;
  141343. /**
  141344. * Gets the incident component
  141345. */
  141346. get incident(): NodeMaterialConnectionPoint;
  141347. /**
  141348. * Gets the normal component
  141349. */
  141350. get normal(): NodeMaterialConnectionPoint;
  141351. /**
  141352. * Gets the output component
  141353. */
  141354. get output(): NodeMaterialConnectionPoint;
  141355. protected _buildBlock(state: NodeMaterialBuildState): this;
  141356. }
  141357. }
  141358. declare module BABYLON {
  141359. /**
  141360. * Block used to get the refracted vector from a direction and a normal
  141361. */
  141362. export class RefractBlock extends NodeMaterialBlock {
  141363. /**
  141364. * Creates a new RefractBlock
  141365. * @param name defines the block name
  141366. */
  141367. constructor(name: string);
  141368. /**
  141369. * Gets the current class name
  141370. * @returns the class name
  141371. */
  141372. getClassName(): string;
  141373. /**
  141374. * Gets the incident component
  141375. */
  141376. get incident(): NodeMaterialConnectionPoint;
  141377. /**
  141378. * Gets the normal component
  141379. */
  141380. get normal(): NodeMaterialConnectionPoint;
  141381. /**
  141382. * Gets the index of refraction component
  141383. */
  141384. get ior(): NodeMaterialConnectionPoint;
  141385. /**
  141386. * Gets the output component
  141387. */
  141388. get output(): NodeMaterialConnectionPoint;
  141389. protected _buildBlock(state: NodeMaterialBuildState): this;
  141390. }
  141391. }
  141392. declare module BABYLON {
  141393. /**
  141394. * Block used to desaturate a color
  141395. */
  141396. export class DesaturateBlock extends NodeMaterialBlock {
  141397. /**
  141398. * Creates a new DesaturateBlock
  141399. * @param name defines the block name
  141400. */
  141401. constructor(name: string);
  141402. /**
  141403. * Gets the current class name
  141404. * @returns the class name
  141405. */
  141406. getClassName(): string;
  141407. /**
  141408. * Gets the color operand input component
  141409. */
  141410. get color(): NodeMaterialConnectionPoint;
  141411. /**
  141412. * Gets the level operand input component
  141413. */
  141414. get level(): NodeMaterialConnectionPoint;
  141415. /**
  141416. * Gets the output component
  141417. */
  141418. get output(): NodeMaterialConnectionPoint;
  141419. protected _buildBlock(state: NodeMaterialBuildState): this;
  141420. }
  141421. }
  141422. declare module BABYLON {
  141423. /**
  141424. * Block used to implement the ambient occlusion module of the PBR material
  141425. */
  141426. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141427. /**
  141428. * Create a new AmbientOcclusionBlock
  141429. * @param name defines the block name
  141430. */
  141431. constructor(name: string);
  141432. /**
  141433. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141434. */
  141435. useAmbientInGrayScale: boolean;
  141436. /**
  141437. * Initialize the block and prepare the context for build
  141438. * @param state defines the state that will be used for the build
  141439. */
  141440. initialize(state: NodeMaterialBuildState): void;
  141441. /**
  141442. * Gets the current class name
  141443. * @returns the class name
  141444. */
  141445. getClassName(): string;
  141446. /**
  141447. * Gets the texture input component
  141448. */
  141449. get texture(): NodeMaterialConnectionPoint;
  141450. /**
  141451. * Gets the texture intensity component
  141452. */
  141453. get intensity(): NodeMaterialConnectionPoint;
  141454. /**
  141455. * Gets the direct light intensity input component
  141456. */
  141457. get directLightIntensity(): NodeMaterialConnectionPoint;
  141458. /**
  141459. * Gets the ambient occlusion object output component
  141460. */
  141461. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141462. /**
  141463. * Gets the main code of the block (fragment side)
  141464. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141465. * @returns the shader code
  141466. */
  141467. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141469. protected _buildBlock(state: NodeMaterialBuildState): this;
  141470. protected _dumpPropertiesCode(): string;
  141471. serialize(): any;
  141472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141473. }
  141474. }
  141475. declare module BABYLON {
  141476. /**
  141477. * Block used to implement the reflection module of the PBR material
  141478. */
  141479. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141480. /** @hidden */
  141481. _defineLODReflectionAlpha: string;
  141482. /** @hidden */
  141483. _defineLinearSpecularReflection: string;
  141484. private _vEnvironmentIrradianceName;
  141485. /** @hidden */
  141486. _vReflectionMicrosurfaceInfosName: string;
  141487. /** @hidden */
  141488. _vReflectionInfosName: string;
  141489. /** @hidden */
  141490. _vReflectionFilteringInfoName: string;
  141491. private _scene;
  141492. /**
  141493. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141494. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141495. * It's less burden on the user side in the editor part.
  141496. */
  141497. /** @hidden */
  141498. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141499. /** @hidden */
  141500. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141501. /** @hidden */
  141502. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141503. /**
  141504. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141505. * diffuse part of the IBL.
  141506. */
  141507. useSphericalHarmonics: boolean;
  141508. /**
  141509. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141510. */
  141511. forceIrradianceInFragment: boolean;
  141512. /**
  141513. * Create a new ReflectionBlock
  141514. * @param name defines the block name
  141515. */
  141516. constructor(name: string);
  141517. /**
  141518. * Gets the current class name
  141519. * @returns the class name
  141520. */
  141521. getClassName(): string;
  141522. /**
  141523. * Gets the position input component
  141524. */
  141525. get position(): NodeMaterialConnectionPoint;
  141526. /**
  141527. * Gets the world position input component
  141528. */
  141529. get worldPosition(): NodeMaterialConnectionPoint;
  141530. /**
  141531. * Gets the world normal input component
  141532. */
  141533. get worldNormal(): NodeMaterialConnectionPoint;
  141534. /**
  141535. * Gets the world input component
  141536. */
  141537. get world(): NodeMaterialConnectionPoint;
  141538. /**
  141539. * Gets the camera (or eye) position component
  141540. */
  141541. get cameraPosition(): NodeMaterialConnectionPoint;
  141542. /**
  141543. * Gets the view input component
  141544. */
  141545. get view(): NodeMaterialConnectionPoint;
  141546. /**
  141547. * Gets the color input component
  141548. */
  141549. get color(): NodeMaterialConnectionPoint;
  141550. /**
  141551. * Gets the reflection object output component
  141552. */
  141553. get reflection(): NodeMaterialConnectionPoint;
  141554. /**
  141555. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141556. */
  141557. get hasTexture(): boolean;
  141558. /**
  141559. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141560. */
  141561. get reflectionColor(): string;
  141562. protected _getTexture(): Nullable<BaseTexture>;
  141563. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141565. /**
  141566. * Gets the code to inject in the vertex shader
  141567. * @param state current state of the node material building
  141568. * @returns the shader code
  141569. */
  141570. handleVertexSide(state: NodeMaterialBuildState): string;
  141571. /**
  141572. * Gets the main code of the block (fragment side)
  141573. * @param state current state of the node material building
  141574. * @param normalVarName name of the existing variable corresponding to the normal
  141575. * @returns the shader code
  141576. */
  141577. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141578. protected _buildBlock(state: NodeMaterialBuildState): this;
  141579. protected _dumpPropertiesCode(): string;
  141580. serialize(): any;
  141581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141582. }
  141583. }
  141584. declare module BABYLON {
  141585. /**
  141586. * Block used to implement the sheen module of the PBR material
  141587. */
  141588. export class SheenBlock extends NodeMaterialBlock {
  141589. /**
  141590. * Create a new SheenBlock
  141591. * @param name defines the block name
  141592. */
  141593. constructor(name: string);
  141594. /**
  141595. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141596. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141597. * making it easier to setup and tweak the effect
  141598. */
  141599. albedoScaling: boolean;
  141600. /**
  141601. * Defines if the sheen is linked to the sheen color.
  141602. */
  141603. linkSheenWithAlbedo: boolean;
  141604. /**
  141605. * Initialize the block and prepare the context for build
  141606. * @param state defines the state that will be used for the build
  141607. */
  141608. initialize(state: NodeMaterialBuildState): void;
  141609. /**
  141610. * Gets the current class name
  141611. * @returns the class name
  141612. */
  141613. getClassName(): string;
  141614. /**
  141615. * Gets the intensity input component
  141616. */
  141617. get intensity(): NodeMaterialConnectionPoint;
  141618. /**
  141619. * Gets the color input component
  141620. */
  141621. get color(): NodeMaterialConnectionPoint;
  141622. /**
  141623. * Gets the roughness input component
  141624. */
  141625. get roughness(): NodeMaterialConnectionPoint;
  141626. /**
  141627. * Gets the sheen object output component
  141628. */
  141629. get sheen(): NodeMaterialConnectionPoint;
  141630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141631. /**
  141632. * Gets the main code of the block (fragment side)
  141633. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141634. * @returns the shader code
  141635. */
  141636. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141637. protected _buildBlock(state: NodeMaterialBuildState): this;
  141638. protected _dumpPropertiesCode(): string;
  141639. serialize(): any;
  141640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141641. }
  141642. }
  141643. declare module BABYLON {
  141644. /**
  141645. * Block used to implement the reflectivity module of the PBR material
  141646. */
  141647. export class ReflectivityBlock extends NodeMaterialBlock {
  141648. private _metallicReflectanceColor;
  141649. private _metallicF0Factor;
  141650. /** @hidden */
  141651. _vMetallicReflectanceFactorsName: string;
  141652. /**
  141653. * The property below is set by the main PBR block prior to calling methods of this class.
  141654. */
  141655. /** @hidden */
  141656. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141657. /**
  141658. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141659. */
  141660. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141661. /**
  141662. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141663. */
  141664. useMetallnessFromMetallicTextureBlue: boolean;
  141665. /**
  141666. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141667. */
  141668. useRoughnessFromMetallicTextureAlpha: boolean;
  141669. /**
  141670. * Specifies if the metallic texture contains the roughness information in its green channel.
  141671. */
  141672. useRoughnessFromMetallicTextureGreen: boolean;
  141673. /**
  141674. * Create a new ReflectivityBlock
  141675. * @param name defines the block name
  141676. */
  141677. constructor(name: string);
  141678. /**
  141679. * Initialize the block and prepare the context for build
  141680. * @param state defines the state that will be used for the build
  141681. */
  141682. initialize(state: NodeMaterialBuildState): void;
  141683. /**
  141684. * Gets the current class name
  141685. * @returns the class name
  141686. */
  141687. getClassName(): string;
  141688. /**
  141689. * Gets the metallic input component
  141690. */
  141691. get metallic(): NodeMaterialConnectionPoint;
  141692. /**
  141693. * Gets the roughness input component
  141694. */
  141695. get roughness(): NodeMaterialConnectionPoint;
  141696. /**
  141697. * Gets the texture input component
  141698. */
  141699. get texture(): NodeMaterialConnectionPoint;
  141700. /**
  141701. * Gets the reflectivity object output component
  141702. */
  141703. get reflectivity(): NodeMaterialConnectionPoint;
  141704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141705. /**
  141706. * Gets the main code of the block (fragment side)
  141707. * @param state current state of the node material building
  141708. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141709. * @returns the shader code
  141710. */
  141711. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141713. protected _buildBlock(state: NodeMaterialBuildState): this;
  141714. protected _dumpPropertiesCode(): string;
  141715. serialize(): any;
  141716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141717. }
  141718. }
  141719. declare module BABYLON {
  141720. /**
  141721. * Block used to implement the anisotropy module of the PBR material
  141722. */
  141723. export class AnisotropyBlock extends NodeMaterialBlock {
  141724. /**
  141725. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141726. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141727. * It's less burden on the user side in the editor part.
  141728. */
  141729. /** @hidden */
  141730. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141731. /** @hidden */
  141732. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141733. /**
  141734. * Create a new AnisotropyBlock
  141735. * @param name defines the block name
  141736. */
  141737. constructor(name: string);
  141738. /**
  141739. * Initialize the block and prepare the context for build
  141740. * @param state defines the state that will be used for the build
  141741. */
  141742. initialize(state: NodeMaterialBuildState): void;
  141743. /**
  141744. * Gets the current class name
  141745. * @returns the class name
  141746. */
  141747. getClassName(): string;
  141748. /**
  141749. * Gets the intensity input component
  141750. */
  141751. get intensity(): NodeMaterialConnectionPoint;
  141752. /**
  141753. * Gets the direction input component
  141754. */
  141755. get direction(): NodeMaterialConnectionPoint;
  141756. /**
  141757. * Gets the texture input component
  141758. */
  141759. get texture(): NodeMaterialConnectionPoint;
  141760. /**
  141761. * Gets the uv input component
  141762. */
  141763. get uv(): NodeMaterialConnectionPoint;
  141764. /**
  141765. * Gets the worldTangent input component
  141766. */
  141767. get worldTangent(): NodeMaterialConnectionPoint;
  141768. /**
  141769. * Gets the anisotropy object output component
  141770. */
  141771. get anisotropy(): NodeMaterialConnectionPoint;
  141772. private _generateTBNSpace;
  141773. /**
  141774. * Gets the main code of the block (fragment side)
  141775. * @param state current state of the node material building
  141776. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141777. * @returns the shader code
  141778. */
  141779. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141781. protected _buildBlock(state: NodeMaterialBuildState): this;
  141782. }
  141783. }
  141784. declare module BABYLON {
  141785. /**
  141786. * Block used to implement the clear coat module of the PBR material
  141787. */
  141788. export class ClearCoatBlock extends NodeMaterialBlock {
  141789. private _scene;
  141790. /**
  141791. * Create a new ClearCoatBlock
  141792. * @param name defines the block name
  141793. */
  141794. constructor(name: string);
  141795. /**
  141796. * Initialize the block and prepare the context for build
  141797. * @param state defines the state that will be used for the build
  141798. */
  141799. initialize(state: NodeMaterialBuildState): void;
  141800. /**
  141801. * Gets the current class name
  141802. * @returns the class name
  141803. */
  141804. getClassName(): string;
  141805. /**
  141806. * Gets the intensity input component
  141807. */
  141808. get intensity(): NodeMaterialConnectionPoint;
  141809. /**
  141810. * Gets the roughness input component
  141811. */
  141812. get roughness(): NodeMaterialConnectionPoint;
  141813. /**
  141814. * Gets the ior input component
  141815. */
  141816. get ior(): NodeMaterialConnectionPoint;
  141817. /**
  141818. * Gets the texture input component
  141819. */
  141820. get texture(): NodeMaterialConnectionPoint;
  141821. /**
  141822. * Gets the bump texture input component
  141823. */
  141824. get bumpTexture(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the uv input component
  141827. */
  141828. get uv(): NodeMaterialConnectionPoint;
  141829. /**
  141830. * Gets the tint color input component
  141831. */
  141832. get tintColor(): NodeMaterialConnectionPoint;
  141833. /**
  141834. * Gets the tint "at distance" input component
  141835. */
  141836. get tintAtDistance(): NodeMaterialConnectionPoint;
  141837. /**
  141838. * Gets the tint thickness input component
  141839. */
  141840. get tintThickness(): NodeMaterialConnectionPoint;
  141841. /**
  141842. * Gets the world tangent input component
  141843. */
  141844. get worldTangent(): NodeMaterialConnectionPoint;
  141845. /**
  141846. * Gets the clear coat object output component
  141847. */
  141848. get clearcoat(): NodeMaterialConnectionPoint;
  141849. autoConfigure(material: NodeMaterial): void;
  141850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141851. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141852. private _generateTBNSpace;
  141853. /**
  141854. * Gets the main code of the block (fragment side)
  141855. * @param state current state of the node material building
  141856. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141857. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141858. * @param worldPosVarName name of the variable holding the world position
  141859. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141860. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141861. * @param worldNormalVarName name of the variable holding the world normal
  141862. * @returns the shader code
  141863. */
  141864. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141865. protected _buildBlock(state: NodeMaterialBuildState): this;
  141866. }
  141867. }
  141868. declare module BABYLON {
  141869. /**
  141870. * Block used to implement the sub surface module of the PBR material
  141871. */
  141872. export class SubSurfaceBlock extends NodeMaterialBlock {
  141873. /**
  141874. * Create a new SubSurfaceBlock
  141875. * @param name defines the block name
  141876. */
  141877. constructor(name: string);
  141878. /**
  141879. * Stores the intensity of the different subsurface effects in the thickness texture.
  141880. * * the green channel is the translucency intensity.
  141881. * * the blue channel is the scattering intensity.
  141882. * * the alpha channel is the refraction intensity.
  141883. */
  141884. useMaskFromThicknessTexture: boolean;
  141885. /**
  141886. * Initialize the block and prepare the context for build
  141887. * @param state defines the state that will be used for the build
  141888. */
  141889. initialize(state: NodeMaterialBuildState): void;
  141890. /**
  141891. * Gets the current class name
  141892. * @returns the class name
  141893. */
  141894. getClassName(): string;
  141895. /**
  141896. * Gets the min thickness input component
  141897. */
  141898. get minThickness(): NodeMaterialConnectionPoint;
  141899. /**
  141900. * Gets the max thickness input component
  141901. */
  141902. get maxThickness(): NodeMaterialConnectionPoint;
  141903. /**
  141904. * Gets the thickness texture component
  141905. */
  141906. get thicknessTexture(): NodeMaterialConnectionPoint;
  141907. /**
  141908. * Gets the tint color input component
  141909. */
  141910. get tintColor(): NodeMaterialConnectionPoint;
  141911. /**
  141912. * Gets the translucency intensity input component
  141913. */
  141914. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141915. /**
  141916. * Gets the translucency diffusion distance input component
  141917. */
  141918. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141919. /**
  141920. * Gets the refraction object parameters
  141921. */
  141922. get refraction(): NodeMaterialConnectionPoint;
  141923. /**
  141924. * Gets the sub surface object output component
  141925. */
  141926. get subsurface(): NodeMaterialConnectionPoint;
  141927. autoConfigure(material: NodeMaterial): void;
  141928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141929. /**
  141930. * Gets the main code of the block (fragment side)
  141931. * @param state current state of the node material building
  141932. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141933. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141934. * @param worldPosVarName name of the variable holding the world position
  141935. * @returns the shader code
  141936. */
  141937. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141938. protected _buildBlock(state: NodeMaterialBuildState): this;
  141939. }
  141940. }
  141941. declare module BABYLON {
  141942. /**
  141943. * Block used to implement the PBR metallic/roughness model
  141944. */
  141945. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141946. /**
  141947. * Gets or sets the light associated with this block
  141948. */
  141949. light: Nullable<Light>;
  141950. private _lightId;
  141951. private _scene;
  141952. private _environmentBRDFTexture;
  141953. private _environmentBrdfSamplerName;
  141954. private _vNormalWName;
  141955. private _invertNormalName;
  141956. /**
  141957. * Create a new ReflectionBlock
  141958. * @param name defines the block name
  141959. */
  141960. constructor(name: string);
  141961. /**
  141962. * Intensity of the direct lights e.g. the four lights available in your scene.
  141963. * This impacts both the direct diffuse and specular highlights.
  141964. */
  141965. directIntensity: number;
  141966. /**
  141967. * Intensity of the environment e.g. how much the environment will light the object
  141968. * either through harmonics for rough material or through the refelction for shiny ones.
  141969. */
  141970. environmentIntensity: number;
  141971. /**
  141972. * This is a special control allowing the reduction of the specular highlights coming from the
  141973. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141974. */
  141975. specularIntensity: number;
  141976. /**
  141977. * Defines the falloff type used in this material.
  141978. * It by default is Physical.
  141979. */
  141980. lightFalloff: number;
  141981. /**
  141982. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141983. */
  141984. useAlphaFromAlbedoTexture: boolean;
  141985. /**
  141986. * Specifies that alpha test should be used
  141987. */
  141988. useAlphaTest: boolean;
  141989. /**
  141990. * Defines the alpha limits in alpha test mode.
  141991. */
  141992. alphaTestCutoff: number;
  141993. /**
  141994. * Specifies that alpha blending should be used
  141995. */
  141996. useAlphaBlending: boolean;
  141997. /**
  141998. * Defines if the alpha value should be determined via the rgb values.
  141999. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142000. */
  142001. opacityRGB: boolean;
  142002. /**
  142003. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142004. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142005. */
  142006. useRadianceOverAlpha: boolean;
  142007. /**
  142008. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142009. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142010. */
  142011. useSpecularOverAlpha: boolean;
  142012. /**
  142013. * Enables specular anti aliasing in the PBR shader.
  142014. * It will both interacts on the Geometry for analytical and IBL lighting.
  142015. * It also prefilter the roughness map based on the bump values.
  142016. */
  142017. enableSpecularAntiAliasing: boolean;
  142018. /**
  142019. * Enables realtime filtering on the texture.
  142020. */
  142021. realTimeFiltering: boolean;
  142022. /**
  142023. * Quality switch for realtime filtering
  142024. */
  142025. realTimeFilteringQuality: number;
  142026. /**
  142027. * Defines if the material uses energy conservation.
  142028. */
  142029. useEnergyConservation: boolean;
  142030. /**
  142031. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142032. * too much the area relying on ambient texture to define their ambient occlusion.
  142033. */
  142034. useRadianceOcclusion: boolean;
  142035. /**
  142036. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142037. * makes the reflect vector face the model (under horizon).
  142038. */
  142039. useHorizonOcclusion: boolean;
  142040. /**
  142041. * If set to true, no lighting calculations will be applied.
  142042. */
  142043. unlit: boolean;
  142044. /**
  142045. * Force normal to face away from face.
  142046. */
  142047. forceNormalForward: boolean;
  142048. /**
  142049. * Defines the material debug mode.
  142050. * It helps seeing only some components of the material while troubleshooting.
  142051. */
  142052. debugMode: number;
  142053. /**
  142054. * Specify from where on screen the debug mode should start.
  142055. * The value goes from -1 (full screen) to 1 (not visible)
  142056. * It helps with side by side comparison against the final render
  142057. * This defaults to 0
  142058. */
  142059. debugLimit: number;
  142060. /**
  142061. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142062. * You can use the factor to better multiply the final value.
  142063. */
  142064. debugFactor: number;
  142065. /**
  142066. * Initialize the block and prepare the context for build
  142067. * @param state defines the state that will be used for the build
  142068. */
  142069. initialize(state: NodeMaterialBuildState): void;
  142070. /**
  142071. * Gets the current class name
  142072. * @returns the class name
  142073. */
  142074. getClassName(): string;
  142075. /**
  142076. * Gets the world position input component
  142077. */
  142078. get worldPosition(): NodeMaterialConnectionPoint;
  142079. /**
  142080. * Gets the world normal input component
  142081. */
  142082. get worldNormal(): NodeMaterialConnectionPoint;
  142083. /**
  142084. * Gets the perturbed normal input component
  142085. */
  142086. get perturbedNormal(): NodeMaterialConnectionPoint;
  142087. /**
  142088. * Gets the camera position input component
  142089. */
  142090. get cameraPosition(): NodeMaterialConnectionPoint;
  142091. /**
  142092. * Gets the base color input component
  142093. */
  142094. get baseColor(): NodeMaterialConnectionPoint;
  142095. /**
  142096. * Gets the opacity texture input component
  142097. */
  142098. get opacityTexture(): NodeMaterialConnectionPoint;
  142099. /**
  142100. * Gets the ambient color input component
  142101. */
  142102. get ambientColor(): NodeMaterialConnectionPoint;
  142103. /**
  142104. * Gets the reflectivity object parameters
  142105. */
  142106. get reflectivity(): NodeMaterialConnectionPoint;
  142107. /**
  142108. * Gets the ambient occlusion object parameters
  142109. */
  142110. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142111. /**
  142112. * Gets the reflection object parameters
  142113. */
  142114. get reflection(): NodeMaterialConnectionPoint;
  142115. /**
  142116. * Gets the sheen object parameters
  142117. */
  142118. get sheen(): NodeMaterialConnectionPoint;
  142119. /**
  142120. * Gets the clear coat object parameters
  142121. */
  142122. get clearcoat(): NodeMaterialConnectionPoint;
  142123. /**
  142124. * Gets the sub surface object parameters
  142125. */
  142126. get subsurface(): NodeMaterialConnectionPoint;
  142127. /**
  142128. * Gets the anisotropy object parameters
  142129. */
  142130. get anisotropy(): NodeMaterialConnectionPoint;
  142131. /**
  142132. * Gets the ambient output component
  142133. */
  142134. get ambient(): NodeMaterialConnectionPoint;
  142135. /**
  142136. * Gets the diffuse output component
  142137. */
  142138. get diffuse(): NodeMaterialConnectionPoint;
  142139. /**
  142140. * Gets the specular output component
  142141. */
  142142. get specular(): NodeMaterialConnectionPoint;
  142143. /**
  142144. * Gets the sheen output component
  142145. */
  142146. get sheenDir(): NodeMaterialConnectionPoint;
  142147. /**
  142148. * Gets the clear coat output component
  142149. */
  142150. get clearcoatDir(): NodeMaterialConnectionPoint;
  142151. /**
  142152. * Gets the indirect diffuse output component
  142153. */
  142154. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142155. /**
  142156. * Gets the indirect specular output component
  142157. */
  142158. get specularIndirect(): NodeMaterialConnectionPoint;
  142159. /**
  142160. * Gets the indirect sheen output component
  142161. */
  142162. get sheenIndirect(): NodeMaterialConnectionPoint;
  142163. /**
  142164. * Gets the indirect clear coat output component
  142165. */
  142166. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142167. /**
  142168. * Gets the refraction output component
  142169. */
  142170. get refraction(): NodeMaterialConnectionPoint;
  142171. /**
  142172. * Gets the global lighting output component
  142173. */
  142174. get lighting(): NodeMaterialConnectionPoint;
  142175. /**
  142176. * Gets the shadow output component
  142177. */
  142178. get shadow(): NodeMaterialConnectionPoint;
  142179. /**
  142180. * Gets the alpha output component
  142181. */
  142182. get alpha(): NodeMaterialConnectionPoint;
  142183. autoConfigure(material: NodeMaterial): void;
  142184. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142185. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142187. private _injectVertexCode;
  142188. /**
  142189. * Gets the code corresponding to the albedo/opacity module
  142190. * @returns the shader code
  142191. */
  142192. getAlbedoOpacityCode(): string;
  142193. protected _buildBlock(state: NodeMaterialBuildState): this;
  142194. protected _dumpPropertiesCode(): string;
  142195. serialize(): any;
  142196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142197. }
  142198. }
  142199. declare module BABYLON {
  142200. /**
  142201. * Block used to compute value of one parameter modulo another
  142202. */
  142203. export class ModBlock extends NodeMaterialBlock {
  142204. /**
  142205. * Creates a new ModBlock
  142206. * @param name defines the block name
  142207. */
  142208. constructor(name: string);
  142209. /**
  142210. * Gets the current class name
  142211. * @returns the class name
  142212. */
  142213. getClassName(): string;
  142214. /**
  142215. * Gets the left operand input component
  142216. */
  142217. get left(): NodeMaterialConnectionPoint;
  142218. /**
  142219. * Gets the right operand input component
  142220. */
  142221. get right(): NodeMaterialConnectionPoint;
  142222. /**
  142223. * Gets the output component
  142224. */
  142225. get output(): NodeMaterialConnectionPoint;
  142226. protected _buildBlock(state: NodeMaterialBuildState): this;
  142227. }
  142228. }
  142229. declare module BABYLON {
  142230. /**
  142231. * Helper class to push actions to a pool of workers.
  142232. */
  142233. export class WorkerPool implements IDisposable {
  142234. private _workerInfos;
  142235. private _pendingActions;
  142236. /**
  142237. * Constructor
  142238. * @param workers Array of workers to use for actions
  142239. */
  142240. constructor(workers: Array<Worker>);
  142241. /**
  142242. * Terminates all workers and clears any pending actions.
  142243. */
  142244. dispose(): void;
  142245. /**
  142246. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142247. * pended until a worker has completed its action.
  142248. * @param action The action to perform. Call onComplete when the action is complete.
  142249. */
  142250. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142251. private _execute;
  142252. }
  142253. }
  142254. declare module BABYLON {
  142255. /**
  142256. * Configuration for Draco compression
  142257. */
  142258. export interface IDracoCompressionConfiguration {
  142259. /**
  142260. * Configuration for the decoder.
  142261. */
  142262. decoder: {
  142263. /**
  142264. * The url to the WebAssembly module.
  142265. */
  142266. wasmUrl?: string;
  142267. /**
  142268. * The url to the WebAssembly binary.
  142269. */
  142270. wasmBinaryUrl?: string;
  142271. /**
  142272. * The url to the fallback JavaScript module.
  142273. */
  142274. fallbackUrl?: string;
  142275. };
  142276. }
  142277. /**
  142278. * Draco compression (https://google.github.io/draco/)
  142279. *
  142280. * This class wraps the Draco module.
  142281. *
  142282. * **Encoder**
  142283. *
  142284. * The encoder is not currently implemented.
  142285. *
  142286. * **Decoder**
  142287. *
  142288. * 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.
  142289. *
  142290. * To update the configuration, use the following code:
  142291. * ```javascript
  142292. * DracoCompression.Configuration = {
  142293. * decoder: {
  142294. * wasmUrl: "<url to the WebAssembly library>",
  142295. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142296. * fallbackUrl: "<url to the fallback JavaScript library>",
  142297. * }
  142298. * };
  142299. * ```
  142300. *
  142301. * 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.
  142302. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142303. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142304. *
  142305. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142306. * ```javascript
  142307. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142308. * ```
  142309. *
  142310. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142311. */
  142312. export class DracoCompression implements IDisposable {
  142313. private _workerPoolPromise?;
  142314. private _decoderModulePromise?;
  142315. /**
  142316. * The configuration. Defaults to the following urls:
  142317. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142318. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142319. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142320. */
  142321. static Configuration: IDracoCompressionConfiguration;
  142322. /**
  142323. * Returns true if the decoder configuration is available.
  142324. */
  142325. static get DecoderAvailable(): boolean;
  142326. /**
  142327. * Default number of workers to create when creating the draco compression object.
  142328. */
  142329. static DefaultNumWorkers: number;
  142330. private static GetDefaultNumWorkers;
  142331. private static _Default;
  142332. /**
  142333. * Default instance for the draco compression object.
  142334. */
  142335. static get Default(): DracoCompression;
  142336. /**
  142337. * Constructor
  142338. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142339. */
  142340. constructor(numWorkers?: number);
  142341. /**
  142342. * Stop all async operations and release resources.
  142343. */
  142344. dispose(): void;
  142345. /**
  142346. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142347. * @returns a promise that resolves when ready
  142348. */
  142349. whenReadyAsync(): Promise<void>;
  142350. /**
  142351. * Decode Draco compressed mesh data to vertex data.
  142352. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142353. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142354. * @returns A promise that resolves with the decoded vertex data
  142355. */
  142356. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142357. [kind: string]: number;
  142358. }): Promise<VertexData>;
  142359. }
  142360. }
  142361. declare module BABYLON {
  142362. /**
  142363. * Class for building Constructive Solid Geometry
  142364. */
  142365. export class CSG {
  142366. private polygons;
  142367. /**
  142368. * The world matrix
  142369. */
  142370. matrix: Matrix;
  142371. /**
  142372. * Stores the position
  142373. */
  142374. position: Vector3;
  142375. /**
  142376. * Stores the rotation
  142377. */
  142378. rotation: Vector3;
  142379. /**
  142380. * Stores the rotation quaternion
  142381. */
  142382. rotationQuaternion: Nullable<Quaternion>;
  142383. /**
  142384. * Stores the scaling vector
  142385. */
  142386. scaling: Vector3;
  142387. /**
  142388. * Convert the Mesh to CSG
  142389. * @param mesh The Mesh to convert to CSG
  142390. * @returns A new CSG from the Mesh
  142391. */
  142392. static FromMesh(mesh: Mesh): CSG;
  142393. /**
  142394. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142395. * @param polygons Polygons used to construct a CSG solid
  142396. */
  142397. private static FromPolygons;
  142398. /**
  142399. * Clones, or makes a deep copy, of the CSG
  142400. * @returns A new CSG
  142401. */
  142402. clone(): CSG;
  142403. /**
  142404. * Unions this CSG with another CSG
  142405. * @param csg The CSG to union against this CSG
  142406. * @returns The unioned CSG
  142407. */
  142408. union(csg: CSG): CSG;
  142409. /**
  142410. * Unions this CSG with another CSG in place
  142411. * @param csg The CSG to union against this CSG
  142412. */
  142413. unionInPlace(csg: CSG): void;
  142414. /**
  142415. * Subtracts this CSG with another CSG
  142416. * @param csg The CSG to subtract against this CSG
  142417. * @returns A new CSG
  142418. */
  142419. subtract(csg: CSG): CSG;
  142420. /**
  142421. * Subtracts this CSG with another CSG in place
  142422. * @param csg The CSG to subtact against this CSG
  142423. */
  142424. subtractInPlace(csg: CSG): void;
  142425. /**
  142426. * Intersect this CSG with another CSG
  142427. * @param csg The CSG to intersect against this CSG
  142428. * @returns A new CSG
  142429. */
  142430. intersect(csg: CSG): CSG;
  142431. /**
  142432. * Intersects this CSG with another CSG in place
  142433. * @param csg The CSG to intersect against this CSG
  142434. */
  142435. intersectInPlace(csg: CSG): void;
  142436. /**
  142437. * Return a new CSG solid with solid and empty space switched. This solid is
  142438. * not modified.
  142439. * @returns A new CSG solid with solid and empty space switched
  142440. */
  142441. inverse(): CSG;
  142442. /**
  142443. * Inverses the CSG in place
  142444. */
  142445. inverseInPlace(): void;
  142446. /**
  142447. * This is used to keep meshes transformations so they can be restored
  142448. * when we build back a Babylon Mesh
  142449. * NB : All CSG operations are performed in world coordinates
  142450. * @param csg The CSG to copy the transform attributes from
  142451. * @returns This CSG
  142452. */
  142453. copyTransformAttributes(csg: CSG): CSG;
  142454. /**
  142455. * Build Raw mesh from CSG
  142456. * Coordinates here are in world space
  142457. * @param name The name of the mesh geometry
  142458. * @param scene The Scene
  142459. * @param keepSubMeshes Specifies if the submeshes should be kept
  142460. * @returns A new Mesh
  142461. */
  142462. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142463. /**
  142464. * Build Mesh from CSG taking material and transforms into account
  142465. * @param name The name of the Mesh
  142466. * @param material The material of the Mesh
  142467. * @param scene The Scene
  142468. * @param keepSubMeshes Specifies if submeshes should be kept
  142469. * @returns The new Mesh
  142470. */
  142471. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142472. }
  142473. }
  142474. declare module BABYLON {
  142475. /**
  142476. * Class used to create a trail following a mesh
  142477. */
  142478. export class TrailMesh extends Mesh {
  142479. private _generator;
  142480. private _autoStart;
  142481. private _running;
  142482. private _diameter;
  142483. private _length;
  142484. private _sectionPolygonPointsCount;
  142485. private _sectionVectors;
  142486. private _sectionNormalVectors;
  142487. private _beforeRenderObserver;
  142488. /**
  142489. * @constructor
  142490. * @param name The value used by scene.getMeshByName() to do a lookup.
  142491. * @param generator The mesh or transform node to generate a trail.
  142492. * @param scene The scene to add this mesh to.
  142493. * @param diameter Diameter of trailing mesh. Default is 1.
  142494. * @param length Length of trailing mesh. Default is 60.
  142495. * @param autoStart Automatically start trailing mesh. Default true.
  142496. */
  142497. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142498. /**
  142499. * "TrailMesh"
  142500. * @returns "TrailMesh"
  142501. */
  142502. getClassName(): string;
  142503. private _createMesh;
  142504. /**
  142505. * Start trailing mesh.
  142506. */
  142507. start(): void;
  142508. /**
  142509. * Stop trailing mesh.
  142510. */
  142511. stop(): void;
  142512. /**
  142513. * Update trailing mesh geometry.
  142514. */
  142515. update(): void;
  142516. /**
  142517. * Returns a new TrailMesh object.
  142518. * @param name is a string, the name given to the new mesh
  142519. * @param newGenerator use new generator object for cloned trail mesh
  142520. * @returns a new mesh
  142521. */
  142522. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142523. /**
  142524. * Serializes this trail mesh
  142525. * @param serializationObject object to write serialization to
  142526. */
  142527. serialize(serializationObject: any): void;
  142528. /**
  142529. * Parses a serialized trail mesh
  142530. * @param parsedMesh the serialized mesh
  142531. * @param scene the scene to create the trail mesh in
  142532. * @returns the created trail mesh
  142533. */
  142534. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142535. }
  142536. }
  142537. declare module BABYLON {
  142538. /**
  142539. * Class containing static functions to help procedurally build meshes
  142540. */
  142541. export class TiledBoxBuilder {
  142542. /**
  142543. * Creates a box mesh
  142544. * 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)
  142545. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142547. * * 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
  142548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142549. * @param name defines the name of the mesh
  142550. * @param options defines the options used to create the mesh
  142551. * @param scene defines the hosting scene
  142552. * @returns the box mesh
  142553. */
  142554. static CreateTiledBox(name: string, options: {
  142555. pattern?: number;
  142556. width?: number;
  142557. height?: number;
  142558. depth?: number;
  142559. tileSize?: number;
  142560. tileWidth?: number;
  142561. tileHeight?: number;
  142562. alignHorizontal?: number;
  142563. alignVertical?: number;
  142564. faceUV?: Vector4[];
  142565. faceColors?: Color4[];
  142566. sideOrientation?: number;
  142567. updatable?: boolean;
  142568. }, scene?: Nullable<Scene>): Mesh;
  142569. }
  142570. }
  142571. declare module BABYLON {
  142572. /**
  142573. * Class containing static functions to help procedurally build meshes
  142574. */
  142575. export class TorusKnotBuilder {
  142576. /**
  142577. * Creates a torus knot mesh
  142578. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142579. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142580. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142581. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142583. * * 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
  142584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142585. * @param name defines the name of the mesh
  142586. * @param options defines the options used to create the mesh
  142587. * @param scene defines the hosting scene
  142588. * @returns the torus knot mesh
  142589. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142590. */
  142591. static CreateTorusKnot(name: string, options: {
  142592. radius?: number;
  142593. tube?: number;
  142594. radialSegments?: number;
  142595. tubularSegments?: number;
  142596. p?: number;
  142597. q?: number;
  142598. updatable?: boolean;
  142599. sideOrientation?: number;
  142600. frontUVs?: Vector4;
  142601. backUVs?: Vector4;
  142602. }, scene: any): Mesh;
  142603. }
  142604. }
  142605. declare module BABYLON {
  142606. /**
  142607. * Polygon
  142608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142609. */
  142610. export class Polygon {
  142611. /**
  142612. * Creates a rectangle
  142613. * @param xmin bottom X coord
  142614. * @param ymin bottom Y coord
  142615. * @param xmax top X coord
  142616. * @param ymax top Y coord
  142617. * @returns points that make the resulting rectation
  142618. */
  142619. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142620. /**
  142621. * Creates a circle
  142622. * @param radius radius of circle
  142623. * @param cx scale in x
  142624. * @param cy scale in y
  142625. * @param numberOfSides number of sides that make up the circle
  142626. * @returns points that make the resulting circle
  142627. */
  142628. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142629. /**
  142630. * Creates a polygon from input string
  142631. * @param input Input polygon data
  142632. * @returns the parsed points
  142633. */
  142634. static Parse(input: string): Vector2[];
  142635. /**
  142636. * Starts building a polygon from x and y coordinates
  142637. * @param x x coordinate
  142638. * @param y y coordinate
  142639. * @returns the started path2
  142640. */
  142641. static StartingAt(x: number, y: number): Path2;
  142642. }
  142643. /**
  142644. * Builds a polygon
  142645. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142646. */
  142647. export class PolygonMeshBuilder {
  142648. private _points;
  142649. private _outlinepoints;
  142650. private _holes;
  142651. private _name;
  142652. private _scene;
  142653. private _epoints;
  142654. private _eholes;
  142655. private _addToepoint;
  142656. /**
  142657. * Babylon reference to the earcut plugin.
  142658. */
  142659. bjsEarcut: any;
  142660. /**
  142661. * Creates a PolygonMeshBuilder
  142662. * @param name name of the builder
  142663. * @param contours Path of the polygon
  142664. * @param scene scene to add to when creating the mesh
  142665. * @param earcutInjection can be used to inject your own earcut reference
  142666. */
  142667. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142668. /**
  142669. * Adds a whole within the polygon
  142670. * @param hole Array of points defining the hole
  142671. * @returns this
  142672. */
  142673. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142674. /**
  142675. * Creates the polygon
  142676. * @param updatable If the mesh should be updatable
  142677. * @param depth The depth of the mesh created
  142678. * @returns the created mesh
  142679. */
  142680. build(updatable?: boolean, depth?: number): Mesh;
  142681. /**
  142682. * Creates the polygon
  142683. * @param depth The depth of the mesh created
  142684. * @returns the created VertexData
  142685. */
  142686. buildVertexData(depth?: number): VertexData;
  142687. /**
  142688. * Adds a side to the polygon
  142689. * @param positions points that make the polygon
  142690. * @param normals normals of the polygon
  142691. * @param uvs uvs of the polygon
  142692. * @param indices indices of the polygon
  142693. * @param bounds bounds of the polygon
  142694. * @param points points of the polygon
  142695. * @param depth depth of the polygon
  142696. * @param flip flip of the polygon
  142697. */
  142698. private addSide;
  142699. }
  142700. }
  142701. declare module BABYLON {
  142702. /**
  142703. * Class containing static functions to help procedurally build meshes
  142704. */
  142705. export class PolygonBuilder {
  142706. /**
  142707. * Creates a polygon mesh
  142708. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142709. * * 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
  142710. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142712. * * 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)
  142713. * * Remember you can only change the shape positions, not their number when updating a polygon
  142714. * @param name defines the name of the mesh
  142715. * @param options defines the options used to create the mesh
  142716. * @param scene defines the hosting scene
  142717. * @param earcutInjection can be used to inject your own earcut reference
  142718. * @returns the polygon mesh
  142719. */
  142720. static CreatePolygon(name: string, options: {
  142721. shape: Vector3[];
  142722. holes?: Vector3[][];
  142723. depth?: number;
  142724. faceUV?: Vector4[];
  142725. faceColors?: Color4[];
  142726. updatable?: boolean;
  142727. sideOrientation?: number;
  142728. frontUVs?: Vector4;
  142729. backUVs?: Vector4;
  142730. wrap?: boolean;
  142731. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142732. /**
  142733. * Creates an extruded polygon mesh, with depth in the Y direction.
  142734. * * 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)
  142735. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142736. * @param name defines the name of the mesh
  142737. * @param options defines the options used to create the mesh
  142738. * @param scene defines the hosting scene
  142739. * @param earcutInjection can be used to inject your own earcut reference
  142740. * @returns the polygon mesh
  142741. */
  142742. static ExtrudePolygon(name: string, options: {
  142743. shape: Vector3[];
  142744. holes?: Vector3[][];
  142745. depth?: number;
  142746. faceUV?: Vector4[];
  142747. faceColors?: Color4[];
  142748. updatable?: boolean;
  142749. sideOrientation?: number;
  142750. frontUVs?: Vector4;
  142751. backUVs?: Vector4;
  142752. wrap?: boolean;
  142753. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142754. }
  142755. }
  142756. declare module BABYLON {
  142757. /**
  142758. * Class containing static functions to help procedurally build meshes
  142759. */
  142760. export class LatheBuilder {
  142761. /**
  142762. * Creates lathe mesh.
  142763. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142764. * * 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
  142765. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142766. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142767. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142768. * * 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
  142769. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142770. * * 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
  142771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142772. * * 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
  142773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142775. * @param name defines the name of the mesh
  142776. * @param options defines the options used to create the mesh
  142777. * @param scene defines the hosting scene
  142778. * @returns the lathe mesh
  142779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142780. */
  142781. static CreateLathe(name: string, options: {
  142782. shape: Vector3[];
  142783. radius?: number;
  142784. tessellation?: number;
  142785. clip?: number;
  142786. arc?: number;
  142787. closed?: boolean;
  142788. updatable?: boolean;
  142789. sideOrientation?: number;
  142790. frontUVs?: Vector4;
  142791. backUVs?: Vector4;
  142792. cap?: number;
  142793. invertUV?: boolean;
  142794. }, scene?: Nullable<Scene>): Mesh;
  142795. }
  142796. }
  142797. declare module BABYLON {
  142798. /**
  142799. * Class containing static functions to help procedurally build meshes
  142800. */
  142801. export class TiledPlaneBuilder {
  142802. /**
  142803. * Creates a tiled plane mesh
  142804. * * The parameter `pattern` will, depending on value, do nothing or
  142805. * * * flip (reflect about central vertical) alternate tiles across and up
  142806. * * * flip every tile on alternate rows
  142807. * * * rotate (180 degs) alternate tiles across and up
  142808. * * * rotate every tile on alternate rows
  142809. * * * flip and rotate alternate tiles across and up
  142810. * * * flip and rotate every tile on alternate rows
  142811. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142812. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142813. * * 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
  142814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142815. * * 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)
  142816. * * 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)
  142817. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142818. * @param name defines the name of the mesh
  142819. * @param options defines the options used to create the mesh
  142820. * @param scene defines the hosting scene
  142821. * @returns the box mesh
  142822. */
  142823. static CreateTiledPlane(name: string, options: {
  142824. pattern?: number;
  142825. tileSize?: number;
  142826. tileWidth?: number;
  142827. tileHeight?: number;
  142828. size?: number;
  142829. width?: number;
  142830. height?: number;
  142831. alignHorizontal?: number;
  142832. alignVertical?: number;
  142833. sideOrientation?: number;
  142834. frontUVs?: Vector4;
  142835. backUVs?: Vector4;
  142836. updatable?: boolean;
  142837. }, scene?: Nullable<Scene>): Mesh;
  142838. }
  142839. }
  142840. declare module BABYLON {
  142841. /**
  142842. * Class containing static functions to help procedurally build meshes
  142843. */
  142844. export class TubeBuilder {
  142845. /**
  142846. * Creates a tube mesh.
  142847. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142848. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142849. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142850. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142851. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142852. * * 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)
  142853. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142854. * * 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
  142855. * * 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
  142856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142857. * * 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
  142858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142860. * @param name defines the name of the mesh
  142861. * @param options defines the options used to create the mesh
  142862. * @param scene defines the hosting scene
  142863. * @returns the tube mesh
  142864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142865. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142866. */
  142867. static CreateTube(name: string, options: {
  142868. path: Vector3[];
  142869. radius?: number;
  142870. tessellation?: number;
  142871. radiusFunction?: {
  142872. (i: number, distance: number): number;
  142873. };
  142874. cap?: number;
  142875. arc?: number;
  142876. updatable?: boolean;
  142877. sideOrientation?: number;
  142878. frontUVs?: Vector4;
  142879. backUVs?: Vector4;
  142880. instance?: Mesh;
  142881. invertUV?: boolean;
  142882. }, scene?: Nullable<Scene>): Mesh;
  142883. }
  142884. }
  142885. declare module BABYLON {
  142886. /**
  142887. * Class containing static functions to help procedurally build meshes
  142888. */
  142889. export class IcoSphereBuilder {
  142890. /**
  142891. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142892. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142893. * * 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`)
  142894. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142895. * * 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
  142896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142897. * * 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
  142898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142899. * @param name defines the name of the mesh
  142900. * @param options defines the options used to create the mesh
  142901. * @param scene defines the hosting scene
  142902. * @returns the icosahedron mesh
  142903. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142904. */
  142905. static CreateIcoSphere(name: string, options: {
  142906. radius?: number;
  142907. radiusX?: number;
  142908. radiusY?: number;
  142909. radiusZ?: number;
  142910. flat?: boolean;
  142911. subdivisions?: number;
  142912. sideOrientation?: number;
  142913. frontUVs?: Vector4;
  142914. backUVs?: Vector4;
  142915. updatable?: boolean;
  142916. }, scene?: Nullable<Scene>): Mesh;
  142917. }
  142918. }
  142919. declare module BABYLON {
  142920. /**
  142921. * Class containing static functions to help procedurally build meshes
  142922. */
  142923. export class DecalBuilder {
  142924. /**
  142925. * Creates a decal mesh.
  142926. * 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
  142927. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142928. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142929. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142930. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142931. * @param name defines the name of the mesh
  142932. * @param sourceMesh defines the mesh where the decal must be applied
  142933. * @param options defines the options used to create the mesh
  142934. * @param scene defines the hosting scene
  142935. * @returns the decal mesh
  142936. * @see https://doc.babylonjs.com/how_to/decals
  142937. */
  142938. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142939. position?: Vector3;
  142940. normal?: Vector3;
  142941. size?: Vector3;
  142942. angle?: number;
  142943. }): Mesh;
  142944. }
  142945. }
  142946. declare module BABYLON {
  142947. /**
  142948. * Class containing static functions to help procedurally build meshes
  142949. */
  142950. export class MeshBuilder {
  142951. /**
  142952. * Creates a box mesh
  142953. * * The parameter `size` sets the size (float) of each box side (default 1)
  142954. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142955. * * 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)
  142956. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142958. * * 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
  142959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142960. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142961. * @param name defines the name of the mesh
  142962. * @param options defines the options used to create the mesh
  142963. * @param scene defines the hosting scene
  142964. * @returns the box mesh
  142965. */
  142966. static CreateBox(name: string, options: {
  142967. size?: number;
  142968. width?: number;
  142969. height?: number;
  142970. depth?: number;
  142971. faceUV?: Vector4[];
  142972. faceColors?: Color4[];
  142973. sideOrientation?: number;
  142974. frontUVs?: Vector4;
  142975. backUVs?: Vector4;
  142976. wrap?: boolean;
  142977. topBaseAt?: number;
  142978. bottomBaseAt?: number;
  142979. updatable?: boolean;
  142980. }, scene?: Nullable<Scene>): Mesh;
  142981. /**
  142982. * Creates a tiled box mesh
  142983. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142985. * @param name defines the name of the mesh
  142986. * @param options defines the options used to create the mesh
  142987. * @param scene defines the hosting scene
  142988. * @returns the tiled box mesh
  142989. */
  142990. static CreateTiledBox(name: string, options: {
  142991. pattern?: number;
  142992. size?: number;
  142993. width?: number;
  142994. height?: number;
  142995. depth: number;
  142996. tileSize?: number;
  142997. tileWidth?: number;
  142998. tileHeight?: number;
  142999. faceUV?: Vector4[];
  143000. faceColors?: Color4[];
  143001. alignHorizontal?: number;
  143002. alignVertical?: number;
  143003. sideOrientation?: number;
  143004. updatable?: boolean;
  143005. }, scene?: Nullable<Scene>): Mesh;
  143006. /**
  143007. * Creates a sphere mesh
  143008. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143009. * * 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`)
  143010. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143011. * * 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
  143012. * * 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)
  143013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143014. * * 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
  143015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143016. * @param name defines the name of the mesh
  143017. * @param options defines the options used to create the mesh
  143018. * @param scene defines the hosting scene
  143019. * @returns the sphere mesh
  143020. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143021. */
  143022. static CreateSphere(name: string, options: {
  143023. segments?: number;
  143024. diameter?: number;
  143025. diameterX?: number;
  143026. diameterY?: number;
  143027. diameterZ?: number;
  143028. arc?: number;
  143029. slice?: number;
  143030. sideOrientation?: number;
  143031. frontUVs?: Vector4;
  143032. backUVs?: Vector4;
  143033. updatable?: boolean;
  143034. }, scene?: Nullable<Scene>): Mesh;
  143035. /**
  143036. * Creates a plane polygonal mesh. By default, this is a disc
  143037. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143038. * * 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
  143039. * * 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
  143040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143041. * * 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
  143042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143043. * @param name defines the name of the mesh
  143044. * @param options defines the options used to create the mesh
  143045. * @param scene defines the hosting scene
  143046. * @returns the plane polygonal mesh
  143047. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143048. */
  143049. static CreateDisc(name: string, options: {
  143050. radius?: number;
  143051. tessellation?: number;
  143052. arc?: number;
  143053. updatable?: boolean;
  143054. sideOrientation?: number;
  143055. frontUVs?: Vector4;
  143056. backUVs?: Vector4;
  143057. }, scene?: Nullable<Scene>): Mesh;
  143058. /**
  143059. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143060. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143061. * * 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`)
  143062. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143063. * * 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
  143064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143065. * * 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
  143066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143067. * @param name defines the name of the mesh
  143068. * @param options defines the options used to create the mesh
  143069. * @param scene defines the hosting scene
  143070. * @returns the icosahedron mesh
  143071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143072. */
  143073. static CreateIcoSphere(name: string, options: {
  143074. radius?: number;
  143075. radiusX?: number;
  143076. radiusY?: number;
  143077. radiusZ?: number;
  143078. flat?: boolean;
  143079. subdivisions?: number;
  143080. sideOrientation?: number;
  143081. frontUVs?: Vector4;
  143082. backUVs?: Vector4;
  143083. updatable?: boolean;
  143084. }, scene?: Nullable<Scene>): Mesh;
  143085. /**
  143086. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143087. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143088. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143089. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143090. * * 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
  143091. * * 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
  143092. * * 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
  143093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143094. * * 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
  143095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143096. * * 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
  143097. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143098. * * 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
  143099. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143101. * @param name defines the name of the mesh
  143102. * @param options defines the options used to create the mesh
  143103. * @param scene defines the hosting scene
  143104. * @returns the ribbon mesh
  143105. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143107. */
  143108. static CreateRibbon(name: string, options: {
  143109. pathArray: Vector3[][];
  143110. closeArray?: boolean;
  143111. closePath?: boolean;
  143112. offset?: number;
  143113. updatable?: boolean;
  143114. sideOrientation?: number;
  143115. frontUVs?: Vector4;
  143116. backUVs?: Vector4;
  143117. instance?: Mesh;
  143118. invertUV?: boolean;
  143119. uvs?: Vector2[];
  143120. colors?: Color4[];
  143121. }, scene?: Nullable<Scene>): Mesh;
  143122. /**
  143123. * Creates a cylinder or a cone mesh
  143124. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143125. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143126. * * 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.
  143127. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143128. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143129. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143130. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143131. * * 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).
  143132. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143133. * * 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).
  143134. * * 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
  143135. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143136. * * 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
  143137. * * 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.
  143138. * * If `enclose` is false, a ring surface is one element.
  143139. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143140. * * 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
  143141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143142. * * 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
  143143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143144. * @param name defines the name of the mesh
  143145. * @param options defines the options used to create the mesh
  143146. * @param scene defines the hosting scene
  143147. * @returns the cylinder mesh
  143148. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143149. */
  143150. static CreateCylinder(name: string, options: {
  143151. height?: number;
  143152. diameterTop?: number;
  143153. diameterBottom?: number;
  143154. diameter?: number;
  143155. tessellation?: number;
  143156. subdivisions?: number;
  143157. arc?: number;
  143158. faceColors?: Color4[];
  143159. faceUV?: Vector4[];
  143160. updatable?: boolean;
  143161. hasRings?: boolean;
  143162. enclose?: boolean;
  143163. cap?: number;
  143164. sideOrientation?: number;
  143165. frontUVs?: Vector4;
  143166. backUVs?: Vector4;
  143167. }, scene?: Nullable<Scene>): Mesh;
  143168. /**
  143169. * Creates a torus mesh
  143170. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143171. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143172. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143174. * * 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
  143175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143176. * @param name defines the name of the mesh
  143177. * @param options defines the options used to create the mesh
  143178. * @param scene defines the hosting scene
  143179. * @returns the torus mesh
  143180. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143181. */
  143182. static CreateTorus(name: string, options: {
  143183. diameter?: number;
  143184. thickness?: number;
  143185. tessellation?: number;
  143186. updatable?: boolean;
  143187. sideOrientation?: number;
  143188. frontUVs?: Vector4;
  143189. backUVs?: Vector4;
  143190. }, scene?: Nullable<Scene>): Mesh;
  143191. /**
  143192. * Creates a torus knot mesh
  143193. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143194. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143195. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143196. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143198. * * 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
  143199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143200. * @param name defines the name of the mesh
  143201. * @param options defines the options used to create the mesh
  143202. * @param scene defines the hosting scene
  143203. * @returns the torus knot mesh
  143204. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143205. */
  143206. static CreateTorusKnot(name: string, options: {
  143207. radius?: number;
  143208. tube?: number;
  143209. radialSegments?: number;
  143210. tubularSegments?: number;
  143211. p?: number;
  143212. q?: number;
  143213. updatable?: boolean;
  143214. sideOrientation?: number;
  143215. frontUVs?: Vector4;
  143216. backUVs?: Vector4;
  143217. }, scene?: Nullable<Scene>): Mesh;
  143218. /**
  143219. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143220. * * 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
  143221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143222. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143223. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143224. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143226. * * 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
  143227. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143230. * @param name defines the name of the new line system
  143231. * @param options defines the options used to create the line system
  143232. * @param scene defines the hosting scene
  143233. * @returns a new line system mesh
  143234. */
  143235. static CreateLineSystem(name: string, options: {
  143236. lines: Vector3[][];
  143237. updatable?: boolean;
  143238. instance?: Nullable<LinesMesh>;
  143239. colors?: Nullable<Color4[][]>;
  143240. useVertexAlpha?: boolean;
  143241. }, scene: Nullable<Scene>): LinesMesh;
  143242. /**
  143243. * Creates a line mesh
  143244. * 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
  143245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143246. * * The parameter `points` is an array successive Vector3
  143247. * * 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
  143248. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143250. * * When updating an instance, remember that only point positions can change, not the number of points
  143251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143253. * @param name defines the name of the new line system
  143254. * @param options defines the options used to create the line system
  143255. * @param scene defines the hosting scene
  143256. * @returns a new line mesh
  143257. */
  143258. static CreateLines(name: string, options: {
  143259. points: Vector3[];
  143260. updatable?: boolean;
  143261. instance?: Nullable<LinesMesh>;
  143262. colors?: Color4[];
  143263. useVertexAlpha?: boolean;
  143264. }, scene?: Nullable<Scene>): LinesMesh;
  143265. /**
  143266. * Creates a dashed line mesh
  143267. * * 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
  143268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143269. * * The parameter `points` is an array successive Vector3
  143270. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143271. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143272. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143273. * * 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
  143274. * * When updating an instance, remember that only point positions can change, not the number of points
  143275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143276. * @param name defines the name of the mesh
  143277. * @param options defines the options used to create the mesh
  143278. * @param scene defines the hosting scene
  143279. * @returns the dashed line mesh
  143280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143281. */
  143282. static CreateDashedLines(name: string, options: {
  143283. points: Vector3[];
  143284. dashSize?: number;
  143285. gapSize?: number;
  143286. dashNb?: number;
  143287. updatable?: boolean;
  143288. instance?: LinesMesh;
  143289. }, scene?: Nullable<Scene>): LinesMesh;
  143290. /**
  143291. * 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.
  143292. * * 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.
  143293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143294. * * 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.
  143295. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143296. * * 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
  143297. * * 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
  143298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143300. * * 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
  143301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143303. * @param name defines the name of the mesh
  143304. * @param options defines the options used to create the mesh
  143305. * @param scene defines the hosting scene
  143306. * @returns the extruded shape mesh
  143307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143309. */
  143310. static ExtrudeShape(name: string, options: {
  143311. shape: Vector3[];
  143312. path: Vector3[];
  143313. scale?: number;
  143314. rotation?: number;
  143315. cap?: number;
  143316. updatable?: boolean;
  143317. sideOrientation?: number;
  143318. frontUVs?: Vector4;
  143319. backUVs?: Vector4;
  143320. instance?: Mesh;
  143321. invertUV?: boolean;
  143322. }, scene?: Nullable<Scene>): Mesh;
  143323. /**
  143324. * Creates an custom extruded shape mesh.
  143325. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143326. * * 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.
  143327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143328. * * 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
  143329. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143330. * * 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
  143331. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143332. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143333. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143334. * * 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
  143335. * * 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
  143336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143338. * * 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
  143339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143341. * @param name defines the name of the mesh
  143342. * @param options defines the options used to create the mesh
  143343. * @param scene defines the hosting scene
  143344. * @returns the custom extruded shape mesh
  143345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143348. */
  143349. static ExtrudeShapeCustom(name: string, options: {
  143350. shape: Vector3[];
  143351. path: Vector3[];
  143352. scaleFunction?: any;
  143353. rotationFunction?: any;
  143354. ribbonCloseArray?: boolean;
  143355. ribbonClosePath?: boolean;
  143356. cap?: number;
  143357. updatable?: boolean;
  143358. sideOrientation?: number;
  143359. frontUVs?: Vector4;
  143360. backUVs?: Vector4;
  143361. instance?: Mesh;
  143362. invertUV?: boolean;
  143363. }, scene?: Nullable<Scene>): Mesh;
  143364. /**
  143365. * Creates lathe mesh.
  143366. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143367. * * 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
  143368. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143369. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143370. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143371. * * 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
  143372. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143373. * * 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
  143374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143375. * * 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
  143376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143378. * @param name defines the name of the mesh
  143379. * @param options defines the options used to create the mesh
  143380. * @param scene defines the hosting scene
  143381. * @returns the lathe mesh
  143382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143383. */
  143384. static CreateLathe(name: string, options: {
  143385. shape: Vector3[];
  143386. radius?: number;
  143387. tessellation?: number;
  143388. clip?: number;
  143389. arc?: number;
  143390. closed?: boolean;
  143391. updatable?: boolean;
  143392. sideOrientation?: number;
  143393. frontUVs?: Vector4;
  143394. backUVs?: Vector4;
  143395. cap?: number;
  143396. invertUV?: boolean;
  143397. }, scene?: Nullable<Scene>): Mesh;
  143398. /**
  143399. * Creates a tiled plane mesh
  143400. * * You can set a limited pattern arrangement with the tiles
  143401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143402. * * 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
  143403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143404. * @param name defines the name of the mesh
  143405. * @param options defines the options used to create the mesh
  143406. * @param scene defines the hosting scene
  143407. * @returns the plane mesh
  143408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143409. */
  143410. static CreateTiledPlane(name: string, options: {
  143411. pattern?: number;
  143412. tileSize?: number;
  143413. tileWidth?: number;
  143414. tileHeight?: number;
  143415. size?: number;
  143416. width?: number;
  143417. height?: number;
  143418. alignHorizontal?: number;
  143419. alignVertical?: number;
  143420. sideOrientation?: number;
  143421. frontUVs?: Vector4;
  143422. backUVs?: Vector4;
  143423. updatable?: boolean;
  143424. }, scene?: Nullable<Scene>): Mesh;
  143425. /**
  143426. * Creates a plane mesh
  143427. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143428. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143429. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143431. * * 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
  143432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143433. * @param name defines the name of the mesh
  143434. * @param options defines the options used to create the mesh
  143435. * @param scene defines the hosting scene
  143436. * @returns the plane mesh
  143437. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143438. */
  143439. static CreatePlane(name: string, options: {
  143440. size?: number;
  143441. width?: number;
  143442. height?: number;
  143443. sideOrientation?: number;
  143444. frontUVs?: Vector4;
  143445. backUVs?: Vector4;
  143446. updatable?: boolean;
  143447. sourcePlane?: Plane;
  143448. }, scene?: Nullable<Scene>): Mesh;
  143449. /**
  143450. * Creates a ground mesh
  143451. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143452. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143454. * @param name defines the name of the mesh
  143455. * @param options defines the options used to create the mesh
  143456. * @param scene defines the hosting scene
  143457. * @returns the ground mesh
  143458. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143459. */
  143460. static CreateGround(name: string, options: {
  143461. width?: number;
  143462. height?: number;
  143463. subdivisions?: number;
  143464. subdivisionsX?: number;
  143465. subdivisionsY?: number;
  143466. updatable?: boolean;
  143467. }, scene?: Nullable<Scene>): Mesh;
  143468. /**
  143469. * Creates a tiled ground mesh
  143470. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143471. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143472. * * 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
  143473. * * 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
  143474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143475. * @param name defines the name of the mesh
  143476. * @param options defines the options used to create the mesh
  143477. * @param scene defines the hosting scene
  143478. * @returns the tiled ground mesh
  143479. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143480. */
  143481. static CreateTiledGround(name: string, options: {
  143482. xmin: number;
  143483. zmin: number;
  143484. xmax: number;
  143485. zmax: number;
  143486. subdivisions?: {
  143487. w: number;
  143488. h: number;
  143489. };
  143490. precision?: {
  143491. w: number;
  143492. h: number;
  143493. };
  143494. updatable?: boolean;
  143495. }, scene?: Nullable<Scene>): Mesh;
  143496. /**
  143497. * Creates a ground mesh from a height map
  143498. * * The parameter `url` sets the URL of the height map image resource.
  143499. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143500. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143501. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143502. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143503. * * 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.
  143504. * * 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).
  143505. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143507. * @param name defines the name of the mesh
  143508. * @param url defines the url to the height map
  143509. * @param options defines the options used to create the mesh
  143510. * @param scene defines the hosting scene
  143511. * @returns the ground mesh
  143512. * @see https://doc.babylonjs.com/babylon101/height_map
  143513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143514. */
  143515. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143516. width?: number;
  143517. height?: number;
  143518. subdivisions?: number;
  143519. minHeight?: number;
  143520. maxHeight?: number;
  143521. colorFilter?: Color3;
  143522. alphaFilter?: number;
  143523. updatable?: boolean;
  143524. onReady?: (mesh: GroundMesh) => void;
  143525. }, scene?: Nullable<Scene>): GroundMesh;
  143526. /**
  143527. * Creates a polygon mesh
  143528. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143529. * * 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
  143530. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143532. * * 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)
  143533. * * Remember you can only change the shape positions, not their number when updating a polygon
  143534. * @param name defines the name of the mesh
  143535. * @param options defines the options used to create the mesh
  143536. * @param scene defines the hosting scene
  143537. * @param earcutInjection can be used to inject your own earcut reference
  143538. * @returns the polygon mesh
  143539. */
  143540. static CreatePolygon(name: string, options: {
  143541. shape: Vector3[];
  143542. holes?: Vector3[][];
  143543. depth?: number;
  143544. faceUV?: Vector4[];
  143545. faceColors?: Color4[];
  143546. updatable?: boolean;
  143547. sideOrientation?: number;
  143548. frontUVs?: Vector4;
  143549. backUVs?: Vector4;
  143550. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143551. /**
  143552. * Creates an extruded polygon mesh, with depth in the Y direction.
  143553. * * 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)
  143554. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143555. * @param name defines the name of the mesh
  143556. * @param options defines the options used to create the mesh
  143557. * @param scene defines the hosting scene
  143558. * @param earcutInjection can be used to inject your own earcut reference
  143559. * @returns the polygon mesh
  143560. */
  143561. static ExtrudePolygon(name: string, options: {
  143562. shape: Vector3[];
  143563. holes?: Vector3[][];
  143564. depth?: number;
  143565. faceUV?: Vector4[];
  143566. faceColors?: Color4[];
  143567. updatable?: boolean;
  143568. sideOrientation?: number;
  143569. frontUVs?: Vector4;
  143570. backUVs?: Vector4;
  143571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143572. /**
  143573. * Creates a tube mesh.
  143574. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143575. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143576. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143577. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143578. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143579. * * 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)
  143580. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143581. * * 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
  143582. * * 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
  143583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143584. * * 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
  143585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143587. * @param name defines the name of the mesh
  143588. * @param options defines the options used to create the mesh
  143589. * @param scene defines the hosting scene
  143590. * @returns the tube mesh
  143591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143592. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143593. */
  143594. static CreateTube(name: string, options: {
  143595. path: Vector3[];
  143596. radius?: number;
  143597. tessellation?: number;
  143598. radiusFunction?: {
  143599. (i: number, distance: number): number;
  143600. };
  143601. cap?: number;
  143602. arc?: number;
  143603. updatable?: boolean;
  143604. sideOrientation?: number;
  143605. frontUVs?: Vector4;
  143606. backUVs?: Vector4;
  143607. instance?: Mesh;
  143608. invertUV?: boolean;
  143609. }, scene?: Nullable<Scene>): Mesh;
  143610. /**
  143611. * Creates a polyhedron mesh
  143612. * * 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
  143613. * * The parameter `size` (positive float, default 1) sets the polygon size
  143614. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143615. * * 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`
  143616. * * 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
  143617. * * 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)`)
  143618. * * 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
  143619. * * 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
  143620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143621. * * 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
  143622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143623. * @param name defines the name of the mesh
  143624. * @param options defines the options used to create the mesh
  143625. * @param scene defines the hosting scene
  143626. * @returns the polyhedron mesh
  143627. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143628. */
  143629. static CreatePolyhedron(name: string, options: {
  143630. type?: number;
  143631. size?: number;
  143632. sizeX?: number;
  143633. sizeY?: number;
  143634. sizeZ?: number;
  143635. custom?: any;
  143636. faceUV?: Vector4[];
  143637. faceColors?: Color4[];
  143638. flat?: boolean;
  143639. updatable?: boolean;
  143640. sideOrientation?: number;
  143641. frontUVs?: Vector4;
  143642. backUVs?: Vector4;
  143643. }, scene?: Nullable<Scene>): Mesh;
  143644. /**
  143645. * Creates a decal mesh.
  143646. * 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
  143647. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143648. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143649. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143650. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143651. * @param name defines the name of the mesh
  143652. * @param sourceMesh defines the mesh where the decal must be applied
  143653. * @param options defines the options used to create the mesh
  143654. * @param scene defines the hosting scene
  143655. * @returns the decal mesh
  143656. * @see https://doc.babylonjs.com/how_to/decals
  143657. */
  143658. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143659. position?: Vector3;
  143660. normal?: Vector3;
  143661. size?: Vector3;
  143662. angle?: number;
  143663. }): Mesh;
  143664. }
  143665. }
  143666. declare module BABYLON {
  143667. /**
  143668. * A simplifier interface for future simplification implementations
  143669. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143670. */
  143671. export interface ISimplifier {
  143672. /**
  143673. * Simplification of a given mesh according to the given settings.
  143674. * Since this requires computation, it is assumed that the function runs async.
  143675. * @param settings The settings of the simplification, including quality and distance
  143676. * @param successCallback A callback that will be called after the mesh was simplified.
  143677. * @param errorCallback in case of an error, this callback will be called. optional.
  143678. */
  143679. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143680. }
  143681. /**
  143682. * Expected simplification settings.
  143683. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143684. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143685. */
  143686. export interface ISimplificationSettings {
  143687. /**
  143688. * Gets or sets the expected quality
  143689. */
  143690. quality: number;
  143691. /**
  143692. * Gets or sets the distance when this optimized version should be used
  143693. */
  143694. distance: number;
  143695. /**
  143696. * Gets an already optimized mesh
  143697. */
  143698. optimizeMesh?: boolean;
  143699. }
  143700. /**
  143701. * Class used to specify simplification options
  143702. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143703. */
  143704. export class SimplificationSettings implements ISimplificationSettings {
  143705. /** expected quality */
  143706. quality: number;
  143707. /** distance when this optimized version should be used */
  143708. distance: number;
  143709. /** already optimized mesh */
  143710. optimizeMesh?: boolean | undefined;
  143711. /**
  143712. * Creates a SimplificationSettings
  143713. * @param quality expected quality
  143714. * @param distance distance when this optimized version should be used
  143715. * @param optimizeMesh already optimized mesh
  143716. */
  143717. constructor(
  143718. /** expected quality */
  143719. quality: number,
  143720. /** distance when this optimized version should be used */
  143721. distance: number,
  143722. /** already optimized mesh */
  143723. optimizeMesh?: boolean | undefined);
  143724. }
  143725. /**
  143726. * Interface used to define a simplification task
  143727. */
  143728. export interface ISimplificationTask {
  143729. /**
  143730. * Array of settings
  143731. */
  143732. settings: Array<ISimplificationSettings>;
  143733. /**
  143734. * Simplification type
  143735. */
  143736. simplificationType: SimplificationType;
  143737. /**
  143738. * Mesh to simplify
  143739. */
  143740. mesh: Mesh;
  143741. /**
  143742. * Callback called on success
  143743. */
  143744. successCallback?: () => void;
  143745. /**
  143746. * Defines if parallel processing can be used
  143747. */
  143748. parallelProcessing: boolean;
  143749. }
  143750. /**
  143751. * Queue used to order the simplification tasks
  143752. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143753. */
  143754. export class SimplificationQueue {
  143755. private _simplificationArray;
  143756. /**
  143757. * Gets a boolean indicating that the process is still running
  143758. */
  143759. running: boolean;
  143760. /**
  143761. * Creates a new queue
  143762. */
  143763. constructor();
  143764. /**
  143765. * Adds a new simplification task
  143766. * @param task defines a task to add
  143767. */
  143768. addTask(task: ISimplificationTask): void;
  143769. /**
  143770. * Execute next task
  143771. */
  143772. executeNext(): void;
  143773. /**
  143774. * Execute a simplification task
  143775. * @param task defines the task to run
  143776. */
  143777. runSimplification(task: ISimplificationTask): void;
  143778. private getSimplifier;
  143779. }
  143780. /**
  143781. * The implemented types of simplification
  143782. * At the moment only Quadratic Error Decimation is implemented
  143783. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143784. */
  143785. export enum SimplificationType {
  143786. /** Quadratic error decimation */
  143787. QUADRATIC = 0
  143788. }
  143789. /**
  143790. * An implementation of the Quadratic Error simplification algorithm.
  143791. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143792. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143793. * @author RaananW
  143794. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143795. */
  143796. export class QuadraticErrorSimplification implements ISimplifier {
  143797. private _mesh;
  143798. private triangles;
  143799. private vertices;
  143800. private references;
  143801. private _reconstructedMesh;
  143802. /** Gets or sets the number pf sync interations */
  143803. syncIterations: number;
  143804. /** Gets or sets the aggressiveness of the simplifier */
  143805. aggressiveness: number;
  143806. /** Gets or sets the number of allowed iterations for decimation */
  143807. decimationIterations: number;
  143808. /** Gets or sets the espilon to use for bounding box computation */
  143809. boundingBoxEpsilon: number;
  143810. /**
  143811. * Creates a new QuadraticErrorSimplification
  143812. * @param _mesh defines the target mesh
  143813. */
  143814. constructor(_mesh: Mesh);
  143815. /**
  143816. * Simplification of a given mesh according to the given settings.
  143817. * Since this requires computation, it is assumed that the function runs async.
  143818. * @param settings The settings of the simplification, including quality and distance
  143819. * @param successCallback A callback that will be called after the mesh was simplified.
  143820. */
  143821. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143822. private runDecimation;
  143823. private initWithMesh;
  143824. private init;
  143825. private reconstructMesh;
  143826. private initDecimatedMesh;
  143827. private isFlipped;
  143828. private updateTriangles;
  143829. private identifyBorder;
  143830. private updateMesh;
  143831. private vertexError;
  143832. private calculateError;
  143833. }
  143834. }
  143835. declare module BABYLON {
  143836. interface Scene {
  143837. /** @hidden (Backing field) */
  143838. _simplificationQueue: SimplificationQueue;
  143839. /**
  143840. * Gets or sets the simplification queue attached to the scene
  143841. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143842. */
  143843. simplificationQueue: SimplificationQueue;
  143844. }
  143845. interface Mesh {
  143846. /**
  143847. * Simplify the mesh according to the given array of settings.
  143848. * Function will return immediately and will simplify async
  143849. * @param settings a collection of simplification settings
  143850. * @param parallelProcessing should all levels calculate parallel or one after the other
  143851. * @param simplificationType the type of simplification to run
  143852. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143853. * @returns the current mesh
  143854. */
  143855. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143856. }
  143857. /**
  143858. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143859. * created in a scene
  143860. */
  143861. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143862. /**
  143863. * The component name helpfull to identify the component in the list of scene components.
  143864. */
  143865. readonly name: string;
  143866. /**
  143867. * The scene the component belongs to.
  143868. */
  143869. scene: Scene;
  143870. /**
  143871. * Creates a new instance of the component for the given scene
  143872. * @param scene Defines the scene to register the component in
  143873. */
  143874. constructor(scene: Scene);
  143875. /**
  143876. * Registers the component in a given scene
  143877. */
  143878. register(): void;
  143879. /**
  143880. * Rebuilds the elements related to this component in case of
  143881. * context lost for instance.
  143882. */
  143883. rebuild(): void;
  143884. /**
  143885. * Disposes the component and the associated ressources
  143886. */
  143887. dispose(): void;
  143888. private _beforeCameraUpdate;
  143889. }
  143890. }
  143891. declare module BABYLON {
  143892. interface Mesh {
  143893. /**
  143894. * Creates a new thin instance
  143895. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  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. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143898. */
  143899. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143900. /**
  143901. * Adds the transformation (matrix) of the current mesh as a thin instance
  143902. * @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
  143903. * @returns the thin instance index number
  143904. */
  143905. thinInstanceAddSelf(refresh: boolean): number;
  143906. /**
  143907. * Registers a custom attribute to be used with thin instances
  143908. * @param kind name of the attribute
  143909. * @param stride size in floats of the attribute
  143910. */
  143911. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143912. /**
  143913. * Sets the matrix of a thin instance
  143914. * @param index index of the thin instance
  143915. * @param matrix matrix to set
  143916. * @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
  143917. */
  143918. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143919. /**
  143920. * Sets the value of a custom attribute for a thin instance
  143921. * @param kind name of the attribute
  143922. * @param index index of the thin instance
  143923. * @param value value to set
  143924. * @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
  143925. */
  143926. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143927. /**
  143928. * 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.
  143929. */
  143930. thinInstanceCount: number;
  143931. /**
  143932. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143933. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143934. * @param buffer buffer to set
  143935. * @param stride size in floats of each value of the buffer
  143936. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143937. */
  143938. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143939. /**
  143940. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143941. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143942. */
  143943. thinInstanceBufferUpdated(kind: string): void;
  143944. /**
  143945. * Refreshes the bounding info, taking into account all the thin instances defined
  143946. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143947. */
  143948. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143949. /** @hidden */
  143950. _thinInstanceInitializeUserStorage(): void;
  143951. /** @hidden */
  143952. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143953. /** @hidden */
  143954. _userThinInstanceBuffersStorage: {
  143955. data: {
  143956. [key: string]: Float32Array;
  143957. };
  143958. sizes: {
  143959. [key: string]: number;
  143960. };
  143961. vertexBuffers: {
  143962. [key: string]: Nullable<VertexBuffer>;
  143963. };
  143964. strides: {
  143965. [key: string]: number;
  143966. };
  143967. };
  143968. }
  143969. }
  143970. declare module BABYLON {
  143971. /**
  143972. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143973. */
  143974. export interface INavigationEnginePlugin {
  143975. /**
  143976. * plugin name
  143977. */
  143978. name: string;
  143979. /**
  143980. * Creates a navigation mesh
  143981. * @param meshes array of all the geometry used to compute the navigatio mesh
  143982. * @param parameters bunch of parameters used to filter geometry
  143983. */
  143984. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143985. /**
  143986. * Create a navigation mesh debug mesh
  143987. * @param scene is where the mesh will be added
  143988. * @returns debug display mesh
  143989. */
  143990. createDebugNavMesh(scene: Scene): Mesh;
  143991. /**
  143992. * Get a navigation mesh constrained position, closest to the parameter position
  143993. * @param position world position
  143994. * @returns the closest point to position constrained by the navigation mesh
  143995. */
  143996. getClosestPoint(position: Vector3): Vector3;
  143997. /**
  143998. * Get a navigation mesh constrained position, closest to the parameter position
  143999. * @param position world position
  144000. * @param result output the closest point to position constrained by the navigation mesh
  144001. */
  144002. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144003. /**
  144004. * Get a navigation mesh constrained position, within a particular radius
  144005. * @param position world position
  144006. * @param maxRadius the maximum distance to the constrained world position
  144007. * @returns the closest point to position constrained by the navigation mesh
  144008. */
  144009. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144010. /**
  144011. * Get a navigation mesh constrained position, within a particular radius
  144012. * @param position world position
  144013. * @param maxRadius the maximum distance to the constrained world position
  144014. * @param result output the closest point to position constrained by the navigation mesh
  144015. */
  144016. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144017. /**
  144018. * Compute the final position from a segment made of destination-position
  144019. * @param position world position
  144020. * @param destination world position
  144021. * @returns the resulting point along the navmesh
  144022. */
  144023. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144024. /**
  144025. * Compute the final position from a segment made of destination-position
  144026. * @param position world position
  144027. * @param destination world position
  144028. * @param result output the resulting point along the navmesh
  144029. */
  144030. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144031. /**
  144032. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144033. * @param start world position
  144034. * @param end world position
  144035. * @returns array containing world position composing the path
  144036. */
  144037. computePath(start: Vector3, end: Vector3): Vector3[];
  144038. /**
  144039. * If this plugin is supported
  144040. * @returns true if plugin is supported
  144041. */
  144042. isSupported(): boolean;
  144043. /**
  144044. * Create a new Crowd so you can add agents
  144045. * @param maxAgents the maximum agent count in the crowd
  144046. * @param maxAgentRadius the maximum radius an agent can have
  144047. * @param scene to attach the crowd to
  144048. * @returns the crowd you can add agents to
  144049. */
  144050. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144051. /**
  144052. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144053. * The queries will try to find a solution within those bounds
  144054. * default is (1,1,1)
  144055. * @param extent x,y,z value that define the extent around the queries point of reference
  144056. */
  144057. setDefaultQueryExtent(extent: Vector3): void;
  144058. /**
  144059. * Get the Bounding box extent specified by setDefaultQueryExtent
  144060. * @returns the box extent values
  144061. */
  144062. getDefaultQueryExtent(): Vector3;
  144063. /**
  144064. * build the navmesh from a previously saved state using getNavmeshData
  144065. * @param data the Uint8Array returned by getNavmeshData
  144066. */
  144067. buildFromNavmeshData(data: Uint8Array): void;
  144068. /**
  144069. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144070. * @returns data the Uint8Array that can be saved and reused
  144071. */
  144072. getNavmeshData(): Uint8Array;
  144073. /**
  144074. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144075. * @param result output the box extent values
  144076. */
  144077. getDefaultQueryExtentToRef(result: Vector3): void;
  144078. /**
  144079. * Release all resources
  144080. */
  144081. dispose(): void;
  144082. }
  144083. /**
  144084. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144085. */
  144086. export interface ICrowd {
  144087. /**
  144088. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144089. * You can attach anything to that node. The node position is updated in the scene update tick.
  144090. * @param pos world position that will be constrained by the navigation mesh
  144091. * @param parameters agent parameters
  144092. * @param transform hooked to the agent that will be update by the scene
  144093. * @returns agent index
  144094. */
  144095. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144096. /**
  144097. * Returns the agent position in world space
  144098. * @param index agent index returned by addAgent
  144099. * @returns world space position
  144100. */
  144101. getAgentPosition(index: number): Vector3;
  144102. /**
  144103. * Gets the agent position result in world space
  144104. * @param index agent index returned by addAgent
  144105. * @param result output world space position
  144106. */
  144107. getAgentPositionToRef(index: number, result: Vector3): void;
  144108. /**
  144109. * Gets the agent velocity in world space
  144110. * @param index agent index returned by addAgent
  144111. * @returns world space velocity
  144112. */
  144113. getAgentVelocity(index: number): Vector3;
  144114. /**
  144115. * Gets the agent velocity result in world space
  144116. * @param index agent index returned by addAgent
  144117. * @param result output world space velocity
  144118. */
  144119. getAgentVelocityToRef(index: number, result: Vector3): void;
  144120. /**
  144121. * remove a particular agent previously created
  144122. * @param index agent index returned by addAgent
  144123. */
  144124. removeAgent(index: number): void;
  144125. /**
  144126. * get the list of all agents attached to this crowd
  144127. * @returns list of agent indices
  144128. */
  144129. getAgents(): number[];
  144130. /**
  144131. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144132. * @param deltaTime in seconds
  144133. */
  144134. update(deltaTime: number): void;
  144135. /**
  144136. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144137. * @param index agent index returned by addAgent
  144138. * @param destination targeted world position
  144139. */
  144140. agentGoto(index: number, destination: Vector3): void;
  144141. /**
  144142. * Teleport the agent to a new position
  144143. * @param index agent index returned by addAgent
  144144. * @param destination targeted world position
  144145. */
  144146. agentTeleport(index: number, destination: Vector3): void;
  144147. /**
  144148. * Update agent parameters
  144149. * @param index agent index returned by addAgent
  144150. * @param parameters agent parameters
  144151. */
  144152. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144153. /**
  144154. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144155. * The queries will try to find a solution within those bounds
  144156. * default is (1,1,1)
  144157. * @param extent x,y,z value that define the extent around the queries point of reference
  144158. */
  144159. setDefaultQueryExtent(extent: Vector3): void;
  144160. /**
  144161. * Get the Bounding box extent specified by setDefaultQueryExtent
  144162. * @returns the box extent values
  144163. */
  144164. getDefaultQueryExtent(): Vector3;
  144165. /**
  144166. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144167. * @param result output the box extent values
  144168. */
  144169. getDefaultQueryExtentToRef(result: Vector3): void;
  144170. /**
  144171. * Release all resources
  144172. */
  144173. dispose(): void;
  144174. }
  144175. /**
  144176. * Configures an agent
  144177. */
  144178. export interface IAgentParameters {
  144179. /**
  144180. * Agent radius. [Limit: >= 0]
  144181. */
  144182. radius: number;
  144183. /**
  144184. * Agent height. [Limit: > 0]
  144185. */
  144186. height: number;
  144187. /**
  144188. * Maximum allowed acceleration. [Limit: >= 0]
  144189. */
  144190. maxAcceleration: number;
  144191. /**
  144192. * Maximum allowed speed. [Limit: >= 0]
  144193. */
  144194. maxSpeed: number;
  144195. /**
  144196. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144197. */
  144198. collisionQueryRange: number;
  144199. /**
  144200. * The path visibility optimization range. [Limit: > 0]
  144201. */
  144202. pathOptimizationRange: number;
  144203. /**
  144204. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144205. */
  144206. separationWeight: number;
  144207. }
  144208. /**
  144209. * Configures the navigation mesh creation
  144210. */
  144211. export interface INavMeshParameters {
  144212. /**
  144213. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144214. */
  144215. cs: number;
  144216. /**
  144217. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144218. */
  144219. ch: number;
  144220. /**
  144221. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144222. */
  144223. walkableSlopeAngle: number;
  144224. /**
  144225. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144226. * be considered walkable. [Limit: >= 3] [Units: vx]
  144227. */
  144228. walkableHeight: number;
  144229. /**
  144230. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144231. */
  144232. walkableClimb: number;
  144233. /**
  144234. * The distance to erode/shrink the walkable area of the heightfield away from
  144235. * obstructions. [Limit: >=0] [Units: vx]
  144236. */
  144237. walkableRadius: number;
  144238. /**
  144239. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144240. */
  144241. maxEdgeLen: number;
  144242. /**
  144243. * The maximum distance a simplfied contour's border edges should deviate
  144244. * the original raw contour. [Limit: >=0] [Units: vx]
  144245. */
  144246. maxSimplificationError: number;
  144247. /**
  144248. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144249. */
  144250. minRegionArea: number;
  144251. /**
  144252. * Any regions with a span count smaller than this value will, if possible,
  144253. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144254. */
  144255. mergeRegionArea: number;
  144256. /**
  144257. * The maximum number of vertices allowed for polygons generated during the
  144258. * contour to polygon conversion process. [Limit: >= 3]
  144259. */
  144260. maxVertsPerPoly: number;
  144261. /**
  144262. * Sets the sampling distance to use when generating the detail mesh.
  144263. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144264. */
  144265. detailSampleDist: number;
  144266. /**
  144267. * The maximum distance the detail mesh surface should deviate from heightfield
  144268. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144269. */
  144270. detailSampleMaxError: number;
  144271. }
  144272. }
  144273. declare module BABYLON {
  144274. /**
  144275. * RecastJS navigation plugin
  144276. */
  144277. export class RecastJSPlugin implements INavigationEnginePlugin {
  144278. /**
  144279. * Reference to the Recast library
  144280. */
  144281. bjsRECAST: any;
  144282. /**
  144283. * plugin name
  144284. */
  144285. name: string;
  144286. /**
  144287. * the first navmesh created. We might extend this to support multiple navmeshes
  144288. */
  144289. navMesh: any;
  144290. /**
  144291. * Initializes the recastJS plugin
  144292. * @param recastInjection can be used to inject your own recast reference
  144293. */
  144294. constructor(recastInjection?: any);
  144295. /**
  144296. * Creates a navigation mesh
  144297. * @param meshes array of all the geometry used to compute the navigatio mesh
  144298. * @param parameters bunch of parameters used to filter geometry
  144299. */
  144300. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144301. /**
  144302. * Create a navigation mesh debug mesh
  144303. * @param scene is where the mesh will be added
  144304. * @returns debug display mesh
  144305. */
  144306. createDebugNavMesh(scene: Scene): Mesh;
  144307. /**
  144308. * Get a navigation mesh constrained position, closest to the parameter position
  144309. * @param position world position
  144310. * @returns the closest point to position constrained by the navigation mesh
  144311. */
  144312. getClosestPoint(position: Vector3): Vector3;
  144313. /**
  144314. * Get a navigation mesh constrained position, closest to the parameter position
  144315. * @param position world position
  144316. * @param result output the closest point to position constrained by the navigation mesh
  144317. */
  144318. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144319. /**
  144320. * Get a navigation mesh constrained position, within a particular radius
  144321. * @param position world position
  144322. * @param maxRadius the maximum distance to the constrained world position
  144323. * @returns the closest point to position constrained by the navigation mesh
  144324. */
  144325. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144326. /**
  144327. * Get a navigation mesh constrained position, within a particular radius
  144328. * @param position world position
  144329. * @param maxRadius the maximum distance to the constrained world position
  144330. * @param result output the closest point to position constrained by the navigation mesh
  144331. */
  144332. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144333. /**
  144334. * Compute the final position from a segment made of destination-position
  144335. * @param position world position
  144336. * @param destination world position
  144337. * @returns the resulting point along the navmesh
  144338. */
  144339. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144340. /**
  144341. * Compute the final position from a segment made of destination-position
  144342. * @param position world position
  144343. * @param destination world position
  144344. * @param result output the resulting point along the navmesh
  144345. */
  144346. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144347. /**
  144348. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144349. * @param start world position
  144350. * @param end world position
  144351. * @returns array containing world position composing the path
  144352. */
  144353. computePath(start: Vector3, end: Vector3): Vector3[];
  144354. /**
  144355. * Create a new Crowd so you can add agents
  144356. * @param maxAgents the maximum agent count in the crowd
  144357. * @param maxAgentRadius the maximum radius an agent can have
  144358. * @param scene to attach the crowd to
  144359. * @returns the crowd you can add agents to
  144360. */
  144361. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144362. /**
  144363. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144364. * The queries will try to find a solution within those bounds
  144365. * default is (1,1,1)
  144366. * @param extent x,y,z value that define the extent around the queries point of reference
  144367. */
  144368. setDefaultQueryExtent(extent: Vector3): void;
  144369. /**
  144370. * Get the Bounding box extent specified by setDefaultQueryExtent
  144371. * @returns the box extent values
  144372. */
  144373. getDefaultQueryExtent(): Vector3;
  144374. /**
  144375. * build the navmesh from a previously saved state using getNavmeshData
  144376. * @param data the Uint8Array returned by getNavmeshData
  144377. */
  144378. buildFromNavmeshData(data: Uint8Array): void;
  144379. /**
  144380. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144381. * @returns data the Uint8Array that can be saved and reused
  144382. */
  144383. getNavmeshData(): Uint8Array;
  144384. /**
  144385. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144386. * @param result output the box extent values
  144387. */
  144388. getDefaultQueryExtentToRef(result: Vector3): void;
  144389. /**
  144390. * Disposes
  144391. */
  144392. dispose(): void;
  144393. /**
  144394. * If this plugin is supported
  144395. * @returns true if plugin is supported
  144396. */
  144397. isSupported(): boolean;
  144398. }
  144399. /**
  144400. * Recast detour crowd implementation
  144401. */
  144402. export class RecastJSCrowd implements ICrowd {
  144403. /**
  144404. * Recast/detour plugin
  144405. */
  144406. bjsRECASTPlugin: RecastJSPlugin;
  144407. /**
  144408. * Link to the detour crowd
  144409. */
  144410. recastCrowd: any;
  144411. /**
  144412. * One transform per agent
  144413. */
  144414. transforms: TransformNode[];
  144415. /**
  144416. * All agents created
  144417. */
  144418. agents: number[];
  144419. /**
  144420. * Link to the scene is kept to unregister the crowd from the scene
  144421. */
  144422. private _scene;
  144423. /**
  144424. * Observer for crowd updates
  144425. */
  144426. private _onBeforeAnimationsObserver;
  144427. /**
  144428. * Constructor
  144429. * @param plugin recastJS plugin
  144430. * @param maxAgents the maximum agent count in the crowd
  144431. * @param maxAgentRadius the maximum radius an agent can have
  144432. * @param scene to attach the crowd to
  144433. * @returns the crowd you can add agents to
  144434. */
  144435. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144436. /**
  144437. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144438. * You can attach anything to that node. The node position is updated in the scene update tick.
  144439. * @param pos world position that will be constrained by the navigation mesh
  144440. * @param parameters agent parameters
  144441. * @param transform hooked to the agent that will be update by the scene
  144442. * @returns agent index
  144443. */
  144444. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144445. /**
  144446. * Returns the agent position in world space
  144447. * @param index agent index returned by addAgent
  144448. * @returns world space position
  144449. */
  144450. getAgentPosition(index: number): Vector3;
  144451. /**
  144452. * Returns the agent position result in world space
  144453. * @param index agent index returned by addAgent
  144454. * @param result output world space position
  144455. */
  144456. getAgentPositionToRef(index: number, result: Vector3): void;
  144457. /**
  144458. * Returns the agent velocity in world space
  144459. * @param index agent index returned by addAgent
  144460. * @returns world space velocity
  144461. */
  144462. getAgentVelocity(index: number): Vector3;
  144463. /**
  144464. * Returns the agent velocity result in world space
  144465. * @param index agent index returned by addAgent
  144466. * @param result output world space velocity
  144467. */
  144468. getAgentVelocityToRef(index: number, result: Vector3): void;
  144469. /**
  144470. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144471. * @param index agent index returned by addAgent
  144472. * @param destination targeted world position
  144473. */
  144474. agentGoto(index: number, destination: Vector3): void;
  144475. /**
  144476. * Teleport the agent to a new position
  144477. * @param index agent index returned by addAgent
  144478. * @param destination targeted world position
  144479. */
  144480. agentTeleport(index: number, destination: Vector3): void;
  144481. /**
  144482. * Update agent parameters
  144483. * @param index agent index returned by addAgent
  144484. * @param parameters agent parameters
  144485. */
  144486. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144487. /**
  144488. * remove a particular agent previously created
  144489. * @param index agent index returned by addAgent
  144490. */
  144491. removeAgent(index: number): void;
  144492. /**
  144493. * get the list of all agents attached to this crowd
  144494. * @returns list of agent indices
  144495. */
  144496. getAgents(): number[];
  144497. /**
  144498. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144499. * @param deltaTime in seconds
  144500. */
  144501. update(deltaTime: number): void;
  144502. /**
  144503. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144504. * The queries will try to find a solution within those bounds
  144505. * default is (1,1,1)
  144506. * @param extent x,y,z value that define the extent around the queries point of reference
  144507. */
  144508. setDefaultQueryExtent(extent: Vector3): void;
  144509. /**
  144510. * Get the Bounding box extent specified by setDefaultQueryExtent
  144511. * @returns the box extent values
  144512. */
  144513. getDefaultQueryExtent(): Vector3;
  144514. /**
  144515. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144516. * @param result output the box extent values
  144517. */
  144518. getDefaultQueryExtentToRef(result: Vector3): void;
  144519. /**
  144520. * Release all resources
  144521. */
  144522. dispose(): void;
  144523. }
  144524. }
  144525. declare module BABYLON {
  144526. /**
  144527. * Class used to enable access to IndexedDB
  144528. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144529. */
  144530. export class Database implements IOfflineProvider {
  144531. private _callbackManifestChecked;
  144532. private _currentSceneUrl;
  144533. private _db;
  144534. private _enableSceneOffline;
  144535. private _enableTexturesOffline;
  144536. private _manifestVersionFound;
  144537. private _mustUpdateRessources;
  144538. private _hasReachedQuota;
  144539. private _isSupported;
  144540. private _idbFactory;
  144541. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144542. private static IsUASupportingBlobStorage;
  144543. /**
  144544. * Gets a boolean indicating if Database storate is enabled (off by default)
  144545. */
  144546. static IDBStorageEnabled: boolean;
  144547. /**
  144548. * Gets a boolean indicating if scene must be saved in the database
  144549. */
  144550. get enableSceneOffline(): boolean;
  144551. /**
  144552. * Gets a boolean indicating if textures must be saved in the database
  144553. */
  144554. get enableTexturesOffline(): boolean;
  144555. /**
  144556. * Creates a new Database
  144557. * @param urlToScene defines the url to load the scene
  144558. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144559. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144560. */
  144561. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144562. private static _ParseURL;
  144563. private static _ReturnFullUrlLocation;
  144564. private _checkManifestFile;
  144565. /**
  144566. * Open the database and make it available
  144567. * @param successCallback defines the callback to call on success
  144568. * @param errorCallback defines the callback to call on error
  144569. */
  144570. open(successCallback: () => void, errorCallback: () => void): void;
  144571. /**
  144572. * Loads an image from the database
  144573. * @param url defines the url to load from
  144574. * @param image defines the target DOM image
  144575. */
  144576. loadImage(url: string, image: HTMLImageElement): void;
  144577. private _loadImageFromDBAsync;
  144578. private _saveImageIntoDBAsync;
  144579. private _checkVersionFromDB;
  144580. private _loadVersionFromDBAsync;
  144581. private _saveVersionIntoDBAsync;
  144582. /**
  144583. * Loads a file from database
  144584. * @param url defines the URL to load from
  144585. * @param sceneLoaded defines a callback to call on success
  144586. * @param progressCallBack defines a callback to call when progress changed
  144587. * @param errorCallback defines a callback to call on error
  144588. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144589. */
  144590. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144591. private _loadFileAsync;
  144592. private _saveFileAsync;
  144593. /**
  144594. * Validates if xhr data is correct
  144595. * @param xhr defines the request to validate
  144596. * @param dataType defines the expected data type
  144597. * @returns true if data is correct
  144598. */
  144599. private static _ValidateXHRData;
  144600. }
  144601. }
  144602. declare module BABYLON {
  144603. /** @hidden */
  144604. export var gpuUpdateParticlesPixelShader: {
  144605. name: string;
  144606. shader: string;
  144607. };
  144608. }
  144609. declare module BABYLON {
  144610. /** @hidden */
  144611. export var gpuUpdateParticlesVertexShader: {
  144612. name: string;
  144613. shader: string;
  144614. };
  144615. }
  144616. declare module BABYLON {
  144617. /** @hidden */
  144618. export var clipPlaneFragmentDeclaration2: {
  144619. name: string;
  144620. shader: string;
  144621. };
  144622. }
  144623. declare module BABYLON {
  144624. /** @hidden */
  144625. export var gpuRenderParticlesPixelShader: {
  144626. name: string;
  144627. shader: string;
  144628. };
  144629. }
  144630. declare module BABYLON {
  144631. /** @hidden */
  144632. export var clipPlaneVertexDeclaration2: {
  144633. name: string;
  144634. shader: string;
  144635. };
  144636. }
  144637. declare module BABYLON {
  144638. /** @hidden */
  144639. export var gpuRenderParticlesVertexShader: {
  144640. name: string;
  144641. shader: string;
  144642. };
  144643. }
  144644. declare module BABYLON {
  144645. /**
  144646. * This represents a GPU particle system in Babylon
  144647. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144648. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144649. */
  144650. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144651. /**
  144652. * The layer mask we are rendering the particles through.
  144653. */
  144654. layerMask: number;
  144655. private _capacity;
  144656. private _activeCount;
  144657. private _currentActiveCount;
  144658. private _accumulatedCount;
  144659. private _renderEffect;
  144660. private _updateEffect;
  144661. private _buffer0;
  144662. private _buffer1;
  144663. private _spriteBuffer;
  144664. private _updateVAO;
  144665. private _renderVAO;
  144666. private _targetIndex;
  144667. private _sourceBuffer;
  144668. private _targetBuffer;
  144669. private _engine;
  144670. private _currentRenderId;
  144671. private _started;
  144672. private _stopped;
  144673. private _timeDelta;
  144674. private _randomTexture;
  144675. private _randomTexture2;
  144676. private _attributesStrideSize;
  144677. private _updateEffectOptions;
  144678. private _randomTextureSize;
  144679. private _actualFrame;
  144680. private _customEffect;
  144681. private readonly _rawTextureWidth;
  144682. /**
  144683. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144684. */
  144685. static get IsSupported(): boolean;
  144686. /**
  144687. * An event triggered when the system is disposed.
  144688. */
  144689. onDisposeObservable: Observable<IParticleSystem>;
  144690. /**
  144691. * Gets the maximum number of particles active at the same time.
  144692. * @returns The max number of active particles.
  144693. */
  144694. getCapacity(): number;
  144695. /**
  144696. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144697. * to override the particles.
  144698. */
  144699. forceDepthWrite: boolean;
  144700. /**
  144701. * Gets or set the number of active particles
  144702. */
  144703. get activeParticleCount(): number;
  144704. set activeParticleCount(value: number);
  144705. private _preWarmDone;
  144706. /**
  144707. * Specifies if the particles are updated in emitter local space or world space.
  144708. */
  144709. isLocal: boolean;
  144710. /**
  144711. * Is this system ready to be used/rendered
  144712. * @return true if the system is ready
  144713. */
  144714. isReady(): boolean;
  144715. /**
  144716. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144717. * @returns True if it has been started, otherwise false.
  144718. */
  144719. isStarted(): boolean;
  144720. /**
  144721. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144722. * @returns True if it has been stopped, otherwise false.
  144723. */
  144724. isStopped(): boolean;
  144725. /**
  144726. * Gets a boolean indicating that the system is stopping
  144727. * @returns true if the system is currently stopping
  144728. */
  144729. isStopping(): boolean;
  144730. /**
  144731. * Gets the number of particles active at the same time.
  144732. * @returns The number of active particles.
  144733. */
  144734. getActiveCount(): number;
  144735. /**
  144736. * Starts the particle system and begins to emit
  144737. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144738. */
  144739. start(delay?: number): void;
  144740. /**
  144741. * Stops the particle system.
  144742. */
  144743. stop(): void;
  144744. /**
  144745. * Remove all active particles
  144746. */
  144747. reset(): void;
  144748. /**
  144749. * Returns the string "GPUParticleSystem"
  144750. * @returns a string containing the class name
  144751. */
  144752. getClassName(): string;
  144753. /**
  144754. * Gets the custom effect used to render the particles
  144755. * @param blendMode Blend mode for which the effect should be retrieved
  144756. * @returns The effect
  144757. */
  144758. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144759. /**
  144760. * Sets the custom effect used to render the particles
  144761. * @param effect The effect to set
  144762. * @param blendMode Blend mode for which the effect should be set
  144763. */
  144764. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144765. /** @hidden */
  144766. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144767. /**
  144768. * Observable that will be called just before the particles are drawn
  144769. */
  144770. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144771. /**
  144772. * Gets the name of the particle vertex shader
  144773. */
  144774. get vertexShaderName(): string;
  144775. private _colorGradientsTexture;
  144776. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144777. /**
  144778. * Adds a new color gradient
  144779. * @param gradient defines the gradient to use (between 0 and 1)
  144780. * @param color1 defines the color to affect to the specified gradient
  144781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144782. * @returns the current particle system
  144783. */
  144784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144785. private _refreshColorGradient;
  144786. /** Force the system to rebuild all gradients that need to be resync */
  144787. forceRefreshGradients(): void;
  144788. /**
  144789. * Remove a specific color gradient
  144790. * @param gradient defines the gradient to remove
  144791. * @returns the current particle system
  144792. */
  144793. removeColorGradient(gradient: number): GPUParticleSystem;
  144794. private _angularSpeedGradientsTexture;
  144795. private _sizeGradientsTexture;
  144796. private _velocityGradientsTexture;
  144797. private _limitVelocityGradientsTexture;
  144798. private _dragGradientsTexture;
  144799. private _addFactorGradient;
  144800. /**
  144801. * Adds a new size gradient
  144802. * @param gradient defines the gradient to use (between 0 and 1)
  144803. * @param factor defines the size factor to affect to the specified gradient
  144804. * @returns the current particle system
  144805. */
  144806. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144807. /**
  144808. * Remove a specific size gradient
  144809. * @param gradient defines the gradient to remove
  144810. * @returns the current particle system
  144811. */
  144812. removeSizeGradient(gradient: number): GPUParticleSystem;
  144813. private _refreshFactorGradient;
  144814. /**
  144815. * Adds a new angular speed gradient
  144816. * @param gradient defines the gradient to use (between 0 and 1)
  144817. * @param factor defines the angular speed to affect to the specified gradient
  144818. * @returns the current particle system
  144819. */
  144820. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144821. /**
  144822. * Remove a specific angular speed gradient
  144823. * @param gradient defines the gradient to remove
  144824. * @returns the current particle system
  144825. */
  144826. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144827. /**
  144828. * Adds a new velocity gradient
  144829. * @param gradient defines the gradient to use (between 0 and 1)
  144830. * @param factor defines the velocity to affect to the specified gradient
  144831. * @returns the current particle system
  144832. */
  144833. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144834. /**
  144835. * Remove a specific velocity gradient
  144836. * @param gradient defines the gradient to remove
  144837. * @returns the current particle system
  144838. */
  144839. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144840. /**
  144841. * Adds a new limit velocity gradient
  144842. * @param gradient defines the gradient to use (between 0 and 1)
  144843. * @param factor defines the limit velocity value to affect to the specified gradient
  144844. * @returns the current particle system
  144845. */
  144846. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144847. /**
  144848. * Remove a specific limit velocity gradient
  144849. * @param gradient defines the gradient to remove
  144850. * @returns the current particle system
  144851. */
  144852. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144853. /**
  144854. * Adds a new drag gradient
  144855. * @param gradient defines the gradient to use (between 0 and 1)
  144856. * @param factor defines the drag value to affect to the specified gradient
  144857. * @returns the current particle system
  144858. */
  144859. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144860. /**
  144861. * Remove a specific drag gradient
  144862. * @param gradient defines the gradient to remove
  144863. * @returns the current particle system
  144864. */
  144865. removeDragGradient(gradient: number): GPUParticleSystem;
  144866. /**
  144867. * Not supported by GPUParticleSystem
  144868. * @param gradient defines the gradient to use (between 0 and 1)
  144869. * @param factor defines the emit rate value to affect to the specified gradient
  144870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144871. * @returns the current particle system
  144872. */
  144873. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144874. /**
  144875. * Not supported by GPUParticleSystem
  144876. * @param gradient defines the gradient to remove
  144877. * @returns the current particle system
  144878. */
  144879. removeEmitRateGradient(gradient: number): IParticleSystem;
  144880. /**
  144881. * Not supported by GPUParticleSystem
  144882. * @param gradient defines the gradient to use (between 0 and 1)
  144883. * @param factor defines the start size value to affect to the specified gradient
  144884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144885. * @returns the current particle system
  144886. */
  144887. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144888. /**
  144889. * Not supported by GPUParticleSystem
  144890. * @param gradient defines the gradient to remove
  144891. * @returns the current particle system
  144892. */
  144893. removeStartSizeGradient(gradient: number): IParticleSystem;
  144894. /**
  144895. * Not supported by GPUParticleSystem
  144896. * @param gradient defines the gradient to use (between 0 and 1)
  144897. * @param min defines the color remap minimal range
  144898. * @param max defines the color remap maximal range
  144899. * @returns the current particle system
  144900. */
  144901. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144902. /**
  144903. * Not supported by GPUParticleSystem
  144904. * @param gradient defines the gradient to remove
  144905. * @returns the current particle system
  144906. */
  144907. removeColorRemapGradient(): IParticleSystem;
  144908. /**
  144909. * Not supported by GPUParticleSystem
  144910. * @param gradient defines the gradient to use (between 0 and 1)
  144911. * @param min defines the alpha remap minimal range
  144912. * @param max defines the alpha remap maximal range
  144913. * @returns the current particle system
  144914. */
  144915. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144916. /**
  144917. * Not supported by GPUParticleSystem
  144918. * @param gradient defines the gradient to remove
  144919. * @returns the current particle system
  144920. */
  144921. removeAlphaRemapGradient(): IParticleSystem;
  144922. /**
  144923. * Not supported by GPUParticleSystem
  144924. * @param gradient defines the gradient to use (between 0 and 1)
  144925. * @param color defines the color to affect to the specified gradient
  144926. * @returns the current particle system
  144927. */
  144928. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144929. /**
  144930. * Not supported by GPUParticleSystem
  144931. * @param gradient defines the gradient to remove
  144932. * @returns the current particle system
  144933. */
  144934. removeRampGradient(): IParticleSystem;
  144935. /**
  144936. * Not supported by GPUParticleSystem
  144937. * @returns the list of ramp gradients
  144938. */
  144939. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144940. /**
  144941. * Not supported by GPUParticleSystem
  144942. * Gets or sets a boolean indicating that ramp gradients must be used
  144943. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144944. */
  144945. get useRampGradients(): boolean;
  144946. set useRampGradients(value: boolean);
  144947. /**
  144948. * Not supported by GPUParticleSystem
  144949. * @param gradient defines the gradient to use (between 0 and 1)
  144950. * @param factor defines the life time factor to affect to the specified gradient
  144951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144952. * @returns the current particle system
  144953. */
  144954. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144955. /**
  144956. * Not supported by GPUParticleSystem
  144957. * @param gradient defines the gradient to remove
  144958. * @returns the current particle system
  144959. */
  144960. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144961. /**
  144962. * Instantiates a GPU particle system.
  144963. * 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.
  144964. * @param name The name of the particle system
  144965. * @param options The options used to create the system
  144966. * @param scene The scene the particle system belongs to
  144967. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144968. * @param customEffect a custom effect used to change the way particles are rendered by default
  144969. */
  144970. constructor(name: string, options: Partial<{
  144971. capacity: number;
  144972. randomTextureSize: number;
  144973. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144974. protected _reset(): void;
  144975. private _createUpdateVAO;
  144976. private _createRenderVAO;
  144977. private _initialize;
  144978. /** @hidden */
  144979. _recreateUpdateEffect(): void;
  144980. private _getEffect;
  144981. /**
  144982. * Fill the defines array according to the current settings of the particle system
  144983. * @param defines Array to be updated
  144984. * @param blendMode blend mode to take into account when updating the array
  144985. */
  144986. fillDefines(defines: Array<string>, blendMode?: number): void;
  144987. /**
  144988. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144989. * @param uniforms Uniforms array to fill
  144990. * @param attributes Attributes array to fill
  144991. * @param samplers Samplers array to fill
  144992. */
  144993. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144994. /** @hidden */
  144995. _recreateRenderEffect(): Effect;
  144996. /**
  144997. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144998. * @param preWarm defines if we are in the pre-warmimg phase
  144999. */
  145000. animate(preWarm?: boolean): void;
  145001. private _createFactorGradientTexture;
  145002. private _createSizeGradientTexture;
  145003. private _createAngularSpeedGradientTexture;
  145004. private _createVelocityGradientTexture;
  145005. private _createLimitVelocityGradientTexture;
  145006. private _createDragGradientTexture;
  145007. private _createColorGradientTexture;
  145008. /**
  145009. * Renders the particle system in its current state
  145010. * @param preWarm defines if the system should only update the particles but not render them
  145011. * @returns the current number of particles
  145012. */
  145013. render(preWarm?: boolean): number;
  145014. /**
  145015. * Rebuilds the particle system
  145016. */
  145017. rebuild(): void;
  145018. private _releaseBuffers;
  145019. private _releaseVAOs;
  145020. /**
  145021. * Disposes the particle system and free the associated resources
  145022. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145023. */
  145024. dispose(disposeTexture?: boolean): void;
  145025. /**
  145026. * Clones the particle system.
  145027. * @param name The name of the cloned object
  145028. * @param newEmitter The new emitter to use
  145029. * @returns the cloned particle system
  145030. */
  145031. clone(name: string, newEmitter: any): GPUParticleSystem;
  145032. /**
  145033. * Serializes the particle system to a JSON object
  145034. * @param serializeTexture defines if the texture must be serialized as well
  145035. * @returns the JSON object
  145036. */
  145037. serialize(serializeTexture?: boolean): any;
  145038. /**
  145039. * Parses a JSON object to create a GPU particle system.
  145040. * @param parsedParticleSystem The JSON object to parse
  145041. * @param scene The scene to create the particle system in
  145042. * @param rootUrl The root url to use to load external dependencies like texture
  145043. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145044. * @returns the parsed GPU particle system
  145045. */
  145046. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145047. }
  145048. }
  145049. declare module BABYLON {
  145050. /**
  145051. * Represents a set of particle systems working together to create a specific effect
  145052. */
  145053. export class ParticleSystemSet implements IDisposable {
  145054. /**
  145055. * Gets or sets base Assets URL
  145056. */
  145057. static BaseAssetsUrl: string;
  145058. private _emitterCreationOptions;
  145059. private _emitterNode;
  145060. /**
  145061. * Gets the particle system list
  145062. */
  145063. systems: IParticleSystem[];
  145064. /**
  145065. * Gets the emitter node used with this set
  145066. */
  145067. get emitterNode(): Nullable<TransformNode>;
  145068. /**
  145069. * Creates a new emitter mesh as a sphere
  145070. * @param options defines the options used to create the sphere
  145071. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145072. * @param scene defines the hosting scene
  145073. */
  145074. setEmitterAsSphere(options: {
  145075. diameter: number;
  145076. segments: number;
  145077. color: Color3;
  145078. }, renderingGroupId: number, scene: Scene): void;
  145079. /**
  145080. * Starts all particle systems of the set
  145081. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145082. */
  145083. start(emitter?: AbstractMesh): void;
  145084. /**
  145085. * Release all associated resources
  145086. */
  145087. dispose(): void;
  145088. /**
  145089. * Serialize the set into a JSON compatible object
  145090. * @param serializeTexture defines if the texture must be serialized as well
  145091. * @returns a JSON compatible representation of the set
  145092. */
  145093. serialize(serializeTexture?: boolean): any;
  145094. /**
  145095. * Parse a new ParticleSystemSet from a serialized source
  145096. * @param data defines a JSON compatible representation of the set
  145097. * @param scene defines the hosting scene
  145098. * @param gpu defines if we want GPU particles or CPU particles
  145099. * @returns a new ParticleSystemSet
  145100. */
  145101. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145102. }
  145103. }
  145104. declare module BABYLON {
  145105. /**
  145106. * This class is made for on one-liner static method to help creating particle system set.
  145107. */
  145108. export class ParticleHelper {
  145109. /**
  145110. * Gets or sets base Assets URL
  145111. */
  145112. static BaseAssetsUrl: string;
  145113. /** Define the Url to load snippets */
  145114. static SnippetUrl: string;
  145115. /**
  145116. * Create a default particle system that you can tweak
  145117. * @param emitter defines the emitter to use
  145118. * @param capacity defines the system capacity (default is 500 particles)
  145119. * @param scene defines the hosting scene
  145120. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145121. * @returns the new Particle system
  145122. */
  145123. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145124. /**
  145125. * This is the main static method (one-liner) of this helper to create different particle systems
  145126. * @param type This string represents the type to the particle system to create
  145127. * @param scene The scene where the particle system should live
  145128. * @param gpu If the system will use gpu
  145129. * @returns the ParticleSystemSet created
  145130. */
  145131. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145132. /**
  145133. * Static function used to export a particle system to a ParticleSystemSet variable.
  145134. * Please note that the emitter shape is not exported
  145135. * @param systems defines the particle systems to export
  145136. * @returns the created particle system set
  145137. */
  145138. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145139. /**
  145140. * Creates a particle system from a snippet saved in a remote file
  145141. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145142. * @param url defines the url to load from
  145143. * @param scene defines the hosting scene
  145144. * @param gpu If the system will use gpu
  145145. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145146. * @returns a promise that will resolve to the new particle system
  145147. */
  145148. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145149. /**
  145150. * Creates a particle system from a snippet saved by the particle system editor
  145151. * @param snippetId defines the snippet to load
  145152. * @param scene defines the hosting scene
  145153. * @param gpu If the system will use gpu
  145154. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145155. * @returns a promise that will resolve to the new particle system
  145156. */
  145157. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145158. }
  145159. }
  145160. declare module BABYLON {
  145161. interface Engine {
  145162. /**
  145163. * Create an effect to use with particle systems.
  145164. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145165. * the particle system for which you want to create a custom effect in the last parameter
  145166. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145167. * @param uniformsNames defines a list of attribute names
  145168. * @param samplers defines an array of string used to represent textures
  145169. * @param defines defines the string containing the defines to use to compile the shaders
  145170. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145171. * @param onCompiled defines a function to call when the effect creation is successful
  145172. * @param onError defines a function to call when the effect creation has failed
  145173. * @param particleSystem the particle system you want to create the effect for
  145174. * @returns the new Effect
  145175. */
  145176. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145177. }
  145178. interface Mesh {
  145179. /**
  145180. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145181. * @returns an array of IParticleSystem
  145182. */
  145183. getEmittedParticleSystems(): IParticleSystem[];
  145184. /**
  145185. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145186. * @returns an array of IParticleSystem
  145187. */
  145188. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145189. }
  145190. }
  145191. declare module BABYLON {
  145192. /** Defines the 4 color options */
  145193. export enum PointColor {
  145194. /** color value */
  145195. Color = 2,
  145196. /** uv value */
  145197. UV = 1,
  145198. /** random value */
  145199. Random = 0,
  145200. /** stated value */
  145201. Stated = 3
  145202. }
  145203. /**
  145204. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145205. * 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.
  145206. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145207. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145208. *
  145209. * Full documentation here : TO BE ENTERED
  145210. */
  145211. export class PointsCloudSystem implements IDisposable {
  145212. /**
  145213. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145214. * Example : var p = SPS.particles[i];
  145215. */
  145216. particles: CloudPoint[];
  145217. /**
  145218. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145219. */
  145220. nbParticles: number;
  145221. /**
  145222. * This a counter for your own usage. It's not set by any SPS functions.
  145223. */
  145224. counter: number;
  145225. /**
  145226. * The PCS name. This name is also given to the underlying mesh.
  145227. */
  145228. name: string;
  145229. /**
  145230. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145231. */
  145232. mesh: Mesh;
  145233. /**
  145234. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145235. * Please read :
  145236. */
  145237. vars: any;
  145238. /**
  145239. * @hidden
  145240. */
  145241. _size: number;
  145242. private _scene;
  145243. private _promises;
  145244. private _positions;
  145245. private _indices;
  145246. private _normals;
  145247. private _colors;
  145248. private _uvs;
  145249. private _indices32;
  145250. private _positions32;
  145251. private _colors32;
  145252. private _uvs32;
  145253. private _updatable;
  145254. private _isVisibilityBoxLocked;
  145255. private _alwaysVisible;
  145256. private _groups;
  145257. private _groupCounter;
  145258. private _computeParticleColor;
  145259. private _computeParticleTexture;
  145260. private _computeParticleRotation;
  145261. private _computeBoundingBox;
  145262. private _isReady;
  145263. /**
  145264. * Creates a PCS (Points Cloud System) object
  145265. * @param name (String) is the PCS name, this will be the underlying mesh name
  145266. * @param pointSize (number) is the size for each point
  145267. * @param scene (Scene) is the scene in which the PCS is added
  145268. * @param options defines the options of the PCS e.g.
  145269. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145270. */
  145271. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145272. updatable?: boolean;
  145273. });
  145274. /**
  145275. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145276. * If no points were added to the PCS, the returned mesh is just a single point.
  145277. * @returns a promise for the created mesh
  145278. */
  145279. buildMeshAsync(): Promise<Mesh>;
  145280. /**
  145281. * @hidden
  145282. */
  145283. private _buildMesh;
  145284. private _addParticle;
  145285. private _randomUnitVector;
  145286. private _getColorIndicesForCoord;
  145287. private _setPointsColorOrUV;
  145288. private _colorFromTexture;
  145289. private _calculateDensity;
  145290. /**
  145291. * Adds points to the PCS in random positions within a unit sphere
  145292. * @param nb (positive integer) the number of particles to be created from this model
  145293. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145294. * @returns the number of groups in the system
  145295. */
  145296. addPoints(nb: number, pointFunction?: any): number;
  145297. /**
  145298. * Adds points to the PCS from the surface of the model shape
  145299. * @param mesh is any Mesh object that will be used as a surface model for the points
  145300. * @param nb (positive integer) the number of particles to be created from this model
  145301. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145302. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145303. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145304. * @returns the number of groups in the system
  145305. */
  145306. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145307. /**
  145308. * Adds points to the PCS inside the model shape
  145309. * @param mesh is any Mesh object that will be used as a surface model for the points
  145310. * @param nb (positive integer) the number of particles to be created from this model
  145311. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145312. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145313. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145314. * @returns the number of groups in the system
  145315. */
  145316. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145317. /**
  145318. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145319. * This method calls `updateParticle()` for each particle of the SPS.
  145320. * For an animated SPS, it is usually called within the render loop.
  145321. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145322. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145323. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145324. * @returns the PCS.
  145325. */
  145326. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145327. /**
  145328. * Disposes the PCS.
  145329. */
  145330. dispose(): void;
  145331. /**
  145332. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145333. * doc :
  145334. * @returns the PCS.
  145335. */
  145336. refreshVisibleSize(): PointsCloudSystem;
  145337. /**
  145338. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145339. * @param size the size (float) of the visibility box
  145340. * note : this doesn't lock the PCS mesh bounding box.
  145341. * doc :
  145342. */
  145343. setVisibilityBox(size: number): void;
  145344. /**
  145345. * Gets whether the PCS is always visible or not
  145346. * doc :
  145347. */
  145348. get isAlwaysVisible(): boolean;
  145349. /**
  145350. * Sets the PCS as always visible or not
  145351. * doc :
  145352. */
  145353. set isAlwaysVisible(val: boolean);
  145354. /**
  145355. * Tells to `setParticles()` to compute the particle rotations or not
  145356. * Default value : false. The PCS is faster when it's set to false
  145357. * Note : particle rotations are only applied to parent particles
  145358. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145359. */
  145360. set computeParticleRotation(val: boolean);
  145361. /**
  145362. * Tells to `setParticles()` to compute the particle colors or not.
  145363. * Default value : true. The PCS is faster when it's set to false.
  145364. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145365. */
  145366. set computeParticleColor(val: boolean);
  145367. set computeParticleTexture(val: boolean);
  145368. /**
  145369. * Gets if `setParticles()` computes the particle colors or not.
  145370. * Default value : false. The PCS is faster when it's set to false.
  145371. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145372. */
  145373. get computeParticleColor(): boolean;
  145374. /**
  145375. * Gets if `setParticles()` computes the particle textures or not.
  145376. * Default value : false. The PCS is faster when it's set to false.
  145377. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145378. */
  145379. get computeParticleTexture(): boolean;
  145380. /**
  145381. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145382. */
  145383. set computeBoundingBox(val: boolean);
  145384. /**
  145385. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145386. */
  145387. get computeBoundingBox(): boolean;
  145388. /**
  145389. * This function does nothing. It may be overwritten to set all the particle first values.
  145390. * The PCS doesn't call this function, you may have to call it by your own.
  145391. * doc :
  145392. */
  145393. initParticles(): void;
  145394. /**
  145395. * This function does nothing. It may be overwritten to recycle a particle
  145396. * The PCS doesn't call this function, you can to call it
  145397. * doc :
  145398. * @param particle The particle to recycle
  145399. * @returns the recycled particle
  145400. */
  145401. recycleParticle(particle: CloudPoint): CloudPoint;
  145402. /**
  145403. * Updates a particle : this function should be overwritten by the user.
  145404. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145405. * doc :
  145406. * @example : just set a particle position or velocity and recycle conditions
  145407. * @param particle The particle to update
  145408. * @returns the updated particle
  145409. */
  145410. updateParticle(particle: CloudPoint): CloudPoint;
  145411. /**
  145412. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145413. * This does nothing and may be overwritten by the user.
  145414. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145415. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145416. * @param update the boolean update value actually passed to setParticles()
  145417. */
  145418. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145419. /**
  145420. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145421. * This will be passed three parameters.
  145422. * This does nothing and may be overwritten by the user.
  145423. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145424. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145425. * @param update the boolean update value actually passed to setParticles()
  145426. */
  145427. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145428. }
  145429. }
  145430. declare module BABYLON {
  145431. /**
  145432. * Represents one particle of a points cloud system.
  145433. */
  145434. export class CloudPoint {
  145435. /**
  145436. * particle global index
  145437. */
  145438. idx: number;
  145439. /**
  145440. * The color of the particle
  145441. */
  145442. color: Nullable<Color4>;
  145443. /**
  145444. * The world space position of the particle.
  145445. */
  145446. position: Vector3;
  145447. /**
  145448. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145449. */
  145450. rotation: Vector3;
  145451. /**
  145452. * The world space rotation quaternion of the particle.
  145453. */
  145454. rotationQuaternion: Nullable<Quaternion>;
  145455. /**
  145456. * The uv of the particle.
  145457. */
  145458. uv: Nullable<Vector2>;
  145459. /**
  145460. * The current speed of the particle.
  145461. */
  145462. velocity: Vector3;
  145463. /**
  145464. * The pivot point in the particle local space.
  145465. */
  145466. pivot: Vector3;
  145467. /**
  145468. * Must the particle be translated from its pivot point in its local space ?
  145469. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145470. * Default : false
  145471. */
  145472. translateFromPivot: boolean;
  145473. /**
  145474. * Index of this particle in the global "positions" array (Internal use)
  145475. * @hidden
  145476. */
  145477. _pos: number;
  145478. /**
  145479. * @hidden Index of this particle in the global "indices" array (Internal use)
  145480. */
  145481. _ind: number;
  145482. /**
  145483. * Group this particle belongs to
  145484. */
  145485. _group: PointsGroup;
  145486. /**
  145487. * Group id of this particle
  145488. */
  145489. groupId: number;
  145490. /**
  145491. * Index of the particle in its group id (Internal use)
  145492. */
  145493. idxInGroup: number;
  145494. /**
  145495. * @hidden Particle BoundingInfo object (Internal use)
  145496. */
  145497. _boundingInfo: BoundingInfo;
  145498. /**
  145499. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145500. */
  145501. _pcs: PointsCloudSystem;
  145502. /**
  145503. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145504. */
  145505. _stillInvisible: boolean;
  145506. /**
  145507. * @hidden Last computed particle rotation matrix
  145508. */
  145509. _rotationMatrix: number[];
  145510. /**
  145511. * Parent particle Id, if any.
  145512. * Default null.
  145513. */
  145514. parentId: Nullable<number>;
  145515. /**
  145516. * @hidden Internal global position in the PCS.
  145517. */
  145518. _globalPosition: Vector3;
  145519. /**
  145520. * Creates a Point Cloud object.
  145521. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145522. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145523. * @param group (PointsGroup) is the group the particle belongs to
  145524. * @param groupId (integer) is the group identifier in the PCS.
  145525. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145526. * @param pcs defines the PCS it is associated to
  145527. */
  145528. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145529. /**
  145530. * get point size
  145531. */
  145532. get size(): Vector3;
  145533. /**
  145534. * Set point size
  145535. */
  145536. set size(scale: Vector3);
  145537. /**
  145538. * Legacy support, changed quaternion to rotationQuaternion
  145539. */
  145540. get quaternion(): Nullable<Quaternion>;
  145541. /**
  145542. * Legacy support, changed quaternion to rotationQuaternion
  145543. */
  145544. set quaternion(q: Nullable<Quaternion>);
  145545. /**
  145546. * Returns a boolean. True if the particle intersects a mesh, else false
  145547. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145548. * @param target is the object (point or mesh) what the intersection is computed against
  145549. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145550. * @returns true if it intersects
  145551. */
  145552. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145553. /**
  145554. * get the rotation matrix of the particle
  145555. * @hidden
  145556. */
  145557. getRotationMatrix(m: Matrix): void;
  145558. }
  145559. /**
  145560. * Represents a group of points in a points cloud system
  145561. * * PCS internal tool, don't use it manually.
  145562. */
  145563. export class PointsGroup {
  145564. /**
  145565. * The group id
  145566. * @hidden
  145567. */
  145568. groupID: number;
  145569. /**
  145570. * image data for group (internal use)
  145571. * @hidden
  145572. */
  145573. _groupImageData: Nullable<ArrayBufferView>;
  145574. /**
  145575. * Image Width (internal use)
  145576. * @hidden
  145577. */
  145578. _groupImgWidth: number;
  145579. /**
  145580. * Image Height (internal use)
  145581. * @hidden
  145582. */
  145583. _groupImgHeight: number;
  145584. /**
  145585. * Custom position function (internal use)
  145586. * @hidden
  145587. */
  145588. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145589. /**
  145590. * density per facet for surface points
  145591. * @hidden
  145592. */
  145593. _groupDensity: number[];
  145594. /**
  145595. * Only when points are colored by texture carries pointer to texture list array
  145596. * @hidden
  145597. */
  145598. _textureNb: number;
  145599. /**
  145600. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145601. * PCS internal tool, don't use it manually.
  145602. * @hidden
  145603. */
  145604. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145605. }
  145606. }
  145607. declare module BABYLON {
  145608. interface Scene {
  145609. /** @hidden (Backing field) */
  145610. _physicsEngine: Nullable<IPhysicsEngine>;
  145611. /** @hidden */
  145612. _physicsTimeAccumulator: number;
  145613. /**
  145614. * Gets the current physics engine
  145615. * @returns a IPhysicsEngine or null if none attached
  145616. */
  145617. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145618. /**
  145619. * Enables physics to the current scene
  145620. * @param gravity defines the scene's gravity for the physics engine
  145621. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145622. * @return a boolean indicating if the physics engine was initialized
  145623. */
  145624. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145625. /**
  145626. * Disables and disposes the physics engine associated with the scene
  145627. */
  145628. disablePhysicsEngine(): void;
  145629. /**
  145630. * Gets a boolean indicating if there is an active physics engine
  145631. * @returns a boolean indicating if there is an active physics engine
  145632. */
  145633. isPhysicsEnabled(): boolean;
  145634. /**
  145635. * Deletes a physics compound impostor
  145636. * @param compound defines the compound to delete
  145637. */
  145638. deleteCompoundImpostor(compound: any): void;
  145639. /**
  145640. * An event triggered when physic simulation is about to be run
  145641. */
  145642. onBeforePhysicsObservable: Observable<Scene>;
  145643. /**
  145644. * An event triggered when physic simulation has been done
  145645. */
  145646. onAfterPhysicsObservable: Observable<Scene>;
  145647. }
  145648. interface AbstractMesh {
  145649. /** @hidden */
  145650. _physicsImpostor: Nullable<PhysicsImpostor>;
  145651. /**
  145652. * Gets or sets impostor used for physic simulation
  145653. * @see https://doc.babylonjs.com/features/physics_engine
  145654. */
  145655. physicsImpostor: Nullable<PhysicsImpostor>;
  145656. /**
  145657. * Gets the current physics impostor
  145658. * @see https://doc.babylonjs.com/features/physics_engine
  145659. * @returns a physics impostor or null
  145660. */
  145661. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145662. /** Apply a physic impulse to the mesh
  145663. * @param force defines the force to apply
  145664. * @param contactPoint defines where to apply the force
  145665. * @returns the current mesh
  145666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145667. */
  145668. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145669. /**
  145670. * Creates a physic joint between two meshes
  145671. * @param otherMesh defines the other mesh to use
  145672. * @param pivot1 defines the pivot to use on this mesh
  145673. * @param pivot2 defines the pivot to use on the other mesh
  145674. * @param options defines additional options (can be plugin dependent)
  145675. * @returns the current mesh
  145676. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145677. */
  145678. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145679. /** @hidden */
  145680. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145681. }
  145682. /**
  145683. * Defines the physics engine scene component responsible to manage a physics engine
  145684. */
  145685. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145686. /**
  145687. * The component name helpful to identify the component in the list of scene components.
  145688. */
  145689. readonly name: string;
  145690. /**
  145691. * The scene the component belongs to.
  145692. */
  145693. scene: Scene;
  145694. /**
  145695. * Creates a new instance of the component for the given scene
  145696. * @param scene Defines the scene to register the component in
  145697. */
  145698. constructor(scene: Scene);
  145699. /**
  145700. * Registers the component in a given scene
  145701. */
  145702. register(): void;
  145703. /**
  145704. * Rebuilds the elements related to this component in case of
  145705. * context lost for instance.
  145706. */
  145707. rebuild(): void;
  145708. /**
  145709. * Disposes the component and the associated ressources
  145710. */
  145711. dispose(): void;
  145712. }
  145713. }
  145714. declare module BABYLON {
  145715. /**
  145716. * A helper for physics simulations
  145717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145718. */
  145719. export class PhysicsHelper {
  145720. private _scene;
  145721. private _physicsEngine;
  145722. /**
  145723. * Initializes the Physics helper
  145724. * @param scene Babylon.js scene
  145725. */
  145726. constructor(scene: Scene);
  145727. /**
  145728. * Applies a radial explosion impulse
  145729. * @param origin the origin of the explosion
  145730. * @param radiusOrEventOptions the radius or the options of radial explosion
  145731. * @param strength the explosion strength
  145732. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145733. * @returns A physics radial explosion event, or null
  145734. */
  145735. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145736. /**
  145737. * Applies a radial explosion force
  145738. * @param origin the origin of the explosion
  145739. * @param radiusOrEventOptions the radius or the options of radial explosion
  145740. * @param strength the explosion strength
  145741. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145742. * @returns A physics radial explosion event, or null
  145743. */
  145744. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145745. /**
  145746. * Creates a gravitational field
  145747. * @param origin the origin of the explosion
  145748. * @param radiusOrEventOptions the radius or the options of radial explosion
  145749. * @param strength the explosion strength
  145750. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145751. * @returns A physics gravitational field event, or null
  145752. */
  145753. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145754. /**
  145755. * Creates a physics updraft event
  145756. * @param origin the origin of the updraft
  145757. * @param radiusOrEventOptions the radius or the options of the updraft
  145758. * @param strength the strength of the updraft
  145759. * @param height the height of the updraft
  145760. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145761. * @returns A physics updraft event, or null
  145762. */
  145763. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145764. /**
  145765. * Creates a physics vortex event
  145766. * @param origin the of the vortex
  145767. * @param radiusOrEventOptions the radius or the options of the vortex
  145768. * @param strength the strength of the vortex
  145769. * @param height the height of the vortex
  145770. * @returns a Physics vortex event, or null
  145771. * A physics vortex event or null
  145772. */
  145773. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145774. }
  145775. /**
  145776. * Represents a physics radial explosion event
  145777. */
  145778. class PhysicsRadialExplosionEvent {
  145779. private _scene;
  145780. private _options;
  145781. private _sphere;
  145782. private _dataFetched;
  145783. /**
  145784. * Initializes a radial explosioin event
  145785. * @param _scene BabylonJS scene
  145786. * @param _options The options for the vortex event
  145787. */
  145788. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145789. /**
  145790. * Returns the data related to the radial explosion event (sphere).
  145791. * @returns The radial explosion event data
  145792. */
  145793. getData(): PhysicsRadialExplosionEventData;
  145794. /**
  145795. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145796. * @param impostor A physics imposter
  145797. * @param origin the origin of the explosion
  145798. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145799. */
  145800. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145801. /**
  145802. * Triggers affecterd impostors callbacks
  145803. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145804. */
  145805. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145806. /**
  145807. * Disposes the sphere.
  145808. * @param force Specifies if the sphere should be disposed by force
  145809. */
  145810. dispose(force?: boolean): void;
  145811. /*** Helpers ***/
  145812. private _prepareSphere;
  145813. private _intersectsWithSphere;
  145814. }
  145815. /**
  145816. * Represents a gravitational field event
  145817. */
  145818. class PhysicsGravitationalFieldEvent {
  145819. private _physicsHelper;
  145820. private _scene;
  145821. private _origin;
  145822. private _options;
  145823. private _tickCallback;
  145824. private _sphere;
  145825. private _dataFetched;
  145826. /**
  145827. * Initializes the physics gravitational field event
  145828. * @param _physicsHelper A physics helper
  145829. * @param _scene BabylonJS scene
  145830. * @param _origin The origin position of the gravitational field event
  145831. * @param _options The options for the vortex event
  145832. */
  145833. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145834. /**
  145835. * Returns the data related to the gravitational field event (sphere).
  145836. * @returns A gravitational field event
  145837. */
  145838. getData(): PhysicsGravitationalFieldEventData;
  145839. /**
  145840. * Enables the gravitational field.
  145841. */
  145842. enable(): void;
  145843. /**
  145844. * Disables the gravitational field.
  145845. */
  145846. disable(): void;
  145847. /**
  145848. * Disposes the sphere.
  145849. * @param force The force to dispose from the gravitational field event
  145850. */
  145851. dispose(force?: boolean): void;
  145852. private _tick;
  145853. }
  145854. /**
  145855. * Represents a physics updraft event
  145856. */
  145857. class PhysicsUpdraftEvent {
  145858. private _scene;
  145859. private _origin;
  145860. private _options;
  145861. private _physicsEngine;
  145862. private _originTop;
  145863. private _originDirection;
  145864. private _tickCallback;
  145865. private _cylinder;
  145866. private _cylinderPosition;
  145867. private _dataFetched;
  145868. /**
  145869. * Initializes the physics updraft event
  145870. * @param _scene BabylonJS scene
  145871. * @param _origin The origin position of the updraft
  145872. * @param _options The options for the updraft event
  145873. */
  145874. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145875. /**
  145876. * Returns the data related to the updraft event (cylinder).
  145877. * @returns A physics updraft event
  145878. */
  145879. getData(): PhysicsUpdraftEventData;
  145880. /**
  145881. * Enables the updraft.
  145882. */
  145883. enable(): void;
  145884. /**
  145885. * Disables the updraft.
  145886. */
  145887. disable(): void;
  145888. /**
  145889. * Disposes the cylinder.
  145890. * @param force Specifies if the updraft should be disposed by force
  145891. */
  145892. dispose(force?: boolean): void;
  145893. private getImpostorHitData;
  145894. private _tick;
  145895. /*** Helpers ***/
  145896. private _prepareCylinder;
  145897. private _intersectsWithCylinder;
  145898. }
  145899. /**
  145900. * Represents a physics vortex event
  145901. */
  145902. class PhysicsVortexEvent {
  145903. private _scene;
  145904. private _origin;
  145905. private _options;
  145906. private _physicsEngine;
  145907. private _originTop;
  145908. private _tickCallback;
  145909. private _cylinder;
  145910. private _cylinderPosition;
  145911. private _dataFetched;
  145912. /**
  145913. * Initializes the physics vortex event
  145914. * @param _scene The BabylonJS scene
  145915. * @param _origin The origin position of the vortex
  145916. * @param _options The options for the vortex event
  145917. */
  145918. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145919. /**
  145920. * Returns the data related to the vortex event (cylinder).
  145921. * @returns The physics vortex event data
  145922. */
  145923. getData(): PhysicsVortexEventData;
  145924. /**
  145925. * Enables the vortex.
  145926. */
  145927. enable(): void;
  145928. /**
  145929. * Disables the cortex.
  145930. */
  145931. disable(): void;
  145932. /**
  145933. * Disposes the sphere.
  145934. * @param force
  145935. */
  145936. dispose(force?: boolean): void;
  145937. private getImpostorHitData;
  145938. private _tick;
  145939. /*** Helpers ***/
  145940. private _prepareCylinder;
  145941. private _intersectsWithCylinder;
  145942. }
  145943. /**
  145944. * Options fot the radial explosion event
  145945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145946. */
  145947. export class PhysicsRadialExplosionEventOptions {
  145948. /**
  145949. * The radius of the sphere for the radial explosion.
  145950. */
  145951. radius: number;
  145952. /**
  145953. * The strenth of the explosion.
  145954. */
  145955. strength: number;
  145956. /**
  145957. * The strenght of the force in correspondence to the distance of the affected object
  145958. */
  145959. falloff: PhysicsRadialImpulseFalloff;
  145960. /**
  145961. * Sphere options for the radial explosion.
  145962. */
  145963. sphere: {
  145964. segments: number;
  145965. diameter: number;
  145966. };
  145967. /**
  145968. * Sphere options for the radial explosion.
  145969. */
  145970. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145971. }
  145972. /**
  145973. * Options fot the updraft event
  145974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145975. */
  145976. export class PhysicsUpdraftEventOptions {
  145977. /**
  145978. * The radius of the cylinder for the vortex
  145979. */
  145980. radius: number;
  145981. /**
  145982. * The strenth of the updraft.
  145983. */
  145984. strength: number;
  145985. /**
  145986. * The height of the cylinder for the updraft.
  145987. */
  145988. height: number;
  145989. /**
  145990. * The mode for the the updraft.
  145991. */
  145992. updraftMode: PhysicsUpdraftMode;
  145993. }
  145994. /**
  145995. * Options fot the vortex event
  145996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145997. */
  145998. export class PhysicsVortexEventOptions {
  145999. /**
  146000. * The radius of the cylinder for the vortex
  146001. */
  146002. radius: number;
  146003. /**
  146004. * The strenth of the vortex.
  146005. */
  146006. strength: number;
  146007. /**
  146008. * The height of the cylinder for the vortex.
  146009. */
  146010. height: number;
  146011. /**
  146012. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146013. */
  146014. centripetalForceThreshold: number;
  146015. /**
  146016. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146017. */
  146018. centripetalForceMultiplier: number;
  146019. /**
  146020. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146021. */
  146022. centrifugalForceMultiplier: number;
  146023. /**
  146024. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146025. */
  146026. updraftForceMultiplier: number;
  146027. }
  146028. /**
  146029. * The strenght of the force in correspondence to the distance of the affected object
  146030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146031. */
  146032. export enum PhysicsRadialImpulseFalloff {
  146033. /** Defines that impulse is constant in strength across it's whole radius */
  146034. Constant = 0,
  146035. /** Defines that impulse gets weaker if it's further from the origin */
  146036. Linear = 1
  146037. }
  146038. /**
  146039. * The strength of the force in correspondence to the distance of the affected object
  146040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146041. */
  146042. export enum PhysicsUpdraftMode {
  146043. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146044. Center = 0,
  146045. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146046. Perpendicular = 1
  146047. }
  146048. /**
  146049. * Interface for a physics hit data
  146050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146051. */
  146052. export interface PhysicsHitData {
  146053. /**
  146054. * The force applied at the contact point
  146055. */
  146056. force: Vector3;
  146057. /**
  146058. * The contact point
  146059. */
  146060. contactPoint: Vector3;
  146061. /**
  146062. * The distance from the origin to the contact point
  146063. */
  146064. distanceFromOrigin: number;
  146065. }
  146066. /**
  146067. * Interface for radial explosion event data
  146068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146069. */
  146070. export interface PhysicsRadialExplosionEventData {
  146071. /**
  146072. * A sphere used for the radial explosion event
  146073. */
  146074. sphere: Mesh;
  146075. }
  146076. /**
  146077. * Interface for gravitational field event data
  146078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146079. */
  146080. export interface PhysicsGravitationalFieldEventData {
  146081. /**
  146082. * A sphere mesh used for the gravitational field event
  146083. */
  146084. sphere: Mesh;
  146085. }
  146086. /**
  146087. * Interface for updraft event data
  146088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146089. */
  146090. export interface PhysicsUpdraftEventData {
  146091. /**
  146092. * A cylinder used for the updraft event
  146093. */
  146094. cylinder: Mesh;
  146095. }
  146096. /**
  146097. * Interface for vortex event data
  146098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146099. */
  146100. export interface PhysicsVortexEventData {
  146101. /**
  146102. * A cylinder used for the vortex event
  146103. */
  146104. cylinder: Mesh;
  146105. }
  146106. /**
  146107. * Interface for an affected physics impostor
  146108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146109. */
  146110. export interface PhysicsAffectedImpostorWithData {
  146111. /**
  146112. * The impostor affected by the effect
  146113. */
  146114. impostor: PhysicsImpostor;
  146115. /**
  146116. * The data about the hit/horce from the explosion
  146117. */
  146118. hitData: PhysicsHitData;
  146119. }
  146120. }
  146121. declare module BABYLON {
  146122. /** @hidden */
  146123. export var blackAndWhitePixelShader: {
  146124. name: string;
  146125. shader: string;
  146126. };
  146127. }
  146128. declare module BABYLON {
  146129. /**
  146130. * Post process used to render in black and white
  146131. */
  146132. export class BlackAndWhitePostProcess extends PostProcess {
  146133. /**
  146134. * Linear about to convert he result to black and white (default: 1)
  146135. */
  146136. degree: number;
  146137. /**
  146138. * Creates a black and white post process
  146139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146140. * @param name The name of the effect.
  146141. * @param options The required width/height ratio to downsize to before computing the render pass.
  146142. * @param camera The camera to apply the render pass to.
  146143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146144. * @param engine The engine which the post process will be applied. (default: current engine)
  146145. * @param reusable If the post process can be reused on the same frame. (default: false)
  146146. */
  146147. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146148. }
  146149. }
  146150. declare module BABYLON {
  146151. /**
  146152. * This represents a set of one or more post processes in Babylon.
  146153. * A post process can be used to apply a shader to a texture after it is rendered.
  146154. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146155. */
  146156. export class PostProcessRenderEffect {
  146157. private _postProcesses;
  146158. private _getPostProcesses;
  146159. private _singleInstance;
  146160. private _cameras;
  146161. private _indicesForCamera;
  146162. /**
  146163. * Name of the effect
  146164. * @hidden
  146165. */
  146166. _name: string;
  146167. /**
  146168. * Instantiates a post process render effect.
  146169. * A post process can be used to apply a shader to a texture after it is rendered.
  146170. * @param engine The engine the effect is tied to
  146171. * @param name The name of the effect
  146172. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146173. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146174. */
  146175. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146176. /**
  146177. * Checks if all the post processes in the effect are supported.
  146178. */
  146179. get isSupported(): boolean;
  146180. /**
  146181. * Updates the current state of the effect
  146182. * @hidden
  146183. */
  146184. _update(): void;
  146185. /**
  146186. * Attaches the effect on cameras
  146187. * @param cameras The camera to attach to.
  146188. * @hidden
  146189. */
  146190. _attachCameras(cameras: Camera): void;
  146191. /**
  146192. * Attaches the effect on cameras
  146193. * @param cameras The camera to attach to.
  146194. * @hidden
  146195. */
  146196. _attachCameras(cameras: Camera[]): void;
  146197. /**
  146198. * Detaches the effect on cameras
  146199. * @param cameras The camera to detatch from.
  146200. * @hidden
  146201. */
  146202. _detachCameras(cameras: Camera): void;
  146203. /**
  146204. * Detatches the effect on cameras
  146205. * @param cameras The camera to detatch from.
  146206. * @hidden
  146207. */
  146208. _detachCameras(cameras: Camera[]): void;
  146209. /**
  146210. * Enables the effect on given cameras
  146211. * @param cameras The camera to enable.
  146212. * @hidden
  146213. */
  146214. _enable(cameras: Camera): void;
  146215. /**
  146216. * Enables the effect on given cameras
  146217. * @param cameras The camera to enable.
  146218. * @hidden
  146219. */
  146220. _enable(cameras: Nullable<Camera[]>): void;
  146221. /**
  146222. * Disables the effect on the given cameras
  146223. * @param cameras The camera to disable.
  146224. * @hidden
  146225. */
  146226. _disable(cameras: Camera): void;
  146227. /**
  146228. * Disables the effect on the given cameras
  146229. * @param cameras The camera to disable.
  146230. * @hidden
  146231. */
  146232. _disable(cameras: Nullable<Camera[]>): void;
  146233. /**
  146234. * Gets a list of the post processes contained in the effect.
  146235. * @param camera The camera to get the post processes on.
  146236. * @returns The list of the post processes in the effect.
  146237. */
  146238. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146239. }
  146240. }
  146241. declare module BABYLON {
  146242. /** @hidden */
  146243. export var extractHighlightsPixelShader: {
  146244. name: string;
  146245. shader: string;
  146246. };
  146247. }
  146248. declare module BABYLON {
  146249. /**
  146250. * 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.
  146251. */
  146252. export class ExtractHighlightsPostProcess extends PostProcess {
  146253. /**
  146254. * The luminance threshold, pixels below this value will be set to black.
  146255. */
  146256. threshold: number;
  146257. /** @hidden */
  146258. _exposure: number;
  146259. /**
  146260. * Post process which has the input texture to be used when performing highlight extraction
  146261. * @hidden
  146262. */
  146263. _inputPostProcess: Nullable<PostProcess>;
  146264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146265. }
  146266. }
  146267. declare module BABYLON {
  146268. /** @hidden */
  146269. export var bloomMergePixelShader: {
  146270. name: string;
  146271. shader: string;
  146272. };
  146273. }
  146274. declare module BABYLON {
  146275. /**
  146276. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146277. */
  146278. export class BloomMergePostProcess extends PostProcess {
  146279. /** Weight of the bloom to be added to the original input. */
  146280. weight: number;
  146281. /**
  146282. * Creates a new instance of @see BloomMergePostProcess
  146283. * @param name The name of the effect.
  146284. * @param originalFromInput Post process which's input will be used for the merge.
  146285. * @param blurred Blurred highlights post process which's output will be used.
  146286. * @param weight Weight of the bloom to be added to the original input.
  146287. * @param options The required width/height ratio to downsize to before computing the render pass.
  146288. * @param camera The camera to apply the render pass to.
  146289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146290. * @param engine The engine which the post process will be applied. (default: current engine)
  146291. * @param reusable If the post process can be reused on the same frame. (default: false)
  146292. * @param textureType Type of textures used when performing the post process. (default: 0)
  146293. * @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)
  146294. */
  146295. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146296. /** Weight of the bloom to be added to the original input. */
  146297. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146298. }
  146299. }
  146300. declare module BABYLON {
  146301. /**
  146302. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146303. */
  146304. export class BloomEffect extends PostProcessRenderEffect {
  146305. private bloomScale;
  146306. /**
  146307. * @hidden Internal
  146308. */
  146309. _effects: Array<PostProcess>;
  146310. /**
  146311. * @hidden Internal
  146312. */
  146313. _downscale: ExtractHighlightsPostProcess;
  146314. private _blurX;
  146315. private _blurY;
  146316. private _merge;
  146317. /**
  146318. * The luminance threshold to find bright areas of the image to bloom.
  146319. */
  146320. get threshold(): number;
  146321. set threshold(value: number);
  146322. /**
  146323. * The strength of the bloom.
  146324. */
  146325. get weight(): number;
  146326. set weight(value: number);
  146327. /**
  146328. * Specifies the size of the bloom blur kernel, relative to the final output size
  146329. */
  146330. get kernel(): number;
  146331. set kernel(value: number);
  146332. /**
  146333. * Creates a new instance of @see BloomEffect
  146334. * @param scene The scene the effect belongs to.
  146335. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146336. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146337. * @param bloomWeight The the strength of bloom.
  146338. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146339. * @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)
  146340. */
  146341. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146342. /**
  146343. * Disposes each of the internal effects for a given camera.
  146344. * @param camera The camera to dispose the effect on.
  146345. */
  146346. disposeEffects(camera: Camera): void;
  146347. /**
  146348. * @hidden Internal
  146349. */
  146350. _updateEffects(): void;
  146351. /**
  146352. * Internal
  146353. * @returns if all the contained post processes are ready.
  146354. * @hidden
  146355. */
  146356. _isReady(): boolean;
  146357. }
  146358. }
  146359. declare module BABYLON {
  146360. /** @hidden */
  146361. export var chromaticAberrationPixelShader: {
  146362. name: string;
  146363. shader: string;
  146364. };
  146365. }
  146366. declare module BABYLON {
  146367. /**
  146368. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146369. */
  146370. export class ChromaticAberrationPostProcess extends PostProcess {
  146371. /**
  146372. * The amount of seperation of rgb channels (default: 30)
  146373. */
  146374. aberrationAmount: number;
  146375. /**
  146376. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146377. */
  146378. radialIntensity: number;
  146379. /**
  146380. * 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))
  146381. */
  146382. direction: Vector2;
  146383. /**
  146384. * 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))
  146385. */
  146386. centerPosition: Vector2;
  146387. /**
  146388. * Creates a new instance ChromaticAberrationPostProcess
  146389. * @param name The name of the effect.
  146390. * @param screenWidth The width of the screen to apply the effect on.
  146391. * @param screenHeight The height of the screen to apply the effect on.
  146392. * @param options The required width/height ratio to downsize to before computing the render pass.
  146393. * @param camera The camera to apply the render pass to.
  146394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146395. * @param engine The engine which the post process will be applied. (default: current engine)
  146396. * @param reusable If the post process can be reused on the same frame. (default: false)
  146397. * @param textureType Type of textures used when performing the post process. (default: 0)
  146398. * @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)
  146399. */
  146400. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146401. }
  146402. }
  146403. declare module BABYLON {
  146404. /** @hidden */
  146405. export var circleOfConfusionPixelShader: {
  146406. name: string;
  146407. shader: string;
  146408. };
  146409. }
  146410. declare module BABYLON {
  146411. /**
  146412. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146413. */
  146414. export class CircleOfConfusionPostProcess extends PostProcess {
  146415. /**
  146416. * 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.
  146417. */
  146418. lensSize: number;
  146419. /**
  146420. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146421. */
  146422. fStop: number;
  146423. /**
  146424. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146425. */
  146426. focusDistance: number;
  146427. /**
  146428. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146429. */
  146430. focalLength: number;
  146431. private _depthTexture;
  146432. /**
  146433. * Creates a new instance CircleOfConfusionPostProcess
  146434. * @param name The name of the effect.
  146435. * @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.
  146436. * @param options The required width/height ratio to downsize to before computing the render pass.
  146437. * @param camera The camera to apply the render pass to.
  146438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146439. * @param engine The engine which the post process will be applied. (default: current engine)
  146440. * @param reusable If the post process can be reused on the same frame. (default: false)
  146441. * @param textureType Type of textures used when performing the post process. (default: 0)
  146442. * @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)
  146443. */
  146444. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146445. /**
  146446. * 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.
  146447. */
  146448. set depthTexture(value: RenderTargetTexture);
  146449. }
  146450. }
  146451. declare module BABYLON {
  146452. /** @hidden */
  146453. export var colorCorrectionPixelShader: {
  146454. name: string;
  146455. shader: string;
  146456. };
  146457. }
  146458. declare module BABYLON {
  146459. /**
  146460. *
  146461. * This post-process allows the modification of rendered colors by using
  146462. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146463. *
  146464. * The object needs to be provided an url to a texture containing the color
  146465. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146466. * Use an image editing software to tweak the LUT to match your needs.
  146467. *
  146468. * For an example of a color LUT, see here:
  146469. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146470. * For explanations on color grading, see here:
  146471. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146472. *
  146473. */
  146474. export class ColorCorrectionPostProcess extends PostProcess {
  146475. private _colorTableTexture;
  146476. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146477. }
  146478. }
  146479. declare module BABYLON {
  146480. /** @hidden */
  146481. export var convolutionPixelShader: {
  146482. name: string;
  146483. shader: string;
  146484. };
  146485. }
  146486. declare module BABYLON {
  146487. /**
  146488. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146489. * input texture to perform effects such as edge detection or sharpening
  146490. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146491. */
  146492. export class ConvolutionPostProcess extends PostProcess {
  146493. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146494. kernel: number[];
  146495. /**
  146496. * Creates a new instance ConvolutionPostProcess
  146497. * @param name The name of the effect.
  146498. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146499. * @param options The required width/height ratio to downsize to before computing the render pass.
  146500. * @param camera The camera to apply the render pass to.
  146501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146502. * @param engine The engine which the post process will be applied. (default: current engine)
  146503. * @param reusable If the post process can be reused on the same frame. (default: false)
  146504. * @param textureType Type of textures used when performing the post process. (default: 0)
  146505. */
  146506. constructor(name: string,
  146507. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146508. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146509. /**
  146510. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146511. */
  146512. static EdgeDetect0Kernel: number[];
  146513. /**
  146514. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146515. */
  146516. static EdgeDetect1Kernel: number[];
  146517. /**
  146518. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146519. */
  146520. static EdgeDetect2Kernel: number[];
  146521. /**
  146522. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146523. */
  146524. static SharpenKernel: number[];
  146525. /**
  146526. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146527. */
  146528. static EmbossKernel: number[];
  146529. /**
  146530. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146531. */
  146532. static GaussianKernel: number[];
  146533. }
  146534. }
  146535. declare module BABYLON {
  146536. /**
  146537. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146538. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146539. * based on samples that have a large difference in distance than the center pixel.
  146540. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146541. */
  146542. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146543. direction: Vector2;
  146544. /**
  146545. * Creates a new instance CircleOfConfusionPostProcess
  146546. * @param name The name of the effect.
  146547. * @param scene The scene the effect belongs to.
  146548. * @param direction The direction the blur should be applied.
  146549. * @param kernel The size of the kernel used to blur.
  146550. * @param options The required width/height ratio to downsize to before computing the render pass.
  146551. * @param camera The camera to apply the render pass to.
  146552. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146553. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146555. * @param engine The engine which the post process will be applied. (default: current engine)
  146556. * @param reusable If the post process can be reused on the same frame. (default: false)
  146557. * @param textureType Type of textures used when performing the post process. (default: 0)
  146558. * @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)
  146559. */
  146560. 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);
  146561. }
  146562. }
  146563. declare module BABYLON {
  146564. /** @hidden */
  146565. export var depthOfFieldMergePixelShader: {
  146566. name: string;
  146567. shader: string;
  146568. };
  146569. }
  146570. declare module BABYLON {
  146571. /**
  146572. * Options to be set when merging outputs from the default pipeline.
  146573. */
  146574. export class DepthOfFieldMergePostProcessOptions {
  146575. /**
  146576. * The original image to merge on top of
  146577. */
  146578. originalFromInput: PostProcess;
  146579. /**
  146580. * Parameters to perform the merge of the depth of field effect
  146581. */
  146582. depthOfField?: {
  146583. circleOfConfusion: PostProcess;
  146584. blurSteps: Array<PostProcess>;
  146585. };
  146586. /**
  146587. * Parameters to perform the merge of bloom effect
  146588. */
  146589. bloom?: {
  146590. blurred: PostProcess;
  146591. weight: number;
  146592. };
  146593. }
  146594. /**
  146595. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146596. */
  146597. export class DepthOfFieldMergePostProcess extends PostProcess {
  146598. private blurSteps;
  146599. /**
  146600. * Creates a new instance of DepthOfFieldMergePostProcess
  146601. * @param name The name of the effect.
  146602. * @param originalFromInput Post process which's input will be used for the merge.
  146603. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146604. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146605. * @param options The required width/height ratio to downsize to before computing the render pass.
  146606. * @param camera The camera to apply the render pass to.
  146607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146608. * @param engine The engine which the post process will be applied. (default: current engine)
  146609. * @param reusable If the post process can be reused on the same frame. (default: false)
  146610. * @param textureType Type of textures used when performing the post process. (default: 0)
  146611. * @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)
  146612. */
  146613. 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);
  146614. /**
  146615. * Updates the effect with the current post process compile time values and recompiles the shader.
  146616. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146617. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146618. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146619. * @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
  146620. * @param onCompiled Called when the shader has been compiled.
  146621. * @param onError Called if there is an error when compiling a shader.
  146622. */
  146623. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146624. }
  146625. }
  146626. declare module BABYLON {
  146627. /**
  146628. * Specifies the level of max blur that should be applied when using the depth of field effect
  146629. */
  146630. export enum DepthOfFieldEffectBlurLevel {
  146631. /**
  146632. * Subtle blur
  146633. */
  146634. Low = 0,
  146635. /**
  146636. * Medium blur
  146637. */
  146638. Medium = 1,
  146639. /**
  146640. * Large blur
  146641. */
  146642. High = 2
  146643. }
  146644. /**
  146645. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146646. */
  146647. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146648. private _circleOfConfusion;
  146649. /**
  146650. * @hidden Internal, blurs from high to low
  146651. */
  146652. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146653. private _depthOfFieldBlurY;
  146654. private _dofMerge;
  146655. /**
  146656. * @hidden Internal post processes in depth of field effect
  146657. */
  146658. _effects: Array<PostProcess>;
  146659. /**
  146660. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146661. */
  146662. set focalLength(value: number);
  146663. get focalLength(): number;
  146664. /**
  146665. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146666. */
  146667. set fStop(value: number);
  146668. get fStop(): number;
  146669. /**
  146670. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146671. */
  146672. set focusDistance(value: number);
  146673. get focusDistance(): number;
  146674. /**
  146675. * 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.
  146676. */
  146677. set lensSize(value: number);
  146678. get lensSize(): number;
  146679. /**
  146680. * Creates a new instance DepthOfFieldEffect
  146681. * @param scene The scene the effect belongs to.
  146682. * @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.
  146683. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146684. * @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)
  146685. */
  146686. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146687. /**
  146688. * Get the current class name of the current effet
  146689. * @returns "DepthOfFieldEffect"
  146690. */
  146691. getClassName(): string;
  146692. /**
  146693. * 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.
  146694. */
  146695. set depthTexture(value: RenderTargetTexture);
  146696. /**
  146697. * Disposes each of the internal effects for a given camera.
  146698. * @param camera The camera to dispose the effect on.
  146699. */
  146700. disposeEffects(camera: Camera): void;
  146701. /**
  146702. * @hidden Internal
  146703. */
  146704. _updateEffects(): void;
  146705. /**
  146706. * Internal
  146707. * @returns if all the contained post processes are ready.
  146708. * @hidden
  146709. */
  146710. _isReady(): boolean;
  146711. }
  146712. }
  146713. declare module BABYLON {
  146714. /** @hidden */
  146715. export var displayPassPixelShader: {
  146716. name: string;
  146717. shader: string;
  146718. };
  146719. }
  146720. declare module BABYLON {
  146721. /**
  146722. * DisplayPassPostProcess which produces an output the same as it's input
  146723. */
  146724. export class DisplayPassPostProcess extends PostProcess {
  146725. /**
  146726. * Creates the DisplayPassPostProcess
  146727. * @param name The name of the effect.
  146728. * @param options The required width/height ratio to downsize to before computing the render pass.
  146729. * @param camera The camera to apply the render pass to.
  146730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146731. * @param engine The engine which the post process will be applied. (default: current engine)
  146732. * @param reusable If the post process can be reused on the same frame. (default: false)
  146733. */
  146734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146735. }
  146736. }
  146737. declare module BABYLON {
  146738. /** @hidden */
  146739. export var filterPixelShader: {
  146740. name: string;
  146741. shader: string;
  146742. };
  146743. }
  146744. declare module BABYLON {
  146745. /**
  146746. * Applies a kernel filter to the image
  146747. */
  146748. export class FilterPostProcess extends PostProcess {
  146749. /** The matrix to be applied to the image */
  146750. kernelMatrix: Matrix;
  146751. /**
  146752. *
  146753. * @param name The name of the effect.
  146754. * @param kernelMatrix The matrix to be applied to the image
  146755. * @param options The required width/height ratio to downsize to before computing the render pass.
  146756. * @param camera The camera to apply the render pass to.
  146757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146758. * @param engine The engine which the post process will be applied. (default: current engine)
  146759. * @param reusable If the post process can be reused on the same frame. (default: false)
  146760. */
  146761. constructor(name: string,
  146762. /** The matrix to be applied to the image */
  146763. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146764. }
  146765. }
  146766. declare module BABYLON {
  146767. /** @hidden */
  146768. export var fxaaPixelShader: {
  146769. name: string;
  146770. shader: string;
  146771. };
  146772. }
  146773. declare module BABYLON {
  146774. /** @hidden */
  146775. export var fxaaVertexShader: {
  146776. name: string;
  146777. shader: string;
  146778. };
  146779. }
  146780. declare module BABYLON {
  146781. /**
  146782. * Fxaa post process
  146783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146784. */
  146785. export class FxaaPostProcess extends PostProcess {
  146786. /** @hidden */
  146787. texelWidth: number;
  146788. /** @hidden */
  146789. texelHeight: number;
  146790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146791. private _getDefines;
  146792. }
  146793. }
  146794. declare module BABYLON {
  146795. /** @hidden */
  146796. export var grainPixelShader: {
  146797. name: string;
  146798. shader: string;
  146799. };
  146800. }
  146801. declare module BABYLON {
  146802. /**
  146803. * The GrainPostProcess adds noise to the image at mid luminance levels
  146804. */
  146805. export class GrainPostProcess extends PostProcess {
  146806. /**
  146807. * The intensity of the grain added (default: 30)
  146808. */
  146809. intensity: number;
  146810. /**
  146811. * If the grain should be randomized on every frame
  146812. */
  146813. animated: boolean;
  146814. /**
  146815. * Creates a new instance of @see GrainPostProcess
  146816. * @param name The name of the effect.
  146817. * @param options The required width/height ratio to downsize to before computing the render pass.
  146818. * @param camera The camera to apply the render pass to.
  146819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146820. * @param engine The engine which the post process will be applied. (default: current engine)
  146821. * @param reusable If the post process can be reused on the same frame. (default: false)
  146822. * @param textureType Type of textures used when performing the post process. (default: 0)
  146823. * @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)
  146824. */
  146825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146826. }
  146827. }
  146828. declare module BABYLON {
  146829. /** @hidden */
  146830. export var highlightsPixelShader: {
  146831. name: string;
  146832. shader: string;
  146833. };
  146834. }
  146835. declare module BABYLON {
  146836. /**
  146837. * Extracts highlights from the image
  146838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146839. */
  146840. export class HighlightsPostProcess extends PostProcess {
  146841. /**
  146842. * Extracts highlights from the image
  146843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146844. * @param name The name of the effect.
  146845. * @param options The required width/height ratio to downsize to before computing the render pass.
  146846. * @param camera The camera to apply the render pass to.
  146847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146848. * @param engine The engine which the post process will be applied. (default: current engine)
  146849. * @param reusable If the post process can be reused on the same frame. (default: false)
  146850. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146851. */
  146852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146853. }
  146854. }
  146855. declare module BABYLON {
  146856. /** @hidden */
  146857. export var mrtFragmentDeclaration: {
  146858. name: string;
  146859. shader: string;
  146860. };
  146861. }
  146862. declare module BABYLON {
  146863. /** @hidden */
  146864. export var geometryPixelShader: {
  146865. name: string;
  146866. shader: string;
  146867. };
  146868. }
  146869. declare module BABYLON {
  146870. /** @hidden */
  146871. export var geometryVertexShader: {
  146872. name: string;
  146873. shader: string;
  146874. };
  146875. }
  146876. declare module BABYLON {
  146877. /** @hidden */
  146878. interface ISavedTransformationMatrix {
  146879. world: Matrix;
  146880. viewProjection: Matrix;
  146881. }
  146882. /**
  146883. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146884. */
  146885. export class GeometryBufferRenderer {
  146886. /**
  146887. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146888. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146889. */
  146890. static readonly POSITION_TEXTURE_TYPE: number;
  146891. /**
  146892. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146893. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146894. */
  146895. static readonly VELOCITY_TEXTURE_TYPE: number;
  146896. /**
  146897. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146898. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146899. */
  146900. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146901. /**
  146902. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146903. * in order to compute objects velocities when enableVelocity is set to "true"
  146904. * @hidden
  146905. */
  146906. _previousTransformationMatrices: {
  146907. [index: number]: ISavedTransformationMatrix;
  146908. };
  146909. /**
  146910. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146911. * in order to compute objects velocities when enableVelocity is set to "true"
  146912. * @hidden
  146913. */
  146914. _previousBonesTransformationMatrices: {
  146915. [index: number]: Float32Array;
  146916. };
  146917. /**
  146918. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146919. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146920. */
  146921. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146922. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146923. renderTransparentMeshes: boolean;
  146924. private _scene;
  146925. private _multiRenderTarget;
  146926. private _ratio;
  146927. private _enablePosition;
  146928. private _enableVelocity;
  146929. private _enableReflectivity;
  146930. private _positionIndex;
  146931. private _velocityIndex;
  146932. private _reflectivityIndex;
  146933. protected _effect: Effect;
  146934. protected _cachedDefines: string;
  146935. /**
  146936. * Set the render list (meshes to be rendered) used in the G buffer.
  146937. */
  146938. set renderList(meshes: Mesh[]);
  146939. /**
  146940. * Gets wether or not G buffer are supported by the running hardware.
  146941. * This requires draw buffer supports
  146942. */
  146943. get isSupported(): boolean;
  146944. /**
  146945. * Returns the index of the given texture type in the G-Buffer textures array
  146946. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146947. * @returns the index of the given texture type in the G-Buffer textures array
  146948. */
  146949. getTextureIndex(textureType: number): number;
  146950. /**
  146951. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146952. */
  146953. get enablePosition(): boolean;
  146954. /**
  146955. * Sets whether or not objects positions are enabled for the G buffer.
  146956. */
  146957. set enablePosition(enable: boolean);
  146958. /**
  146959. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146960. */
  146961. get enableVelocity(): boolean;
  146962. /**
  146963. * Sets wether or not objects velocities are enabled for the G buffer.
  146964. */
  146965. set enableVelocity(enable: boolean);
  146966. /**
  146967. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146968. */
  146969. get enableReflectivity(): boolean;
  146970. /**
  146971. * Sets wether or not objects roughness are enabled for the G buffer.
  146972. */
  146973. set enableReflectivity(enable: boolean);
  146974. /**
  146975. * Gets the scene associated with the buffer.
  146976. */
  146977. get scene(): Scene;
  146978. /**
  146979. * Gets the ratio used by the buffer during its creation.
  146980. * How big is the buffer related to the main canvas.
  146981. */
  146982. get ratio(): number;
  146983. /** @hidden */
  146984. static _SceneComponentInitialization: (scene: Scene) => void;
  146985. /**
  146986. * Creates a new G Buffer for the scene
  146987. * @param scene The scene the buffer belongs to
  146988. * @param ratio How big is the buffer related to the main canvas.
  146989. */
  146990. constructor(scene: Scene, ratio?: number);
  146991. /**
  146992. * Checks wether everything is ready to render a submesh to the G buffer.
  146993. * @param subMesh the submesh to check readiness for
  146994. * @param useInstances is the mesh drawn using instance or not
  146995. * @returns true if ready otherwise false
  146996. */
  146997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146998. /**
  146999. * Gets the current underlying G Buffer.
  147000. * @returns the buffer
  147001. */
  147002. getGBuffer(): MultiRenderTarget;
  147003. /**
  147004. * Gets the number of samples used to render the buffer (anti aliasing).
  147005. */
  147006. get samples(): number;
  147007. /**
  147008. * Sets the number of samples used to render the buffer (anti aliasing).
  147009. */
  147010. set samples(value: number);
  147011. /**
  147012. * Disposes the renderer and frees up associated resources.
  147013. */
  147014. dispose(): void;
  147015. protected _createRenderTargets(): void;
  147016. private _copyBonesTransformationMatrices;
  147017. }
  147018. }
  147019. declare module BABYLON {
  147020. interface Scene {
  147021. /** @hidden (Backing field) */
  147022. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147023. /**
  147024. * Gets or Sets the current geometry buffer associated to the scene.
  147025. */
  147026. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147027. /**
  147028. * Enables a GeometryBufferRender and associates it with the scene
  147029. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147030. * @returns the GeometryBufferRenderer
  147031. */
  147032. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147033. /**
  147034. * Disables the GeometryBufferRender associated with the scene
  147035. */
  147036. disableGeometryBufferRenderer(): void;
  147037. }
  147038. /**
  147039. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147040. * in several rendering techniques.
  147041. */
  147042. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147043. /**
  147044. * The component name helpful to identify the component in the list of scene components.
  147045. */
  147046. readonly name: string;
  147047. /**
  147048. * The scene the component belongs to.
  147049. */
  147050. scene: Scene;
  147051. /**
  147052. * Creates a new instance of the component for the given scene
  147053. * @param scene Defines the scene to register the component in
  147054. */
  147055. constructor(scene: Scene);
  147056. /**
  147057. * Registers the component in a given scene
  147058. */
  147059. register(): void;
  147060. /**
  147061. * Rebuilds the elements related to this component in case of
  147062. * context lost for instance.
  147063. */
  147064. rebuild(): void;
  147065. /**
  147066. * Disposes the component and the associated ressources
  147067. */
  147068. dispose(): void;
  147069. private _gatherRenderTargets;
  147070. }
  147071. }
  147072. declare module BABYLON {
  147073. /** @hidden */
  147074. export var motionBlurPixelShader: {
  147075. name: string;
  147076. shader: string;
  147077. };
  147078. }
  147079. declare module BABYLON {
  147080. /**
  147081. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147082. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147083. * As an example, all you have to do is to create the post-process:
  147084. * var mb = new BABYLON.MotionBlurPostProcess(
  147085. * 'mb', // The name of the effect.
  147086. * scene, // The scene containing the objects to blur according to their velocity.
  147087. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147088. * camera // The camera to apply the render pass to.
  147089. * );
  147090. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147091. */
  147092. export class MotionBlurPostProcess extends PostProcess {
  147093. /**
  147094. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147095. */
  147096. motionStrength: number;
  147097. /**
  147098. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147099. */
  147100. get motionBlurSamples(): number;
  147101. /**
  147102. * Sets the number of iterations to be used for motion blur quality
  147103. */
  147104. set motionBlurSamples(samples: number);
  147105. private _motionBlurSamples;
  147106. private _geometryBufferRenderer;
  147107. /**
  147108. * Creates a new instance MotionBlurPostProcess
  147109. * @param name The name of the effect.
  147110. * @param scene The scene containing the objects to blur according to their velocity.
  147111. * @param options The required width/height ratio to downsize to before computing the render pass.
  147112. * @param camera The camera to apply the render pass to.
  147113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147114. * @param engine The engine which the post process will be applied. (default: current engine)
  147115. * @param reusable If the post process can be reused on the same frame. (default: false)
  147116. * @param textureType Type of textures used when performing the post process. (default: 0)
  147117. * @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)
  147118. */
  147119. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147120. /**
  147121. * Excludes the given skinned mesh from computing bones velocities.
  147122. * 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.
  147123. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147124. */
  147125. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147126. /**
  147127. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147128. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147129. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147130. */
  147131. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147132. /**
  147133. * Disposes the post process.
  147134. * @param camera The camera to dispose the post process on.
  147135. */
  147136. dispose(camera?: Camera): void;
  147137. }
  147138. }
  147139. declare module BABYLON {
  147140. /** @hidden */
  147141. export var refractionPixelShader: {
  147142. name: string;
  147143. shader: string;
  147144. };
  147145. }
  147146. declare module BABYLON {
  147147. /**
  147148. * Post process which applies a refractin texture
  147149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147150. */
  147151. export class RefractionPostProcess extends PostProcess {
  147152. /** the base color of the refraction (used to taint the rendering) */
  147153. color: Color3;
  147154. /** simulated refraction depth */
  147155. depth: number;
  147156. /** the coefficient of the base color (0 to remove base color tainting) */
  147157. colorLevel: number;
  147158. private _refTexture;
  147159. private _ownRefractionTexture;
  147160. /**
  147161. * Gets or sets the refraction texture
  147162. * Please note that you are responsible for disposing the texture if you set it manually
  147163. */
  147164. get refractionTexture(): Texture;
  147165. set refractionTexture(value: Texture);
  147166. /**
  147167. * Initializes the RefractionPostProcess
  147168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147169. * @param name The name of the effect.
  147170. * @param refractionTextureUrl Url of the refraction texture to use
  147171. * @param color the base color of the refraction (used to taint the rendering)
  147172. * @param depth simulated refraction depth
  147173. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147174. * @param camera The camera to apply the render pass to.
  147175. * @param options The required width/height ratio to downsize to before computing the render pass.
  147176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147177. * @param engine The engine which the post process will be applied. (default: current engine)
  147178. * @param reusable If the post process can be reused on the same frame. (default: false)
  147179. */
  147180. constructor(name: string, refractionTextureUrl: string,
  147181. /** the base color of the refraction (used to taint the rendering) */
  147182. color: Color3,
  147183. /** simulated refraction depth */
  147184. depth: number,
  147185. /** the coefficient of the base color (0 to remove base color tainting) */
  147186. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147187. /**
  147188. * Disposes of the post process
  147189. * @param camera Camera to dispose post process on
  147190. */
  147191. dispose(camera: Camera): void;
  147192. }
  147193. }
  147194. declare module BABYLON {
  147195. /** @hidden */
  147196. export var sharpenPixelShader: {
  147197. name: string;
  147198. shader: string;
  147199. };
  147200. }
  147201. declare module BABYLON {
  147202. /**
  147203. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147204. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147205. */
  147206. export class SharpenPostProcess extends PostProcess {
  147207. /**
  147208. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147209. */
  147210. colorAmount: number;
  147211. /**
  147212. * How much sharpness should be applied (default: 0.3)
  147213. */
  147214. edgeAmount: number;
  147215. /**
  147216. * Creates a new instance ConvolutionPostProcess
  147217. * @param name The name of the effect.
  147218. * @param options The required width/height ratio to downsize to before computing the render pass.
  147219. * @param camera The camera to apply the render pass to.
  147220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147221. * @param engine The engine which the post process will be applied. (default: current engine)
  147222. * @param reusable If the post process can be reused on the same frame. (default: false)
  147223. * @param textureType Type of textures used when performing the post process. (default: 0)
  147224. * @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)
  147225. */
  147226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147227. }
  147228. }
  147229. declare module BABYLON {
  147230. /**
  147231. * PostProcessRenderPipeline
  147232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147233. */
  147234. export class PostProcessRenderPipeline {
  147235. private engine;
  147236. private _renderEffects;
  147237. private _renderEffectsForIsolatedPass;
  147238. /**
  147239. * List of inspectable custom properties (used by the Inspector)
  147240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147241. */
  147242. inspectableCustomProperties: IInspectable[];
  147243. /**
  147244. * @hidden
  147245. */
  147246. protected _cameras: Camera[];
  147247. /** @hidden */
  147248. _name: string;
  147249. /**
  147250. * Gets pipeline name
  147251. */
  147252. get name(): string;
  147253. /** Gets the list of attached cameras */
  147254. get cameras(): Camera[];
  147255. /**
  147256. * Initializes a PostProcessRenderPipeline
  147257. * @param engine engine to add the pipeline to
  147258. * @param name name of the pipeline
  147259. */
  147260. constructor(engine: Engine, name: string);
  147261. /**
  147262. * Gets the class name
  147263. * @returns "PostProcessRenderPipeline"
  147264. */
  147265. getClassName(): string;
  147266. /**
  147267. * If all the render effects in the pipeline are supported
  147268. */
  147269. get isSupported(): boolean;
  147270. /**
  147271. * Adds an effect to the pipeline
  147272. * @param renderEffect the effect to add
  147273. */
  147274. addEffect(renderEffect: PostProcessRenderEffect): void;
  147275. /** @hidden */
  147276. _rebuild(): void;
  147277. /** @hidden */
  147278. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147279. /** @hidden */
  147280. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147281. /** @hidden */
  147282. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147283. /** @hidden */
  147284. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147285. /** @hidden */
  147286. _attachCameras(cameras: Camera, unique: boolean): void;
  147287. /** @hidden */
  147288. _attachCameras(cameras: Camera[], unique: boolean): void;
  147289. /** @hidden */
  147290. _detachCameras(cameras: Camera): void;
  147291. /** @hidden */
  147292. _detachCameras(cameras: Nullable<Camera[]>): void;
  147293. /** @hidden */
  147294. _update(): void;
  147295. /** @hidden */
  147296. _reset(): void;
  147297. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147298. /**
  147299. * Disposes of the pipeline
  147300. */
  147301. dispose(): void;
  147302. }
  147303. }
  147304. declare module BABYLON {
  147305. /**
  147306. * PostProcessRenderPipelineManager class
  147307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147308. */
  147309. export class PostProcessRenderPipelineManager {
  147310. private _renderPipelines;
  147311. /**
  147312. * Initializes a PostProcessRenderPipelineManager
  147313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147314. */
  147315. constructor();
  147316. /**
  147317. * Gets the list of supported render pipelines
  147318. */
  147319. get supportedPipelines(): PostProcessRenderPipeline[];
  147320. /**
  147321. * Adds a pipeline to the manager
  147322. * @param renderPipeline The pipeline to add
  147323. */
  147324. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147325. /**
  147326. * Attaches a camera to the pipeline
  147327. * @param renderPipelineName The name of the pipeline to attach to
  147328. * @param cameras the camera to attach
  147329. * @param unique if the camera can be attached multiple times to the pipeline
  147330. */
  147331. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147332. /**
  147333. * Detaches a camera from the pipeline
  147334. * @param renderPipelineName The name of the pipeline to detach from
  147335. * @param cameras the camera to detach
  147336. */
  147337. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147338. /**
  147339. * Enables an effect by name on a pipeline
  147340. * @param renderPipelineName the name of the pipeline to enable the effect in
  147341. * @param renderEffectName the name of the effect to enable
  147342. * @param cameras the cameras that the effect should be enabled on
  147343. */
  147344. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147345. /**
  147346. * Disables an effect by name on a pipeline
  147347. * @param renderPipelineName the name of the pipeline to disable the effect in
  147348. * @param renderEffectName the name of the effect to disable
  147349. * @param cameras the cameras that the effect should be disabled on
  147350. */
  147351. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147352. /**
  147353. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147354. */
  147355. update(): void;
  147356. /** @hidden */
  147357. _rebuild(): void;
  147358. /**
  147359. * Disposes of the manager and pipelines
  147360. */
  147361. dispose(): void;
  147362. }
  147363. }
  147364. declare module BABYLON {
  147365. interface Scene {
  147366. /** @hidden (Backing field) */
  147367. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147368. /**
  147369. * Gets the postprocess render pipeline manager
  147370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147371. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147372. */
  147373. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147374. }
  147375. /**
  147376. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147377. */
  147378. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147379. /**
  147380. * The component name helpfull to identify the component in the list of scene components.
  147381. */
  147382. readonly name: string;
  147383. /**
  147384. * The scene the component belongs to.
  147385. */
  147386. scene: Scene;
  147387. /**
  147388. * Creates a new instance of the component for the given scene
  147389. * @param scene Defines the scene to register the component in
  147390. */
  147391. constructor(scene: Scene);
  147392. /**
  147393. * Registers the component in a given scene
  147394. */
  147395. register(): void;
  147396. /**
  147397. * Rebuilds the elements related to this component in case of
  147398. * context lost for instance.
  147399. */
  147400. rebuild(): void;
  147401. /**
  147402. * Disposes the component and the associated ressources
  147403. */
  147404. dispose(): void;
  147405. private _gatherRenderTargets;
  147406. }
  147407. }
  147408. declare module BABYLON {
  147409. /**
  147410. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147411. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147412. */
  147413. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147414. private _scene;
  147415. private _camerasToBeAttached;
  147416. /**
  147417. * ID of the sharpen post process,
  147418. */
  147419. private readonly SharpenPostProcessId;
  147420. /**
  147421. * @ignore
  147422. * ID of the image processing post process;
  147423. */
  147424. readonly ImageProcessingPostProcessId: string;
  147425. /**
  147426. * @ignore
  147427. * ID of the Fast Approximate Anti-Aliasing post process;
  147428. */
  147429. readonly FxaaPostProcessId: string;
  147430. /**
  147431. * ID of the chromatic aberration post process,
  147432. */
  147433. private readonly ChromaticAberrationPostProcessId;
  147434. /**
  147435. * ID of the grain post process
  147436. */
  147437. private readonly GrainPostProcessId;
  147438. /**
  147439. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147440. */
  147441. sharpen: SharpenPostProcess;
  147442. private _sharpenEffect;
  147443. private bloom;
  147444. /**
  147445. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147446. */
  147447. depthOfField: DepthOfFieldEffect;
  147448. /**
  147449. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147450. */
  147451. fxaa: FxaaPostProcess;
  147452. /**
  147453. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147454. */
  147455. imageProcessing: ImageProcessingPostProcess;
  147456. /**
  147457. * Chromatic aberration post process which will shift rgb colors in the image
  147458. */
  147459. chromaticAberration: ChromaticAberrationPostProcess;
  147460. private _chromaticAberrationEffect;
  147461. /**
  147462. * Grain post process which add noise to the image
  147463. */
  147464. grain: GrainPostProcess;
  147465. private _grainEffect;
  147466. /**
  147467. * Glow post process which adds a glow to emissive areas of the image
  147468. */
  147469. private _glowLayer;
  147470. /**
  147471. * Animations which can be used to tweak settings over a period of time
  147472. */
  147473. animations: Animation[];
  147474. private _imageProcessingConfigurationObserver;
  147475. private _sharpenEnabled;
  147476. private _bloomEnabled;
  147477. private _depthOfFieldEnabled;
  147478. private _depthOfFieldBlurLevel;
  147479. private _fxaaEnabled;
  147480. private _imageProcessingEnabled;
  147481. private _defaultPipelineTextureType;
  147482. private _bloomScale;
  147483. private _chromaticAberrationEnabled;
  147484. private _grainEnabled;
  147485. private _buildAllowed;
  147486. /**
  147487. * Gets active scene
  147488. */
  147489. get scene(): Scene;
  147490. /**
  147491. * Enable or disable the sharpen process from the pipeline
  147492. */
  147493. set sharpenEnabled(enabled: boolean);
  147494. get sharpenEnabled(): boolean;
  147495. private _resizeObserver;
  147496. private _hardwareScaleLevel;
  147497. private _bloomKernel;
  147498. /**
  147499. * Specifies the size of the bloom blur kernel, relative to the final output size
  147500. */
  147501. get bloomKernel(): number;
  147502. set bloomKernel(value: number);
  147503. /**
  147504. * Specifies the weight of the bloom in the final rendering
  147505. */
  147506. private _bloomWeight;
  147507. /**
  147508. * Specifies the luma threshold for the area that will be blurred by the bloom
  147509. */
  147510. private _bloomThreshold;
  147511. private _hdr;
  147512. /**
  147513. * The strength of the bloom.
  147514. */
  147515. set bloomWeight(value: number);
  147516. get bloomWeight(): number;
  147517. /**
  147518. * The strength of the bloom.
  147519. */
  147520. set bloomThreshold(value: number);
  147521. get bloomThreshold(): number;
  147522. /**
  147523. * The scale of the bloom, lower value will provide better performance.
  147524. */
  147525. set bloomScale(value: number);
  147526. get bloomScale(): number;
  147527. /**
  147528. * Enable or disable the bloom from the pipeline
  147529. */
  147530. set bloomEnabled(enabled: boolean);
  147531. get bloomEnabled(): boolean;
  147532. private _rebuildBloom;
  147533. /**
  147534. * If the depth of field is enabled.
  147535. */
  147536. get depthOfFieldEnabled(): boolean;
  147537. set depthOfFieldEnabled(enabled: boolean);
  147538. /**
  147539. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147540. */
  147541. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147542. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147543. /**
  147544. * If the anti aliasing is enabled.
  147545. */
  147546. set fxaaEnabled(enabled: boolean);
  147547. get fxaaEnabled(): boolean;
  147548. private _samples;
  147549. /**
  147550. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147551. */
  147552. set samples(sampleCount: number);
  147553. get samples(): number;
  147554. /**
  147555. * If image processing is enabled.
  147556. */
  147557. set imageProcessingEnabled(enabled: boolean);
  147558. get imageProcessingEnabled(): boolean;
  147559. /**
  147560. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147561. */
  147562. set glowLayerEnabled(enabled: boolean);
  147563. get glowLayerEnabled(): boolean;
  147564. /**
  147565. * Gets the glow layer (or null if not defined)
  147566. */
  147567. get glowLayer(): Nullable<GlowLayer>;
  147568. /**
  147569. * Enable or disable the chromaticAberration process from the pipeline
  147570. */
  147571. set chromaticAberrationEnabled(enabled: boolean);
  147572. get chromaticAberrationEnabled(): boolean;
  147573. /**
  147574. * Enable or disable the grain process from the pipeline
  147575. */
  147576. set grainEnabled(enabled: boolean);
  147577. get grainEnabled(): boolean;
  147578. /**
  147579. * @constructor
  147580. * @param name - The rendering pipeline name (default: "")
  147581. * @param hdr - If high dynamic range textures should be used (default: true)
  147582. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147583. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147584. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147585. */
  147586. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147587. /**
  147588. * Get the class name
  147589. * @returns "DefaultRenderingPipeline"
  147590. */
  147591. getClassName(): string;
  147592. /**
  147593. * Force the compilation of the entire pipeline.
  147594. */
  147595. prepare(): void;
  147596. private _hasCleared;
  147597. private _prevPostProcess;
  147598. private _prevPrevPostProcess;
  147599. private _setAutoClearAndTextureSharing;
  147600. private _depthOfFieldSceneObserver;
  147601. private _buildPipeline;
  147602. private _disposePostProcesses;
  147603. /**
  147604. * Adds a camera to the pipeline
  147605. * @param camera the camera to be added
  147606. */
  147607. addCamera(camera: Camera): void;
  147608. /**
  147609. * Removes a camera from the pipeline
  147610. * @param camera the camera to remove
  147611. */
  147612. removeCamera(camera: Camera): void;
  147613. /**
  147614. * Dispose of the pipeline and stop all post processes
  147615. */
  147616. dispose(): void;
  147617. /**
  147618. * Serialize the rendering pipeline (Used when exporting)
  147619. * @returns the serialized object
  147620. */
  147621. serialize(): any;
  147622. /**
  147623. * Parse the serialized pipeline
  147624. * @param source Source pipeline.
  147625. * @param scene The scene to load the pipeline to.
  147626. * @param rootUrl The URL of the serialized pipeline.
  147627. * @returns An instantiated pipeline from the serialized object.
  147628. */
  147629. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147630. }
  147631. }
  147632. declare module BABYLON {
  147633. /** @hidden */
  147634. export var lensHighlightsPixelShader: {
  147635. name: string;
  147636. shader: string;
  147637. };
  147638. }
  147639. declare module BABYLON {
  147640. /** @hidden */
  147641. export var depthOfFieldPixelShader: {
  147642. name: string;
  147643. shader: string;
  147644. };
  147645. }
  147646. declare module BABYLON {
  147647. /**
  147648. * BABYLON.JS Chromatic Aberration GLSL Shader
  147649. * Author: Olivier Guyot
  147650. * Separates very slightly R, G and B colors on the edges of the screen
  147651. * Inspired by Francois Tarlier & Martins Upitis
  147652. */
  147653. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147654. /**
  147655. * @ignore
  147656. * The chromatic aberration PostProcess id in the pipeline
  147657. */
  147658. LensChromaticAberrationEffect: string;
  147659. /**
  147660. * @ignore
  147661. * The highlights enhancing PostProcess id in the pipeline
  147662. */
  147663. HighlightsEnhancingEffect: string;
  147664. /**
  147665. * @ignore
  147666. * The depth-of-field PostProcess id in the pipeline
  147667. */
  147668. LensDepthOfFieldEffect: string;
  147669. private _scene;
  147670. private _depthTexture;
  147671. private _grainTexture;
  147672. private _chromaticAberrationPostProcess;
  147673. private _highlightsPostProcess;
  147674. private _depthOfFieldPostProcess;
  147675. private _edgeBlur;
  147676. private _grainAmount;
  147677. private _chromaticAberration;
  147678. private _distortion;
  147679. private _highlightsGain;
  147680. private _highlightsThreshold;
  147681. private _dofDistance;
  147682. private _dofAperture;
  147683. private _dofDarken;
  147684. private _dofPentagon;
  147685. private _blurNoise;
  147686. /**
  147687. * @constructor
  147688. *
  147689. * Effect parameters are as follow:
  147690. * {
  147691. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147692. * edge_blur: number; // from 0 to x (1 for realism)
  147693. * distortion: number; // from 0 to x (1 for realism)
  147694. * grain_amount: number; // from 0 to 1
  147695. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147696. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147697. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147698. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147699. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147700. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147701. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147702. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147703. * }
  147704. * Note: if an effect parameter is unset, effect is disabled
  147705. *
  147706. * @param name The rendering pipeline name
  147707. * @param parameters - An object containing all parameters (see above)
  147708. * @param scene The scene linked to this pipeline
  147709. * @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)
  147710. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147711. */
  147712. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147713. /**
  147714. * Get the class name
  147715. * @returns "LensRenderingPipeline"
  147716. */
  147717. getClassName(): string;
  147718. /**
  147719. * Gets associated scene
  147720. */
  147721. get scene(): Scene;
  147722. /**
  147723. * Gets or sets the edge blur
  147724. */
  147725. get edgeBlur(): number;
  147726. set edgeBlur(value: number);
  147727. /**
  147728. * Gets or sets the grain amount
  147729. */
  147730. get grainAmount(): number;
  147731. set grainAmount(value: number);
  147732. /**
  147733. * Gets or sets the chromatic aberration amount
  147734. */
  147735. get chromaticAberration(): number;
  147736. set chromaticAberration(value: number);
  147737. /**
  147738. * Gets or sets the depth of field aperture
  147739. */
  147740. get dofAperture(): number;
  147741. set dofAperture(value: number);
  147742. /**
  147743. * Gets or sets the edge distortion
  147744. */
  147745. get edgeDistortion(): number;
  147746. set edgeDistortion(value: number);
  147747. /**
  147748. * Gets or sets the depth of field distortion
  147749. */
  147750. get dofDistortion(): number;
  147751. set dofDistortion(value: number);
  147752. /**
  147753. * Gets or sets the darken out of focus amount
  147754. */
  147755. get darkenOutOfFocus(): number;
  147756. set darkenOutOfFocus(value: number);
  147757. /**
  147758. * Gets or sets a boolean indicating if blur noise is enabled
  147759. */
  147760. get blurNoise(): boolean;
  147761. set blurNoise(value: boolean);
  147762. /**
  147763. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147764. */
  147765. get pentagonBokeh(): boolean;
  147766. set pentagonBokeh(value: boolean);
  147767. /**
  147768. * Gets or sets the highlight grain amount
  147769. */
  147770. get highlightsGain(): number;
  147771. set highlightsGain(value: number);
  147772. /**
  147773. * Gets or sets the highlight threshold
  147774. */
  147775. get highlightsThreshold(): number;
  147776. set highlightsThreshold(value: number);
  147777. /**
  147778. * Sets the amount of blur at the edges
  147779. * @param amount blur amount
  147780. */
  147781. setEdgeBlur(amount: number): void;
  147782. /**
  147783. * Sets edge blur to 0
  147784. */
  147785. disableEdgeBlur(): void;
  147786. /**
  147787. * Sets the amout of grain
  147788. * @param amount Amount of grain
  147789. */
  147790. setGrainAmount(amount: number): void;
  147791. /**
  147792. * Set grain amount to 0
  147793. */
  147794. disableGrain(): void;
  147795. /**
  147796. * Sets the chromatic aberration amount
  147797. * @param amount amount of chromatic aberration
  147798. */
  147799. setChromaticAberration(amount: number): void;
  147800. /**
  147801. * Sets chromatic aberration amount to 0
  147802. */
  147803. disableChromaticAberration(): void;
  147804. /**
  147805. * Sets the EdgeDistortion amount
  147806. * @param amount amount of EdgeDistortion
  147807. */
  147808. setEdgeDistortion(amount: number): void;
  147809. /**
  147810. * Sets edge distortion to 0
  147811. */
  147812. disableEdgeDistortion(): void;
  147813. /**
  147814. * Sets the FocusDistance amount
  147815. * @param amount amount of FocusDistance
  147816. */
  147817. setFocusDistance(amount: number): void;
  147818. /**
  147819. * Disables depth of field
  147820. */
  147821. disableDepthOfField(): void;
  147822. /**
  147823. * Sets the Aperture amount
  147824. * @param amount amount of Aperture
  147825. */
  147826. setAperture(amount: number): void;
  147827. /**
  147828. * Sets the DarkenOutOfFocus amount
  147829. * @param amount amount of DarkenOutOfFocus
  147830. */
  147831. setDarkenOutOfFocus(amount: number): void;
  147832. private _pentagonBokehIsEnabled;
  147833. /**
  147834. * Creates a pentagon bokeh effect
  147835. */
  147836. enablePentagonBokeh(): void;
  147837. /**
  147838. * Disables the pentagon bokeh effect
  147839. */
  147840. disablePentagonBokeh(): void;
  147841. /**
  147842. * Enables noise blur
  147843. */
  147844. enableNoiseBlur(): void;
  147845. /**
  147846. * Disables noise blur
  147847. */
  147848. disableNoiseBlur(): void;
  147849. /**
  147850. * Sets the HighlightsGain amount
  147851. * @param amount amount of HighlightsGain
  147852. */
  147853. setHighlightsGain(amount: number): void;
  147854. /**
  147855. * Sets the HighlightsThreshold amount
  147856. * @param amount amount of HighlightsThreshold
  147857. */
  147858. setHighlightsThreshold(amount: number): void;
  147859. /**
  147860. * Disables highlights
  147861. */
  147862. disableHighlights(): void;
  147863. /**
  147864. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147865. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147866. */
  147867. dispose(disableDepthRender?: boolean): void;
  147868. private _createChromaticAberrationPostProcess;
  147869. private _createHighlightsPostProcess;
  147870. private _createDepthOfFieldPostProcess;
  147871. private _createGrainTexture;
  147872. }
  147873. }
  147874. declare module BABYLON {
  147875. /** @hidden */
  147876. export var ssao2PixelShader: {
  147877. name: string;
  147878. shader: string;
  147879. };
  147880. }
  147881. declare module BABYLON {
  147882. /** @hidden */
  147883. export var ssaoCombinePixelShader: {
  147884. name: string;
  147885. shader: string;
  147886. };
  147887. }
  147888. declare module BABYLON {
  147889. /**
  147890. * Render pipeline to produce ssao effect
  147891. */
  147892. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147893. /**
  147894. * @ignore
  147895. * The PassPostProcess id in the pipeline that contains the original scene color
  147896. */
  147897. SSAOOriginalSceneColorEffect: string;
  147898. /**
  147899. * @ignore
  147900. * The SSAO PostProcess id in the pipeline
  147901. */
  147902. SSAORenderEffect: string;
  147903. /**
  147904. * @ignore
  147905. * The horizontal blur PostProcess id in the pipeline
  147906. */
  147907. SSAOBlurHRenderEffect: string;
  147908. /**
  147909. * @ignore
  147910. * The vertical blur PostProcess id in the pipeline
  147911. */
  147912. SSAOBlurVRenderEffect: string;
  147913. /**
  147914. * @ignore
  147915. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147916. */
  147917. SSAOCombineRenderEffect: string;
  147918. /**
  147919. * The output strength of the SSAO post-process. Default value is 1.0.
  147920. */
  147921. totalStrength: number;
  147922. /**
  147923. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147924. */
  147925. maxZ: number;
  147926. /**
  147927. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147928. */
  147929. minZAspect: number;
  147930. private _samples;
  147931. /**
  147932. * Number of samples used for the SSAO calculations. Default value is 8
  147933. */
  147934. set samples(n: number);
  147935. get samples(): number;
  147936. private _textureSamples;
  147937. /**
  147938. * Number of samples to use for antialiasing
  147939. */
  147940. set textureSamples(n: number);
  147941. get textureSamples(): number;
  147942. /**
  147943. * Ratio object used for SSAO ratio and blur ratio
  147944. */
  147945. private _ratio;
  147946. /**
  147947. * Dynamically generated sphere sampler.
  147948. */
  147949. private _sampleSphere;
  147950. /**
  147951. * Blur filter offsets
  147952. */
  147953. private _samplerOffsets;
  147954. private _expensiveBlur;
  147955. /**
  147956. * If bilateral blur should be used
  147957. */
  147958. set expensiveBlur(b: boolean);
  147959. get expensiveBlur(): boolean;
  147960. /**
  147961. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147962. */
  147963. radius: number;
  147964. /**
  147965. * The base color of the SSAO post-process
  147966. * The final result is "base + ssao" between [0, 1]
  147967. */
  147968. base: number;
  147969. /**
  147970. * Support test.
  147971. */
  147972. static get IsSupported(): boolean;
  147973. private _scene;
  147974. private _depthTexture;
  147975. private _normalTexture;
  147976. private _randomTexture;
  147977. private _originalColorPostProcess;
  147978. private _ssaoPostProcess;
  147979. private _blurHPostProcess;
  147980. private _blurVPostProcess;
  147981. private _ssaoCombinePostProcess;
  147982. /**
  147983. * Gets active scene
  147984. */
  147985. get scene(): Scene;
  147986. /**
  147987. * @constructor
  147988. * @param name The rendering pipeline name
  147989. * @param scene The scene linked to this pipeline
  147990. * @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 }
  147991. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147992. */
  147993. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147994. /**
  147995. * Get the class name
  147996. * @returns "SSAO2RenderingPipeline"
  147997. */
  147998. getClassName(): string;
  147999. /**
  148000. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148001. */
  148002. dispose(disableGeometryBufferRenderer?: boolean): void;
  148003. private _createBlurPostProcess;
  148004. /** @hidden */
  148005. _rebuild(): void;
  148006. private _bits;
  148007. private _radicalInverse_VdC;
  148008. private _hammersley;
  148009. private _hemisphereSample_uniform;
  148010. private _generateHemisphere;
  148011. private _createSSAOPostProcess;
  148012. private _createSSAOCombinePostProcess;
  148013. private _createRandomTexture;
  148014. /**
  148015. * Serialize the rendering pipeline (Used when exporting)
  148016. * @returns the serialized object
  148017. */
  148018. serialize(): any;
  148019. /**
  148020. * Parse the serialized pipeline
  148021. * @param source Source pipeline.
  148022. * @param scene The scene to load the pipeline to.
  148023. * @param rootUrl The URL of the serialized pipeline.
  148024. * @returns An instantiated pipeline from the serialized object.
  148025. */
  148026. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148027. }
  148028. }
  148029. declare module BABYLON {
  148030. /** @hidden */
  148031. export var ssaoPixelShader: {
  148032. name: string;
  148033. shader: string;
  148034. };
  148035. }
  148036. declare module BABYLON {
  148037. /**
  148038. * Render pipeline to produce ssao effect
  148039. */
  148040. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148041. /**
  148042. * @ignore
  148043. * The PassPostProcess id in the pipeline that contains the original scene color
  148044. */
  148045. SSAOOriginalSceneColorEffect: string;
  148046. /**
  148047. * @ignore
  148048. * The SSAO PostProcess id in the pipeline
  148049. */
  148050. SSAORenderEffect: string;
  148051. /**
  148052. * @ignore
  148053. * The horizontal blur PostProcess id in the pipeline
  148054. */
  148055. SSAOBlurHRenderEffect: string;
  148056. /**
  148057. * @ignore
  148058. * The vertical blur PostProcess id in the pipeline
  148059. */
  148060. SSAOBlurVRenderEffect: string;
  148061. /**
  148062. * @ignore
  148063. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148064. */
  148065. SSAOCombineRenderEffect: string;
  148066. /**
  148067. * The output strength of the SSAO post-process. Default value is 1.0.
  148068. */
  148069. totalStrength: number;
  148070. /**
  148071. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148072. */
  148073. radius: number;
  148074. /**
  148075. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148076. * Must not be equal to fallOff and superior to fallOff.
  148077. * Default value is 0.0075
  148078. */
  148079. area: number;
  148080. /**
  148081. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148082. * Must not be equal to area and inferior to area.
  148083. * Default value is 0.000001
  148084. */
  148085. fallOff: number;
  148086. /**
  148087. * The base color of the SSAO post-process
  148088. * The final result is "base + ssao" between [0, 1]
  148089. */
  148090. base: number;
  148091. private _scene;
  148092. private _depthTexture;
  148093. private _randomTexture;
  148094. private _originalColorPostProcess;
  148095. private _ssaoPostProcess;
  148096. private _blurHPostProcess;
  148097. private _blurVPostProcess;
  148098. private _ssaoCombinePostProcess;
  148099. private _firstUpdate;
  148100. /**
  148101. * Gets active scene
  148102. */
  148103. get scene(): Scene;
  148104. /**
  148105. * @constructor
  148106. * @param name - The rendering pipeline name
  148107. * @param scene - The scene linked to this pipeline
  148108. * @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 }
  148109. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148110. */
  148111. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148112. /**
  148113. * Get the class name
  148114. * @returns "SSAORenderingPipeline"
  148115. */
  148116. getClassName(): string;
  148117. /**
  148118. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148119. */
  148120. dispose(disableDepthRender?: boolean): void;
  148121. private _createBlurPostProcess;
  148122. /** @hidden */
  148123. _rebuild(): void;
  148124. private _createSSAOPostProcess;
  148125. private _createSSAOCombinePostProcess;
  148126. private _createRandomTexture;
  148127. }
  148128. }
  148129. declare module BABYLON {
  148130. /** @hidden */
  148131. export var screenSpaceReflectionPixelShader: {
  148132. name: string;
  148133. shader: string;
  148134. };
  148135. }
  148136. declare module BABYLON {
  148137. /**
  148138. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148139. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148140. */
  148141. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148142. /**
  148143. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148144. */
  148145. threshold: number;
  148146. /**
  148147. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148148. */
  148149. strength: number;
  148150. /**
  148151. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148152. */
  148153. reflectionSpecularFalloffExponent: number;
  148154. /**
  148155. * 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]
  148156. */
  148157. step: number;
  148158. /**
  148159. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148160. */
  148161. roughnessFactor: number;
  148162. private _geometryBufferRenderer;
  148163. private _enableSmoothReflections;
  148164. private _reflectionSamples;
  148165. private _smoothSteps;
  148166. /**
  148167. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148168. * @param name The name of the effect.
  148169. * @param scene The scene containing the objects to calculate reflections.
  148170. * @param options The required width/height ratio to downsize to before computing the render pass.
  148171. * @param camera The camera to apply the render pass to.
  148172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148173. * @param engine The engine which the post process will be applied. (default: current engine)
  148174. * @param reusable If the post process can be reused on the same frame. (default: false)
  148175. * @param textureType Type of textures used when performing the post process. (default: 0)
  148176. * @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)
  148177. */
  148178. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148179. /**
  148180. * Gets wether or not smoothing reflections is enabled.
  148181. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148182. */
  148183. get enableSmoothReflections(): boolean;
  148184. /**
  148185. * Sets wether or not smoothing reflections is enabled.
  148186. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148187. */
  148188. set enableSmoothReflections(enabled: boolean);
  148189. /**
  148190. * Gets the number of samples taken while computing reflections. More samples count is high,
  148191. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148192. */
  148193. get reflectionSamples(): number;
  148194. /**
  148195. * Sets the number of samples taken while computing reflections. More samples count is high,
  148196. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148197. */
  148198. set reflectionSamples(samples: number);
  148199. /**
  148200. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148201. * more the post-process will require GPU power and can generate a drop in FPS.
  148202. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148203. */
  148204. get smoothSteps(): number;
  148205. set smoothSteps(steps: number);
  148206. private _updateEffectDefines;
  148207. }
  148208. }
  148209. declare module BABYLON {
  148210. /** @hidden */
  148211. export var standardPixelShader: {
  148212. name: string;
  148213. shader: string;
  148214. };
  148215. }
  148216. declare module BABYLON {
  148217. /**
  148218. * Standard rendering pipeline
  148219. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148220. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148221. */
  148222. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148223. /**
  148224. * Public members
  148225. */
  148226. /**
  148227. * Post-process which contains the original scene color before the pipeline applies all the effects
  148228. */
  148229. originalPostProcess: Nullable<PostProcess>;
  148230. /**
  148231. * Post-process used to down scale an image x4
  148232. */
  148233. downSampleX4PostProcess: Nullable<PostProcess>;
  148234. /**
  148235. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148236. */
  148237. brightPassPostProcess: Nullable<PostProcess>;
  148238. /**
  148239. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148240. */
  148241. blurHPostProcesses: PostProcess[];
  148242. /**
  148243. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148244. */
  148245. blurVPostProcesses: PostProcess[];
  148246. /**
  148247. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148248. */
  148249. textureAdderPostProcess: Nullable<PostProcess>;
  148250. /**
  148251. * Post-process used to create volumetric lighting effect
  148252. */
  148253. volumetricLightPostProcess: Nullable<PostProcess>;
  148254. /**
  148255. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148256. */
  148257. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148258. /**
  148259. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148260. */
  148261. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148262. /**
  148263. * Post-process used to merge the volumetric light effect and the real scene color
  148264. */
  148265. volumetricLightMergePostProces: Nullable<PostProcess>;
  148266. /**
  148267. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148268. */
  148269. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148270. /**
  148271. * Base post-process used to calculate the average luminance of the final image for HDR
  148272. */
  148273. luminancePostProcess: Nullable<PostProcess>;
  148274. /**
  148275. * Post-processes used to create down sample post-processes in order to get
  148276. * the average luminance of the final image for HDR
  148277. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148278. */
  148279. luminanceDownSamplePostProcesses: PostProcess[];
  148280. /**
  148281. * Post-process used to create a HDR effect (light adaptation)
  148282. */
  148283. hdrPostProcess: Nullable<PostProcess>;
  148284. /**
  148285. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148286. */
  148287. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148288. /**
  148289. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148290. */
  148291. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148292. /**
  148293. * Post-process used to merge the final HDR post-process and the real scene color
  148294. */
  148295. hdrFinalPostProcess: Nullable<PostProcess>;
  148296. /**
  148297. * Post-process used to create a lens flare effect
  148298. */
  148299. lensFlarePostProcess: Nullable<PostProcess>;
  148300. /**
  148301. * Post-process that merges the result of the lens flare post-process and the real scene color
  148302. */
  148303. lensFlareComposePostProcess: Nullable<PostProcess>;
  148304. /**
  148305. * Post-process used to create a motion blur effect
  148306. */
  148307. motionBlurPostProcess: Nullable<PostProcess>;
  148308. /**
  148309. * Post-process used to create a depth of field effect
  148310. */
  148311. depthOfFieldPostProcess: Nullable<PostProcess>;
  148312. /**
  148313. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148314. */
  148315. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148316. /**
  148317. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148318. */
  148319. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148320. /**
  148321. * Represents the brightness threshold in order to configure the illuminated surfaces
  148322. */
  148323. brightThreshold: number;
  148324. /**
  148325. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148326. */
  148327. blurWidth: number;
  148328. /**
  148329. * Sets if the blur for highlighted surfaces must be only horizontal
  148330. */
  148331. horizontalBlur: boolean;
  148332. /**
  148333. * Gets the overall exposure used by the pipeline
  148334. */
  148335. get exposure(): number;
  148336. /**
  148337. * Sets the overall exposure used by the pipeline
  148338. */
  148339. set exposure(value: number);
  148340. /**
  148341. * Texture used typically to simulate "dirty" on camera lens
  148342. */
  148343. lensTexture: Nullable<Texture>;
  148344. /**
  148345. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148346. */
  148347. volumetricLightCoefficient: number;
  148348. /**
  148349. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148350. */
  148351. volumetricLightPower: number;
  148352. /**
  148353. * Used the set the blur intensity to smooth the volumetric lights
  148354. */
  148355. volumetricLightBlurScale: number;
  148356. /**
  148357. * Light (spot or directional) used to generate the volumetric lights rays
  148358. * The source light must have a shadow generate so the pipeline can get its
  148359. * depth map
  148360. */
  148361. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148362. /**
  148363. * For eye adaptation, represents the minimum luminance the eye can see
  148364. */
  148365. hdrMinimumLuminance: number;
  148366. /**
  148367. * For eye adaptation, represents the decrease luminance speed
  148368. */
  148369. hdrDecreaseRate: number;
  148370. /**
  148371. * For eye adaptation, represents the increase luminance speed
  148372. */
  148373. hdrIncreaseRate: number;
  148374. /**
  148375. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148376. */
  148377. get hdrAutoExposure(): boolean;
  148378. /**
  148379. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148380. */
  148381. set hdrAutoExposure(value: boolean);
  148382. /**
  148383. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148384. */
  148385. lensColorTexture: Nullable<Texture>;
  148386. /**
  148387. * The overall strengh for the lens flare effect
  148388. */
  148389. lensFlareStrength: number;
  148390. /**
  148391. * Dispersion coefficient for lens flare ghosts
  148392. */
  148393. lensFlareGhostDispersal: number;
  148394. /**
  148395. * Main lens flare halo width
  148396. */
  148397. lensFlareHaloWidth: number;
  148398. /**
  148399. * Based on the lens distortion effect, defines how much the lens flare result
  148400. * is distorted
  148401. */
  148402. lensFlareDistortionStrength: number;
  148403. /**
  148404. * Configures the blur intensity used for for lens flare (halo)
  148405. */
  148406. lensFlareBlurWidth: number;
  148407. /**
  148408. * Lens star texture must be used to simulate rays on the flares and is available
  148409. * in the documentation
  148410. */
  148411. lensStarTexture: Nullable<Texture>;
  148412. /**
  148413. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148414. * flare effect by taking account of the dirt texture
  148415. */
  148416. lensFlareDirtTexture: Nullable<Texture>;
  148417. /**
  148418. * Represents the focal length for the depth of field effect
  148419. */
  148420. depthOfFieldDistance: number;
  148421. /**
  148422. * Represents the blur intensity for the blurred part of the depth of field effect
  148423. */
  148424. depthOfFieldBlurWidth: number;
  148425. /**
  148426. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148427. */
  148428. get motionStrength(): number;
  148429. /**
  148430. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148431. */
  148432. set motionStrength(strength: number);
  148433. /**
  148434. * Gets wether or not the motion blur post-process is object based or screen based.
  148435. */
  148436. get objectBasedMotionBlur(): boolean;
  148437. /**
  148438. * Sets wether or not the motion blur post-process should be object based or screen based
  148439. */
  148440. set objectBasedMotionBlur(value: boolean);
  148441. /**
  148442. * List of animations for the pipeline (IAnimatable implementation)
  148443. */
  148444. animations: Animation[];
  148445. /**
  148446. * Private members
  148447. */
  148448. private _scene;
  148449. private _currentDepthOfFieldSource;
  148450. private _basePostProcess;
  148451. private _fixedExposure;
  148452. private _currentExposure;
  148453. private _hdrAutoExposure;
  148454. private _hdrCurrentLuminance;
  148455. private _motionStrength;
  148456. private _isObjectBasedMotionBlur;
  148457. private _floatTextureType;
  148458. private _camerasToBeAttached;
  148459. private _ratio;
  148460. private _bloomEnabled;
  148461. private _depthOfFieldEnabled;
  148462. private _vlsEnabled;
  148463. private _lensFlareEnabled;
  148464. private _hdrEnabled;
  148465. private _motionBlurEnabled;
  148466. private _fxaaEnabled;
  148467. private _screenSpaceReflectionsEnabled;
  148468. private _motionBlurSamples;
  148469. private _volumetricLightStepsCount;
  148470. private _samples;
  148471. /**
  148472. * @ignore
  148473. * Specifies if the bloom pipeline is enabled
  148474. */
  148475. get BloomEnabled(): boolean;
  148476. set BloomEnabled(enabled: boolean);
  148477. /**
  148478. * @ignore
  148479. * Specifies if the depth of field pipeline is enabed
  148480. */
  148481. get DepthOfFieldEnabled(): boolean;
  148482. set DepthOfFieldEnabled(enabled: boolean);
  148483. /**
  148484. * @ignore
  148485. * Specifies if the lens flare pipeline is enabed
  148486. */
  148487. get LensFlareEnabled(): boolean;
  148488. set LensFlareEnabled(enabled: boolean);
  148489. /**
  148490. * @ignore
  148491. * Specifies if the HDR pipeline is enabled
  148492. */
  148493. get HDREnabled(): boolean;
  148494. set HDREnabled(enabled: boolean);
  148495. /**
  148496. * @ignore
  148497. * Specifies if the volumetric lights scattering effect is enabled
  148498. */
  148499. get VLSEnabled(): boolean;
  148500. set VLSEnabled(enabled: boolean);
  148501. /**
  148502. * @ignore
  148503. * Specifies if the motion blur effect is enabled
  148504. */
  148505. get MotionBlurEnabled(): boolean;
  148506. set MotionBlurEnabled(enabled: boolean);
  148507. /**
  148508. * Specifies if anti-aliasing is enabled
  148509. */
  148510. get fxaaEnabled(): boolean;
  148511. set fxaaEnabled(enabled: boolean);
  148512. /**
  148513. * Specifies if screen space reflections are enabled.
  148514. */
  148515. get screenSpaceReflectionsEnabled(): boolean;
  148516. set screenSpaceReflectionsEnabled(enabled: boolean);
  148517. /**
  148518. * Specifies the number of steps used to calculate the volumetric lights
  148519. * Typically in interval [50, 200]
  148520. */
  148521. get volumetricLightStepsCount(): number;
  148522. set volumetricLightStepsCount(count: number);
  148523. /**
  148524. * Specifies the number of samples used for the motion blur effect
  148525. * Typically in interval [16, 64]
  148526. */
  148527. get motionBlurSamples(): number;
  148528. set motionBlurSamples(samples: number);
  148529. /**
  148530. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148531. */
  148532. get samples(): number;
  148533. set samples(sampleCount: number);
  148534. /**
  148535. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148536. * @constructor
  148537. * @param name The rendering pipeline name
  148538. * @param scene The scene linked to this pipeline
  148539. * @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)
  148540. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148541. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148542. */
  148543. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148544. private _buildPipeline;
  148545. private _createDownSampleX4PostProcess;
  148546. private _createBrightPassPostProcess;
  148547. private _createBlurPostProcesses;
  148548. private _createTextureAdderPostProcess;
  148549. private _createVolumetricLightPostProcess;
  148550. private _createLuminancePostProcesses;
  148551. private _createHdrPostProcess;
  148552. private _createLensFlarePostProcess;
  148553. private _createDepthOfFieldPostProcess;
  148554. private _createMotionBlurPostProcess;
  148555. private _getDepthTexture;
  148556. private _disposePostProcesses;
  148557. /**
  148558. * Dispose of the pipeline and stop all post processes
  148559. */
  148560. dispose(): void;
  148561. /**
  148562. * Serialize the rendering pipeline (Used when exporting)
  148563. * @returns the serialized object
  148564. */
  148565. serialize(): any;
  148566. /**
  148567. * Parse the serialized pipeline
  148568. * @param source Source pipeline.
  148569. * @param scene The scene to load the pipeline to.
  148570. * @param rootUrl The URL of the serialized pipeline.
  148571. * @returns An instantiated pipeline from the serialized object.
  148572. */
  148573. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  148574. /**
  148575. * Luminance steps
  148576. */
  148577. static LuminanceSteps: number;
  148578. }
  148579. }
  148580. declare module BABYLON {
  148581. /** @hidden */
  148582. export var stereoscopicInterlacePixelShader: {
  148583. name: string;
  148584. shader: string;
  148585. };
  148586. }
  148587. declare module BABYLON {
  148588. /**
  148589. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  148590. */
  148591. export class StereoscopicInterlacePostProcessI extends PostProcess {
  148592. private _stepSize;
  148593. private _passedProcess;
  148594. /**
  148595. * Initializes a StereoscopicInterlacePostProcessI
  148596. * @param name The name of the effect.
  148597. * @param rigCameras The rig cameras to be appled to the post process
  148598. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  148599. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  148600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148601. * @param engine The engine which the post process will be applied. (default: current engine)
  148602. * @param reusable If the post process can be reused on the same frame. (default: false)
  148603. */
  148604. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148605. }
  148606. /**
  148607. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  148608. */
  148609. export class StereoscopicInterlacePostProcess extends PostProcess {
  148610. private _stepSize;
  148611. private _passedProcess;
  148612. /**
  148613. * Initializes a StereoscopicInterlacePostProcess
  148614. * @param name The name of the effect.
  148615. * @param rigCameras The rig cameras to be appled to the post process
  148616. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  148617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148618. * @param engine The engine which the post process will be applied. (default: current engine)
  148619. * @param reusable If the post process can be reused on the same frame. (default: false)
  148620. */
  148621. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148622. }
  148623. }
  148624. declare module BABYLON {
  148625. /** @hidden */
  148626. export var tonemapPixelShader: {
  148627. name: string;
  148628. shader: string;
  148629. };
  148630. }
  148631. declare module BABYLON {
  148632. /** Defines operator used for tonemapping */
  148633. export enum TonemappingOperator {
  148634. /** Hable */
  148635. Hable = 0,
  148636. /** Reinhard */
  148637. Reinhard = 1,
  148638. /** HejiDawson */
  148639. HejiDawson = 2,
  148640. /** Photographic */
  148641. Photographic = 3
  148642. }
  148643. /**
  148644. * Defines a post process to apply tone mapping
  148645. */
  148646. export class TonemapPostProcess extends PostProcess {
  148647. private _operator;
  148648. /** Defines the required exposure adjustement */
  148649. exposureAdjustment: number;
  148650. /**
  148651. * Creates a new TonemapPostProcess
  148652. * @param name defines the name of the postprocess
  148653. * @param _operator defines the operator to use
  148654. * @param exposureAdjustment defines the required exposure adjustement
  148655. * @param camera defines the camera to use (can be null)
  148656. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  148657. * @param engine defines the hosting engine (can be ignore if camera is set)
  148658. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  148659. */
  148660. constructor(name: string, _operator: TonemappingOperator,
  148661. /** Defines the required exposure adjustement */
  148662. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  148663. }
  148664. }
  148665. declare module BABYLON {
  148666. /** @hidden */
  148667. export var volumetricLightScatteringPixelShader: {
  148668. name: string;
  148669. shader: string;
  148670. };
  148671. }
  148672. declare module BABYLON {
  148673. /** @hidden */
  148674. export var volumetricLightScatteringPassVertexShader: {
  148675. name: string;
  148676. shader: string;
  148677. };
  148678. }
  148679. declare module BABYLON {
  148680. /** @hidden */
  148681. export var volumetricLightScatteringPassPixelShader: {
  148682. name: string;
  148683. shader: string;
  148684. };
  148685. }
  148686. declare module BABYLON {
  148687. /**
  148688. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  148689. */
  148690. export class VolumetricLightScatteringPostProcess extends PostProcess {
  148691. private _volumetricLightScatteringPass;
  148692. private _volumetricLightScatteringRTT;
  148693. private _viewPort;
  148694. private _screenCoordinates;
  148695. private _cachedDefines;
  148696. /**
  148697. * If not undefined, the mesh position is computed from the attached node position
  148698. */
  148699. attachedNode: {
  148700. position: Vector3;
  148701. };
  148702. /**
  148703. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  148704. */
  148705. customMeshPosition: Vector3;
  148706. /**
  148707. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  148708. */
  148709. useCustomMeshPosition: boolean;
  148710. /**
  148711. * If the post-process should inverse the light scattering direction
  148712. */
  148713. invert: boolean;
  148714. /**
  148715. * The internal mesh used by the post-process
  148716. */
  148717. mesh: Mesh;
  148718. /**
  148719. * @hidden
  148720. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  148721. */
  148722. get useDiffuseColor(): boolean;
  148723. set useDiffuseColor(useDiffuseColor: boolean);
  148724. /**
  148725. * Array containing the excluded meshes not rendered in the internal pass
  148726. */
  148727. excludedMeshes: AbstractMesh[];
  148728. /**
  148729. * Controls the overall intensity of the post-process
  148730. */
  148731. exposure: number;
  148732. /**
  148733. * Dissipates each sample's contribution in range [0, 1]
  148734. */
  148735. decay: number;
  148736. /**
  148737. * Controls the overall intensity of each sample
  148738. */
  148739. weight: number;
  148740. /**
  148741. * Controls the density of each sample
  148742. */
  148743. density: number;
  148744. /**
  148745. * @constructor
  148746. * @param name The post-process name
  148747. * @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)
  148748. * @param camera The camera that the post-process will be attached to
  148749. * @param mesh The mesh used to create the light scattering
  148750. * @param samples The post-process quality, default 100
  148751. * @param samplingModeThe post-process filtering mode
  148752. * @param engine The babylon engine
  148753. * @param reusable If the post-process is reusable
  148754. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148755. */
  148756. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148757. /**
  148758. * Returns the string "VolumetricLightScatteringPostProcess"
  148759. * @returns "VolumetricLightScatteringPostProcess"
  148760. */
  148761. getClassName(): string;
  148762. private _isReady;
  148763. /**
  148764. * Sets the new light position for light scattering effect
  148765. * @param position The new custom light position
  148766. */
  148767. setCustomMeshPosition(position: Vector3): void;
  148768. /**
  148769. * Returns the light position for light scattering effect
  148770. * @return Vector3 The custom light position
  148771. */
  148772. getCustomMeshPosition(): Vector3;
  148773. /**
  148774. * Disposes the internal assets and detaches the post-process from the camera
  148775. */
  148776. dispose(camera: Camera): void;
  148777. /**
  148778. * Returns the render target texture used by the post-process
  148779. * @return the render target texture used by the post-process
  148780. */
  148781. getPass(): RenderTargetTexture;
  148782. private _meshExcluded;
  148783. private _createPass;
  148784. private _updateMeshScreenCoordinates;
  148785. /**
  148786. * Creates a default mesh for the Volumeric Light Scattering post-process
  148787. * @param name The mesh name
  148788. * @param scene The scene where to create the mesh
  148789. * @return the default mesh
  148790. */
  148791. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148792. }
  148793. }
  148794. declare module BABYLON {
  148795. interface Scene {
  148796. /** @hidden (Backing field) */
  148797. _boundingBoxRenderer: BoundingBoxRenderer;
  148798. /** @hidden (Backing field) */
  148799. _forceShowBoundingBoxes: boolean;
  148800. /**
  148801. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148802. */
  148803. forceShowBoundingBoxes: boolean;
  148804. /**
  148805. * Gets the bounding box renderer associated with the scene
  148806. * @returns a BoundingBoxRenderer
  148807. */
  148808. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148809. }
  148810. interface AbstractMesh {
  148811. /** @hidden (Backing field) */
  148812. _showBoundingBox: boolean;
  148813. /**
  148814. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148815. */
  148816. showBoundingBox: boolean;
  148817. }
  148818. /**
  148819. * Component responsible of rendering the bounding box of the meshes in a scene.
  148820. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148821. */
  148822. export class BoundingBoxRenderer implements ISceneComponent {
  148823. /**
  148824. * The component name helpfull to identify the component in the list of scene components.
  148825. */
  148826. readonly name: string;
  148827. /**
  148828. * The scene the component belongs to.
  148829. */
  148830. scene: Scene;
  148831. /**
  148832. * Color of the bounding box lines placed in front of an object
  148833. */
  148834. frontColor: Color3;
  148835. /**
  148836. * Color of the bounding box lines placed behind an object
  148837. */
  148838. backColor: Color3;
  148839. /**
  148840. * Defines if the renderer should show the back lines or not
  148841. */
  148842. showBackLines: boolean;
  148843. /**
  148844. * Observable raised before rendering a bounding box
  148845. */
  148846. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148847. /**
  148848. * Observable raised after rendering a bounding box
  148849. */
  148850. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148851. /**
  148852. * @hidden
  148853. */
  148854. renderList: SmartArray<BoundingBox>;
  148855. private _colorShader;
  148856. private _vertexBuffers;
  148857. private _indexBuffer;
  148858. private _fillIndexBuffer;
  148859. private _fillIndexData;
  148860. /**
  148861. * Instantiates a new bounding box renderer in a scene.
  148862. * @param scene the scene the renderer renders in
  148863. */
  148864. constructor(scene: Scene);
  148865. /**
  148866. * Registers the component in a given scene
  148867. */
  148868. register(): void;
  148869. private _evaluateSubMesh;
  148870. private _activeMesh;
  148871. private _prepareRessources;
  148872. private _createIndexBuffer;
  148873. /**
  148874. * Rebuilds the elements related to this component in case of
  148875. * context lost for instance.
  148876. */
  148877. rebuild(): void;
  148878. /**
  148879. * @hidden
  148880. */
  148881. reset(): void;
  148882. /**
  148883. * Render the bounding boxes of a specific rendering group
  148884. * @param renderingGroupId defines the rendering group to render
  148885. */
  148886. render(renderingGroupId: number): void;
  148887. /**
  148888. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148889. * @param mesh Define the mesh to render the occlusion bounding box for
  148890. */
  148891. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148892. /**
  148893. * Dispose and release the resources attached to this renderer.
  148894. */
  148895. dispose(): void;
  148896. }
  148897. }
  148898. declare module BABYLON {
  148899. interface Scene {
  148900. /** @hidden (Backing field) */
  148901. _depthRenderer: {
  148902. [id: string]: DepthRenderer;
  148903. };
  148904. /**
  148905. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148906. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148907. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148908. * @returns the created depth renderer
  148909. */
  148910. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148911. /**
  148912. * Disables a depth renderer for a given camera
  148913. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148914. */
  148915. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148916. }
  148917. /**
  148918. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148919. * in several rendering techniques.
  148920. */
  148921. export class DepthRendererSceneComponent implements ISceneComponent {
  148922. /**
  148923. * The component name helpfull to identify the component in the list of scene components.
  148924. */
  148925. readonly name: string;
  148926. /**
  148927. * The scene the component belongs to.
  148928. */
  148929. scene: Scene;
  148930. /**
  148931. * Creates a new instance of the component for the given scene
  148932. * @param scene Defines the scene to register the component in
  148933. */
  148934. constructor(scene: Scene);
  148935. /**
  148936. * Registers the component in a given scene
  148937. */
  148938. register(): void;
  148939. /**
  148940. * Rebuilds the elements related to this component in case of
  148941. * context lost for instance.
  148942. */
  148943. rebuild(): void;
  148944. /**
  148945. * Disposes the component and the associated ressources
  148946. */
  148947. dispose(): void;
  148948. private _gatherRenderTargets;
  148949. private _gatherActiveCameraRenderTargets;
  148950. }
  148951. }
  148952. declare module BABYLON {
  148953. /** @hidden */
  148954. export var fibonacci: {
  148955. name: string;
  148956. shader: string;
  148957. };
  148958. }
  148959. declare module BABYLON {
  148960. /** @hidden */
  148961. export var diffusionProfile: {
  148962. name: string;
  148963. shader: string;
  148964. };
  148965. }
  148966. declare module BABYLON {
  148967. /** @hidden */
  148968. export var subSurfaceScatteringPixelShader: {
  148969. name: string;
  148970. shader: string;
  148971. };
  148972. }
  148973. declare module BABYLON {
  148974. /**
  148975. * Sub surface scattering post process
  148976. */
  148977. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148978. /** @hidden */
  148979. texelWidth: number;
  148980. /** @hidden */
  148981. texelHeight: number;
  148982. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148983. }
  148984. }
  148985. declare module BABYLON {
  148986. /**
  148987. * Contains all parameters needed for the prepass to perform
  148988. * screen space subsurface scattering
  148989. */
  148990. export class SubSurfaceConfiguration {
  148991. private _ssDiffusionS;
  148992. private _ssFilterRadii;
  148993. private _ssDiffusionD;
  148994. /**
  148995. * Diffusion profile color for subsurface scattering
  148996. */
  148997. get ssDiffusionS(): number[];
  148998. /**
  148999. * Diffusion profile max color channel value for subsurface scattering
  149000. */
  149001. get ssDiffusionD(): number[];
  149002. /**
  149003. * Diffusion profile filter radius for subsurface scattering
  149004. */
  149005. get ssFilterRadii(): number[];
  149006. /**
  149007. * Diffusion profile colors for subsurface scattering
  149008. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  149009. * See ...
  149010. * Note that you can only store up to 5 of them
  149011. */
  149012. ssDiffusionProfileColors: Color3[];
  149013. /**
  149014. * Defines the ratio real world => scene units.
  149015. * Used for subsurface scattering
  149016. */
  149017. metersPerUnit: number;
  149018. /**
  149019. * Builds a subsurface configuration object
  149020. * @param scene The scene
  149021. */
  149022. constructor();
  149023. /**
  149024. * Adds a new diffusion profile.
  149025. * Useful for more realistic subsurface scattering on diverse materials.
  149026. * @param color The color of the diffusion profile. Should be the average color of the material.
  149027. * @return The index of the diffusion profile for the material subsurface configuration
  149028. */
  149029. addDiffusionProfile(color: Color3): number;
  149030. /**
  149031. * Deletes all diffusion profiles.
  149032. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  149033. */
  149034. clearAllDiffusionProfiles(): void;
  149035. /**
  149036. * Disposes this object
  149037. */
  149038. dispose(): void;
  149039. /**
  149040. * @hidden
  149041. * https://zero-radiance.github.io/post/sampling-diffusion/
  149042. *
  149043. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  149044. * ------------------------------------------------------------------------------------
  149045. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  149046. * PDF[r, phi, s] = r * R[r, phi, s]
  149047. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  149048. * ------------------------------------------------------------------------------------
  149049. * We importance sample the color channel with the widest scattering distance.
  149050. */
  149051. getDiffusionProfileParameters(color: Color3): number;
  149052. /**
  149053. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  149054. * 'u' is the random number (the value of the CDF): [0, 1).
  149055. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  149056. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  149057. */
  149058. private _sampleBurleyDiffusionProfile;
  149059. }
  149060. }
  149061. declare module BABYLON {
  149062. /**
  149063. * Renders a pre pass of the scene
  149064. * This means every mesh in the scene will be rendered to a render target texture
  149065. * And then this texture will be composited to the rendering canvas with post processes
  149066. * It is necessary for effects like subsurface scattering or deferred shading
  149067. */
  149068. export class PrePassRenderer {
  149069. /** @hidden */
  149070. static _SceneComponentInitialization: (scene: Scene) => void;
  149071. private _scene;
  149072. private _engine;
  149073. private _isDirty;
  149074. /**
  149075. * Number of textures in the multi render target texture where the scene is directly rendered
  149076. */
  149077. readonly mrtCount: number;
  149078. /**
  149079. * The render target where the scene is directly rendered
  149080. */
  149081. prePassRT: MultiRenderTarget;
  149082. private _mrtTypes;
  149083. private _multiRenderAttachments;
  149084. private _defaultAttachments;
  149085. private _clearAttachments;
  149086. private readonly _clearColor;
  149087. /**
  149088. * Image processing post process for composition
  149089. */
  149090. imageProcessingPostProcess: ImageProcessingPostProcess;
  149091. /**
  149092. * Post process for subsurface scattering
  149093. */
  149094. subSurfaceScatteringPostProcess: SubSurfaceScatteringPostProcess;
  149095. /**
  149096. * Configuration for sub surface scattering post process
  149097. */
  149098. subSurfaceConfiguration: SubSurfaceConfiguration;
  149099. private _enabled;
  149100. /**
  149101. * Indicates if the prepass is enabled
  149102. */
  149103. get enabled(): boolean;
  149104. /**
  149105. * How many samples are used for MSAA of the scene render target
  149106. */
  149107. get samples(): number;
  149108. set samples(n: number);
  149109. /**
  149110. * Instanciates a prepass renderer
  149111. * @param scene The scene
  149112. */
  149113. constructor(scene: Scene);
  149114. private _initializeAttachments;
  149115. private _createEffects;
  149116. /**
  149117. * Indicates if rendering a prepass is supported
  149118. */
  149119. get isSupported(): boolean;
  149120. /**
  149121. * Sets the proper output textures to draw in the engine.
  149122. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  149123. */
  149124. bindAttachmentsForEffect(effect: Effect): void;
  149125. /**
  149126. * @hidden
  149127. */
  149128. _beforeCameraDraw(): void;
  149129. /**
  149130. * @hidden
  149131. */
  149132. _afterCameraDraw(): void;
  149133. private _checkRTSize;
  149134. private _bindFrameBuffer;
  149135. /**
  149136. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  149137. */
  149138. clear(): void;
  149139. private _setState;
  149140. private _enable;
  149141. private _disable;
  149142. /**
  149143. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  149144. */
  149145. markAsDirty(): void;
  149146. private _update;
  149147. /**
  149148. * Disposes the prepass renderer.
  149149. */
  149150. dispose(): void;
  149151. }
  149152. }
  149153. declare module BABYLON {
  149154. interface AbstractScene {
  149155. /** @hidden (Backing field) */
  149156. _prePassRenderer: Nullable<PrePassRenderer>;
  149157. /**
  149158. * Gets or Sets the current prepass renderer associated to the scene.
  149159. */
  149160. prePassRenderer: Nullable<PrePassRenderer>;
  149161. /**
  149162. * Enables the prepass and associates it with the scene
  149163. * @returns the PrePassRenderer
  149164. */
  149165. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149166. /**
  149167. * Disables the prepass associated with the scene
  149168. */
  149169. disablePrePassRenderer(): void;
  149170. }
  149171. /**
  149172. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149173. * in several rendering techniques.
  149174. */
  149175. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149176. /**
  149177. * The component name helpful to identify the component in the list of scene components.
  149178. */
  149179. readonly name: string;
  149180. /**
  149181. * The scene the component belongs to.
  149182. */
  149183. scene: Scene;
  149184. /**
  149185. * Creates a new instance of the component for the given scene
  149186. * @param scene Defines the scene to register the component in
  149187. */
  149188. constructor(scene: Scene);
  149189. /**
  149190. * Registers the component in a given scene
  149191. */
  149192. register(): void;
  149193. private _beforeCameraDraw;
  149194. private _afterCameraDraw;
  149195. private _beforeClearStage;
  149196. /**
  149197. * Serializes the component data to the specified json object
  149198. * @param serializationObject The object to serialize to
  149199. */
  149200. serialize(serializationObject: any): void;
  149201. /**
  149202. * Adds all the elements from the container to the scene
  149203. * @param container the container holding the elements
  149204. */
  149205. addFromContainer(container: AbstractScene): void;
  149206. /**
  149207. * Removes all the elements in the container from the scene
  149208. * @param container contains the elements to remove
  149209. * @param dispose if the removed element should be disposed (default: false)
  149210. */
  149211. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149212. /**
  149213. * Rebuilds the elements related to this component in case of
  149214. * context lost for instance.
  149215. */
  149216. rebuild(): void;
  149217. /**
  149218. * Disposes the component and the associated ressources
  149219. */
  149220. dispose(): void;
  149221. }
  149222. }
  149223. declare module BABYLON {
  149224. /** @hidden */
  149225. export var outlinePixelShader: {
  149226. name: string;
  149227. shader: string;
  149228. };
  149229. }
  149230. declare module BABYLON {
  149231. /** @hidden */
  149232. export var outlineVertexShader: {
  149233. name: string;
  149234. shader: string;
  149235. };
  149236. }
  149237. declare module BABYLON {
  149238. interface Scene {
  149239. /** @hidden */
  149240. _outlineRenderer: OutlineRenderer;
  149241. /**
  149242. * Gets the outline renderer associated with the scene
  149243. * @returns a OutlineRenderer
  149244. */
  149245. getOutlineRenderer(): OutlineRenderer;
  149246. }
  149247. interface AbstractMesh {
  149248. /** @hidden (Backing field) */
  149249. _renderOutline: boolean;
  149250. /**
  149251. * Gets or sets a boolean indicating if the outline must be rendered as well
  149252. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149253. */
  149254. renderOutline: boolean;
  149255. /** @hidden (Backing field) */
  149256. _renderOverlay: boolean;
  149257. /**
  149258. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149259. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149260. */
  149261. renderOverlay: boolean;
  149262. }
  149263. /**
  149264. * This class is responsible to draw bothe outline/overlay of meshes.
  149265. * It should not be used directly but through the available method on mesh.
  149266. */
  149267. export class OutlineRenderer implements ISceneComponent {
  149268. /**
  149269. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149270. */
  149271. private static _StencilReference;
  149272. /**
  149273. * The name of the component. Each component must have a unique name.
  149274. */
  149275. name: string;
  149276. /**
  149277. * The scene the component belongs to.
  149278. */
  149279. scene: Scene;
  149280. /**
  149281. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149282. */
  149283. zOffset: number;
  149284. private _engine;
  149285. private _effect;
  149286. private _cachedDefines;
  149287. private _savedDepthWrite;
  149288. /**
  149289. * Instantiates a new outline renderer. (There could be only one per scene).
  149290. * @param scene Defines the scene it belongs to
  149291. */
  149292. constructor(scene: Scene);
  149293. /**
  149294. * Register the component to one instance of a scene.
  149295. */
  149296. register(): void;
  149297. /**
  149298. * Rebuilds the elements related to this component in case of
  149299. * context lost for instance.
  149300. */
  149301. rebuild(): void;
  149302. /**
  149303. * Disposes the component and the associated ressources.
  149304. */
  149305. dispose(): void;
  149306. /**
  149307. * Renders the outline in the canvas.
  149308. * @param subMesh Defines the sumesh to render
  149309. * @param batch Defines the batch of meshes in case of instances
  149310. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149311. */
  149312. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149313. /**
  149314. * Returns whether or not the outline renderer is ready for a given submesh.
  149315. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149316. * @param subMesh Defines the submesh to check readyness for
  149317. * @param useInstances Defines wheter wee are trying to render instances or not
  149318. * @returns true if ready otherwise false
  149319. */
  149320. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149321. private _beforeRenderingMesh;
  149322. private _afterRenderingMesh;
  149323. }
  149324. }
  149325. declare module BABYLON {
  149326. /**
  149327. * Defines the basic options interface of a Sprite Frame Source Size.
  149328. */
  149329. export interface ISpriteJSONSpriteSourceSize {
  149330. /**
  149331. * number of the original width of the Frame
  149332. */
  149333. w: number;
  149334. /**
  149335. * number of the original height of the Frame
  149336. */
  149337. h: number;
  149338. }
  149339. /**
  149340. * Defines the basic options interface of a Sprite Frame Data.
  149341. */
  149342. export interface ISpriteJSONSpriteFrameData {
  149343. /**
  149344. * number of the x offset of the Frame
  149345. */
  149346. x: number;
  149347. /**
  149348. * number of the y offset of the Frame
  149349. */
  149350. y: number;
  149351. /**
  149352. * number of the width of the Frame
  149353. */
  149354. w: number;
  149355. /**
  149356. * number of the height of the Frame
  149357. */
  149358. h: number;
  149359. }
  149360. /**
  149361. * Defines the basic options interface of a JSON Sprite.
  149362. */
  149363. export interface ISpriteJSONSprite {
  149364. /**
  149365. * string name of the Frame
  149366. */
  149367. filename: string;
  149368. /**
  149369. * ISpriteJSONSpriteFrame basic object of the frame data
  149370. */
  149371. frame: ISpriteJSONSpriteFrameData;
  149372. /**
  149373. * boolean to flag is the frame was rotated.
  149374. */
  149375. rotated: boolean;
  149376. /**
  149377. * boolean to flag is the frame was trimmed.
  149378. */
  149379. trimmed: boolean;
  149380. /**
  149381. * ISpriteJSONSpriteFrame basic object of the source data
  149382. */
  149383. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149384. /**
  149385. * ISpriteJSONSpriteFrame basic object of the source data
  149386. */
  149387. sourceSize: ISpriteJSONSpriteSourceSize;
  149388. }
  149389. /**
  149390. * Defines the basic options interface of a JSON atlas.
  149391. */
  149392. export interface ISpriteJSONAtlas {
  149393. /**
  149394. * Array of objects that contain the frame data.
  149395. */
  149396. frames: Array<ISpriteJSONSprite>;
  149397. /**
  149398. * object basic object containing the sprite meta data.
  149399. */
  149400. meta?: object;
  149401. }
  149402. }
  149403. declare module BABYLON {
  149404. /** @hidden */
  149405. export var spriteMapPixelShader: {
  149406. name: string;
  149407. shader: string;
  149408. };
  149409. }
  149410. declare module BABYLON {
  149411. /** @hidden */
  149412. export var spriteMapVertexShader: {
  149413. name: string;
  149414. shader: string;
  149415. };
  149416. }
  149417. declare module BABYLON {
  149418. /**
  149419. * Defines the basic options interface of a SpriteMap
  149420. */
  149421. export interface ISpriteMapOptions {
  149422. /**
  149423. * Vector2 of the number of cells in the grid.
  149424. */
  149425. stageSize?: Vector2;
  149426. /**
  149427. * Vector2 of the size of the output plane in World Units.
  149428. */
  149429. outputSize?: Vector2;
  149430. /**
  149431. * Vector3 of the position of the output plane in World Units.
  149432. */
  149433. outputPosition?: Vector3;
  149434. /**
  149435. * Vector3 of the rotation of the output plane.
  149436. */
  149437. outputRotation?: Vector3;
  149438. /**
  149439. * number of layers that the system will reserve in resources.
  149440. */
  149441. layerCount?: number;
  149442. /**
  149443. * number of max animation frames a single cell will reserve in resources.
  149444. */
  149445. maxAnimationFrames?: number;
  149446. /**
  149447. * number cell index of the base tile when the system compiles.
  149448. */
  149449. baseTile?: number;
  149450. /**
  149451. * boolean flip the sprite after its been repositioned by the framing data.
  149452. */
  149453. flipU?: boolean;
  149454. /**
  149455. * Vector3 scalar of the global RGB values of the SpriteMap.
  149456. */
  149457. colorMultiply?: Vector3;
  149458. }
  149459. /**
  149460. * Defines the IDisposable interface in order to be cleanable from resources.
  149461. */
  149462. export interface ISpriteMap extends IDisposable {
  149463. /**
  149464. * String name of the SpriteMap.
  149465. */
  149466. name: string;
  149467. /**
  149468. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149469. */
  149470. atlasJSON: ISpriteJSONAtlas;
  149471. /**
  149472. * Texture of the SpriteMap.
  149473. */
  149474. spriteSheet: Texture;
  149475. /**
  149476. * The parameters to initialize the SpriteMap with.
  149477. */
  149478. options: ISpriteMapOptions;
  149479. }
  149480. /**
  149481. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149482. */
  149483. export class SpriteMap implements ISpriteMap {
  149484. /** The Name of the spriteMap */
  149485. name: string;
  149486. /** The JSON file with the frame and meta data */
  149487. atlasJSON: ISpriteJSONAtlas;
  149488. /** The systems Sprite Sheet Texture */
  149489. spriteSheet: Texture;
  149490. /** Arguments passed with the Constructor */
  149491. options: ISpriteMapOptions;
  149492. /** Public Sprite Storage array, parsed from atlasJSON */
  149493. sprites: Array<ISpriteJSONSprite>;
  149494. /** Returns the Number of Sprites in the System */
  149495. get spriteCount(): number;
  149496. /** Returns the Position of Output Plane*/
  149497. get position(): Vector3;
  149498. /** Returns the Position of Output Plane*/
  149499. set position(v: Vector3);
  149500. /** Returns the Rotation of Output Plane*/
  149501. get rotation(): Vector3;
  149502. /** Returns the Rotation of Output Plane*/
  149503. set rotation(v: Vector3);
  149504. /** Sets the AnimationMap*/
  149505. get animationMap(): RawTexture;
  149506. /** Sets the AnimationMap*/
  149507. set animationMap(v: RawTexture);
  149508. /** Scene that the SpriteMap was created in */
  149509. private _scene;
  149510. /** Texture Buffer of Float32 that holds tile frame data*/
  149511. private _frameMap;
  149512. /** Texture Buffers of Float32 that holds tileMap data*/
  149513. private _tileMaps;
  149514. /** Texture Buffer of Float32 that holds Animation Data*/
  149515. private _animationMap;
  149516. /** Custom ShaderMaterial Central to the System*/
  149517. private _material;
  149518. /** Custom ShaderMaterial Central to the System*/
  149519. private _output;
  149520. /** Systems Time Ticker*/
  149521. private _time;
  149522. /**
  149523. * Creates a new SpriteMap
  149524. * @param name defines the SpriteMaps Name
  149525. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149526. * @param spriteSheet is the Texture that the Sprites are on.
  149527. * @param options a basic deployment configuration
  149528. * @param scene The Scene that the map is deployed on
  149529. */
  149530. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149531. /**
  149532. * Returns tileID location
  149533. * @returns Vector2 the cell position ID
  149534. */
  149535. getTileID(): Vector2;
  149536. /**
  149537. * Gets the UV location of the mouse over the SpriteMap.
  149538. * @returns Vector2 the UV position of the mouse interaction
  149539. */
  149540. getMousePosition(): Vector2;
  149541. /**
  149542. * Creates the "frame" texture Buffer
  149543. * -------------------------------------
  149544. * Structure of frames
  149545. * "filename": "Falling-Water-2.png",
  149546. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149547. * "rotated": true,
  149548. * "trimmed": true,
  149549. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149550. * "sourceSize": {"w":32,"h":32}
  149551. * @returns RawTexture of the frameMap
  149552. */
  149553. private _createFrameBuffer;
  149554. /**
  149555. * Creates the tileMap texture Buffer
  149556. * @param buffer normally and array of numbers, or a false to generate from scratch
  149557. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149558. * @returns RawTexture of the tileMap
  149559. */
  149560. private _createTileBuffer;
  149561. /**
  149562. * Modifies the data of the tileMaps
  149563. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149564. * @param pos is the iVector2 Coordinates of the Tile
  149565. * @param tile The SpriteIndex of the new Tile
  149566. */
  149567. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149568. /**
  149569. * Creates the animationMap texture Buffer
  149570. * @param buffer normally and array of numbers, or a false to generate from scratch
  149571. * @returns RawTexture of the animationMap
  149572. */
  149573. private _createTileAnimationBuffer;
  149574. /**
  149575. * Modifies the data of the animationMap
  149576. * @param cellID is the Index of the Sprite
  149577. * @param _frame is the target Animation frame
  149578. * @param toCell is the Target Index of the next frame of the animation
  149579. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149580. * @param speed is a global scalar of the time variable on the map.
  149581. */
  149582. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149583. /**
  149584. * Exports the .tilemaps file
  149585. */
  149586. saveTileMaps(): void;
  149587. /**
  149588. * Imports the .tilemaps file
  149589. * @param url of the .tilemaps file
  149590. */
  149591. loadTileMaps(url: string): void;
  149592. /**
  149593. * Release associated resources
  149594. */
  149595. dispose(): void;
  149596. }
  149597. }
  149598. declare module BABYLON {
  149599. /**
  149600. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149601. * @see https://doc.babylonjs.com/babylon101/sprites
  149602. */
  149603. export class SpritePackedManager extends SpriteManager {
  149604. /** defines the packed manager's name */
  149605. name: string;
  149606. /**
  149607. * Creates a new sprite manager from a packed sprite sheet
  149608. * @param name defines the manager's name
  149609. * @param imgUrl defines the sprite sheet url
  149610. * @param capacity defines the maximum allowed number of sprites
  149611. * @param scene defines the hosting scene
  149612. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149613. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149614. * @param samplingMode defines the smapling mode to use with spritesheet
  149615. * @param fromPacked set to true; do not alter
  149616. */
  149617. constructor(
  149618. /** defines the packed manager's name */
  149619. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149620. }
  149621. }
  149622. declare module BABYLON {
  149623. /**
  149624. * Defines the list of states available for a task inside a AssetsManager
  149625. */
  149626. export enum AssetTaskState {
  149627. /**
  149628. * Initialization
  149629. */
  149630. INIT = 0,
  149631. /**
  149632. * Running
  149633. */
  149634. RUNNING = 1,
  149635. /**
  149636. * Done
  149637. */
  149638. DONE = 2,
  149639. /**
  149640. * Error
  149641. */
  149642. ERROR = 3
  149643. }
  149644. /**
  149645. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149646. */
  149647. export abstract class AbstractAssetTask {
  149648. /**
  149649. * Task name
  149650. */ name: string;
  149651. /**
  149652. * Callback called when the task is successful
  149653. */
  149654. onSuccess: (task: any) => void;
  149655. /**
  149656. * Callback called when the task is not successful
  149657. */
  149658. onError: (task: any, message?: string, exception?: any) => void;
  149659. /**
  149660. * Creates a new AssetsManager
  149661. * @param name defines the name of the task
  149662. */
  149663. constructor(
  149664. /**
  149665. * Task name
  149666. */ name: string);
  149667. private _isCompleted;
  149668. private _taskState;
  149669. private _errorObject;
  149670. /**
  149671. * Get if the task is completed
  149672. */
  149673. get isCompleted(): boolean;
  149674. /**
  149675. * Gets the current state of the task
  149676. */
  149677. get taskState(): AssetTaskState;
  149678. /**
  149679. * Gets the current error object (if task is in error)
  149680. */
  149681. get errorObject(): {
  149682. message?: string;
  149683. exception?: any;
  149684. };
  149685. /**
  149686. * Internal only
  149687. * @hidden
  149688. */
  149689. _setErrorObject(message?: string, exception?: any): void;
  149690. /**
  149691. * Execute the current task
  149692. * @param scene defines the scene where you want your assets to be loaded
  149693. * @param onSuccess is a callback called when the task is successfully executed
  149694. * @param onError is a callback called if an error occurs
  149695. */
  149696. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149697. /**
  149698. * Execute the current task
  149699. * @param scene defines the scene where you want your assets to be loaded
  149700. * @param onSuccess is a callback called when the task is successfully executed
  149701. * @param onError is a callback called if an error occurs
  149702. */
  149703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149704. /**
  149705. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149706. * This can be used with failed tasks that have the reason for failure fixed.
  149707. */
  149708. reset(): void;
  149709. private onErrorCallback;
  149710. private onDoneCallback;
  149711. }
  149712. /**
  149713. * Define the interface used by progress events raised during assets loading
  149714. */
  149715. export interface IAssetsProgressEvent {
  149716. /**
  149717. * Defines the number of remaining tasks to process
  149718. */
  149719. remainingCount: number;
  149720. /**
  149721. * Defines the total number of tasks
  149722. */
  149723. totalCount: number;
  149724. /**
  149725. * Defines the task that was just processed
  149726. */
  149727. task: AbstractAssetTask;
  149728. }
  149729. /**
  149730. * Class used to share progress information about assets loading
  149731. */
  149732. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149733. /**
  149734. * Defines the number of remaining tasks to process
  149735. */
  149736. remainingCount: number;
  149737. /**
  149738. * Defines the total number of tasks
  149739. */
  149740. totalCount: number;
  149741. /**
  149742. * Defines the task that was just processed
  149743. */
  149744. task: AbstractAssetTask;
  149745. /**
  149746. * Creates a AssetsProgressEvent
  149747. * @param remainingCount defines the number of remaining tasks to process
  149748. * @param totalCount defines the total number of tasks
  149749. * @param task defines the task that was just processed
  149750. */
  149751. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  149752. }
  149753. /**
  149754. * Define a task used by AssetsManager to load meshes
  149755. */
  149756. export class MeshAssetTask extends AbstractAssetTask {
  149757. /**
  149758. * Defines the name of the task
  149759. */
  149760. name: string;
  149761. /**
  149762. * Defines the list of mesh's names you want to load
  149763. */
  149764. meshesNames: any;
  149765. /**
  149766. * Defines the root url to use as a base to load your meshes and associated resources
  149767. */
  149768. rootUrl: string;
  149769. /**
  149770. * Defines the filename or File of the scene to load from
  149771. */
  149772. sceneFilename: string | File;
  149773. /**
  149774. * Gets the list of loaded meshes
  149775. */
  149776. loadedMeshes: Array<AbstractMesh>;
  149777. /**
  149778. * Gets the list of loaded particle systems
  149779. */
  149780. loadedParticleSystems: Array<IParticleSystem>;
  149781. /**
  149782. * Gets the list of loaded skeletons
  149783. */
  149784. loadedSkeletons: Array<Skeleton>;
  149785. /**
  149786. * Gets the list of loaded animation groups
  149787. */
  149788. loadedAnimationGroups: Array<AnimationGroup>;
  149789. /**
  149790. * Callback called when the task is successful
  149791. */
  149792. onSuccess: (task: MeshAssetTask) => void;
  149793. /**
  149794. * Callback called when the task is successful
  149795. */
  149796. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  149797. /**
  149798. * Creates a new MeshAssetTask
  149799. * @param name defines the name of the task
  149800. * @param meshesNames defines the list of mesh's names you want to load
  149801. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  149802. * @param sceneFilename defines the filename or File of the scene to load from
  149803. */
  149804. constructor(
  149805. /**
  149806. * Defines the name of the task
  149807. */
  149808. name: string,
  149809. /**
  149810. * Defines the list of mesh's names you want to load
  149811. */
  149812. meshesNames: any,
  149813. /**
  149814. * Defines the root url to use as a base to load your meshes and associated resources
  149815. */
  149816. rootUrl: string,
  149817. /**
  149818. * Defines the filename or File of the scene to load from
  149819. */
  149820. sceneFilename: string | File);
  149821. /**
  149822. * Execute the current task
  149823. * @param scene defines the scene where you want your assets to be loaded
  149824. * @param onSuccess is a callback called when the task is successfully executed
  149825. * @param onError is a callback called if an error occurs
  149826. */
  149827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149828. }
  149829. /**
  149830. * Define a task used by AssetsManager to load text content
  149831. */
  149832. export class TextFileAssetTask extends AbstractAssetTask {
  149833. /**
  149834. * Defines the name of the task
  149835. */
  149836. name: string;
  149837. /**
  149838. * Defines the location of the file to load
  149839. */
  149840. url: string;
  149841. /**
  149842. * Gets the loaded text string
  149843. */
  149844. text: string;
  149845. /**
  149846. * Callback called when the task is successful
  149847. */
  149848. onSuccess: (task: TextFileAssetTask) => void;
  149849. /**
  149850. * Callback called when the task is successful
  149851. */
  149852. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  149853. /**
  149854. * Creates a new TextFileAssetTask object
  149855. * @param name defines the name of the task
  149856. * @param url defines the location of the file to load
  149857. */
  149858. constructor(
  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. * Execute the current task
  149869. * @param scene defines the scene where you want your assets to be loaded
  149870. * @param onSuccess is a callback called when the task is successfully executed
  149871. * @param onError is a callback called if an error occurs
  149872. */
  149873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149874. }
  149875. /**
  149876. * Define a task used by AssetsManager to load binary data
  149877. */
  149878. export class BinaryFileAssetTask extends AbstractAssetTask {
  149879. /**
  149880. * Defines the name of the task
  149881. */
  149882. name: string;
  149883. /**
  149884. * Defines the location of the file to load
  149885. */
  149886. url: string;
  149887. /**
  149888. * Gets the lodaded data (as an array buffer)
  149889. */
  149890. data: ArrayBuffer;
  149891. /**
  149892. * Callback called when the task is successful
  149893. */
  149894. onSuccess: (task: BinaryFileAssetTask) => void;
  149895. /**
  149896. * Callback called when the task is successful
  149897. */
  149898. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  149899. /**
  149900. * Creates a new BinaryFileAssetTask object
  149901. * @param name defines the name of the new task
  149902. * @param url defines the location of the file to load
  149903. */
  149904. constructor(
  149905. /**
  149906. * Defines the name of the task
  149907. */
  149908. name: string,
  149909. /**
  149910. * Defines the location of the file to load
  149911. */
  149912. url: string);
  149913. /**
  149914. * Execute the current task
  149915. * @param scene defines the scene where you want your assets to be loaded
  149916. * @param onSuccess is a callback called when the task is successfully executed
  149917. * @param onError is a callback called if an error occurs
  149918. */
  149919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149920. }
  149921. /**
  149922. * Define a task used by AssetsManager to load images
  149923. */
  149924. export class ImageAssetTask extends AbstractAssetTask {
  149925. /**
  149926. * Defines the name of the task
  149927. */
  149928. name: string;
  149929. /**
  149930. * Defines the location of the image to load
  149931. */
  149932. url: string;
  149933. /**
  149934. * Gets the loaded images
  149935. */
  149936. image: HTMLImageElement;
  149937. /**
  149938. * Callback called when the task is successful
  149939. */
  149940. onSuccess: (task: ImageAssetTask) => void;
  149941. /**
  149942. * Callback called when the task is successful
  149943. */
  149944. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  149945. /**
  149946. * Creates a new ImageAssetTask
  149947. * @param name defines the name of the task
  149948. * @param url defines the location of the image to load
  149949. */
  149950. constructor(
  149951. /**
  149952. * Defines the name of the task
  149953. */
  149954. name: string,
  149955. /**
  149956. * Defines the location of the image to load
  149957. */
  149958. url: string);
  149959. /**
  149960. * Execute the current task
  149961. * @param scene defines the scene where you want your assets to be loaded
  149962. * @param onSuccess is a callback called when the task is successfully executed
  149963. * @param onError is a callback called if an error occurs
  149964. */
  149965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149966. }
  149967. /**
  149968. * Defines the interface used by texture loading tasks
  149969. */
  149970. export interface ITextureAssetTask<TEX extends BaseTexture> {
  149971. /**
  149972. * Gets the loaded texture
  149973. */
  149974. texture: TEX;
  149975. }
  149976. /**
  149977. * Define a task used by AssetsManager to load 2D textures
  149978. */
  149979. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  149980. /**
  149981. * Defines the name of the task
  149982. */
  149983. name: string;
  149984. /**
  149985. * Defines the location of the file to load
  149986. */
  149987. url: string;
  149988. /**
  149989. * Defines if mipmap should not be generated (default is false)
  149990. */
  149991. noMipmap?: boolean | undefined;
  149992. /**
  149993. * Defines if texture must be inverted on Y axis (default is true)
  149994. */
  149995. invertY: boolean;
  149996. /**
  149997. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149998. */
  149999. samplingMode: number;
  150000. /**
  150001. * Gets the loaded texture
  150002. */
  150003. texture: Texture;
  150004. /**
  150005. * Callback called when the task is successful
  150006. */
  150007. onSuccess: (task: TextureAssetTask) => void;
  150008. /**
  150009. * Callback called when the task is successful
  150010. */
  150011. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150012. /**
  150013. * Creates a new TextureAssetTask object
  150014. * @param name defines the name of the task
  150015. * @param url defines the location of the file to load
  150016. * @param noMipmap defines if mipmap should not be generated (default is false)
  150017. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150018. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150019. */
  150020. constructor(
  150021. /**
  150022. * Defines the name of the task
  150023. */
  150024. name: string,
  150025. /**
  150026. * Defines the location of the file to load
  150027. */
  150028. url: string,
  150029. /**
  150030. * Defines if mipmap should not be generated (default is false)
  150031. */
  150032. noMipmap?: boolean | undefined,
  150033. /**
  150034. * Defines if texture must be inverted on Y axis (default is true)
  150035. */
  150036. invertY?: boolean,
  150037. /**
  150038. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150039. */
  150040. samplingMode?: number);
  150041. /**
  150042. * Execute the current task
  150043. * @param scene defines the scene where you want your assets to be loaded
  150044. * @param onSuccess is a callback called when the task is successfully executed
  150045. * @param onError is a callback called if an error occurs
  150046. */
  150047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150048. }
  150049. /**
  150050. * Define a task used by AssetsManager to load cube textures
  150051. */
  150052. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150053. /**
  150054. * Defines the name of the task
  150055. */
  150056. name: string;
  150057. /**
  150058. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150059. */
  150060. url: string;
  150061. /**
  150062. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150063. */
  150064. extensions?: string[] | undefined;
  150065. /**
  150066. * Defines if mipmaps should not be generated (default is false)
  150067. */
  150068. noMipmap?: boolean | undefined;
  150069. /**
  150070. * Defines the explicit list of files (undefined by default)
  150071. */
  150072. files?: string[] | undefined;
  150073. /**
  150074. * Gets the loaded texture
  150075. */
  150076. texture: CubeTexture;
  150077. /**
  150078. * Callback called when the task is successful
  150079. */
  150080. onSuccess: (task: CubeTextureAssetTask) => void;
  150081. /**
  150082. * Callback called when the task is successful
  150083. */
  150084. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150085. /**
  150086. * Creates a new CubeTextureAssetTask
  150087. * @param name defines the name of the task
  150088. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150089. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150090. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150091. * @param files defines the explicit list of files (undefined by default)
  150092. */
  150093. constructor(
  150094. /**
  150095. * Defines the name of the task
  150096. */
  150097. name: string,
  150098. /**
  150099. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150100. */
  150101. url: string,
  150102. /**
  150103. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150104. */
  150105. extensions?: string[] | undefined,
  150106. /**
  150107. * Defines if mipmaps should not be generated (default is false)
  150108. */
  150109. noMipmap?: boolean | undefined,
  150110. /**
  150111. * Defines the explicit list of files (undefined by default)
  150112. */
  150113. files?: string[] | undefined);
  150114. /**
  150115. * Execute the current task
  150116. * @param scene defines the scene where you want your assets to be loaded
  150117. * @param onSuccess is a callback called when the task is successfully executed
  150118. * @param onError is a callback called if an error occurs
  150119. */
  150120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150121. }
  150122. /**
  150123. * Define a task used by AssetsManager to load HDR cube textures
  150124. */
  150125. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150126. /**
  150127. * Defines the name of the task
  150128. */
  150129. name: string;
  150130. /**
  150131. * Defines the location of the file to load
  150132. */
  150133. url: string;
  150134. /**
  150135. * Defines the desired size (the more it increases the longer the generation will be)
  150136. */
  150137. size: number;
  150138. /**
  150139. * Defines if mipmaps should not be generated (default is false)
  150140. */
  150141. noMipmap: boolean;
  150142. /**
  150143. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150144. */
  150145. generateHarmonics: boolean;
  150146. /**
  150147. * 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)
  150148. */
  150149. gammaSpace: boolean;
  150150. /**
  150151. * Internal Use Only
  150152. */
  150153. reserved: boolean;
  150154. /**
  150155. * Gets the loaded texture
  150156. */
  150157. texture: HDRCubeTexture;
  150158. /**
  150159. * Callback called when the task is successful
  150160. */
  150161. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150162. /**
  150163. * Callback called when the task is successful
  150164. */
  150165. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150166. /**
  150167. * Creates a new HDRCubeTextureAssetTask object
  150168. * @param name defines the name of the task
  150169. * @param url defines the location of the file to load
  150170. * @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.
  150171. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150172. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150173. * @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)
  150174. * @param reserved Internal use only
  150175. */
  150176. constructor(
  150177. /**
  150178. * Defines the name of the task
  150179. */
  150180. name: string,
  150181. /**
  150182. * Defines the location of the file to load
  150183. */
  150184. url: string,
  150185. /**
  150186. * Defines the desired size (the more it increases the longer the generation will be)
  150187. */
  150188. size: number,
  150189. /**
  150190. * Defines if mipmaps should not be generated (default is false)
  150191. */
  150192. noMipmap?: boolean,
  150193. /**
  150194. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150195. */
  150196. generateHarmonics?: boolean,
  150197. /**
  150198. * 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)
  150199. */
  150200. gammaSpace?: boolean,
  150201. /**
  150202. * Internal Use Only
  150203. */
  150204. reserved?: boolean);
  150205. /**
  150206. * Execute the current task
  150207. * @param scene defines the scene where you want your assets to be loaded
  150208. * @param onSuccess is a callback called when the task is successfully executed
  150209. * @param onError is a callback called if an error occurs
  150210. */
  150211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150212. }
  150213. /**
  150214. * Define a task used by AssetsManager to load Equirectangular cube textures
  150215. */
  150216. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150217. /**
  150218. * Defines the name of the task
  150219. */
  150220. name: string;
  150221. /**
  150222. * Defines the location of the file to load
  150223. */
  150224. url: string;
  150225. /**
  150226. * Defines the desired size (the more it increases the longer the generation will be)
  150227. */
  150228. size: number;
  150229. /**
  150230. * Defines if mipmaps should not be generated (default is false)
  150231. */
  150232. noMipmap: boolean;
  150233. /**
  150234. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150235. * but the standard material would require them in Gamma space) (default is true)
  150236. */
  150237. gammaSpace: boolean;
  150238. /**
  150239. * Gets the loaded texture
  150240. */
  150241. texture: EquiRectangularCubeTexture;
  150242. /**
  150243. * Callback called when the task is successful
  150244. */
  150245. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150246. /**
  150247. * Callback called when the task is successful
  150248. */
  150249. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150250. /**
  150251. * Creates a new EquiRectangularCubeTextureAssetTask object
  150252. * @param name defines the name of the task
  150253. * @param url defines the location of the file to load
  150254. * @param size defines the desired size (the more it increases the longer the generation will be)
  150255. * If the size is omitted this implies you are using a preprocessed cubemap.
  150256. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150257. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150258. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150259. * (default is true)
  150260. */
  150261. constructor(
  150262. /**
  150263. * Defines the name of the task
  150264. */
  150265. name: string,
  150266. /**
  150267. * Defines the location of the file to load
  150268. */
  150269. url: string,
  150270. /**
  150271. * Defines the desired size (the more it increases the longer the generation will be)
  150272. */
  150273. size: number,
  150274. /**
  150275. * Defines if mipmaps should not be generated (default is false)
  150276. */
  150277. noMipmap?: boolean,
  150278. /**
  150279. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150280. * but the standard material would require them in Gamma space) (default is true)
  150281. */
  150282. gammaSpace?: boolean);
  150283. /**
  150284. * Execute the current task
  150285. * @param scene defines the scene where you want your assets to be loaded
  150286. * @param onSuccess is a callback called when the task is successfully executed
  150287. * @param onError is a callback called if an error occurs
  150288. */
  150289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150290. }
  150291. /**
  150292. * This class can be used to easily import assets into a scene
  150293. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150294. */
  150295. export class AssetsManager {
  150296. private _scene;
  150297. private _isLoading;
  150298. protected _tasks: AbstractAssetTask[];
  150299. protected _waitingTasksCount: number;
  150300. protected _totalTasksCount: number;
  150301. /**
  150302. * Callback called when all tasks are processed
  150303. */
  150304. onFinish: (tasks: AbstractAssetTask[]) => void;
  150305. /**
  150306. * Callback called when a task is successful
  150307. */
  150308. onTaskSuccess: (task: AbstractAssetTask) => void;
  150309. /**
  150310. * Callback called when a task had an error
  150311. */
  150312. onTaskError: (task: AbstractAssetTask) => void;
  150313. /**
  150314. * Callback called when a task is done (whatever the result is)
  150315. */
  150316. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150317. /**
  150318. * Observable called when all tasks are processed
  150319. */
  150320. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150321. /**
  150322. * Observable called when a task had an error
  150323. */
  150324. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150325. /**
  150326. * Observable called when all tasks were executed
  150327. */
  150328. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150329. /**
  150330. * Observable called when a task is done (whatever the result is)
  150331. */
  150332. onProgressObservable: Observable<IAssetsProgressEvent>;
  150333. /**
  150334. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150335. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150336. */
  150337. useDefaultLoadingScreen: boolean;
  150338. /**
  150339. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150340. * when all assets have been downloaded.
  150341. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150342. */
  150343. autoHideLoadingUI: boolean;
  150344. /**
  150345. * Creates a new AssetsManager
  150346. * @param scene defines the scene to work on
  150347. */
  150348. constructor(scene: Scene);
  150349. /**
  150350. * Add a MeshAssetTask to the list of active tasks
  150351. * @param taskName defines the name of the new task
  150352. * @param meshesNames defines the name of meshes to load
  150353. * @param rootUrl defines the root url to use to locate files
  150354. * @param sceneFilename defines the filename of the scene file
  150355. * @returns a new MeshAssetTask object
  150356. */
  150357. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150358. /**
  150359. * Add a TextFileAssetTask to the list of active tasks
  150360. * @param taskName defines the name of the new task
  150361. * @param url defines the url of the file to load
  150362. * @returns a new TextFileAssetTask object
  150363. */
  150364. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150365. /**
  150366. * Add a BinaryFileAssetTask to the list of active tasks
  150367. * @param taskName defines the name of the new task
  150368. * @param url defines the url of the file to load
  150369. * @returns a new BinaryFileAssetTask object
  150370. */
  150371. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150372. /**
  150373. * Add a ImageAssetTask to the list of active tasks
  150374. * @param taskName defines the name of the new task
  150375. * @param url defines the url of the file to load
  150376. * @returns a new ImageAssetTask object
  150377. */
  150378. addImageTask(taskName: string, url: string): ImageAssetTask;
  150379. /**
  150380. * Add a TextureAssetTask to the list of active tasks
  150381. * @param taskName defines the name of the new task
  150382. * @param url defines the url of the file to load
  150383. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150384. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150385. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150386. * @returns a new TextureAssetTask object
  150387. */
  150388. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150389. /**
  150390. * Add a CubeTextureAssetTask to the list of active tasks
  150391. * @param taskName defines the name of the new task
  150392. * @param url defines the url of the file to load
  150393. * @param extensions defines the extension to use to load the cube map (can be null)
  150394. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150395. * @param files defines the list of files to load (can be null)
  150396. * @returns a new CubeTextureAssetTask object
  150397. */
  150398. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150399. /**
  150400. *
  150401. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150402. * @param taskName defines the name of the new task
  150403. * @param url defines the url of the file to load
  150404. * @param size defines the size you want for the cubemap (can be null)
  150405. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150406. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150407. * @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)
  150408. * @param reserved Internal use only
  150409. * @returns a new HDRCubeTextureAssetTask object
  150410. */
  150411. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150412. /**
  150413. *
  150414. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150415. * @param taskName defines the name of the new task
  150416. * @param url defines the url of the file to load
  150417. * @param size defines the size you want for the cubemap (can be null)
  150418. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150419. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150420. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150421. * @returns a new EquiRectangularCubeTextureAssetTask object
  150422. */
  150423. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150424. /**
  150425. * Remove a task from the assets manager.
  150426. * @param task the task to remove
  150427. */
  150428. removeTask(task: AbstractAssetTask): void;
  150429. private _decreaseWaitingTasksCount;
  150430. private _runTask;
  150431. /**
  150432. * Reset the AssetsManager and remove all tasks
  150433. * @return the current instance of the AssetsManager
  150434. */
  150435. reset(): AssetsManager;
  150436. /**
  150437. * Start the loading process
  150438. * @return the current instance of the AssetsManager
  150439. */
  150440. load(): AssetsManager;
  150441. /**
  150442. * Start the loading process as an async operation
  150443. * @return a promise returning the list of failed tasks
  150444. */
  150445. loadAsync(): Promise<void>;
  150446. }
  150447. }
  150448. declare module BABYLON {
  150449. /**
  150450. * Wrapper class for promise with external resolve and reject.
  150451. */
  150452. export class Deferred<T> {
  150453. /**
  150454. * The promise associated with this deferred object.
  150455. */
  150456. readonly promise: Promise<T>;
  150457. private _resolve;
  150458. private _reject;
  150459. /**
  150460. * The resolve method of the promise associated with this deferred object.
  150461. */
  150462. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150463. /**
  150464. * The reject method of the promise associated with this deferred object.
  150465. */
  150466. get reject(): (reason?: any) => void;
  150467. /**
  150468. * Constructor for this deferred object.
  150469. */
  150470. constructor();
  150471. }
  150472. }
  150473. declare module BABYLON {
  150474. /**
  150475. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150476. */
  150477. export class MeshExploder {
  150478. private _centerMesh;
  150479. private _meshes;
  150480. private _meshesOrigins;
  150481. private _toCenterVectors;
  150482. private _scaledDirection;
  150483. private _newPosition;
  150484. private _centerPosition;
  150485. /**
  150486. * Explodes meshes from a center mesh.
  150487. * @param meshes The meshes to explode.
  150488. * @param centerMesh The mesh to be center of explosion.
  150489. */
  150490. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150491. private _setCenterMesh;
  150492. /**
  150493. * Get class name
  150494. * @returns "MeshExploder"
  150495. */
  150496. getClassName(): string;
  150497. /**
  150498. * "Exploded meshes"
  150499. * @returns Array of meshes with the centerMesh at index 0.
  150500. */
  150501. getMeshes(): Array<Mesh>;
  150502. /**
  150503. * Explodes meshes giving a specific direction
  150504. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150505. */
  150506. explode(direction?: number): void;
  150507. }
  150508. }
  150509. declare module BABYLON {
  150510. /**
  150511. * Class used to help managing file picking and drag'n'drop
  150512. */
  150513. export class FilesInput {
  150514. /**
  150515. * List of files ready to be loaded
  150516. */
  150517. static get FilesToLoad(): {
  150518. [key: string]: File;
  150519. };
  150520. /**
  150521. * Callback called when a file is processed
  150522. */
  150523. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150524. private _engine;
  150525. private _currentScene;
  150526. private _sceneLoadedCallback;
  150527. private _progressCallback;
  150528. private _additionalRenderLoopLogicCallback;
  150529. private _textureLoadingCallback;
  150530. private _startingProcessingFilesCallback;
  150531. private _onReloadCallback;
  150532. private _errorCallback;
  150533. private _elementToMonitor;
  150534. private _sceneFileToLoad;
  150535. private _filesToLoad;
  150536. /**
  150537. * Creates a new FilesInput
  150538. * @param engine defines the rendering engine
  150539. * @param scene defines the hosting scene
  150540. * @param sceneLoadedCallback callback called when scene is loaded
  150541. * @param progressCallback callback called to track progress
  150542. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150543. * @param textureLoadingCallback callback called when a texture is loading
  150544. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150545. * @param onReloadCallback callback called when a reload is requested
  150546. * @param errorCallback callback call if an error occurs
  150547. */
  150548. 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>);
  150549. private _dragEnterHandler;
  150550. private _dragOverHandler;
  150551. private _dropHandler;
  150552. /**
  150553. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150554. * @param elementToMonitor defines the DOM element to track
  150555. */
  150556. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150557. /** Gets the current list of files to load */
  150558. get filesToLoad(): File[];
  150559. /**
  150560. * Release all associated resources
  150561. */
  150562. dispose(): void;
  150563. private renderFunction;
  150564. private drag;
  150565. private drop;
  150566. private _traverseFolder;
  150567. private _processFiles;
  150568. /**
  150569. * Load files from a drop event
  150570. * @param event defines the drop event to use as source
  150571. */
  150572. loadFiles(event: any): void;
  150573. private _processReload;
  150574. /**
  150575. * Reload the current scene from the loaded files
  150576. */
  150577. reload(): void;
  150578. }
  150579. }
  150580. declare module BABYLON {
  150581. /**
  150582. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150583. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150584. */
  150585. export class SceneOptimization {
  150586. /**
  150587. * Defines the priority of this optimization (0 by default which means first in the list)
  150588. */
  150589. priority: number;
  150590. /**
  150591. * Gets a string describing the action executed by the current optimization
  150592. * @returns description string
  150593. */
  150594. getDescription(): string;
  150595. /**
  150596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150597. * @param scene defines the current scene where to apply this optimization
  150598. * @param optimizer defines the current optimizer
  150599. * @returns true if everything that can be done was applied
  150600. */
  150601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150602. /**
  150603. * Creates the SceneOptimization object
  150604. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150605. * @param desc defines the description associated with the optimization
  150606. */
  150607. constructor(
  150608. /**
  150609. * Defines the priority of this optimization (0 by default which means first in the list)
  150610. */
  150611. priority?: number);
  150612. }
  150613. /**
  150614. * Defines an optimization used to reduce the size of render target textures
  150615. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150616. */
  150617. export class TextureOptimization extends SceneOptimization {
  150618. /**
  150619. * Defines the priority of this optimization (0 by default which means first in the list)
  150620. */
  150621. priority: number;
  150622. /**
  150623. * 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
  150624. */
  150625. maximumSize: number;
  150626. /**
  150627. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150628. */
  150629. step: number;
  150630. /**
  150631. * Gets a string describing the action executed by the current optimization
  150632. * @returns description string
  150633. */
  150634. getDescription(): string;
  150635. /**
  150636. * Creates the TextureOptimization object
  150637. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150638. * @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
  150639. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150640. */
  150641. constructor(
  150642. /**
  150643. * Defines the priority of this optimization (0 by default which means first in the list)
  150644. */
  150645. priority?: number,
  150646. /**
  150647. * 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
  150648. */
  150649. maximumSize?: number,
  150650. /**
  150651. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150652. */
  150653. step?: number);
  150654. /**
  150655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150656. * @param scene defines the current scene where to apply this optimization
  150657. * @param optimizer defines the current optimizer
  150658. * @returns true if everything that can be done was applied
  150659. */
  150660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150661. }
  150662. /**
  150663. * Defines an optimization used to increase or decrease the rendering resolution
  150664. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150665. */
  150666. export class HardwareScalingOptimization extends SceneOptimization {
  150667. /**
  150668. * Defines the priority of this optimization (0 by default which means first in the list)
  150669. */
  150670. priority: number;
  150671. /**
  150672. * Defines the maximum scale to use (2 by default)
  150673. */
  150674. maximumScale: number;
  150675. /**
  150676. * Defines the step to use between two passes (0.5 by default)
  150677. */
  150678. step: number;
  150679. private _currentScale;
  150680. private _directionOffset;
  150681. /**
  150682. * Gets a string describing the action executed by the current optimization
  150683. * @return description string
  150684. */
  150685. getDescription(): string;
  150686. /**
  150687. * Creates the HardwareScalingOptimization object
  150688. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150689. * @param maximumScale defines the maximum scale to use (2 by default)
  150690. * @param step defines the step to use between two passes (0.5 by default)
  150691. */
  150692. constructor(
  150693. /**
  150694. * Defines the priority of this optimization (0 by default which means first in the list)
  150695. */
  150696. priority?: number,
  150697. /**
  150698. * Defines the maximum scale to use (2 by default)
  150699. */
  150700. maximumScale?: number,
  150701. /**
  150702. * Defines the step to use between two passes (0.5 by default)
  150703. */
  150704. step?: number);
  150705. /**
  150706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150707. * @param scene defines the current scene where to apply this optimization
  150708. * @param optimizer defines the current optimizer
  150709. * @returns true if everything that can be done was applied
  150710. */
  150711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150712. }
  150713. /**
  150714. * Defines an optimization used to remove shadows
  150715. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150716. */
  150717. export class ShadowsOptimization extends SceneOptimization {
  150718. /**
  150719. * Gets a string describing the action executed by the current optimization
  150720. * @return description string
  150721. */
  150722. getDescription(): string;
  150723. /**
  150724. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150725. * @param scene defines the current scene where to apply this optimization
  150726. * @param optimizer defines the current optimizer
  150727. * @returns true if everything that can be done was applied
  150728. */
  150729. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150730. }
  150731. /**
  150732. * Defines an optimization used to turn post-processes off
  150733. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150734. */
  150735. export class PostProcessesOptimization extends SceneOptimization {
  150736. /**
  150737. * Gets a string describing the action executed by the current optimization
  150738. * @return description string
  150739. */
  150740. getDescription(): string;
  150741. /**
  150742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150743. * @param scene defines the current scene where to apply this optimization
  150744. * @param optimizer defines the current optimizer
  150745. * @returns true if everything that can be done was applied
  150746. */
  150747. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150748. }
  150749. /**
  150750. * Defines an optimization used to turn lens flares off
  150751. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150752. */
  150753. export class LensFlaresOptimization extends SceneOptimization {
  150754. /**
  150755. * Gets a string describing the action executed by the current optimization
  150756. * @return description string
  150757. */
  150758. getDescription(): string;
  150759. /**
  150760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150761. * @param scene defines the current scene where to apply this optimization
  150762. * @param optimizer defines the current optimizer
  150763. * @returns true if everything that can be done was applied
  150764. */
  150765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150766. }
  150767. /**
  150768. * Defines an optimization based on user defined callback.
  150769. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150770. */
  150771. export class CustomOptimization extends SceneOptimization {
  150772. /**
  150773. * Callback called to apply the custom optimization.
  150774. */
  150775. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  150776. /**
  150777. * Callback called to get custom description
  150778. */
  150779. onGetDescription: () => string;
  150780. /**
  150781. * Gets a string describing the action executed by the current optimization
  150782. * @returns description string
  150783. */
  150784. getDescription(): string;
  150785. /**
  150786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150787. * @param scene defines the current scene where to apply this optimization
  150788. * @param optimizer defines the current optimizer
  150789. * @returns true if everything that can be done was applied
  150790. */
  150791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150792. }
  150793. /**
  150794. * Defines an optimization used to turn particles off
  150795. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150796. */
  150797. export class ParticlesOptimization extends SceneOptimization {
  150798. /**
  150799. * Gets a string describing the action executed by the current optimization
  150800. * @return description string
  150801. */
  150802. getDescription(): string;
  150803. /**
  150804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150805. * @param scene defines the current scene where to apply this optimization
  150806. * @param optimizer defines the current optimizer
  150807. * @returns true if everything that can be done was applied
  150808. */
  150809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150810. }
  150811. /**
  150812. * Defines an optimization used to turn render targets off
  150813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150814. */
  150815. export class RenderTargetsOptimization extends SceneOptimization {
  150816. /**
  150817. * Gets a string describing the action executed by the current optimization
  150818. * @return description string
  150819. */
  150820. getDescription(): string;
  150821. /**
  150822. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150823. * @param scene defines the current scene where to apply this optimization
  150824. * @param optimizer defines the current optimizer
  150825. * @returns true if everything that can be done was applied
  150826. */
  150827. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150828. }
  150829. /**
  150830. * Defines an optimization used to merge meshes with compatible materials
  150831. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150832. */
  150833. export class MergeMeshesOptimization extends SceneOptimization {
  150834. private static _UpdateSelectionTree;
  150835. /**
  150836. * Gets or sets a boolean which defines if optimization octree has to be updated
  150837. */
  150838. static get UpdateSelectionTree(): boolean;
  150839. /**
  150840. * Gets or sets a boolean which defines if optimization octree has to be updated
  150841. */
  150842. static set UpdateSelectionTree(value: boolean);
  150843. /**
  150844. * Gets a string describing the action executed by the current optimization
  150845. * @return description string
  150846. */
  150847. getDescription(): string;
  150848. private _canBeMerged;
  150849. /**
  150850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150851. * @param scene defines the current scene where to apply this optimization
  150852. * @param optimizer defines the current optimizer
  150853. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  150854. * @returns true if everything that can be done was applied
  150855. */
  150856. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  150857. }
  150858. /**
  150859. * Defines a list of options used by SceneOptimizer
  150860. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150861. */
  150862. export class SceneOptimizerOptions {
  150863. /**
  150864. * Defines the target frame rate to reach (60 by default)
  150865. */
  150866. targetFrameRate: number;
  150867. /**
  150868. * Defines the interval between two checkes (2000ms by default)
  150869. */
  150870. trackerDuration: number;
  150871. /**
  150872. * Gets the list of optimizations to apply
  150873. */
  150874. optimizations: SceneOptimization[];
  150875. /**
  150876. * Creates a new list of options used by SceneOptimizer
  150877. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  150878. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  150879. */
  150880. constructor(
  150881. /**
  150882. * Defines the target frame rate to reach (60 by default)
  150883. */
  150884. targetFrameRate?: number,
  150885. /**
  150886. * Defines the interval between two checkes (2000ms by default)
  150887. */
  150888. trackerDuration?: number);
  150889. /**
  150890. * Add a new optimization
  150891. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  150892. * @returns the current SceneOptimizerOptions
  150893. */
  150894. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  150895. /**
  150896. * Add a new custom optimization
  150897. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  150898. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  150899. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150900. * @returns the current SceneOptimizerOptions
  150901. */
  150902. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  150903. /**
  150904. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  150905. * @param targetFrameRate defines the target frame rate (60 by default)
  150906. * @returns a SceneOptimizerOptions object
  150907. */
  150908. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150909. /**
  150910. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  150911. * @param targetFrameRate defines the target frame rate (60 by default)
  150912. * @returns a SceneOptimizerOptions object
  150913. */
  150914. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150915. /**
  150916. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  150917. * @param targetFrameRate defines the target frame rate (60 by default)
  150918. * @returns a SceneOptimizerOptions object
  150919. */
  150920. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  150921. }
  150922. /**
  150923. * Class used to run optimizations in order to reach a target frame rate
  150924. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150925. */
  150926. export class SceneOptimizer implements IDisposable {
  150927. private _isRunning;
  150928. private _options;
  150929. private _scene;
  150930. private _currentPriorityLevel;
  150931. private _targetFrameRate;
  150932. private _trackerDuration;
  150933. private _currentFrameRate;
  150934. private _sceneDisposeObserver;
  150935. private _improvementMode;
  150936. /**
  150937. * Defines an observable called when the optimizer reaches the target frame rate
  150938. */
  150939. onSuccessObservable: Observable<SceneOptimizer>;
  150940. /**
  150941. * Defines an observable called when the optimizer enables an optimization
  150942. */
  150943. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  150944. /**
  150945. * Defines an observable called when the optimizer is not able to reach the target frame rate
  150946. */
  150947. onFailureObservable: Observable<SceneOptimizer>;
  150948. /**
  150949. * Gets a boolean indicating if the optimizer is in improvement mode
  150950. */
  150951. get isInImprovementMode(): boolean;
  150952. /**
  150953. * Gets the current priority level (0 at start)
  150954. */
  150955. get currentPriorityLevel(): number;
  150956. /**
  150957. * Gets the current frame rate checked by the SceneOptimizer
  150958. */
  150959. get currentFrameRate(): number;
  150960. /**
  150961. * Gets or sets the current target frame rate (60 by default)
  150962. */
  150963. get targetFrameRate(): number;
  150964. /**
  150965. * Gets or sets the current target frame rate (60 by default)
  150966. */
  150967. set targetFrameRate(value: number);
  150968. /**
  150969. * Gets or sets the current interval between two checks (every 2000ms by default)
  150970. */
  150971. get trackerDuration(): number;
  150972. /**
  150973. * Gets or sets the current interval between two checks (every 2000ms by default)
  150974. */
  150975. set trackerDuration(value: number);
  150976. /**
  150977. * Gets the list of active optimizations
  150978. */
  150979. get optimizations(): SceneOptimization[];
  150980. /**
  150981. * Creates a new SceneOptimizer
  150982. * @param scene defines the scene to work on
  150983. * @param options defines the options to use with the SceneOptimizer
  150984. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  150985. * @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)
  150986. */
  150987. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  150988. /**
  150989. * Stops the current optimizer
  150990. */
  150991. stop(): void;
  150992. /**
  150993. * Reset the optimizer to initial step (current priority level = 0)
  150994. */
  150995. reset(): void;
  150996. /**
  150997. * Start the optimizer. By default it will try to reach a specific framerate
  150998. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  150999. */
  151000. start(): void;
  151001. private _checkCurrentState;
  151002. /**
  151003. * Release all resources
  151004. */
  151005. dispose(): void;
  151006. /**
  151007. * Helper function to create a SceneOptimizer with one single line of code
  151008. * @param scene defines the scene to work on
  151009. * @param options defines the options to use with the SceneOptimizer
  151010. * @param onSuccess defines a callback to call on success
  151011. * @param onFailure defines a callback to call on failure
  151012. * @returns the new SceneOptimizer object
  151013. */
  151014. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151015. }
  151016. }
  151017. declare module BABYLON {
  151018. /**
  151019. * Class used to serialize a scene into a string
  151020. */
  151021. export class SceneSerializer {
  151022. /**
  151023. * Clear cache used by a previous serialization
  151024. */
  151025. static ClearCache(): void;
  151026. /**
  151027. * Serialize a scene into a JSON compatible object
  151028. * @param scene defines the scene to serialize
  151029. * @returns a JSON compatible object
  151030. */
  151031. static Serialize(scene: Scene): any;
  151032. /**
  151033. * Serialize a mesh into a JSON compatible object
  151034. * @param toSerialize defines the mesh to serialize
  151035. * @param withParents defines if parents must be serialized as well
  151036. * @param withChildren defines if children must be serialized as well
  151037. * @returns a JSON compatible object
  151038. */
  151039. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151040. }
  151041. }
  151042. declare module BABYLON {
  151043. /**
  151044. * Class used to host texture specific utilities
  151045. */
  151046. export class TextureTools {
  151047. /**
  151048. * Uses the GPU to create a copy texture rescaled at a given size
  151049. * @param texture Texture to copy from
  151050. * @param width defines the desired width
  151051. * @param height defines the desired height
  151052. * @param useBilinearMode defines if bilinear mode has to be used
  151053. * @return the generated texture
  151054. */
  151055. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151056. }
  151057. }
  151058. declare module BABYLON {
  151059. /**
  151060. * This represents the different options available for the video capture.
  151061. */
  151062. export interface VideoRecorderOptions {
  151063. /** Defines the mime type of the video. */
  151064. mimeType: string;
  151065. /** Defines the FPS the video should be recorded at. */
  151066. fps: number;
  151067. /** Defines the chunk size for the recording data. */
  151068. recordChunckSize: number;
  151069. /** The audio tracks to attach to the recording. */
  151070. audioTracks?: MediaStreamTrack[];
  151071. }
  151072. /**
  151073. * This can help with recording videos from BabylonJS.
  151074. * This is based on the available WebRTC functionalities of the browser.
  151075. *
  151076. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151077. */
  151078. export class VideoRecorder {
  151079. private static readonly _defaultOptions;
  151080. /**
  151081. * Returns whether or not the VideoRecorder is available in your browser.
  151082. * @param engine Defines the Babylon Engine.
  151083. * @returns true if supported otherwise false.
  151084. */
  151085. static IsSupported(engine: Engine): boolean;
  151086. private readonly _options;
  151087. private _canvas;
  151088. private _mediaRecorder;
  151089. private _recordedChunks;
  151090. private _fileName;
  151091. private _resolve;
  151092. private _reject;
  151093. /**
  151094. * True when a recording is already in progress.
  151095. */
  151096. get isRecording(): boolean;
  151097. /**
  151098. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151099. * @param engine Defines the BabylonJS Engine you wish to record.
  151100. * @param options Defines options that can be used to customize the capture.
  151101. */
  151102. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151103. /**
  151104. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151105. */
  151106. stopRecording(): void;
  151107. /**
  151108. * Starts recording the canvas for a max duration specified in parameters.
  151109. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151110. * If null no automatic download will start and you can rely on the promise to get the data back.
  151111. * @param maxDuration Defines the maximum recording time in seconds.
  151112. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151113. * @return A promise callback at the end of the recording with the video data in Blob.
  151114. */
  151115. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151116. /**
  151117. * Releases internal resources used during the recording.
  151118. */
  151119. dispose(): void;
  151120. private _handleDataAvailable;
  151121. private _handleError;
  151122. private _handleStop;
  151123. }
  151124. }
  151125. declare module BABYLON {
  151126. /**
  151127. * Class containing a set of static utilities functions for screenshots
  151128. */
  151129. export class ScreenshotTools {
  151130. /**
  151131. * Captures a screenshot of the current rendering
  151132. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151133. * @param engine defines the rendering engine
  151134. * @param camera defines the source camera
  151135. * @param size This parameter can be set to a single number or to an object with the
  151136. * following (optional) properties: precision, width, height. If a single number is passed,
  151137. * it will be used for both width and height. If an object is passed, the screenshot size
  151138. * will be derived from the parameters. The precision property is a multiplier allowing
  151139. * rendering at a higher or lower resolution
  151140. * @param successCallback defines the callback receives a single parameter which contains the
  151141. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151142. * src parameter of an <img> to display it
  151143. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151144. * Check your browser for supported MIME types
  151145. */
  151146. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151147. /**
  151148. * Captures a screenshot of the current rendering
  151149. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151150. * @param engine defines the rendering engine
  151151. * @param camera defines the source camera
  151152. * @param size This parameter can be set to a single number or to an object with the
  151153. * following (optional) properties: precision, width, height. If a single number is passed,
  151154. * it will be used for both width and height. If an object is passed, the screenshot size
  151155. * will be derived from the parameters. The precision property is a multiplier allowing
  151156. * rendering at a higher or lower resolution
  151157. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151158. * Check your browser for supported MIME types
  151159. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151160. * to the src parameter of an <img> to display it
  151161. */
  151162. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151163. /**
  151164. * Generates an image screenshot from the specified camera.
  151165. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151166. * @param engine The engine to use for rendering
  151167. * @param camera The camera to use for rendering
  151168. * @param size This parameter can be set to a single number or to an object with the
  151169. * following (optional) properties: precision, width, height. If a single number is passed,
  151170. * it will be used for both width and height. If an object is passed, the screenshot size
  151171. * will be derived from the parameters. The precision property is a multiplier allowing
  151172. * rendering at a higher or lower resolution
  151173. * @param successCallback The callback receives a single parameter which contains the
  151174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151175. * src parameter of an <img> to display it
  151176. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151177. * Check your browser for supported MIME types
  151178. * @param samples Texture samples (default: 1)
  151179. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151180. * @param fileName A name for for the downloaded file.
  151181. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151182. */
  151183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151184. /**
  151185. * Generates an image screenshot from the specified camera.
  151186. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151187. * @param engine The engine to use for rendering
  151188. * @param camera The camera to use for rendering
  151189. * @param size This parameter can be set to a single number or to an object with the
  151190. * following (optional) properties: precision, width, height. If a single number is passed,
  151191. * it will be used for both width and height. If an object is passed, the screenshot size
  151192. * will be derived from the parameters. The precision property is a multiplier allowing
  151193. * rendering at a higher or lower resolution
  151194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151195. * Check your browser for supported MIME types
  151196. * @param samples Texture samples (default: 1)
  151197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151198. * @param fileName A name for for the downloaded file.
  151199. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151200. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151201. * to the src parameter of an <img> to display it
  151202. */
  151203. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151204. /**
  151205. * Gets height and width for screenshot size
  151206. * @private
  151207. */
  151208. private static _getScreenshotSize;
  151209. }
  151210. }
  151211. declare module BABYLON {
  151212. /**
  151213. * Interface for a data buffer
  151214. */
  151215. export interface IDataBuffer {
  151216. /**
  151217. * Reads bytes from the data buffer.
  151218. * @param byteOffset The byte offset to read
  151219. * @param byteLength The byte length to read
  151220. * @returns A promise that resolves when the bytes are read
  151221. */
  151222. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151223. /**
  151224. * The byte length of the buffer.
  151225. */
  151226. readonly byteLength: number;
  151227. }
  151228. /**
  151229. * Utility class for reading from a data buffer
  151230. */
  151231. export class DataReader {
  151232. /**
  151233. * The data buffer associated with this data reader.
  151234. */
  151235. readonly buffer: IDataBuffer;
  151236. /**
  151237. * The current byte offset from the beginning of the data buffer.
  151238. */
  151239. byteOffset: number;
  151240. private _dataView;
  151241. private _dataByteOffset;
  151242. /**
  151243. * Constructor
  151244. * @param buffer The buffer to read
  151245. */
  151246. constructor(buffer: IDataBuffer);
  151247. /**
  151248. * Loads the given byte length.
  151249. * @param byteLength The byte length to load
  151250. * @returns A promise that resolves when the load is complete
  151251. */
  151252. loadAsync(byteLength: number): Promise<void>;
  151253. /**
  151254. * Read a unsigned 32-bit integer from the currently loaded data range.
  151255. * @returns The 32-bit integer read
  151256. */
  151257. readUint32(): number;
  151258. /**
  151259. * Read a byte array from the currently loaded data range.
  151260. * @param byteLength The byte length to read
  151261. * @returns The byte array read
  151262. */
  151263. readUint8Array(byteLength: number): Uint8Array;
  151264. /**
  151265. * Read a string from the currently loaded data range.
  151266. * @param byteLength The byte length to read
  151267. * @returns The string read
  151268. */
  151269. readString(byteLength: number): string;
  151270. /**
  151271. * Skips the given byte length the currently loaded data range.
  151272. * @param byteLength The byte length to skip
  151273. */
  151274. skipBytes(byteLength: number): void;
  151275. }
  151276. }
  151277. declare module BABYLON {
  151278. /**
  151279. * Class for storing data to local storage if available or in-memory storage otherwise
  151280. */
  151281. export class DataStorage {
  151282. private static _Storage;
  151283. private static _GetStorage;
  151284. /**
  151285. * Reads a string from the data storage
  151286. * @param key The key to read
  151287. * @param defaultValue The value if the key doesn't exist
  151288. * @returns The string value
  151289. */
  151290. static ReadString(key: string, defaultValue: string): string;
  151291. /**
  151292. * Writes a string to the data storage
  151293. * @param key The key to write
  151294. * @param value The value to write
  151295. */
  151296. static WriteString(key: string, value: string): void;
  151297. /**
  151298. * Reads a boolean from the data storage
  151299. * @param key The key to read
  151300. * @param defaultValue The value if the key doesn't exist
  151301. * @returns The boolean value
  151302. */
  151303. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151304. /**
  151305. * Writes a boolean to the data storage
  151306. * @param key The key to write
  151307. * @param value The value to write
  151308. */
  151309. static WriteBoolean(key: string, value: boolean): void;
  151310. /**
  151311. * Reads a number from the data storage
  151312. * @param key The key to read
  151313. * @param defaultValue The value if the key doesn't exist
  151314. * @returns The number value
  151315. */
  151316. static ReadNumber(key: string, defaultValue: number): number;
  151317. /**
  151318. * Writes a number to the data storage
  151319. * @param key The key to write
  151320. * @param value The value to write
  151321. */
  151322. static WriteNumber(key: string, value: number): void;
  151323. }
  151324. }
  151325. declare module BABYLON {
  151326. /**
  151327. * An interface for all Hit test features
  151328. */
  151329. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151330. /**
  151331. * Triggered when new babylon (transformed) hit test results are available
  151332. */
  151333. onHitTestResultObservable: Observable<T[]>;
  151334. }
  151335. /**
  151336. * Options used for hit testing
  151337. */
  151338. export interface IWebXRLegacyHitTestOptions {
  151339. /**
  151340. * Only test when user interacted with the scene. Default - hit test every frame
  151341. */
  151342. testOnPointerDownOnly?: boolean;
  151343. /**
  151344. * The node to use to transform the local results to world coordinates
  151345. */
  151346. worldParentNode?: TransformNode;
  151347. }
  151348. /**
  151349. * Interface defining the babylon result of raycasting/hit-test
  151350. */
  151351. export interface IWebXRLegacyHitResult {
  151352. /**
  151353. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151354. */
  151355. transformationMatrix: Matrix;
  151356. /**
  151357. * The native hit test result
  151358. */
  151359. xrHitResult: XRHitResult | XRHitTestResult;
  151360. }
  151361. /**
  151362. * The currently-working hit-test module.
  151363. * Hit test (or Ray-casting) is used to interact with the real world.
  151364. * For further information read here - https://github.com/immersive-web/hit-test
  151365. */
  151366. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151367. /**
  151368. * options to use when constructing this feature
  151369. */
  151370. readonly options: IWebXRLegacyHitTestOptions;
  151371. private _direction;
  151372. private _mat;
  151373. private _onSelectEnabled;
  151374. private _origin;
  151375. /**
  151376. * The module's name
  151377. */
  151378. static readonly Name: string;
  151379. /**
  151380. * The (Babylon) version of this module.
  151381. * This is an integer representing the implementation version.
  151382. * This number does not correspond to the WebXR specs version
  151383. */
  151384. static readonly Version: number;
  151385. /**
  151386. * Populated with the last native XR Hit Results
  151387. */
  151388. lastNativeXRHitResults: XRHitResult[];
  151389. /**
  151390. * Triggered when new babylon (transformed) hit test results are available
  151391. */
  151392. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151393. /**
  151394. * Creates a new instance of the (legacy version) hit test feature
  151395. * @param _xrSessionManager an instance of WebXRSessionManager
  151396. * @param options options to use when constructing this feature
  151397. */
  151398. constructor(_xrSessionManager: WebXRSessionManager,
  151399. /**
  151400. * options to use when constructing this feature
  151401. */
  151402. options?: IWebXRLegacyHitTestOptions);
  151403. /**
  151404. * execute a hit test with an XR Ray
  151405. *
  151406. * @param xrSession a native xrSession that will execute this hit test
  151407. * @param xrRay the ray (position and direction) to use for ray-casting
  151408. * @param referenceSpace native XR reference space to use for the hit-test
  151409. * @param filter filter function that will filter the results
  151410. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151411. */
  151412. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151413. /**
  151414. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151415. * @param event the (select) event to use to select with
  151416. * @param referenceSpace the reference space to use for this hit test
  151417. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151418. */
  151419. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151420. /**
  151421. * attach this feature
  151422. * Will usually be called by the features manager
  151423. *
  151424. * @returns true if successful.
  151425. */
  151426. attach(): boolean;
  151427. /**
  151428. * detach this feature.
  151429. * Will usually be called by the features manager
  151430. *
  151431. * @returns true if successful.
  151432. */
  151433. detach(): boolean;
  151434. /**
  151435. * Dispose this feature and all of the resources attached
  151436. */
  151437. dispose(): void;
  151438. protected _onXRFrame(frame: XRFrame): void;
  151439. private _onHitTestResults;
  151440. private _onSelect;
  151441. }
  151442. }
  151443. declare module BABYLON {
  151444. /**
  151445. * Options used for hit testing (version 2)
  151446. */
  151447. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151448. /**
  151449. * Do not create a permanent hit test. Will usually be used when only
  151450. * transient inputs are needed.
  151451. */
  151452. disablePermanentHitTest?: boolean;
  151453. /**
  151454. * Enable transient (for example touch-based) hit test inspections
  151455. */
  151456. enableTransientHitTest?: boolean;
  151457. /**
  151458. * Offset ray for the permanent hit test
  151459. */
  151460. offsetRay?: Vector3;
  151461. /**
  151462. * Offset ray for the transient hit test
  151463. */
  151464. transientOffsetRay?: Vector3;
  151465. /**
  151466. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151467. */
  151468. useReferenceSpace?: boolean;
  151469. }
  151470. /**
  151471. * Interface defining the babylon result of hit-test
  151472. */
  151473. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151474. /**
  151475. * The input source that generated this hit test (if transient)
  151476. */
  151477. inputSource?: XRInputSource;
  151478. /**
  151479. * Is this a transient hit test
  151480. */
  151481. isTransient?: boolean;
  151482. /**
  151483. * Position of the hit test result
  151484. */
  151485. position: Vector3;
  151486. /**
  151487. * Rotation of the hit test result
  151488. */
  151489. rotationQuaternion: Quaternion;
  151490. /**
  151491. * The native hit test result
  151492. */
  151493. xrHitResult: XRHitTestResult;
  151494. }
  151495. /**
  151496. * The currently-working hit-test module.
  151497. * Hit test (or Ray-casting) is used to interact with the real world.
  151498. * For further information read here - https://github.com/immersive-web/hit-test
  151499. *
  151500. * Tested on chrome (mobile) 80.
  151501. */
  151502. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151503. /**
  151504. * options to use when constructing this feature
  151505. */
  151506. readonly options: IWebXRHitTestOptions;
  151507. private _tmpMat;
  151508. private _tmpPos;
  151509. private _tmpQuat;
  151510. private _transientXrHitTestSource;
  151511. private _xrHitTestSource;
  151512. private initHitTestSource;
  151513. /**
  151514. * The module's name
  151515. */
  151516. static readonly Name: string;
  151517. /**
  151518. * The (Babylon) version of this module.
  151519. * This is an integer representing the implementation version.
  151520. * This number does not correspond to the WebXR specs version
  151521. */
  151522. static readonly Version: number;
  151523. /**
  151524. * When set to true, each hit test will have its own position/rotation objects
  151525. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151526. * the developers will clone them or copy them as they see fit.
  151527. */
  151528. autoCloneTransformation: boolean;
  151529. /**
  151530. * Triggered when new babylon (transformed) hit test results are available
  151531. */
  151532. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151533. /**
  151534. * Use this to temporarily pause hit test checks.
  151535. */
  151536. paused: boolean;
  151537. /**
  151538. * Creates a new instance of the hit test feature
  151539. * @param _xrSessionManager an instance of WebXRSessionManager
  151540. * @param options options to use when constructing this feature
  151541. */
  151542. constructor(_xrSessionManager: WebXRSessionManager,
  151543. /**
  151544. * options to use when constructing this feature
  151545. */
  151546. options?: IWebXRHitTestOptions);
  151547. /**
  151548. * attach this feature
  151549. * Will usually be called by the features manager
  151550. *
  151551. * @returns true if successful.
  151552. */
  151553. attach(): boolean;
  151554. /**
  151555. * detach this feature.
  151556. * Will usually be called by the features manager
  151557. *
  151558. * @returns true if successful.
  151559. */
  151560. detach(): boolean;
  151561. /**
  151562. * Dispose this feature and all of the resources attached
  151563. */
  151564. dispose(): void;
  151565. protected _onXRFrame(frame: XRFrame): void;
  151566. private _processWebXRHitTestResult;
  151567. }
  151568. }
  151569. declare module BABYLON {
  151570. /**
  151571. * Configuration options of the anchor system
  151572. */
  151573. export interface IWebXRAnchorSystemOptions {
  151574. /**
  151575. * a node that will be used to convert local to world coordinates
  151576. */
  151577. worldParentNode?: TransformNode;
  151578. /**
  151579. * If set to true a reference of the created anchors will be kept until the next session starts
  151580. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151581. */
  151582. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151583. }
  151584. /**
  151585. * A babylon container for an XR Anchor
  151586. */
  151587. export interface IWebXRAnchor {
  151588. /**
  151589. * A babylon-assigned ID for this anchor
  151590. */
  151591. id: number;
  151592. /**
  151593. * Transformation matrix to apply to an object attached to this anchor
  151594. */
  151595. transformationMatrix: Matrix;
  151596. /**
  151597. * The native anchor object
  151598. */
  151599. xrAnchor: XRAnchor;
  151600. /**
  151601. * if defined, this object will be constantly updated by the anchor's position and rotation
  151602. */
  151603. attachedNode?: TransformNode;
  151604. }
  151605. /**
  151606. * An implementation of the anchor system for WebXR.
  151607. * For further information see https://github.com/immersive-web/anchors/
  151608. */
  151609. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151610. private _options;
  151611. private _lastFrameDetected;
  151612. private _trackedAnchors;
  151613. private _referenceSpaceForFrameAnchors;
  151614. private _futureAnchors;
  151615. /**
  151616. * The module's name
  151617. */
  151618. static readonly Name: string;
  151619. /**
  151620. * The (Babylon) version of this module.
  151621. * This is an integer representing the implementation version.
  151622. * This number does not correspond to the WebXR specs version
  151623. */
  151624. static readonly Version: number;
  151625. /**
  151626. * Observers registered here will be executed when a new anchor was added to the session
  151627. */
  151628. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151629. /**
  151630. * Observers registered here will be executed when an anchor was removed from the session
  151631. */
  151632. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151633. /**
  151634. * Observers registered here will be executed when an existing anchor updates
  151635. * This can execute N times every frame
  151636. */
  151637. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151638. /**
  151639. * Set the reference space to use for anchor creation, when not using a hit test.
  151640. * Will default to the session's reference space if not defined
  151641. */
  151642. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151643. /**
  151644. * constructs a new anchor system
  151645. * @param _xrSessionManager an instance of WebXRSessionManager
  151646. * @param _options configuration object for this feature
  151647. */
  151648. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151649. private _tmpVector;
  151650. private _tmpQuaternion;
  151651. private _populateTmpTransformation;
  151652. /**
  151653. * Create a new anchor point using a hit test result at a specific point in the scene
  151654. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151655. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151656. *
  151657. * @param hitTestResult The hit test result to use for this anchor creation
  151658. * @param position an optional position offset for this anchor
  151659. * @param rotationQuaternion an optional rotation offset for this anchor
  151660. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151661. */
  151662. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151663. /**
  151664. * Add a new anchor at a specific position and rotation
  151665. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151666. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151667. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151668. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151669. *
  151670. * @param position the position in which to add an anchor
  151671. * @param rotationQuaternion an optional rotation for the anchor transformation
  151672. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151673. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151674. */
  151675. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151676. /**
  151677. * detach this feature.
  151678. * Will usually be called by the features manager
  151679. *
  151680. * @returns true if successful.
  151681. */
  151682. detach(): boolean;
  151683. /**
  151684. * Dispose this feature and all of the resources attached
  151685. */
  151686. dispose(): void;
  151687. protected _onXRFrame(frame: XRFrame): void;
  151688. /**
  151689. * avoiding using Array.find for global support.
  151690. * @param xrAnchor the plane to find in the array
  151691. */
  151692. private _findIndexInAnchorArray;
  151693. private _updateAnchorWithXRFrame;
  151694. private _createAnchorAtTransformation;
  151695. }
  151696. }
  151697. declare module BABYLON {
  151698. /**
  151699. * Options used in the plane detector module
  151700. */
  151701. export interface IWebXRPlaneDetectorOptions {
  151702. /**
  151703. * The node to use to transform the local results to world coordinates
  151704. */
  151705. worldParentNode?: TransformNode;
  151706. /**
  151707. * If set to true a reference of the created planes will be kept until the next session starts
  151708. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151709. */
  151710. doNotRemovePlanesOnSessionEnded?: boolean;
  151711. }
  151712. /**
  151713. * A babylon interface for a WebXR plane.
  151714. * A Plane is actually a polygon, built from N points in space
  151715. *
  151716. * Supported in chrome 79, not supported in canary 81 ATM
  151717. */
  151718. export interface IWebXRPlane {
  151719. /**
  151720. * a babylon-assigned ID for this polygon
  151721. */
  151722. id: number;
  151723. /**
  151724. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151725. */
  151726. polygonDefinition: Array<Vector3>;
  151727. /**
  151728. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151729. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151730. */
  151731. transformationMatrix: Matrix;
  151732. /**
  151733. * the native xr-plane object
  151734. */
  151735. xrPlane: XRPlane;
  151736. }
  151737. /**
  151738. * The plane detector is used to detect planes in the real world when in AR
  151739. * For more information see https://github.com/immersive-web/real-world-geometry/
  151740. */
  151741. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151742. private _options;
  151743. private _detectedPlanes;
  151744. private _enabled;
  151745. private _lastFrameDetected;
  151746. /**
  151747. * The module's name
  151748. */
  151749. static readonly Name: string;
  151750. /**
  151751. * The (Babylon) version of this module.
  151752. * This is an integer representing the implementation version.
  151753. * This number does not correspond to the WebXR specs version
  151754. */
  151755. static readonly Version: number;
  151756. /**
  151757. * Observers registered here will be executed when a new plane was added to the session
  151758. */
  151759. onPlaneAddedObservable: Observable<IWebXRPlane>;
  151760. /**
  151761. * Observers registered here will be executed when a plane is no longer detected in the session
  151762. */
  151763. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  151764. /**
  151765. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  151766. * This can execute N times every frame
  151767. */
  151768. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  151769. /**
  151770. * construct a new Plane Detector
  151771. * @param _xrSessionManager an instance of xr Session manager
  151772. * @param _options configuration to use when constructing this feature
  151773. */
  151774. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  151775. /**
  151776. * detach this feature.
  151777. * Will usually be called by the features manager
  151778. *
  151779. * @returns true if successful.
  151780. */
  151781. detach(): boolean;
  151782. /**
  151783. * Dispose this feature and all of the resources attached
  151784. */
  151785. dispose(): void;
  151786. protected _onXRFrame(frame: XRFrame): void;
  151787. private _init;
  151788. private _updatePlaneWithXRPlane;
  151789. /**
  151790. * avoiding using Array.find for global support.
  151791. * @param xrPlane the plane to find in the array
  151792. */
  151793. private findIndexInPlaneArray;
  151794. }
  151795. }
  151796. declare module BABYLON {
  151797. /**
  151798. * Options interface for the background remover plugin
  151799. */
  151800. export interface IWebXRBackgroundRemoverOptions {
  151801. /**
  151802. * Further background meshes to disable when entering AR
  151803. */
  151804. backgroundMeshes?: AbstractMesh[];
  151805. /**
  151806. * flags to configure the removal of the environment helper.
  151807. * If not set, the entire background will be removed. If set, flags should be set as well.
  151808. */
  151809. environmentHelperRemovalFlags?: {
  151810. /**
  151811. * Should the skybox be removed (default false)
  151812. */
  151813. skyBox?: boolean;
  151814. /**
  151815. * Should the ground be removed (default false)
  151816. */
  151817. ground?: boolean;
  151818. };
  151819. /**
  151820. * don't disable the environment helper
  151821. */
  151822. ignoreEnvironmentHelper?: boolean;
  151823. }
  151824. /**
  151825. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  151826. */
  151827. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  151828. /**
  151829. * read-only options to be used in this module
  151830. */
  151831. readonly options: IWebXRBackgroundRemoverOptions;
  151832. /**
  151833. * The module's name
  151834. */
  151835. static readonly Name: string;
  151836. /**
  151837. * The (Babylon) version of this module.
  151838. * This is an integer representing the implementation version.
  151839. * This number does not correspond to the WebXR specs version
  151840. */
  151841. static readonly Version: number;
  151842. /**
  151843. * registered observers will be triggered when the background state changes
  151844. */
  151845. onBackgroundStateChangedObservable: Observable<boolean>;
  151846. /**
  151847. * constructs a new background remover module
  151848. * @param _xrSessionManager the session manager for this module
  151849. * @param options read-only options to be used in this module
  151850. */
  151851. constructor(_xrSessionManager: WebXRSessionManager,
  151852. /**
  151853. * read-only options to be used in this module
  151854. */
  151855. options?: IWebXRBackgroundRemoverOptions);
  151856. /**
  151857. * attach this feature
  151858. * Will usually be called by the features manager
  151859. *
  151860. * @returns true if successful.
  151861. */
  151862. attach(): boolean;
  151863. /**
  151864. * detach this feature.
  151865. * Will usually be called by the features manager
  151866. *
  151867. * @returns true if successful.
  151868. */
  151869. detach(): boolean;
  151870. /**
  151871. * Dispose this feature and all of the resources attached
  151872. */
  151873. dispose(): void;
  151874. protected _onXRFrame(_xrFrame: XRFrame): void;
  151875. private _setBackgroundState;
  151876. }
  151877. }
  151878. declare module BABYLON {
  151879. /**
  151880. * Options for the controller physics feature
  151881. */
  151882. export class IWebXRControllerPhysicsOptions {
  151883. /**
  151884. * Should the headset get its own impostor
  151885. */
  151886. enableHeadsetImpostor?: boolean;
  151887. /**
  151888. * Optional parameters for the headset impostor
  151889. */
  151890. headsetImpostorParams?: {
  151891. /**
  151892. * The type of impostor to create. Default is sphere
  151893. */
  151894. impostorType: number;
  151895. /**
  151896. * the size of the impostor. Defaults to 10cm
  151897. */
  151898. impostorSize?: number | {
  151899. width: number;
  151900. height: number;
  151901. depth: number;
  151902. };
  151903. /**
  151904. * Friction definitions
  151905. */
  151906. friction?: number;
  151907. /**
  151908. * Restitution
  151909. */
  151910. restitution?: number;
  151911. };
  151912. /**
  151913. * The physics properties of the future impostors
  151914. */
  151915. physicsProperties?: {
  151916. /**
  151917. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  151918. * Note that this requires a physics engine that supports mesh impostors!
  151919. */
  151920. useControllerMesh?: boolean;
  151921. /**
  151922. * The type of impostor to create. Default is sphere
  151923. */
  151924. impostorType?: number;
  151925. /**
  151926. * the size of the impostor. Defaults to 10cm
  151927. */
  151928. impostorSize?: number | {
  151929. width: number;
  151930. height: number;
  151931. depth: number;
  151932. };
  151933. /**
  151934. * Friction definitions
  151935. */
  151936. friction?: number;
  151937. /**
  151938. * Restitution
  151939. */
  151940. restitution?: number;
  151941. };
  151942. /**
  151943. * the xr input to use with this pointer selection
  151944. */
  151945. xrInput: WebXRInput;
  151946. }
  151947. /**
  151948. * Add physics impostor to your webxr controllers,
  151949. * including naive calculation of their linear and angular velocity
  151950. */
  151951. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  151952. private readonly _options;
  151953. private _attachController;
  151954. private _controllers;
  151955. private _debugMode;
  151956. private _delta;
  151957. private _headsetImpostor?;
  151958. private _headsetMesh?;
  151959. private _lastTimestamp;
  151960. private _tmpQuaternion;
  151961. private _tmpVector;
  151962. /**
  151963. * The module's name
  151964. */
  151965. static readonly Name: string;
  151966. /**
  151967. * The (Babylon) version of this module.
  151968. * This is an integer representing the implementation version.
  151969. * This number does not correspond to the webxr specs version
  151970. */
  151971. static readonly Version: number;
  151972. /**
  151973. * Construct a new Controller Physics Feature
  151974. * @param _xrSessionManager the corresponding xr session manager
  151975. * @param _options options to create this feature with
  151976. */
  151977. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  151978. /**
  151979. * @hidden
  151980. * enable debugging - will show console outputs and the impostor mesh
  151981. */
  151982. _enablePhysicsDebug(): void;
  151983. /**
  151984. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  151985. * @param xrController the controller to add
  151986. */
  151987. addController(xrController: WebXRInputSource): void;
  151988. /**
  151989. * attach this feature
  151990. * Will usually be called by the features manager
  151991. *
  151992. * @returns true if successful.
  151993. */
  151994. attach(): boolean;
  151995. /**
  151996. * detach this feature.
  151997. * Will usually be called by the features manager
  151998. *
  151999. * @returns true if successful.
  152000. */
  152001. detach(): boolean;
  152002. /**
  152003. * Get the headset impostor, if enabled
  152004. * @returns the impostor
  152005. */
  152006. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152007. /**
  152008. * Get the physics impostor of a specific controller.
  152009. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152010. * @param controller the controller or the controller id of which to get the impostor
  152011. * @returns the impostor or null
  152012. */
  152013. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152014. /**
  152015. * Update the physics properties provided in the constructor
  152016. * @param newProperties the new properties object
  152017. */
  152018. setPhysicsProperties(newProperties: {
  152019. impostorType?: number;
  152020. impostorSize?: number | {
  152021. width: number;
  152022. height: number;
  152023. depth: number;
  152024. };
  152025. friction?: number;
  152026. restitution?: number;
  152027. }): void;
  152028. protected _onXRFrame(_xrFrame: any): void;
  152029. private _detachController;
  152030. }
  152031. }
  152032. declare module BABYLON {
  152033. /**
  152034. * The motion controller class for all microsoft mixed reality controllers
  152035. */
  152036. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152037. protected readonly _mapping: {
  152038. defaultButton: {
  152039. valueNodeName: string;
  152040. unpressedNodeName: string;
  152041. pressedNodeName: string;
  152042. };
  152043. defaultAxis: {
  152044. valueNodeName: string;
  152045. minNodeName: string;
  152046. maxNodeName: string;
  152047. };
  152048. buttons: {
  152049. "xr-standard-trigger": {
  152050. rootNodeName: string;
  152051. componentProperty: string;
  152052. states: string[];
  152053. };
  152054. "xr-standard-squeeze": {
  152055. rootNodeName: string;
  152056. componentProperty: string;
  152057. states: string[];
  152058. };
  152059. "xr-standard-touchpad": {
  152060. rootNodeName: string;
  152061. labelAnchorNodeName: string;
  152062. touchPointNodeName: string;
  152063. };
  152064. "xr-standard-thumbstick": {
  152065. rootNodeName: string;
  152066. componentProperty: string;
  152067. states: string[];
  152068. };
  152069. };
  152070. axes: {
  152071. "xr-standard-touchpad": {
  152072. "x-axis": {
  152073. rootNodeName: string;
  152074. };
  152075. "y-axis": {
  152076. rootNodeName: string;
  152077. };
  152078. };
  152079. "xr-standard-thumbstick": {
  152080. "x-axis": {
  152081. rootNodeName: string;
  152082. };
  152083. "y-axis": {
  152084. rootNodeName: string;
  152085. };
  152086. };
  152087. };
  152088. };
  152089. /**
  152090. * The base url used to load the left and right controller models
  152091. */
  152092. static MODEL_BASE_URL: string;
  152093. /**
  152094. * The name of the left controller model file
  152095. */
  152096. static MODEL_LEFT_FILENAME: string;
  152097. /**
  152098. * The name of the right controller model file
  152099. */
  152100. static MODEL_RIGHT_FILENAME: string;
  152101. profileId: string;
  152102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152103. protected _getFilenameAndPath(): {
  152104. filename: string;
  152105. path: string;
  152106. };
  152107. protected _getModelLoadingConstraints(): boolean;
  152108. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152109. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152110. protected _updateModel(): void;
  152111. }
  152112. }
  152113. declare module BABYLON {
  152114. /**
  152115. * The motion controller class for oculus touch (quest, rift).
  152116. * This class supports legacy mapping as well the standard xr mapping
  152117. */
  152118. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152119. private _forceLegacyControllers;
  152120. private _modelRootNode;
  152121. /**
  152122. * The base url used to load the left and right controller models
  152123. */
  152124. static MODEL_BASE_URL: string;
  152125. /**
  152126. * The name of the left controller model file
  152127. */
  152128. static MODEL_LEFT_FILENAME: string;
  152129. /**
  152130. * The name of the right controller model file
  152131. */
  152132. static MODEL_RIGHT_FILENAME: string;
  152133. /**
  152134. * Base Url for the Quest controller model.
  152135. */
  152136. static QUEST_MODEL_BASE_URL: string;
  152137. profileId: string;
  152138. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152139. protected _getFilenameAndPath(): {
  152140. filename: string;
  152141. path: string;
  152142. };
  152143. protected _getModelLoadingConstraints(): boolean;
  152144. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152145. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152146. protected _updateModel(): void;
  152147. /**
  152148. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152149. * between the touch and touch 2.
  152150. */
  152151. private _isQuest;
  152152. }
  152153. }
  152154. declare module BABYLON {
  152155. /**
  152156. * The motion controller class for the standard HTC-Vive controllers
  152157. */
  152158. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152159. private _modelRootNode;
  152160. /**
  152161. * The base url used to load the left and right controller models
  152162. */
  152163. static MODEL_BASE_URL: string;
  152164. /**
  152165. * File name for the controller model.
  152166. */
  152167. static MODEL_FILENAME: string;
  152168. profileId: string;
  152169. /**
  152170. * Create a new Vive motion controller object
  152171. * @param scene the scene to use to create this controller
  152172. * @param gamepadObject the corresponding gamepad object
  152173. * @param handedness the handedness of the controller
  152174. */
  152175. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152176. protected _getFilenameAndPath(): {
  152177. filename: string;
  152178. path: string;
  152179. };
  152180. protected _getModelLoadingConstraints(): boolean;
  152181. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152182. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152183. protected _updateModel(): void;
  152184. }
  152185. }
  152186. declare module BABYLON {
  152187. /**
  152188. * A cursor which tracks a point on a path
  152189. */
  152190. export class PathCursor {
  152191. private path;
  152192. /**
  152193. * Stores path cursor callbacks for when an onchange event is triggered
  152194. */
  152195. private _onchange;
  152196. /**
  152197. * The value of the path cursor
  152198. */
  152199. value: number;
  152200. /**
  152201. * The animation array of the path cursor
  152202. */
  152203. animations: Animation[];
  152204. /**
  152205. * Initializes the path cursor
  152206. * @param path The path to track
  152207. */
  152208. constructor(path: Path2);
  152209. /**
  152210. * Gets the cursor point on the path
  152211. * @returns A point on the path cursor at the cursor location
  152212. */
  152213. getPoint(): Vector3;
  152214. /**
  152215. * Moves the cursor ahead by the step amount
  152216. * @param step The amount to move the cursor forward
  152217. * @returns This path cursor
  152218. */
  152219. moveAhead(step?: number): PathCursor;
  152220. /**
  152221. * Moves the cursor behind by the step amount
  152222. * @param step The amount to move the cursor back
  152223. * @returns This path cursor
  152224. */
  152225. moveBack(step?: number): PathCursor;
  152226. /**
  152227. * Moves the cursor by the step amount
  152228. * If the step amount is greater than one, an exception is thrown
  152229. * @param step The amount to move the cursor
  152230. * @returns This path cursor
  152231. */
  152232. move(step: number): PathCursor;
  152233. /**
  152234. * Ensures that the value is limited between zero and one
  152235. * @returns This path cursor
  152236. */
  152237. private ensureLimits;
  152238. /**
  152239. * Runs onchange callbacks on change (used by the animation engine)
  152240. * @returns This path cursor
  152241. */
  152242. private raiseOnChange;
  152243. /**
  152244. * Executes a function on change
  152245. * @param f A path cursor onchange callback
  152246. * @returns This path cursor
  152247. */
  152248. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152249. }
  152250. }
  152251. declare module BABYLON {
  152252. /** @hidden */
  152253. export var blurPixelShader: {
  152254. name: string;
  152255. shader: string;
  152256. };
  152257. }
  152258. declare module BABYLON {
  152259. /** @hidden */
  152260. export var pointCloudVertexDeclaration: {
  152261. name: string;
  152262. shader: string;
  152263. };
  152264. }
  152265. // Mixins
  152266. interface Window {
  152267. mozIndexedDB: IDBFactory;
  152268. webkitIndexedDB: IDBFactory;
  152269. msIndexedDB: IDBFactory;
  152270. webkitURL: typeof URL;
  152271. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152272. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152273. WebGLRenderingContext: WebGLRenderingContext;
  152274. MSGesture: MSGesture;
  152275. CANNON: any;
  152276. AudioContext: AudioContext;
  152277. webkitAudioContext: AudioContext;
  152278. PointerEvent: any;
  152279. Math: Math;
  152280. Uint8Array: Uint8ArrayConstructor;
  152281. Float32Array: Float32ArrayConstructor;
  152282. mozURL: typeof URL;
  152283. msURL: typeof URL;
  152284. VRFrameData: any; // WebVR, from specs 1.1
  152285. DracoDecoderModule: any;
  152286. setImmediate(handler: (...args: any[]) => void): number;
  152287. }
  152288. interface HTMLCanvasElement {
  152289. requestPointerLock(): void;
  152290. msRequestPointerLock?(): void;
  152291. mozRequestPointerLock?(): void;
  152292. webkitRequestPointerLock?(): void;
  152293. /** Track wether a record is in progress */
  152294. isRecording: boolean;
  152295. /** Capture Stream method defined by some browsers */
  152296. captureStream(fps?: number): MediaStream;
  152297. }
  152298. interface CanvasRenderingContext2D {
  152299. msImageSmoothingEnabled: boolean;
  152300. }
  152301. interface MouseEvent {
  152302. mozMovementX: number;
  152303. mozMovementY: number;
  152304. webkitMovementX: number;
  152305. webkitMovementY: number;
  152306. msMovementX: number;
  152307. msMovementY: number;
  152308. }
  152309. interface Navigator {
  152310. mozGetVRDevices: (any: any) => any;
  152311. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152312. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152313. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152314. webkitGetGamepads(): Gamepad[];
  152315. msGetGamepads(): Gamepad[];
  152316. webkitGamepads(): Gamepad[];
  152317. }
  152318. interface HTMLVideoElement {
  152319. mozSrcObject: any;
  152320. }
  152321. interface Math {
  152322. fround(x: number): number;
  152323. imul(a: number, b: number): number;
  152324. }
  152325. interface WebGLRenderingContext {
  152326. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152327. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152328. vertexAttribDivisor(index: number, divisor: number): void;
  152329. createVertexArray(): any;
  152330. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152331. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152332. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152333. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152334. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152335. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152336. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152337. // Queries
  152338. createQuery(): WebGLQuery;
  152339. deleteQuery(query: WebGLQuery): void;
  152340. beginQuery(target: number, query: WebGLQuery): void;
  152341. endQuery(target: number): void;
  152342. getQueryParameter(query: WebGLQuery, pname: number): any;
  152343. getQuery(target: number, pname: number): any;
  152344. MAX_SAMPLES: number;
  152345. RGBA8: number;
  152346. READ_FRAMEBUFFER: number;
  152347. DRAW_FRAMEBUFFER: number;
  152348. UNIFORM_BUFFER: number;
  152349. HALF_FLOAT_OES: number;
  152350. RGBA16F: number;
  152351. RGBA32F: number;
  152352. R32F: number;
  152353. RG32F: number;
  152354. RGB32F: number;
  152355. R16F: number;
  152356. RG16F: number;
  152357. RGB16F: number;
  152358. RED: number;
  152359. RG: number;
  152360. R8: number;
  152361. RG8: number;
  152362. UNSIGNED_INT_24_8: number;
  152363. DEPTH24_STENCIL8: number;
  152364. MIN: number;
  152365. MAX: number;
  152366. /* Multiple Render Targets */
  152367. drawBuffers(buffers: number[]): void;
  152368. readBuffer(src: number): void;
  152369. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152370. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152371. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152372. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152373. // Occlusion Query
  152374. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152375. ANY_SAMPLES_PASSED: number;
  152376. QUERY_RESULT_AVAILABLE: number;
  152377. QUERY_RESULT: number;
  152378. }
  152379. interface WebGLProgram {
  152380. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152381. }
  152382. interface EXT_disjoint_timer_query {
  152383. QUERY_COUNTER_BITS_EXT: number;
  152384. TIME_ELAPSED_EXT: number;
  152385. TIMESTAMP_EXT: number;
  152386. GPU_DISJOINT_EXT: number;
  152387. QUERY_RESULT_EXT: number;
  152388. QUERY_RESULT_AVAILABLE_EXT: number;
  152389. queryCounterEXT(query: WebGLQuery, target: number): void;
  152390. createQueryEXT(): WebGLQuery;
  152391. beginQueryEXT(target: number, query: WebGLQuery): void;
  152392. endQueryEXT(target: number): void;
  152393. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152394. deleteQueryEXT(query: WebGLQuery): void;
  152395. }
  152396. interface WebGLUniformLocation {
  152397. _currentState: any;
  152398. }
  152399. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152400. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152401. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152402. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152403. interface WebGLRenderingContext {
  152404. readonly RASTERIZER_DISCARD: number;
  152405. readonly DEPTH_COMPONENT24: number;
  152406. readonly TEXTURE_3D: number;
  152407. readonly TEXTURE_2D_ARRAY: number;
  152408. readonly TEXTURE_COMPARE_FUNC: number;
  152409. readonly TEXTURE_COMPARE_MODE: number;
  152410. readonly COMPARE_REF_TO_TEXTURE: number;
  152411. readonly TEXTURE_WRAP_R: number;
  152412. readonly HALF_FLOAT: number;
  152413. readonly RGB8: number;
  152414. readonly RED_INTEGER: number;
  152415. readonly RG_INTEGER: number;
  152416. readonly RGB_INTEGER: number;
  152417. readonly RGBA_INTEGER: number;
  152418. readonly R8_SNORM: number;
  152419. readonly RG8_SNORM: number;
  152420. readonly RGB8_SNORM: number;
  152421. readonly RGBA8_SNORM: number;
  152422. readonly R8I: number;
  152423. readonly RG8I: number;
  152424. readonly RGB8I: number;
  152425. readonly RGBA8I: number;
  152426. readonly R8UI: number;
  152427. readonly RG8UI: number;
  152428. readonly RGB8UI: number;
  152429. readonly RGBA8UI: number;
  152430. readonly R16I: number;
  152431. readonly RG16I: number;
  152432. readonly RGB16I: number;
  152433. readonly RGBA16I: number;
  152434. readonly R16UI: number;
  152435. readonly RG16UI: number;
  152436. readonly RGB16UI: number;
  152437. readonly RGBA16UI: number;
  152438. readonly R32I: number;
  152439. readonly RG32I: number;
  152440. readonly RGB32I: number;
  152441. readonly RGBA32I: number;
  152442. readonly R32UI: number;
  152443. readonly RG32UI: number;
  152444. readonly RGB32UI: number;
  152445. readonly RGBA32UI: number;
  152446. readonly RGB10_A2UI: number;
  152447. readonly R11F_G11F_B10F: number;
  152448. readonly RGB9_E5: number;
  152449. readonly RGB10_A2: number;
  152450. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152451. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152452. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152453. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152454. readonly DEPTH_COMPONENT32F: number;
  152455. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152456. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152457. 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;
  152458. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152459. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152460. readonly TRANSFORM_FEEDBACK: number;
  152461. readonly INTERLEAVED_ATTRIBS: number;
  152462. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152463. createTransformFeedback(): WebGLTransformFeedback;
  152464. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152465. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152466. beginTransformFeedback(primitiveMode: number): void;
  152467. endTransformFeedback(): void;
  152468. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152469. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152470. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152471. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152472. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152473. }
  152474. interface ImageBitmap {
  152475. readonly width: number;
  152476. readonly height: number;
  152477. close(): void;
  152478. }
  152479. interface WebGLQuery extends WebGLObject {
  152480. }
  152481. declare var WebGLQuery: {
  152482. prototype: WebGLQuery;
  152483. new(): WebGLQuery;
  152484. };
  152485. interface WebGLSampler extends WebGLObject {
  152486. }
  152487. declare var WebGLSampler: {
  152488. prototype: WebGLSampler;
  152489. new(): WebGLSampler;
  152490. };
  152491. interface WebGLSync extends WebGLObject {
  152492. }
  152493. declare var WebGLSync: {
  152494. prototype: WebGLSync;
  152495. new(): WebGLSync;
  152496. };
  152497. interface WebGLTransformFeedback extends WebGLObject {
  152498. }
  152499. declare var WebGLTransformFeedback: {
  152500. prototype: WebGLTransformFeedback;
  152501. new(): WebGLTransformFeedback;
  152502. };
  152503. interface WebGLVertexArrayObject extends WebGLObject {
  152504. }
  152505. declare var WebGLVertexArrayObject: {
  152506. prototype: WebGLVertexArrayObject;
  152507. new(): WebGLVertexArrayObject;
  152508. };
  152509. // Type definitions for WebVR API
  152510. // Project: https://w3c.github.io/webvr/
  152511. // Definitions by: six a <https://github.com/lostfictions>
  152512. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152513. interface VRDisplay extends EventTarget {
  152514. /**
  152515. * Dictionary of capabilities describing the VRDisplay.
  152516. */
  152517. readonly capabilities: VRDisplayCapabilities;
  152518. /**
  152519. * z-depth defining the far plane of the eye view frustum
  152520. * enables mapping of values in the render target depth
  152521. * attachment to scene coordinates. Initially set to 10000.0.
  152522. */
  152523. depthFar: number;
  152524. /**
  152525. * z-depth defining the near plane of the eye view frustum
  152526. * enables mapping of values in the render target depth
  152527. * attachment to scene coordinates. Initially set to 0.01.
  152528. */
  152529. depthNear: number;
  152530. /**
  152531. * An identifier for this distinct VRDisplay. Used as an
  152532. * association point in the Gamepad API.
  152533. */
  152534. readonly displayId: number;
  152535. /**
  152536. * A display name, a user-readable name identifying it.
  152537. */
  152538. readonly displayName: string;
  152539. readonly isConnected: boolean;
  152540. readonly isPresenting: boolean;
  152541. /**
  152542. * If this VRDisplay supports room-scale experiences, the optional
  152543. * stage attribute contains details on the room-scale parameters.
  152544. */
  152545. readonly stageParameters: VRStageParameters | null;
  152546. /**
  152547. * Passing the value returned by `requestAnimationFrame` to
  152548. * `cancelAnimationFrame` will unregister the callback.
  152549. * @param handle Define the hanle of the request to cancel
  152550. */
  152551. cancelAnimationFrame(handle: number): void;
  152552. /**
  152553. * Stops presenting to the VRDisplay.
  152554. * @returns a promise to know when it stopped
  152555. */
  152556. exitPresent(): Promise<void>;
  152557. /**
  152558. * Return the current VREyeParameters for the given eye.
  152559. * @param whichEye Define the eye we want the parameter for
  152560. * @returns the eye parameters
  152561. */
  152562. getEyeParameters(whichEye: string): VREyeParameters;
  152563. /**
  152564. * Populates the passed VRFrameData with the information required to render
  152565. * the current frame.
  152566. * @param frameData Define the data structure to populate
  152567. * @returns true if ok otherwise false
  152568. */
  152569. getFrameData(frameData: VRFrameData): boolean;
  152570. /**
  152571. * Get the layers currently being presented.
  152572. * @returns the list of VR layers
  152573. */
  152574. getLayers(): VRLayer[];
  152575. /**
  152576. * Return a VRPose containing the future predicted pose of the VRDisplay
  152577. * when the current frame will be presented. The value returned will not
  152578. * change until JavaScript has returned control to the browser.
  152579. *
  152580. * The VRPose will contain the position, orientation, velocity,
  152581. * and acceleration of each of these properties.
  152582. * @returns the pose object
  152583. */
  152584. getPose(): VRPose;
  152585. /**
  152586. * Return the current instantaneous pose of the VRDisplay, with no
  152587. * prediction applied.
  152588. * @returns the current instantaneous pose
  152589. */
  152590. getImmediatePose(): VRPose;
  152591. /**
  152592. * The callback passed to `requestAnimationFrame` will be called
  152593. * any time a new frame should be rendered. When the VRDisplay is
  152594. * presenting the callback will be called at the native refresh
  152595. * rate of the HMD. When not presenting this function acts
  152596. * identically to how window.requestAnimationFrame acts. Content should
  152597. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152598. * asynchronously from other displays and at differing refresh rates.
  152599. * @param callback Define the eaction to run next frame
  152600. * @returns the request handle it
  152601. */
  152602. requestAnimationFrame(callback: FrameRequestCallback): number;
  152603. /**
  152604. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152605. * Repeat calls while already presenting will update the VRLayers being displayed.
  152606. * @param layers Define the list of layer to present
  152607. * @returns a promise to know when the request has been fulfilled
  152608. */
  152609. requestPresent(layers: VRLayer[]): Promise<void>;
  152610. /**
  152611. * Reset the pose for this display, treating its current position and
  152612. * orientation as the "origin/zero" values. VRPose.position,
  152613. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152614. * updated when calling resetPose(). This should be called in only
  152615. * sitting-space experiences.
  152616. */
  152617. resetPose(): void;
  152618. /**
  152619. * The VRLayer provided to the VRDisplay will be captured and presented
  152620. * in the HMD. Calling this function has the same effect on the source
  152621. * canvas as any other operation that uses its source image, and canvases
  152622. * created without preserveDrawingBuffer set to true will be cleared.
  152623. * @param pose Define the pose to submit
  152624. */
  152625. submitFrame(pose?: VRPose): void;
  152626. }
  152627. declare var VRDisplay: {
  152628. prototype: VRDisplay;
  152629. new(): VRDisplay;
  152630. };
  152631. interface VRLayer {
  152632. leftBounds?: number[] | Float32Array | null;
  152633. rightBounds?: number[] | Float32Array | null;
  152634. source?: HTMLCanvasElement | null;
  152635. }
  152636. interface VRDisplayCapabilities {
  152637. readonly canPresent: boolean;
  152638. readonly hasExternalDisplay: boolean;
  152639. readonly hasOrientation: boolean;
  152640. readonly hasPosition: boolean;
  152641. readonly maxLayers: number;
  152642. }
  152643. interface VREyeParameters {
  152644. /** @deprecated */
  152645. readonly fieldOfView: VRFieldOfView;
  152646. readonly offset: Float32Array;
  152647. readonly renderHeight: number;
  152648. readonly renderWidth: number;
  152649. }
  152650. interface VRFieldOfView {
  152651. readonly downDegrees: number;
  152652. readonly leftDegrees: number;
  152653. readonly rightDegrees: number;
  152654. readonly upDegrees: number;
  152655. }
  152656. interface VRFrameData {
  152657. readonly leftProjectionMatrix: Float32Array;
  152658. readonly leftViewMatrix: Float32Array;
  152659. readonly pose: VRPose;
  152660. readonly rightProjectionMatrix: Float32Array;
  152661. readonly rightViewMatrix: Float32Array;
  152662. readonly timestamp: number;
  152663. }
  152664. interface VRPose {
  152665. readonly angularAcceleration: Float32Array | null;
  152666. readonly angularVelocity: Float32Array | null;
  152667. readonly linearAcceleration: Float32Array | null;
  152668. readonly linearVelocity: Float32Array | null;
  152669. readonly orientation: Float32Array | null;
  152670. readonly position: Float32Array | null;
  152671. readonly timestamp: number;
  152672. }
  152673. interface VRStageParameters {
  152674. sittingToStandingTransform?: Float32Array;
  152675. sizeX?: number;
  152676. sizeY?: number;
  152677. }
  152678. interface Navigator {
  152679. getVRDisplays(): Promise<VRDisplay[]>;
  152680. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152681. }
  152682. interface Window {
  152683. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152684. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152685. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152686. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152687. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152688. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152689. }
  152690. interface Gamepad {
  152691. readonly displayId: number;
  152692. }
  152693. type XRSessionMode =
  152694. | "inline"
  152695. | "immersive-vr"
  152696. | "immersive-ar";
  152697. type XRReferenceSpaceType =
  152698. | "viewer"
  152699. | "local"
  152700. | "local-floor"
  152701. | "bounded-floor"
  152702. | "unbounded";
  152703. type XREnvironmentBlendMode =
  152704. | "opaque"
  152705. | "additive"
  152706. | "alpha-blend";
  152707. type XRVisibilityState =
  152708. | "visible"
  152709. | "visible-blurred"
  152710. | "hidden";
  152711. type XRHandedness =
  152712. | "none"
  152713. | "left"
  152714. | "right";
  152715. type XRTargetRayMode =
  152716. | "gaze"
  152717. | "tracked-pointer"
  152718. | "screen";
  152719. type XREye =
  152720. | "none"
  152721. | "left"
  152722. | "right";
  152723. type XREventType =
  152724. | "devicechange"
  152725. | "visibilitychange"
  152726. | "end"
  152727. | "inputsourceschange"
  152728. | "select"
  152729. | "selectstart"
  152730. | "selectend"
  152731. | "squeeze"
  152732. | "squeezestart"
  152733. | "squeezeend"
  152734. | "reset";
  152735. interface XRSpace extends EventTarget {
  152736. }
  152737. interface XRRenderState {
  152738. depthNear?: number;
  152739. depthFar?: number;
  152740. inlineVerticalFieldOfView?: number;
  152741. baseLayer?: XRWebGLLayer;
  152742. }
  152743. interface XRInputSource {
  152744. handedness: XRHandedness;
  152745. targetRayMode: XRTargetRayMode;
  152746. targetRaySpace: XRSpace;
  152747. gripSpace: XRSpace | undefined;
  152748. gamepad: Gamepad | undefined;
  152749. profiles: Array<string>;
  152750. }
  152751. interface XRSessionInit {
  152752. optionalFeatures?: string[];
  152753. requiredFeatures?: string[];
  152754. }
  152755. interface XRSession {
  152756. addEventListener: Function;
  152757. removeEventListener: Function;
  152758. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  152759. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  152760. requestAnimationFrame: Function;
  152761. end(): Promise<void>;
  152762. renderState: XRRenderState;
  152763. inputSources: Array<XRInputSource>;
  152764. // hit test
  152765. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  152766. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  152767. // legacy AR hit test
  152768. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152769. // legacy plane detection
  152770. updateWorldTrackingState(options: {
  152771. planeDetectionState?: { enabled: boolean; }
  152772. }): void;
  152773. }
  152774. interface XRReferenceSpace extends XRSpace {
  152775. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  152776. onreset: any;
  152777. }
  152778. type XRPlaneSet = Set<XRPlane>;
  152779. type XRAnchorSet = Set<XRAnchor>;
  152780. interface XRFrame {
  152781. session: XRSession;
  152782. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  152783. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  152784. // AR
  152785. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  152786. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  152787. // Anchors
  152788. trackedAnchors?: XRAnchorSet;
  152789. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  152790. // Planes
  152791. worldInformation: {
  152792. detectedPlanes?: XRPlaneSet;
  152793. };
  152794. }
  152795. interface XRViewerPose extends XRPose {
  152796. views: Array<XRView>;
  152797. }
  152798. interface XRPose {
  152799. transform: XRRigidTransform;
  152800. emulatedPosition: boolean;
  152801. }
  152802. interface XRWebGLLayerOptions {
  152803. antialias?: boolean;
  152804. depth?: boolean;
  152805. stencil?: boolean;
  152806. alpha?: boolean;
  152807. multiview?: boolean;
  152808. framebufferScaleFactor?: number;
  152809. }
  152810. declare var XRWebGLLayer: {
  152811. prototype: XRWebGLLayer;
  152812. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  152813. };
  152814. interface XRWebGLLayer {
  152815. framebuffer: WebGLFramebuffer;
  152816. framebufferWidth: number;
  152817. framebufferHeight: number;
  152818. getViewport: Function;
  152819. }
  152820. declare class XRRigidTransform {
  152821. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  152822. position: DOMPointReadOnly;
  152823. orientation: DOMPointReadOnly;
  152824. matrix: Float32Array;
  152825. inverse: XRRigidTransform;
  152826. }
  152827. interface XRView {
  152828. eye: XREye;
  152829. projectionMatrix: Float32Array;
  152830. transform: XRRigidTransform;
  152831. }
  152832. interface XRInputSourceChangeEvent {
  152833. session: XRSession;
  152834. removed: Array<XRInputSource>;
  152835. added: Array<XRInputSource>;
  152836. }
  152837. interface XRInputSourceEvent extends Event {
  152838. readonly frame: XRFrame;
  152839. readonly inputSource: XRInputSource;
  152840. }
  152841. // Experimental(er) features
  152842. declare class XRRay {
  152843. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  152844. origin: DOMPointReadOnly;
  152845. direction: DOMPointReadOnly;
  152846. matrix: Float32Array;
  152847. }
  152848. declare enum XRHitTestTrackableType {
  152849. "point",
  152850. "plane"
  152851. }
  152852. interface XRHitResult {
  152853. hitMatrix: Float32Array;
  152854. }
  152855. interface XRTransientInputHitTestResult {
  152856. readonly inputSource: XRInputSource;
  152857. readonly results: Array<XRHitTestResult>;
  152858. }
  152859. interface XRHitTestResult {
  152860. getPose(baseSpace: XRSpace): XRPose | undefined;
  152861. // When anchor system is enabled
  152862. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  152863. }
  152864. interface XRHitTestSource {
  152865. cancel(): void;
  152866. }
  152867. interface XRTransientInputHitTestSource {
  152868. cancel(): void;
  152869. }
  152870. interface XRHitTestOptionsInit {
  152871. space: XRSpace;
  152872. entityTypes?: Array<XRHitTestTrackableType>;
  152873. offsetRay?: XRRay;
  152874. }
  152875. interface XRTransientInputHitTestOptionsInit {
  152876. profile: string;
  152877. entityTypes?: Array<XRHitTestTrackableType>;
  152878. offsetRay?: XRRay;
  152879. }
  152880. interface XRAnchor {
  152881. anchorSpace: XRSpace;
  152882. delete(): void;
  152883. }
  152884. interface XRPlane {
  152885. orientation: "Horizontal" | "Vertical";
  152886. planeSpace: XRSpace;
  152887. polygon: Array<DOMPointReadOnly>;
  152888. lastChangedTime: number;
  152889. }